diff mbox

[FFmpeg-devel] lavd/v4l2: skip buffers not matching frame_size

Message ID 20180825212458.3009-1-stephan@ecshi.net
State Accepted
Commit b761ae072a169eb183abe0785a258b9787e267d3
Headers show

Commit Message

Stephan Hilb Aug. 25, 2018, 9:24 p.m. UTC
By adopting the same behaviour as if there was corrupted data in the
buffer (see the check for V4L2_BUF_FLAG_ERROR) the resulting rawvideo
now at least contains valid data (the previous frame being duplicated).
Fixes video capturing for some stk1160 devices.
---
 libavdevice/v4l2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Stephan Hilb Sept. 2, 2018, 4:01 p.m. UTC | #1
>  libavdevice/v4l2.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Any comments on this?
diff mbox

Patch

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 10a0ff0dd6..ab903bbcee 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -534,11 +534,10 @@  static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
             s->frame_size = buf.bytesused;
 
         if (s->frame_size > 0 && buf.bytesused != s->frame_size) {
-            av_log(ctx, AV_LOG_ERROR,
+            av_log(ctx, AV_LOG_WARNING,
                    "Dequeued v4l2 buffer contains %d bytes, but %d were expected. Flags: 0x%08X.\n",
                    buf.bytesused, s->frame_size, buf.flags);
-            enqueue_buffer(s, &buf);
-            return AVERROR_INVALIDDATA;
+            buf.bytesused = 0;
         }
     }