Re: [PATCH 2/2] libv4lconvert: Support for RGB32 and BGR32 format

2013-08-02 Thread Gregor Jasny

Hello,

On 8/1/13 3:04 PM, Ricardo Ribalda Delgado wrote:

--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -108,7 +108,7 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
  int v4lconvert_oom_error(struct v4lconvert_data *data);

  void v4lconvert_rgb24_to_yuv420(const unsigned char *src, unsigned char *dest,
-   const struct v4l2_format *src_fmt, int bgr, int yvu);
+   const struct v4l2_format *src_fmt, int bgr, int yvu, int rgb32);

  void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst,
int width, int height, int yvu);



@@ -47,9 +47,15 @@ void v4lconvert_rgb24_to_yuv420(const unsigned char *src, 
unsigned char *dest,
RGB2Y(src[2], src[1], src[0], *dest++);
else
RGB2Y(src[0], src[1], src[2], *dest++);
-   src += 3;
+   if (rgb32)
+   src += 4;
+   else
+   src += 3;


Instead of passing a 0/1 flag here I would call this variable 
bits_per_pixel or bpp and pass 3 or 4 here. This would reduce the if 
condition ugliness.


Thanks,
Gregor

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] libv4lconvert: Support for RGB32 and BGR32 format

2013-08-02 Thread Ricardo Ribalda Delgado
Hello Gregor

Totally agree,

I have just uploaded a new set.

Thanks!

On Sat, Aug 3, 2013 at 12:15 AM, Gregor Jasny gja...@googlemail.com wrote:
 Hello,


 On 8/1/13 3:04 PM, Ricardo Ribalda Delgado wrote:

 --- a/lib/libv4lconvert/libv4lconvert-priv.h
 +++ b/lib/libv4lconvert/libv4lconvert-priv.h
 @@ -108,7 +108,7 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
   int v4lconvert_oom_error(struct v4lconvert_data *data);

   void v4lconvert_rgb24_to_yuv420(const unsigned char *src, unsigned char
 *dest,
 -   const struct v4l2_format *src_fmt, int bgr, int yvu);
 +   const struct v4l2_format *src_fmt, int bgr, int yvu, int
 rgb32);

   void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char
 *dst,
 int width, int height, int yvu);


 @@ -47,9 +47,15 @@ void v4lconvert_rgb24_to_yuv420(const unsigned char
 *src, unsigned char *dest,
 RGB2Y(src[2], src[1], src[0], *dest++);
 else
 RGB2Y(src[0], src[1], src[2], *dest++);
 -   src += 3;
 +   if (rgb32)
 +   src += 4;
 +   else
 +   src += 3;


 Instead of passing a 0/1 flag here I would call this variable bits_per_pixel
 or bpp and pass 3 or 4 here. This would reduce the if condition ugliness.

 Thanks,
 Gregor




-- 
Ricardo Ribalda
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] libv4lconvert: Support for RGB32 and BGR32 format

2013-08-01 Thread Ricardo Ribalda Delgado
This patch adds support for V4L2_PIX_FMT_BGR32 and V4L2_PIX_FMT_BGR32
formats.

Signed-off-by: Ricardo Ribalda Delgado ricardo.riba...@gmail.com
---
 lib/libv4lconvert/libv4lconvert-priv.h |5 ++-
 lib/libv4lconvert/libv4lconvert.c  |   58 +---
 lib/libv4lconvert/rgbyuv.c |   66 ++--
 3 files changed, 111 insertions(+), 18 deletions(-)

diff --git a/lib/libv4lconvert/libv4lconvert-priv.h 
b/lib/libv4lconvert/libv4lconvert-priv.h
index 6422fdd..2f411ea 100644
--- a/lib/libv4lconvert/libv4lconvert-priv.h
+++ b/lib/libv4lconvert/libv4lconvert-priv.h
@@ -108,7 +108,7 @@ unsigned char *v4lconvert_alloc_buffer(int needed,
 int v4lconvert_oom_error(struct v4lconvert_data *data);
 
 void v4lconvert_rgb24_to_yuv420(const unsigned char *src, unsigned char *dest,
-   const struct v4l2_format *src_fmt, int bgr, int yvu);
+   const struct v4l2_format *src_fmt, int bgr, int yvu, int rgb32);
 
 void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst,
