--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -131,14 +131,22 @@ static int v4l2_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
      V4L2Context *const capture = &s->capture;
      V4L2Context *const output = &s->output;
      AVPacket avpkt = {0};
-    int ret;
+    int i, ret;
ret = ff_decode_get_packet(avctx, &avpkt);
      if (ret < 0 && ret != AVERROR_EOF)
          return ret;
- if (s->draining)
-        goto dequeue;
+    if (s->draining) {
+        for (i = 0; i < capture->num_buffers; i++) {
+            if (capture->buffers[i].status == V4L2BUF_IN_DRIVER)
+                goto dequeue;
+        }
+
+        /* no more buffers in the driver, we are done */
+        capture->done = 1;
+        return AVERROR_EOF;
+    }
ret = ff_v4l2_context_enqueue_packet(output, &avpkt);
      if (ret < 0) {
diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
index 4c9ea1f..3d7c241 100644
--- a/libavcodec/v4l2_m2m_enc.c
+++ b/libavcodec/v4l2_m2m_enc.c
@@ -253,10 +253,18 @@ static int v4l2_receive_packet(AVCodecContext *avctx, 
AVPacket *avpkt)
      V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
      V4L2Context *const capture = &s->capture;
      V4L2Context *const output = &s->output;
-    int ret;
+    int i, ret;
+
+    if (s->draining) {

um, I shouldnt be exposing this information in this file. I'll push it back to v4l2_context at the time of dequeue instead so the interface remains clean and I dont duplicate the code in the decoder
please ignore this patch


+        for (i = 0; i < capture->num_buffers; i++) {
+            if (capture->buffers[i].status == V4L2BUF_IN_DRIVER)
+                goto dequeue;
+        }
- if (s->draining)
-        goto dequeue;
+        /* no more buffers in the driver, we are done */
+        capture->done = 1;
+        return AVERROR_EOF;
+    }
if (!output->streamon) {
          ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to