diff options
author | James Almer <jamrial@gmail.com> | 2017-04-22 20:06:47 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-04-22 20:06:47 -0300 |
commit | 1fd76277708cf83572ba243e98f9e848c652f83d (patch) | |
tree | a6dc1008a0d893df430a9debbdc201d8e8305954 /libavcodec/decode.c | |
parent | 5b281b476b32c35527c0eea5f42161c4acad83f9 (diff) | |
parent | 549d0bdca53af7a6e0c612ab4b03baecf3a5878f (diff) | |
download | ffmpeg-1fd76277708cf83572ba243e98f9e848c652f83d.tar.gz |
Merge commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f'
* commit '549d0bdca53af7a6e0c612ab4b03baecf3a5878f':
decode: be more explicit about storing the last packet properties
Also copy pkt->size in extract_packet_props(), as it's needed for
AVFrame.pkt_size
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index df9af689f2..5c8b4cbf56 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -118,6 +118,19 @@ fail2: return 0; } +static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) +{ + int ret = 0; + + av_packet_unref(avci->last_pkt_props); + if (pkt) { + ret = av_packet_copy_props(avci->last_pkt_props, pkt); + if (!ret) + avci->last_pkt_props->size = pkt->size; // HACK: Needed for ff_init_buffer_info(). + } + return ret; +} + static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame) { int ret; @@ -394,7 +407,9 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi if ((avctx->coded_width || avctx->coded_height) && av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) return AVERROR(EINVAL); - avctx->internal->pkt = avpkt; + ret = extract_packet_props(avci, avpkt); + if (ret < 0) + return ret; ret = apply_param_change(avctx, avpkt); if (ret < 0) return ret; @@ -412,7 +427,9 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ret < 0) goto fail; - avctx->internal->pkt = &tmp; + ret = extract_packet_props(avci, &tmp); + if (ret < 0) + return ret; if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, &tmp); @@ -438,7 +455,6 @@ FF_ENABLE_DEPRECATION_WARNINGS fail: emms_c(); //needed to avoid an emms_c() call before every return; - avctx->internal->pkt = NULL; #if FF_API_MERGE_SD if (did_split) { av_packet_free_side_data(&tmp); @@ -524,7 +540,9 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ret < 0) goto fail; - avctx->internal->pkt = &tmp; + ret = extract_packet_props(avci, &tmp); + if (ret < 0) + return ret; if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp); else { @@ -548,7 +566,7 @@ FF_ENABLE_DEPRECATION_WARNINGS frame->sample_rate = avctx->sample_rate; } - side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); + side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avctx->internal->skip_samples = AV_RL32(side) * avctx->internal->skip_samples_multiplier; discard_padding = AV_RL32(side + 4); @@ -630,7 +648,6 @@ FF_ENABLE_DEPRECATION_WARNINGS } } fail: - avctx->internal->pkt = NULL; #if FF_API_MERGE_SD if (did_split) { av_packet_free_side_data(&tmp); @@ -862,7 +879,9 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ret < 0) { *got_sub_ptr = 0; } else { - avctx->internal->pkt = &pkt_recoded; + ret = extract_packet_props(avctx->internal, &pkt_recoded); + if (ret < 0) + return ret; if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, @@ -912,7 +931,6 @@ FF_ENABLE_DEPRECATION_WARNINGS av_packet_unref(&pkt_recoded); } - avctx->internal->pkt = NULL; } #if FF_API_MERGE_SD @@ -1292,7 +1310,7 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) { - const AVPacket *pkt = avctx->internal->pkt; + const AVPacket *pkt = avctx->internal->last_pkt_props; int i; static const struct { enum AVPacketSideDataType packet; @@ -1338,16 +1356,6 @@ FF_ENABLE_DEPRECATION_WARNINGS } else { frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); } - } else { - frame->pts = AV_NOPTS_VALUE; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - frame->pkt_pts = AV_NOPTS_VALUE; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - av_frame_set_pkt_pos (frame, -1); - av_frame_set_pkt_duration(frame, 0); - av_frame_set_pkt_size (frame, -1); } frame->reordered_opaque = avctx->reordered_opaque; |