This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/v4l-utils.git tree:

Subject: libv4l: Add support for 8-bits grey format (V4L2_PIX_FMT_GREY)
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Wed Dec 8 12:10:36 2010 -0200

Grey format is like YUV, with U/V channels with 0. Add the corresponding
bits to libv4l, for it to handle this format.

v2: Fixed U/V "zero" value (0x80), thanks to Hans de Goede
    <[email protected]>

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 lib/libv4lconvert/libv4lconvert-priv.h |    9 +++++++++
 lib/libv4lconvert/libv4lconvert.c      |   18 ++++++++++++++++++
 lib/libv4lconvert/rgbyuv.c             |   28 ++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 0 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=1994b83657e94732165b2e70ad2ff8bd94268590

diff --git a/lib/libv4lconvert/libv4lconvert-priv.h 
b/lib/libv4lconvert/libv4lconvert-priv.h
index 61a8c39..2680ed7 100644
--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -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);
 
diff --git a/lib/libv4lconvert/libv4lconvert.c 
b/lib/libv4lconvert/libv4lconvert.c
index f08996a..26a0978 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -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:
diff --git a/lib/libv4lconvert/rgbyuv.c b/lib/libv4lconvert/rgbyuv.c
index f205b39..2ee7e58 100644
--- a/lib/libv4lconvert/rgbyuv.c
+++ b/lib/libv4lconvert/rgbyuv.c
@@ -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, 0x80, src_fmt->fmt.pix.width * src_fmt->fmt.pix.height / 
2);
+}

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to