@@ -157,7 +157,7 @@ void v4lconvert_swap_uv(const unsigned char *src, unsigned char *dst,
const struct v4l2_format *src_fmt);
void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,
- int width, int height);
+ int width, int height, int stride);
void v4lconvert_grey_to_yuv420(const unsigned char *src, unsigned char *dest,
const struct v4l2_format *src_fmt);
@@ -1245,7 +1245,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
switch (dest_pix_fmt) {
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
- v4lconvert_grey_to_rgb24(src, dest, width, height);
+ v4lconvert_grey_to_rgb24(src, dest, width, height, bytesperline);
break;
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
@@ -654,7 +654,7 @@ void v4lconvert_y16_to_yuv420(const unsigned char *src, unsigned char *dest,
}
void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,
- int width, int height)
+ int width, int height, int stride)
{
int j;
while (--height >= 0) {
@@ -664,6 +664,7 @@ void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,
*dest++ = *src;
src++;
}
+ src += stride - width;
}
}
Drivers are allowed to generate buffers where stride != width. Where as v4lconvert_grey_to_rgb24() assumed that stride == width is always true. This resulted in wrong frames for monochrome sensors, with padding bytes being visible diagonally and messing up the image alignment. Tested with rasbperry pi unicam driver using strides of 32 paired with the st-vgxy61 driver, which native resolution is 1944x1204, producing a frame of 1952x1204. Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> --- lib/libv4lconvert/libv4lconvert-priv.h | 2 +- lib/libv4lconvert/libv4lconvert.c | 2 +- lib/libv4lconvert/rgbyuv.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)