Add support for GRBG10 format conversion.
    
Signed-off-by: Pavel Machek <pa...@ucw.cz>

diff --git a/lib/libv4lconvert/libv4lconvert.c 
b/lib/libv4lconvert/libv4lconvert.c
index d3d8936..a7376b8 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -123,6 +123,7 @@ static const struct v4lconvert_pixfmt 
supported_src_pixfmts[] = {
        { V4L2_PIX_FMT_SGRBG8,           8,      8,      8,     1 },
        { V4L2_PIX_FMT_SRGGB8,           8,      8,      8,     1 },
        { V4L2_PIX_FMT_STV0680,          8,      8,      8,     1 },
+       { V4L2_PIX_FMT_SGRBG10,         16,      8,      8,     1 },
        /* compressed bayer */
        { V4L2_PIX_FMT_SPCA561,          0,      9,      9,     1 },
        { V4L2_PIX_FMT_SN9C10X,          0,      9,      9,     1 },
@@ -694,6 +695,16 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
        return *buf;
 }
 
+static void v4lconvert_10to8(void *_src, unsigned char *dst, int width, int 
height)
+{
+       int i;
+       uint16_t *src = _src;
+       
+       for (i=0; i<width*height; i++) {
+               dst[i] = src[i] >> 2;
+       }
+}
+
 int v4lconvert_oom_error(struct v4lconvert_data *data)
 {
        V4LCONVERT_ERR("could not allocate memory\n");
@@ -867,7 +878,8 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data 
*data,
 #endif
        case V4L2_PIX_FMT_SN9C2028:
        case V4L2_PIX_FMT_SQ905C:
-       case V4L2_PIX_FMT_STV0680: { /* Not compressed but needs some shuffling 
*/
+       case V4L2_PIX_FMT_STV0680:
+       case V4L2_PIX_FMT_SGRBG10: { /* Not compressed but needs some shuffling 
*/
                unsigned char *tmpbuf;
                struct v4l2_format tmpfmt = *fmt;
 
@@ -877,6 +889,11 @@ static int v4lconvert_convert_pixfmt(struct 
v4lconvert_data *data,
                        return v4lconvert_oom_error(data);
 
                switch (src_pix_fmt) {
+               case V4L2_PIX_FMT_SGRBG10:
+                       v4lconvert_10to8(src, tmpbuf, width, height);
+                       tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8;
+                       bytesperline = width;
+                       break;
                case V4L2_PIX_FMT_SPCA561:
                        v4lconvert_decode_spca561(src, tmpbuf, width, height);
                        tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature

Reply via email to