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
c85852d3
Commit
c85852d3
authored
Aug 17, 2018
by
Kieran Kunhya
Committed by
Josh de Kock
Aug 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h264: Support multi-field closed captions by using AVBufferRef and not resetting per field
Signed-off-by:
Josh de Kock
<
joshdk@obe.tv
>
parent
f631c328
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
19 deletions
+26
-19
h264_sei.c
libavcodec/h264_sei.c
+8
-7
h264_sei.h
libavcodec/h264_sei.h
+1
-2
h264_slice.c
libavcodec/h264_slice.c
+14
-8
h264dec.c
libavcodec/h264dec.c
+3
-2
No files found.
libavcodec/h264_sei.c
View file @
c85852d3
...
...
@@ -51,8 +51,7 @@ void ff_h264_sei_uninit(H264SEIContext *h)
h
->
display_orientation
.
present
=
0
;
h
->
afd
.
present
=
0
;
h
->
a53_caption
.
a53_caption_size
=
0
;
av_freep
(
&
h
->
a53_caption
.
a53_caption
);
av_buffer_unref
(
&
h
->
a53_caption
.
buf_ref
);
}
static
int
decode_picture_timing
(
H264SEIPictureTiming
*
h
,
GetBitContext
*
gb
,
...
...
@@ -169,7 +168,8 @@ static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h,
size
-=
2
;
if
(
cc_count
&&
size
>=
cc_count
*
3
)
{
const
uint64_t
new_size
=
(
h
->
a53_caption_size
+
cc_count
int
old_size
=
h
->
buf_ref
?
h
->
buf_ref
->
size
:
0
;
const
uint64_t
new_size
=
(
old_size
+
cc_count
*
UINT64_C
(
3
));
int
i
,
ret
;
...
...
@@ -177,14 +177,15 @@ static int decode_registered_user_data_closed_caption(H264SEIA53Caption *h,
return
AVERROR
(
EINVAL
);
/* Allow merging of the cc data from two fields. */
ret
=
av_
reallocp
(
&
h
->
a53_caption
,
new_size
);
ret
=
av_
buffer_realloc
(
&
h
->
buf_ref
,
new_size
);
if
(
ret
<
0
)
return
ret
;
/* Use of av_buffer_realloc assumes buffer is writeable */
for
(
i
=
0
;
i
<
cc_count
;
i
++
)
{
h
->
a53_caption
[
h
->
a53_caption
_size
++
]
=
get_bits
(
gb
,
8
);
h
->
a53_caption
[
h
->
a53_caption
_size
++
]
=
get_bits
(
gb
,
8
);
h
->
a53_caption
[
h
->
a53_caption
_size
++
]
=
get_bits
(
gb
,
8
);
h
->
buf_ref
->
data
[
old
_size
++
]
=
get_bits
(
gb
,
8
);
h
->
buf_ref
->
data
[
old
_size
++
]
=
get_bits
(
gb
,
8
);
h
->
buf_ref
->
data
[
old
_size
++
]
=
get_bits
(
gb
,
8
);
}
skip_bits
(
gb
,
8
);
// marker_bits
...
...
libavcodec/h264_sei.h
View file @
c85852d3
...
...
@@ -95,8 +95,7 @@ typedef struct H264SEIAFD {
}
H264SEIAFD
;
typedef
struct
H264SEIA53Caption
{
int
a53_caption_size
;
uint8_t
*
a53_caption
;
AVBufferRef
*
buf_ref
;
}
H264SEIA53Caption
;
typedef
struct
H264SEIUnregistered
{
...
...
libavcodec/h264_slice.c
View file @
c85852d3
...
...
@@ -430,6 +430,13 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
h
->
frame_recovered
=
h1
->
frame_recovered
;
av_buffer_unref
(
&
h
->
sei
.
a53_caption
.
buf_ref
);
if
(
h1
->
sei
.
a53_caption
.
buf_ref
)
{
h
->
sei
.
a53_caption
.
buf_ref
=
av_buffer_ref
(
h1
->
sei
.
a53_caption
.
buf_ref
);
if
(
!
h
->
sei
.
a53_caption
.
buf_ref
)
return
AVERROR
(
ENOMEM
);
}
if
(
!
h
->
cur_pic_ptr
)
return
0
;
...
...
@@ -1269,15 +1276,14 @@ static int h264_export_frame_props(H264Context *h)
}
}
if
(
h
->
sei
.
a53_caption
.
a53_caption
)
{
if
(
h
->
sei
.
a53_caption
.
buf_ref
)
{
H264SEIA53Caption
*
a53
=
&
h
->
sei
.
a53_caption
;
AVFrameSideData
*
sd
=
av_frame_new_side_data
(
cur
->
f
,
AV_FRAME_DATA_A53_CC
,
a53
->
a53_caption_size
);
if
(
sd
)
memcpy
(
sd
->
data
,
a53
->
a53_caption
,
a53
->
a53_caption_size
);
av_freep
(
&
a53
->
a53_caption
);
a53
->
a53_caption_size
=
0
;
AVFrameSideData
*
sd
=
av_frame_new_side_data_from_buf
(
cur
->
f
,
AV_FRAME_DATA_A53_CC
,
a53
->
buf_ref
);
if
(
!
sd
)
av_buffer_unref
(
&
a53
->
buf_ref
);
a53
->
buf_ref
=
NULL
;
h
->
avctx
->
properties
|=
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
;
}
...
...
libavcodec/h264dec.c
View file @
c85852d3
...
...
@@ -609,9 +609,10 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
if
(
!
(
avctx
->
flags2
&
AV_CODEC_FLAG2_CHUNKS
))
{
h
->
current_slice
=
0
;
if
(
!
h
->
first_field
)
if
(
!
h
->
first_field
)
{
h
->
cur_pic_ptr
=
NULL
;
ff_h264_sei_uninit
(
&
h
->
sei
);
ff_h264_sei_uninit
(
&
h
->
sei
);
}
}
if
(
h
->
nal_length_size
==
4
)
{
...
...
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