Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
69062d0f
Commit
69062d0f
authored
Feb 11, 2018
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h264_metadata: Use common SEI addition function
parent
a2ca8ed9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
53 deletions
+19
-53
h264_metadata_bsf.c
libavcodec/h264_metadata_bsf.c
+19
-53
No files found.
libavcodec/h264_metadata_bsf.c
View file @
69062d0f
...
...
@@ -208,7 +208,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out)
AVPacket
*
in
=
NULL
;
CodedBitstreamFragment
*
au
=
&
ctx
->
access_unit
;
int
err
,
i
,
j
,
has_sps
;
char
*
sei_udu_string
=
NULL
;
err
=
ff_bsf_get_packet
(
bsf
,
&
in
);
if
(
err
<
0
)
...
...
@@ -290,42 +289,11 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out)
// Only insert the SEI in access units containing SPSs.
if
(
has_sps
&&
ctx
->
sei_user_data
)
{
H264RawSEI
*
sei
;
H264RawSEIPayload
*
payload
;
H264RawSEIUserDataUnregistered
*
udu
;
int
sei_pos
,
sei_new
;
for
(
i
=
0
;
i
<
au
->
nb_units
;
i
++
)
{
if
(
au
->
units
[
i
].
type
==
H264_NAL_SEI
||
au
->
units
[
i
].
type
==
H264_NAL_SLICE
||
au
->
units
[
i
].
type
==
H264_NAL_IDR_SLICE
)
break
;
}
sei_pos
=
i
;
if
(
sei_pos
<
au
->
nb_units
&&
au
->
units
[
sei_pos
].
type
==
H264_NAL_SEI
)
{
sei_new
=
0
;
sei
=
au
->
units
[
sei_pos
].
content
;
}
else
{
sei_new
=
1
;
sei
=
&
ctx
->
sei_nal
;
memset
(
sei
,
0
,
sizeof
(
*
sei
));
sei
->
nal_unit_header
.
nal_unit_type
=
H264_NAL_SEI
;
err
=
ff_cbs_insert_unit_content
(
ctx
->
cbc
,
au
,
sei_pos
,
H264_NAL_SEI
,
sei
,
NULL
);
if
(
err
<
0
)
{
av_log
(
bsf
,
AV_LOG_ERROR
,
"Failed to insert SEI.
\n
"
);
goto
fail
;
}
}
payload
=
&
sei
->
payload
[
sei
->
payload_count
];
payload
->
payload_type
=
H264_SEI_TYPE_USER_DATA_UNREGISTERED
;
udu
=
&
payload
->
payload
.
user_data_unregistered
;
H264RawSEIPayload
payload
=
{
.
payload_type
=
H264_SEI_TYPE_USER_DATA_UNREGISTERED
,
};
H264RawSEIUserDataUnregistered
*
udu
=
&
payload
.
payload
.
user_data_unregistered
;
for
(
i
=
j
=
0
;
j
<
32
&&
ctx
->
sei_user_data
[
i
];
i
++
)
{
int
c
,
v
;
...
...
@@ -345,21 +313,25 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out)
++
j
;
}
if
(
j
==
32
&&
ctx
->
sei_user_data
[
i
]
==
'+'
)
{
sei_udu_string
=
av_strdup
(
ctx
->
sei_user_data
+
i
+
1
);
if
(
!
sei_udu_string
)
{
size_t
len
=
strlen
(
ctx
->
sei_user_data
+
i
+
1
);
udu
->
data_ref
=
av_buffer_alloc
(
len
+
1
);
if
(
!
udu
->
data_ref
)
{
err
=
AVERROR
(
ENOMEM
);
goto
sei_
fail
;
goto
fail
;
}
udu
->
data
=
sei_udu_string
;
udu
->
data_length
=
strlen
(
sei_udu_string
);
udu
->
data
=
udu
->
data_ref
->
data
;
udu
->
data_length
=
len
+
1
;
memcpy
(
udu
->
data
,
ctx
->
sei_user_data
+
i
+
1
,
len
+
1
);
payload
->
payload_size
=
16
+
udu
->
data_length
;
payload
.
payload_size
=
16
+
udu
->
data_length
;
if
(
!
sei_new
)
{
// This will be freed by the existing internal
// reference in fragment_uninit().
sei_udu_string
=
NULL
;
err
=
ff_cbs_h264_add_sei_message
(
ctx
->
cbc
,
au
,
&
payload
);
if
(
err
<
0
)
{
av_log
(
bsf
,
AV_LOG_ERROR
,
"Failed to add user data SEI "
"message to access unit.
\n
"
);
goto
fail
;
}
}
else
{
...
...
@@ -367,12 +339,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out)
av_log
(
bsf
,
AV_LOG_ERROR
,
"Invalid user data: "
"must be
\"
UUID+string
\"
.
\n
"
);
err
=
AVERROR
(
EINVAL
);
sei_fail:
memset
(
payload
,
0
,
sizeof
(
*
payload
));
goto
fail
;
}
++
sei
->
payload_count
;
}
err
=
ff_cbs_write_packet
(
ctx
->
cbc
,
out
,
au
);
...
...
@@ -388,7 +355,6 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *out)
err
=
0
;
fail:
ff_cbs_fragment_uninit
(
ctx
->
cbc
,
au
);
av_freep
(
&
sei_udu_string
);
av_packet_free
(
&
in
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment