Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
8234f0e3
Commit
8234f0e3
authored
Jul 06, 2015
by
Kieran Kunhya
Committed by
Michael Niedermayer
Jul 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: Add support for Closed Caption export in h264
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
38402754
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
2 deletions
+48
-2
h264.c
libavcodec/h264.c
+9
-0
h264.h
libavcodec/h264.h
+2
-0
h264_sei.c
libavcodec/h264_sei.c
+37
-2
No files found.
libavcodec/h264.c
View file @
8234f0e3
...
...
@@ -879,6 +879,15 @@ static void decode_postinit(H264Context *h, int setup_finished)
}
}
if
(
h
->
a53_caption
)
{
AVFrameSideData
*
sd
=
av_frame_new_side_data
(
cur
->
f
,
AV_FRAME_DATA_A53_CC
,
h
->
a53_caption_size
);
if
(
sd
)
memcpy
(
sd
->
data
,
h
->
a53_caption
,
h
->
a53_caption_size
);
av_freep
(
&
h
->
a53_caption
);
h
->
a53_caption_size
=
0
;
}
cur
->
mmco_reset
=
h
->
mmco_reset
;
h
->
mmco_reset
=
0
;
...
...
libavcodec/h264.h
View file @
8234f0e3
...
...
@@ -805,6 +805,8 @@ typedef struct H264Context {
int
missing_fields
;
int
a53_caption_size
;
uint8_t
*
a53_caption
;
/* for frame threading, this is set to 1
* after finish_setup() has been called, so we cannot modify
...
...
libavcodec/h264_sei.c
View file @
8234f0e3
...
...
@@ -43,6 +43,9 @@ void ff_h264_reset_sei(H264Context *h)
h
->
sei_frame_packing_present
=
0
;
h
->
sei_display_orientation_present
=
0
;
h
->
sei_reguserdata_afd_present
=
0
;
if
(
h
->
a53_caption
)
av_freep
(
&
h
->
a53_caption
);
h
->
a53_caption_size
=
0
;
}
static
int
decode_picture_timing
(
H264Context
*
h
)
...
...
@@ -113,8 +116,7 @@ static int decode_registered_user_data(H264Context *h, int size)
{
uint32_t
country_code
;
uint32_t
user_identifier
;
int
dtg_active_format
;
int
flag
;
int
flag
,
cc_count
,
user_data_type_code
;
if
(
size
<
7
)
return
AVERROR_INVALIDDATA
;
...
...
@@ -152,6 +154,39 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
/* FF_API_AFD */
}
break
;
case
MKBETAG
(
'G'
,
'A'
,
'9'
,
'4'
):
// "GA94" closed captions
if
(
size
<
3
)
return
AVERROR
(
EINVAL
);
user_data_type_code
=
get_bits
(
&
h
->
gb
,
8
);
if
(
user_data_type_code
==
0x3
)
{
skip_bits
(
&
h
->
gb
,
1
);
if
(
get_bits
(
&
h
->
gb
,
1
))
{
skip_bits
(
&
h
->
gb
,
1
);
cc_count
=
get_bits
(
&
h
->
gb
,
5
);
skip_bits
(
&
h
->
gb
,
8
);
size
-=
2
;
if
(
cc_count
&&
size
>=
cc_count
*
3
)
{
int
i
;
uint8_t
*
tmp
;
if
((
int64_t
)
h
->
a53_caption_size
+
(
int64_t
)
cc_count
*
3
>
INT_MAX
)
return
AVERROR
(
EINVAL
);
// Allow merging of the cc data from two fields
tmp
=
av_realloc
(
h
->
a53_caption
,
h
->
a53_caption_size
+
cc_count
*
3
);
if
(
!
tmp
)
return
AVERROR
(
ENOMEM
);
h
->
a53_caption
=
tmp
;
for
(
i
=
0
;
i
<
cc_count
;
i
++
)
{
h
->
a53_caption
[
h
->
a53_caption_size
++
]
=
get_bits
(
&
h
->
gb
,
8
);
h
->
a53_caption
[
h
->
a53_caption_size
++
]
=
get_bits
(
&
h
->
gb
,
8
);
h
->
a53_caption
[
h
->
a53_caption_size
++
]
=
get_bits
(
&
h
->
gb
,
8
);
}
skip_bits
(
&
h
->
gb
,
8
);
}
}
}
break
;
default:
skip_bits
(
&
h
->
gb
,
size
*
8
);
break
;
...
...
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