aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--lib/libv4lconvert/libv4lconvert-priv.h2
-rw-r--r--lib/libv4lconvert/libv4lconvert.c8
-rw-r--r--lib/libv4lconvert/rgbyuv.c16
3 files changed, 15 insertions, 11 deletions
diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h
index d4e8310b..dd0c86d0 100644
--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -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);
diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c
index fc9287c9..02ea0906 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -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:
diff --git a/lib/libv4lconvert/rgbyuv.c b/lib/libv4lconvert/rgbyuv.c
index e9fe6df9..ce31a1ba 100644
--- a/lib/libv4lconvert/rgbyuv.c
+++ b/lib/libv4lconvert/rgbyuv.c
@@ -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;
}
}

Privacy Policy

close