[FFmpeg-cvslog] fftools/ffmpeg_dec: Always receive frames from decoder

Andreas Rheinhardt git at videolan.org
Thu May 15 03:03:01 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon May  5 14:13:58 2025 +0200| [b18aaf209f007e67ac4490ba5647ea139d1a6dcb] | committer: Andreas Rheinhardt

fftools/ffmpeg_dec: Always receive frames from decoder

Up until now if avcodec_send_packet() returned an error,
no attempt to receive a frame from the decoder would be made.
Instead the decoder was presumed to be drained, so that more
packets could be sent to it. Yet this need not be so:
It can happen that a packet would decode to multiple frames
and that decoding the first of these (the one that is decoded
during the avcodec_send_packet() call) returns an error,
in which case the decoder is not yet ready to receive more
input as the remaining parts of the packet have not been decoded
yet. In this case, an AERROR_BUG is triggered.

This happens in ticket #11553 with VP9 (which uses a BSF
to split VP9 superframes and is therefore affected by this).

Fix this by always calling avcodec_receive_frame() unless
xerror is set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b18aaf209f007e67ac4490ba5647ea139d1a6dcb
---

 fftools/ffmpeg_dec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 62edbb6c24..b06455c7b1 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -733,13 +733,12 @@ static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
         av_log(dp, AV_LOG_ERROR, "Error submitting %s to decoder: %s\n",
                pkt ? "packet" : "EOF", av_err2str(ret));
 
-        if (ret != AVERROR_EOF) {
-            dp->dec.decode_errors++;
-            if (!exit_on_error)
-                ret = 0;
-        }
+        if (ret == AVERROR_EOF)
+            return ret;
 
-        return ret;
+        dp->dec.decode_errors++;
+        if (exit_on_error)
+            return ret;
     }
 
     while (1) {



More information about the ffmpeg-cvslog mailing list