changeset 1407:fb4bf3858f77 libavformat

Make read_packet fail is the v4l2 driver returns an unexpected frame size (driver's bug? If not, we will have to support this in some way)
author lucabe
date Sun, 22 Oct 2006 09:56:08 +0000
parents c7d4c4279fb7
children 9ce44c5f6fee
files v4l2.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/v4l2.c	Sat Oct 21 11:17:39 2006 +0000
+++ b/v4l2.c	Sun Oct 22 09:56:08 2006 +0000
@@ -308,7 +308,12 @@
         return -1;
     }
     assert (buf.index < s->buffers);
-    assert(buf.bytesused == s->frame_size);
+    if (buf.bytesused != s->frame_size) {
+        av_log(NULL, AV_LOG_ERROR, "The v4l2 frame is %d bytes, but %d bytes are expected\n", buf.bytesused, s->frame_size);
+
+        return -1;
+    }
+
     /* Image is at s->buff_start[buf.index] */
     memcpy(frame, s->buf_start[buf.index], buf.bytesused);
     *ts = buf.timestamp.tv_sec * int64_t_C(1000000) + buf.timestamp.tv_usec;