diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-01-31 14:32:39 +0000 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-02-01 18:19:24 +0000 |
commit | 792a5cefbe53914c6be8d7cd94856763fcc651b2 (patch) | |
tree | 970a549fcf3ab7f83c76481c95cf574c347d70f9 /libavcodec | |
parent | 66e9d2f44ee0b5d9a4b042a5a895ce88a43f10be (diff) | |
download | ffmpeg-streaming-792a5cefbe53914c6be8d7cd94856763fcc651b2.zip ffmpeg-streaming-792a5cefbe53914c6be8d7cd94856763fcc651b2.tar.gz |
mpeg12dec: Export GOP timecodes as side data
The codec context field was rightly deprecated, and the data
may change per-frame.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpeg12dec.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 23c77cd..cc8ace8 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2423,7 +2423,13 @@ static void mpeg_decode_gop(AVCodecContext *avctx, init_get_bits(&s->gb, buf, buf_size * 8); - tc = avctx->timecode_frame_start = get_bits(&s->gb, 25); + tc = s-> timecode_frame_start = get_bits(&s->gb, 25); + +#if FF_API_PRIVATE_OPT +FF_DISABLE_DEPRECATION_WARNINGS + avctx->timecode_frame_start = tc; +FF_ENABLE_DEPRECATION_WARNINGS +#endif s->closed_gop = get_bits1(&s->gb); /* broken_link indicate that after editing the @@ -2831,9 +2837,21 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data, } ret = decode_chunks(avctx, picture, got_output, buf, buf_size); - if (ret<0 || *got_output) + if (ret<0 || *got_output) { s2->current_picture_ptr = NULL; + if (s2->timecode_frame_start != -1 && *got_output) { + AVFrameSideData *tcside = av_frame_new_side_data(picture, + AV_FRAME_DATA_GOP_TIMECODE, + sizeof(int64_t)); + if (!tcside) + return AVERROR(ENOMEM); + memcpy(tcside->data, &s2->timecode_frame_start, sizeof(int64_t)); + + s2->timecode_frame_start = -1; + } + } + return ret; } |