diff options
author | James Almer <jamrial@gmail.com> | 2021-03-01 14:10:36 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-03-03 13:10:27 -0300 |
commit | b34d1de8dc64466aea226183bd8701fa8bf95788 (patch) | |
tree | 1b6d039e8bc2a97f50970d803bb4b7db84d40284 /libavcodec/decode.c | |
parent | 7819412f4468514a2bab924291d79806a569388c (diff) | |
download | ffmpeg-b34d1de8dc64466aea226183bd8701fa8bf95788.tar.gz |
avcodec/decode: port last_pkt_props to AVFifoBuffer
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 8086362eb2..d445ac75b0 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -43,7 +43,6 @@ #include "decode.h" #include "hwconfig.h" #include "internal.h" -#include "packet_internal.h" #include "thread.h" typedef struct FramePool { @@ -145,24 +144,44 @@ fail2: #define IS_EMPTY(pkt) (!(pkt)->data) +static int copy_packet_props(AVPacket *dst, 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, AVPacket *pkt) { + AVPacket tmp = { 0 }; int ret = 0; - ret = avpriv_packet_list_put(&avci->pkt_props, &avci->pkt_props_tail, pkt, - av_packet_copy_props, 0); + if (IS_EMPTY(avci->last_pkt_props)) { + if (av_fifo_size(avci->pkt_props) >= sizeof(*pkt)) { + av_fifo_generic_read(avci->pkt_props, avci->last_pkt_props, + sizeof(*avci->last_pkt_props), NULL); + } else + return copy_packet_props(avci->last_pkt_props, pkt); + } + + if (av_fifo_space(avci->pkt_props) < sizeof(*pkt)) { + ret = av_fifo_grow(avci->pkt_props, sizeof(*pkt)); + if (ret < 0) + return ret; + } + + ret = copy_packet_props(&tmp, pkt); if (ret < 0) return ret; - avci->pkt_props_tail->pkt.size = pkt->size; // HACK: Needed for ff_decode_frame_props(). - avci->pkt_props_tail->pkt.data = (void*)1; // HACK: Needed for IS_EMPTY(). - if (IS_EMPTY(avci->last_pkt_props)) { - ret = avpriv_packet_list_get(&avci->pkt_props, - &avci->pkt_props_tail, - avci->last_pkt_props); - av_assert0(ret != AVERROR(EAGAIN)); - } - return ret; + av_fifo_generic_write(avci->pkt_props, &tmp, sizeof(tmp), NULL); + + return 0; } int ff_decode_bsfs_init(AVCodecContext *avctx) @@ -1726,10 +1745,9 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, }; - if (IS_EMPTY(pkt)) - avpriv_packet_list_get(&avctx->internal->pkt_props, - &avctx->internal->pkt_props_tail, - pkt); + if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt)) + av_fifo_generic_read(avctx->internal->pkt_props, + pkt, sizeof(*pkt), NULL); if (pkt) { frame->pts = pkt->pts; |