Skip to content
Snippets Groups Projects
Commit 4fbe2663 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab
Browse files

libv4lconvert: Fix v4lconvert_nv16_to_yuyv() not taking stride into account


The atomisp driver can generate V4L2_PIX_FMT_NV16 buffers where
stride != width. Where as v4lconvert_nv16_to_yuyv() assumed that
stride == width is always true.

Add a stride argument to v4lconvert_nv16_to_yuyv() to fix this.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 59eb95e5
No related branches found
No related tags found
No related merge requests found
......@@ -133,7 +133,7 @@ void v4lconvert_yuyv_to_yuv420(const unsigned char *src, unsigned char *dst,
int width, int height, int stride, int yvu);
void v4lconvert_nv16_to_yuyv(const unsigned char *src, unsigned char *dest,
int width, int height);
int width, int height, int stride);
void v4lconvert_yvyu_to_rgb24(const unsigned char *src, unsigned char *dst,
int width, int height, int stride);
......
......@@ -1445,10 +1445,10 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
if (!tmpbuf)
return v4lconvert_oom_error(data);
v4lconvert_nv16_to_yuyv(src, tmpbuf, width, height);
v4lconvert_nv16_to_yuyv(src, tmpbuf, width, height, bytesperline);
src_pix_fmt = V4L2_PIX_FMT_YUYV;
src = tmpbuf;
bytesperline = bytesperline * 2;
bytesperline = width * 2;
/* fall through */
}
case V4L2_PIX_FMT_YUYV:
......@@ -1482,10 +1482,10 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
return v4lconvert_oom_error(data);
/* Note NV61 is NV16 with U and V swapped so this becomes yvyu. */
v4lconvert_nv16_to_yuyv(src, tmpbuf, width, height);
v4lconvert_nv16_to_yuyv(src, tmpbuf, width, height, bytesperline);
src_pix_fmt = V4L2_PIX_FMT_YVYU;
src = tmpbuf;
bytesperline = bytesperline * 2;
bytesperline = width * 2;
/* fall through */
}
case V4L2_PIX_FMT_YVYU:
......
......@@ -304,17 +304,21 @@ void v4lconvert_yuyv_to_yuv420(const unsigned char *src, unsigned char *dest,
}
void v4lconvert_nv16_to_yuyv(const unsigned char *src, unsigned char *dest,
int width, int height)
int width, int height, int stride)
{
const unsigned char *y, *cbcr;
int count = 0;
int i, j;
y = src;
cbcr = src + width*height;
cbcr = src + stride * height;
while (count++ < width*height) {
*dest++ = *y++;
*dest++ = *cbcr++;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
*dest++ = *y++;
*dest++ = *cbcr++;
}
y += stride - width;
cbcr += stride - width;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment