summaryrefslogtreecommitdiff
path: root/libavcodec/h264_slice.c
diff options
context:
space:
mode:
authorKieran Kunhya <kierank@obe.tv>2018-08-17 15:12:14 +0100
committerJosh de Kock <josh@itanimul.li>2018-08-17 16:24:19 +0100
commitc85852d3de636d18b41c4e5fdcdbc18bde7f3b1f (patch)
treee00be118dd028eea576b14292a7dd646804a5da6 /libavcodec/h264_slice.c
parentf631c328e680a3dd491936b92f69970c20cdcfc7 (diff)
h264: Support multi-field closed captions by using AVBufferRef and not resetting per field
Signed-off-by: Josh de Kock <joshdk@obe.tv>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index ede9a1a6ea..58e1aaf02f 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -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;
}