aboutsummaryrefslogtreecommitdiffstats
path: root/src/v4l.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-21 10:23:20 (GMT)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-23 17:57:52 (GMT)
commit8a7bdf9d3b48ca50186864faae9e56928594286d (patch)
tree004abc0609501e56bdf00b9a0a3afbbf1f5ae729 /src/v4l.c
parentaa973596fd61d4e91f66cf53ab51cbed9042be30 (diff)
Ignore pad bytes on camera streams
On a perfect world, the memory mapped buffer would contain the exact frame image. However, due to hardware constraints (typically at their DMA engines), sometimes there are pad bytes after the end of each line. So, change the memcpy algorithm to take it into account.
Diffstat (limited to 'src/v4l.c')
-rw-r--r--src/v4l.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/v4l.c b/src/v4l.c
index b6483a4..f265512 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -384,10 +384,11 @@ void start_streaming(cam * cam)
}
}
-void capture_buffers(cam * cam, char *outbuf, int len)
+void capture_buffers(cam * cam, unsigned char *outbuf, int len)
{
char *msg;
- int r;
+ unsigned char *inbuf;
+ int r, y;
fd_set fds;
struct v4l2_buffer buf;
struct timeval tv;
@@ -418,7 +419,12 @@ void capture_buffers(cam * cam, char *outbuf, int len)
if (len > buf.bytesused)
len = buf.bytesused;
- memcpy(outbuf, cam->buffers[buf.index].start, len);
+ inbuf = cam->buffers[buf.index].start;
+ for (y = 0; y < cam->height; y++) {
+ memcpy(outbuf, inbuf, cam->width * cam->depth / 8);
+ outbuf += cam->width * cam->depth / 8;
+ inbuf += cam->bytesperline;
+ }
v4l2_ioctl(cam->dev, VIDIOC_QBUF, &buf);
}

Privacy Policy