diff mbox series

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

Message ID 2abad3ef.AUoAACIcJvIAAAAAAAAAALF60VUAARpcY_sAAAAAAAeRJgBgJaZe@mailjet.com
State New
Headers show
Series mjpeg_mmal and avoid a frame copy in mmaldec | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Lluís Batlle i Rossell Feb. 11, 2021, 9:48 p.m. UTC
From: Lluís Batlle i Rossell <viric@viric.name>

From: Cosmin Gorgovan <cosmin@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 mbox series

Patch

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;