diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-07-21 19:23:20 +0900 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-07-23 14:57:52 -0300 |
commit | 8a7bdf9d3b48ca50186864faae9e56928594286d (patch) | |
tree | 004abc0609501e56bdf00b9a0a3afbbf1f5ae729 /src/v4l.c | |
parent | aa973596fd61d4e91f66cf53ab51cbed9042be30 (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.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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); } |