[FFmpeg-devel] [PATCH 2/3] libavcodec/mmaldec: continue after receiving EOS without having sent one

Lluís Batlle i Rossel viric at viric.name
Thu Feb 11 23:48:20 EET 2021


From: Lluís Batlle i Rossell <viric at viric.name>

From: Cosmin Gorgovan <cosmin at linux-geek.org>

The previous logic in mmaldec was causing the MMAL MJPEG decoder
to stop if it received an invalid frame - which happened to be the
first frame received from a UVC camera via V4L2 in my application
---
 libavcodec/mmaldec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index df14b9fc95..4dfaacbb41 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -711,9 +711,13 @@ static int ffmmal_read_frame(AVCodecContext *avctx, AVFrame *frame, int *got_fra
                 goto done;
         }
 
-        ctx->eos_received |= !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS);
-        if (ctx->eos_received)
+        int eos = !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS);
+        if (eos) {
+            if (ctx->eos_sent) {
+              ctx->eos_received = 1;
+            }
             goto done;
+        }
 
         if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) {
             MMAL_COMPONENT_T *decoder = ctx->decoder;
-- 
2.29.2



More information about the ffmpeg-devel mailing list