Browse Source

Merge commit 'b0017579b6e8de3d0d13dcfe0a4dd848dc6baa37'

* commit 'b0017579b6e8de3d0d13dcfe0a4dd848dc6baa37':
  h264: Add support for Closed Caption export

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_sei.c

See: 8234f0e3b4
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n2.8
Michael Niedermayer 10 years ago
parent
commit
441d5a7084
3 changed files with 17 additions and 13 deletions
  1. +3
    -2
      libavcodec/h264.c
  2. +2
    -3
      libavcodec/h264.h
  3. +12
    -8
      libavcodec/h264_sei.c

+ 3
- 2
libavcodec/h264.c View File

@@ -880,8 +880,9 @@ 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);
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);


+ 2
- 3
libavcodec/h264.h View File

@@ -746,6 +746,8 @@ typedef struct H264Context {
*/
int sei_reguserdata_afd_present;
uint8_t active_format_description;
int a53_caption_size;
uint8_t *a53_caption;

/**
* Bit set of clock types for fields/frames in picture timing SEI message.
@@ -805,9 +807,6 @@ 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
* some context properties (which are supposed to stay constant between


+ 12
- 8
libavcodec/h264_sei.c View File

@@ -43,9 +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;
av_freep(&h->a53_caption);
}

static int decode_picture_timing(H264Context *h)
@@ -159,13 +159,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
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);
skip_bits(&h->gb, 1); // reserved

flag = get_bits(&h->gb, 1); // process_cc_data_flag
if (flag) {
skip_bits(&h->gb, 1); // zero bit
cc_count = get_bits(&h->gb, 5);
skip_bits(&h->gb, 8);
skip_bits(&h->gb, 8); // reserved
size -= 2;
if (cc_count && size >= cc_count*3) {

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)
@@ -176,13 +179,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
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);
skip_bits(&h->gb, 8); // marker_bits
}
}
}


Loading…
Cancel
Save