diff options
author | James Almer <jamrial@gmail.com> | 2022-12-04 14:53:13 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-12-07 08:55:33 -0300 |
commit | b1fdb0b347c1d7d022a16cf682ba7de03bd491db (patch) | |
tree | f0276d305ad68b395fe680cb20b23e3fe0a79f09 /libavcodec/decode.c | |
parent | c06e88e05c5154cce31f5c12fde1da9b2070979e (diff) | |
download | ffmpeg-b1fdb0b347c1d7d022a16cf682ba7de03bd491db.tar.gz |
Revert "avcodec/decode: use a packet list to store packet properties"
The idea behind last_pkt_props was to store the properties of the last packet
fed to the decoder. Any sort of queueing required by CODEC_CAP_DELAY decoders
that consume several packets before they start outputting frames should be done
by the decoders in question. An example of this is libdav1d.
This is required for the following commits that will fix last_pkt_props in
frame threading scenarios, as well as maintain its contents during flush.
This revers commit 022a12b306ab2096e6ac9fc9b149828a849d65b2.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 6be2d3d6ed..c94d9aa33c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -132,38 +132,16 @@ fail2: return 0; } -#define IS_EMPTY(pkt) (!(pkt)->data) - -static int copy_packet_props(AVPacket *dst, const AVPacket *src) -{ - int ret = av_packet_copy_props(dst, src); - if (ret < 0) - return ret; - - dst->size = src->size; // HACK: Needed for ff_decode_frame_props(). - dst->data = (void*)1; // HACK: Needed for IS_EMPTY(). - - return 0; -} - static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) { - AVPacket tmp = { 0 }; int ret = 0; - if (IS_EMPTY(avci->last_pkt_props)) { - if (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) < 0) - return copy_packet_props(avci->last_pkt_props, pkt); + 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_decode_frame_props(). } - - ret = copy_packet_props(&tmp, pkt); - if (ret < 0) - return ret; - - ret = av_fifo_write(avci->pkt_props, &tmp, 1); - if (ret < 0) - av_packet_unref(&tmp); - return ret; } @@ -483,7 +461,6 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ret >= pkt->size || ret < 0) { av_packet_unref(pkt); - av_packet_unref(avci->last_pkt_props); } else { int consumed = ret; @@ -578,8 +555,6 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) { ret = codec->cb.receive_frame(avctx, frame); - if (ret != AVERROR(EAGAIN)) - av_packet_unref(avci->last_pkt_props); } else ret = decode_simple_receive_frame(avctx, frame); @@ -593,12 +568,6 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) return ok; } - if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS) && - IS_EMPTY(avci->last_pkt_props)) { - // May fail if the FIFO is empty. - av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); - } - if (!ret) { frame->best_effort_timestamp = guess_correct_pts(avctx, frame->pts, @@ -1293,7 +1262,7 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { - AVPacket *pkt = avctx->internal->last_pkt_props; + const AVPacket *pkt = avctx->internal->last_pkt_props; static const struct { enum AVPacketSideDataType packet; enum AVFrameSideDataType frame; @@ -1651,9 +1620,7 @@ FF_ENABLE_DEPRECATION_WARNINGS avci->in_pkt = av_packet_alloc(); avci->last_pkt_props = av_packet_alloc(); - avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props), - AV_FIFO_FLAG_AUTO_GROW); - if (!avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) + if (!avci->in_pkt || !avci->last_pkt_props) return AVERROR(ENOMEM); ret = decode_bsfs_init(avctx); |