From 454203ed354c84c6947bb774c8deda9b2646e190 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 May 2010 15:17:31 +0200 Subject: Warn when v4l2_buffer::bytesused has an unexpected value For uncompressed formats in capture devices, the v4l2_buffer::bytesused field should have the same value as the v4l2_pix_format::sizeimage field reported by the VIDIOC_G_FMT ioctl. Print a warning on VIDIOC_DQBUG when the values don't match. Signed-off-by: Laurent Pinchart --- yavta.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/yavta.c b/yavta.c index 4c0d97b..3d42915 100644 --- a/yavta.c +++ b/yavta.c @@ -42,6 +42,7 @@ struct device enum v4l2_memory memtype; unsigned int nbufs; unsigned int bufsize; + unsigned int imagesize; void **mem; }; @@ -186,6 +187,8 @@ static int video_get_format(struct device *dev) return ret; } + dev->imagesize = fmt.fmt.pix.bytesperline ? fmt.fmt.pix.sizeimage : 0; + printf("Video format: %c%c%c%c (%08x) %ux%u\n", (fmt.fmt.pix.pixelformat >> 0) & 0xff, (fmt.fmt.pix.pixelformat >> 8) & 0xff, @@ -765,6 +768,11 @@ static int video_do_capture(struct device *dev, unsigned int nframes, buf.m.userptr = (unsigned long)dev->mem[i]; } + if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && + dev->imagesize != 0 && buf.bytesused != dev->imagesize) + printf("Warning: bytes used %u != image size %u\n", + buf.bytesused, dev->imagesize); + size += buf.bytesused; gettimeofday(&ts, NULL); -- cgit v1.2.3