PR #24545 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24545 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24545.patch
FFCodec->cb.decode() decoders should only return bytes consumed or actual decoding error codecs >From a95e137cbe34f59287f4b55e04dafbac6c60df5e Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 16 Sep 2026 23:20:55 -0300 Subject: [PATCH 1/4] avcodec/gifdec: don't return AVERROR_EOF FFCodec->cb.decode() decoders should only return bytes consumed or actual decoding error codecs. Signed-off-by: James Almer <[email protected]> --- libavcodec/gifdec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index ae45eb0f6d..4f0f42e315 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -506,8 +506,11 @@ static int gif_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return ret; ret = gif_parse_next_image(s, s->frame); - if (ret < 0) + if (ret < 0) { + if (ret == AVERROR_EOF) + ret = bytestream2_tell(&s->gb); return ret; + } if ((ret = av_frame_ref(rframe, s->frame)) < 0) return ret; -- 2.52.0 >From 9fe88a1a78a9ba0576f706ceb1f949e3e86be552 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 16 Sep 2026 23:21:36 -0300 Subject: [PATCH 2/4] avcodec/libfdk-aacdec: don't return AVERROR_EOF FFCodec->cb.decode() decoders should only return bytes consumed or actual decoding error codecs. Signed-off-by: James Almer <[email protected]> --- libavcodec/libfdk-aacdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c index 41ff4887a6..57926addb4 100644 --- a/libavcodec/libfdk-aacdec.c +++ b/libavcodec/libfdk-aacdec.c @@ -478,10 +478,10 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (s->flush_samples > 0) { flags |= AACDEC_FLUSH; } else { - return AVERROR_EOF; + return 0; } #else - return AVERROR_EOF; + return 0; #endif } -- 2.52.0 >From db150632fbbc6cdd826e2f904a030f3aebe6f79b Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 16 Sep 2026 23:21:47 -0300 Subject: [PATCH 3/4] avcodec/tiff: don't return AVERROR_EOF FFCodec->cb.decode() decoders should only return bytes consumed or actual decoding error codecs. Signed-off-by: James Almer <[email protected]> --- libavcodec/tiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index b8ce7b0b55..d6db7ef519 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -2027,7 +2027,7 @@ again: if (s->get_thumbnail && !s->is_thumbnail) { av_log(avctx, AV_LOG_INFO, "No embedded thumbnail present\n"); - return AVERROR_EOF; + return 0; } /** whether we should process this IFD's SubIFD */ -- 2.52.0 >From f5efc40ac760a9a7d792a3a51b984e15ab1f3dac Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 16 Sep 2026 23:22:44 -0300 Subject: [PATCH 4/4] avcodec/decode: ensure decoders using the simple API don't return AVERROR_EOF FFCodec->cb.decode() decoders should only return bytes consumed or actual decoding error codecs. Signed-off-by: James Almer <[email protected]> --- libavcodec/decode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 22954b0626..94dfc06a84 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -477,8 +477,9 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, av_frame_unref(frame); // FF_CODEC_CB_TYPE_DECODE decoders must not return AVERROR EAGAIN + // or AVERROR_EOF. // code later will add AVERROR(EAGAIN) to a pointer - av_assert0(consumed != AVERROR(EAGAIN)); + av_assert0(consumed != AVERROR(EAGAIN) && consumed != AVERROR_EOF); if (consumed < 0) ret = consumed; if (consumed >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