int width, int height, int yvu);
@@ -158,6 +158,9 @@ void v4lconvert_y16_to_rgb24(const unsigned char *src, 
unsigned char *dest,
 void v4lconvert_y16_to_yuv420(const unsigned char *src, unsigned char *dest,
const struct v4l2_format *src_fmt);
 
+void v4lconvert_rgb32_to_rgb24(const unsigned char *src, unsigned char *dest,
+   int width, int height, int bgr);
+
 int v4lconvert_y10b_to_rgb24(struct v4lconvert_data *data,
const unsigned char *src, unsigned char *dest, int width, int height);
 
diff --git a/lib/libv4lconvert/libv4lconvert.c 
b/lib/libv4lconvert/libv4lconvert.c
index bc5e34f..a5ada5b 100644
--- a/lib/libv4lconvert/libv4lconvert.c
+++ b/lib/libv4lconvert/libv4lconvert.c
@@ -84,6 +84,8 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] 
= {
SUPPORTED_DST_PIXFMTS,
/* packed rgb formats */
{ V4L2_PIX_FMT_RGB565,  16,  4,  6, 0 },
+   { V4L2_PIX_FMT_BGR32,   32,  4,  6, 0 },
+   { V4L2_PIX_FMT_RGB32,   32,  4,  6, 0 },
/* yuv 4:2:2 formats */
{ V4L2_PIX_FMT_YUYV,16,  5,  4, 0 },
{ V4L2_PIX_FMT_YVYU,16,  5,  4, 0 },
@@ -981,10 +983,10 @@ static int v4lconvert_convert_pixfmt(struct 
v4lconvert_data *data,
v4lconvert_swap_rgb(d, dest, width, height);
break;
case V4L2_PIX_FMT_YUV420:
-   v4lconvert_rgb24_to_yuv420(d, dest, fmt, 0, 0);
+   v4lconvert_rgb24_to_yuv420(d, dest, fmt, 0, 0, 0);
break;
case V4L2_PIX_FMT_YVU420:
-   v4lconvert_rgb24_to_yuv420(d, dest, fmt, 0, 1);
+   v4lconvert_rgb24_to_yuv420(d, dest, fmt, 0, 1, 0);
break;
}
break;
@@ -1079,10 +1081,10 @@ static int v4lconvert_convert_pixfmt(struct 
v4lconvert_data *data,
v4lconvert_swap_rgb(src, dest, width, height);
break;
case V4L2_PIX_FMT_YUV420:
-   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 0);
+   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 0, 0);
break;
case V4L2_PIX_FMT_YVU420:
-   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 1);
+   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 1, 0);
break;
}
if (src_size  (width * height * 3)) {
@@ -1101,10 +1103,10 @@ static int v4lconvert_convert_pixfmt(struct 
v4lconvert_data *data,
memcpy(dest, src, width * height * 3);
break;
case V4L2_PIX_FMT_YUV420:
-   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 0);
+   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 0, 0);
break;
case V4L2_PIX_FMT_YVU420:
-   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 1);
+   v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 1, 0);
break;
}
if (src_size  (width * height * 3)) {
@@ -1114,6 +1116,50 @@ static int v4lconvert_convert_pixfmt(struct 
v4lconvert_data *data,
}
break;
 
+   case V4L2_PIX_FMT_RGB32:
+   switch (dest_pix_fmt) {
+   case V4L2_PIX_FMT_RGB24:
+   v4lconvert_rgb32_to_rgb24(src, dest, width, height, 0);
+   break;
+   case V4L2_PIX_FMT_BGR24:
+   v4lconvert_rgb32_to_rgb24(src, dest, width, height, 1);
+   break;
+   case V4L2_PIX_FMT_YUV420:
+