@@ -127,6 +127,15 @@ void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst,
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);
+
+void v4lconvert_grey_to_yuv420(const unsigned char *src, unsigned char *dest,
+ const struct v4l2_format *src_fmt);
+
+void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,
+ int width, int height);
+
void v4lconvert_rgb565_to_rgb24(const unsigned char *src, unsigned char *dest,
int width, int height);
@@ -43,6 +43,7 @@ static void v4lconvert_get_framesizes(struct v4lconvert_data *data,
v4lconvert_try_format for low resolutions */
static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
SUPPORTED_DST_PIXFMTS,
+ { V4L2_PIX_FMT_GREY, 0 },
{ V4L2_PIX_FMT_YUYV, 0 },
{ V4L2_PIX_FMT_YVYU, 0 },
{ V4L2_PIX_FMT_UYVY, 0 },
@@ -839,6 +840,23 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,
}
break;
+ case V4L2_PIX_FMT_GREY:
+ switch (dest_pix_fmt) {
+ case V4L2_PIX_FMT_RGB24:
+ case V4L2_PIX_FMT_BGR24:
+ v4lconvert_grey_to_rgb24(src, dest, width, height);
+ break;
+ case V4L2_PIX_FMT_YUV420:
+ case V4L2_PIX_FMT_YVU420:
+ v4lconvert_grey_to_yuv420(src, dest, fmt);
+ break;
+ }
+ if (src_size < (width * height)) {
+ V4LCONVERT_ERR("short grey data frame\n");
+ errno = EPIPE;
+ result = -1;
+ }
+ break;
case V4L2_PIX_FMT_RGB565:
switch (dest_pix_fmt) {
case V4L2_PIX_FMT_RGB24:
@@ -575,3 +575,31 @@ void v4lconvert_rgb565_to_yuv420(const unsigned char *src, unsigned char *dest,
src += 2 * src_fmt->fmt.pix.bytesperline - 2 * src_fmt->fmt.pix.width;
}
}
+
+void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,
+ int width, int height)
+{
+ int j;
+ while (--height >= 0) {
+ for (j = 0; j < width; j++) {
+ *dest++ = *src;
+ *dest++ = *src;
+ *dest++ = *src;
+ src++;
+ }
+ }
+}
+
+void v4lconvert_grey_to_yuv420(const unsigned char *src, unsigned char *dest,
+ const struct v4l2_format *src_fmt)
+{
+ int x, y;
+
+ /* Y */
+ for (y = 0; y < src_fmt->fmt.pix.height; y++)
+ for (x = 0; x < src_fmt->fmt.pix.width; x++)
+ *dest++ = *src++;
+
+ /* Clear U/V */
+ memset(dest, 0, src_fmt->fmt.pix.width * src_fmt->fmt.pix.height / 2);
+}