From 3c16f9eb0d2eea9c64d011bca6c52f520d66ec09 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:17:08 +0200 Subject: avcodec/qoidec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/qoidec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/qoidec.c b/libavcodec/qoidec.c index d218d649de..9414d2fbe9 100644 --- a/libavcodec/qoidec.c +++ b/libavcodec/qoidec.c @@ -28,19 +28,18 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int ret, buf_size = avpkt->size; int width, height, channels, space, run = 0; uint8_t index[64][4] = { 0 }; uint8_t px[4] = { 0, 0, 0, 255 }; GetByteContext gb; uint8_t *dst; uint64_t len; + int ret; - if (buf_size < 20) + if (avpkt->size < 20) return AVERROR_INVALIDDATA; - bytestream2_init(&gb, buf, buf_size); + bytestream2_init(&gb, avpkt->data, avpkt->size); bytestream2_skip(&gb, 4); width = bytestream2_get_be32(&gb); height = bytestream2_get_be32(&gb); @@ -61,6 +60,9 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, default: return AVERROR_INVALIDDATA; } + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; @@ -109,7 +111,7 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, *got_frame = 1; - return buf_size; + return avpkt->size; } const FFCodec ff_qoi_decoder = { @@ -118,5 +120,6 @@ const FFCodec ff_qoi_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(qoi_decode_frame), }; -- cgit v1.2.3