Add support for V4L2_PIX_FMT_Y16, V4L2_PIX_FMT_RGB32 and V4L2_PIX_FMT_BGR32
v2 cover Add support for V4L2_PIX_FMT_Y16, V4L2_PIX_FMT_RGB32 and V4L2_PIX_FMT_BGR32
This patch adds support for 3 new formats.
v2: Includes feedback from Gregor Jasny
Gregor: Replaces rbg32 flag with bytesperpixes
Ricardo Ribalda Delgado (2):
libv4lconvert: Support for Y16 pixel format
libv4lconvert: Support for RGB32 and BGR32 format
lib/libv4lconvert/libv4lconvert-priv.h | 11 ++++- lib/libv4lconvert/libv4lconvert.c | 77 +++++++++++++++++++++++++++++--- lib/libv4lconvert/rgbyuv.c | 75 ++++++++++++++++++++++++++----- 3 files changed, 145 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/2 libv4lconvert: Support for Y16 pixel format
This patch adds support for V4L2_PIX_FMT_Y16 format.
--- lib/libv4lconvert/libv4lconvert-priv.h | 6 ++++++ lib/libv4lconvert/libv4lconvert.c | 19 +++++++++++++++++++ lib/libv4lconvert/rgbyuv.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)
lib/libv4lconvert/libv4lconvert-priv.h +6 -0
@@ -152,6 +152,12 @@ void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,void v4lconvert_grey_to_yuv420 (const unsigned char *src,unsigned char *dest,const struct v4l2_format *src_fmt); +void v4lconvert_y16_to_rgb24 (const unsigned char *src,unsigned char *dest, +int width,int height); + +void v4lconvert_y16_to_yuv420 (const unsigned char *src,unsigned char *dest, +const struct v4l2_format *src_fmt); +int v4lconvert_y10b_to_rgb24 (struct v4lconvert_data *data,const unsigned char *src,unsigned char *dest,int width,int height);
lib/libv4lconvert/libv4lconvert.c +19 -0
@@ -128,6 +128,7 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = { { V4L2_PIX_FMT_Y4, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y6, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y10BPACK, 10, 20, 20, 0 }, + { V4L2_PIX_FMT_Y16, 16, 20, 20, 0 }, }; static const struct v4lconvert_pixfmt supported_dst_pixfmts[] = {
@@ -989,6 +990,24 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,break ; } +case V4L2_PIX_FMT_Y16 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : +case V4L2_PIX_FMT_BGR24 : +v4lconvert_y16_to_rgb24 (src, dest, width, height); +break ; +case V4L2_PIX_FMT_YUV420 : +case V4L2_PIX_FMT_YVU420 : +v4lconvert_y16_to_yuv420 (src, dest, fmt); +break ; + } +if (src_size < (width * height *2 )) { +V4LCONVERT_ERR ("short y16 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ; +case V4L2_PIX_FMT_GREY :case V4L2_PIX_FMT_Y4 :case V4L2_PIX_FMT_Y6 :
lib/libv4lconvert/rgbyuv.c +30 -0
@@ -586,6 +586,36 @@ void v4lconvert_rgb565_to_yuv420(const unsigned char *src, unsigned char *dest, } } +void v4lconvert_y16_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+=2 ; + } + } +} + +void v4lconvert_y16_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; + src+=2 ; + } + +/* Clear U/V */ +memset (dest,0x80 , src_fmt->fmt.pix.width * src_fmt->fmt.pix.height /2 ); +} +void v4lconvert_grey_to_rgb24 (const unsigned char *src,unsigned char *dest,int width,int height) {
Signature · 1 line
1.7.10.4
PATCH v2 2/2 libv4lconvert: Support for RGB32 and BGR32 format
In reply to Ricardo Ribalda DelgadoThis patch adds support for V4L2_PIX_FMT_BGR32 and V4L2_PIX_FMT_BGR32 formats.
--- lib/libv4lconvert/libv4lconvert-priv.h | 5 ++- lib/libv4lconvert/libv4lconvert.c | 58 ++++++++++++++++++++++++++++---- lib/libv4lconvert/rgbyuv.c | 45 +++++++++++++++++++------ 3 files changed, 90 insertions(+), 18 deletions(-)
lib/libv4lconvert/libv4lconvert-priv.h +4 -1
@@ -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 bpp);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);
lib/libv4lconvert/libv4lconvert.c +52 -6
94 lines not on this page · raw message
lib/libv4lconvert/rgbyuv.c +34 -11
72 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH v2 2/2] libv4lconvert: Support for RGB32 and BGR32 format
Quoted 11 lines · Ricardo Ribalda Delgado
lib/libv4lconvert/libv4lconvert.c +11
-0+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 : +v4lconvert_rgb24_to_yuv420 (src, dest, fmt,0 ,0 ,4 ); +break ;
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1139
Quoted 10 lines
lib/libv4lconvert/libv4lconvert.c +10
-0+case V4L2_PIX_FMT_YVU420 : +v4lconvert_rgb24_to_yuv420 (src, dest, fmt,0 ,1 ,4 ); +break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short rgb32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;
I have not looked at the whole function but shouldn't this sanity check happen before the actual work? Also aren't you applying the condition here also for rgb24_to_xxx which should have only three bpp?
Quoted 11 lines
lib/libv4lconvert/libv4lconvert.c +11
-0+case V4L2_PIX_FMT_BGR32 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : +v4lconvert_rgb32_to_rgb24 (src, dest, width, height,1 ); +break ; +case V4L2_PIX_FMT_BGR24 : +v4lconvert_rgb32_to_rgb24 (src, dest, width, height,0 ); +break ; +case V4L2_PIX_FMT_YUV420 : +v4lconvert_rgb24_to_yuv420 (src, dest, fmt,1 ,0 ,4 ); +break ;
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1161
Quoted 10 lines
lib/libv4lconvert/libv4lconvert.c +10
-0+case V4L2_PIX_FMT_YVU420 : +v4lconvert_rgb24_to_yuv420 (src, dest, fmt,1 ,1 ,4 ); +break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short bgr32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;
Same here. And also in the other patch.
Re: [PATCH v2 2/2] libv4lconvert: Support for RGB32 and BGR32 format
Hello Gregor
Thanks for your comments. I have replied inline.
Quoted 29 lines · Gregor Jasny
Quoted 18 lines · Ricardo Ribalda Delgado
lib/libv4lconvert/libv4lconvert.c +4
-0+case V4L2_PIX_FMT_RGB32 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 0);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_BGR24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 1);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YUV420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 0,4);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YVU420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 1,4);
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1139
Quoted 8 lines
lib/libv4lconvert/libv4lconvert.c +8
-0+break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short rgb32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;
Quoted 2 lines
I have not looked at the whole function but shouldn't this sanity check happen before the actual work?
Yes, but it is how it is done in the whole library with all the formats. Please grep for "short " on libv4lconvert.c
Quoted 3 lines
Also aren't you applying the condition here also for
rgb24_to_xxxwhich should have only three bpp?
I have modified the function rgb24_to_yuv420 to support other bytes per pixel.
Quoted 28 lines
Quoted 18 lines
lib/libv4lconvert/libv4lconvert.c +4
-0+case V4L2_PIX_FMT_BGR32 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 1);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_BGR24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 0);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YUV420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 0,4);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YVU420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 1,4);
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1161
Quoted 8 lines
lib/libv4lconvert/libv4lconvert.c +8
-0+break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short bgr32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;
Quoted 3 lines
Same here. And also in the other patch.
Thanks again
Signature · 1 line
Ricardo Ribalda
Re: [PATCH v2 2/2] libv4lconvert: Support for RGB32 and BGR32 format
ping?
Quoted 82 lines · Ricardo Ribalda Delgado
Hello Gregor
Thanks for your comments. I have replied inline.
Quoted 29 lines · Gregor Jasny
Quoted 18 lines · Ricardo Ribalda Delgado
lib/libv4lconvert/libv4lconvert.c +4
-0+case V4L2_PIX_FMT_RGB32 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 0);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_BGR24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 1);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YUV420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 0,4);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YVU420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 0, 1,4);
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1139
Quoted 8 lines
lib/libv4lconvert/libv4lconvert.c +8
-0+break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short rgb32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;Quoted 2 lines
I have not looked at the whole function but shouldn't this sanity check happen before the actual work?
Yes, but it is how it is done in the whole library with all the formats. Please grep for "short " on
libv4lconvert.cQuoted 3 lines
Also aren't you applying the condition here also for
rgb24_to_xxxwhich should have only three bpp?I have modified the function
rgb24_to_yuv420to support other bytes per pixel.Quoted 28 lines
Quoted 18 lines
lib/libv4lconvert/libv4lconvert.c +4
-0+case V4L2_PIX_FMT_BGR32 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 1);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_BGR24 : + v4lconvert_rgb32_to_rgb24(src, dest, width,height, 0);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YUV420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 0,4);
lib/libv4lconvert/libv4lconvert.c +3
-0+break ; +case V4L2_PIX_FMT_YVU420 : + v4lconvert_rgb24_to_yuv420(src, dest, fmt, 1, 1,4);
lib/libv4lconvert/libv4lconvert.c static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, · line 1161
Quoted 8 lines
lib/libv4lconvert/libv4lconvert.c +8
-0+break ; + } +if (src_size < (width * height *4 )) { +V4LCONVERT_ERR ("short bgr32 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ;Quoted 3 lines
Same here. And also in the other patch.
Thanks again
--
Ricardo Ribalda
Signature · 1 line
Ricardo Ribalda
Re: [PATCH v2 1/2] libv4lconvert: Support for Y16 pixel format
In reply to Ricardo Ribalda Delgadoping?
Quoted 107 lines · Ricardo Ribalda Delgado
This patch adds support for
V4L2_PIX_FMT_Y16format.Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- lib/libv4lconvert/libv4lconvert-priv.h | 6 ++++++ lib/libv4lconvert/libv4lconvert.c | 19 +++++++++++++++++++ lib/libv4lconvert/rgbyuv.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)lib/libv4lconvert/libv4lconvert-priv.h +6
-0@@ -152,6 +152,12 @@ void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest,void v4lconvert_grey_to_yuv420 (const unsigned char *src,unsigned char *dest,const struct v4l2_format *src_fmt); +void v4lconvert_y16_to_rgb24 (const unsigned char *src,unsigned char *dest, +int width,int height); + +void v4lconvert_y16_to_yuv420 (const unsigned char *src,unsigned char *dest, +const struct v4l2_format *src_fmt); +int v4lconvert_y10b_to_rgb24 (struct v4lconvert_data *data,const unsigned char *src,unsigned char *dest,int width,int height);lib/libv4lconvert/libv4lconvert.c +19
-0@@ -128,6 +128,7 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = { { V4L2_PIX_FMT_Y4, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y6, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y10BPACK, 10, 20, 20, 0 }, + { V4L2_PIX_FMT_Y16, 16, 20, 20, 0 }, }; static const struct v4lconvert_pixfmt supported_dst_pixfmts[] = {@@ -989,6 +990,24 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data,break ; } +case V4L2_PIX_FMT_Y16 : +switch (dest_pix_fmt) { +case V4L2_PIX_FMT_RGB24 : +case V4L2_PIX_FMT_BGR24 : +v4lconvert_y16_to_rgb24 (src, dest, width, height); +break ; +case V4L2_PIX_FMT_YUV420 : +case V4L2_PIX_FMT_YVU420 : +v4lconvert_y16_to_yuv420 (src, dest, fmt); +break ; + } +if (src_size < (width * height *2 )) { +V4LCONVERT_ERR ("short y16 data frame\n" ); + errno =EPIPE ; + result =-1 ; + } +break ; +case V4L2_PIX_FMT_GREY :case V4L2_PIX_FMT_Y4 :case V4L2_PIX_FMT_Y6 :lib/libv4lconvert/rgbyuv.c +30
-1@@ -586,6 +586,36 @@ void v4lconvert_rgb565_to_yuv420(const unsigned char *src, unsigned char *dest, } } +void v4lconvert_y16_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+=2 ; + } + } +} + +void v4lconvert_y16_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; + src+=2 ; + } + +/* Clear U/V */ +memset (dest,0x80 , src_fmt->fmt.pix.width * src_fmt->fmt.pix.height /2 ); +} +void v4lconvert_grey_to_rgb24 (const unsigned char *src,unsigned char *dest,int width,int height) { --1.7.10.4
Signature · 1 line
Ricardo Ribalda
Re: [PATCH v2 1/2] libv4lconvert: Support for Y16 pixel format
Quoted 1 line · Ricardo Ribalda Delgado
ping?
Thank you for your the updated series.
Unfortunately I'm still partially busy with moving. I hoped the v4lconvert maintainer Hans (de Goede) will ack these patches. If this series does not get an ack by Sunday I'll double check and commit.
What hardware did you use to test this?
Thanks,
Gregor
Re: [PATCH v2 1/2] libv4lconvert: Support for Y16 pixel format
Hello Gregor
I am using some cameras from qtec.com. In fact, I am developing the firmware for them :)
qv4l2 has been very useful for testing.
Thanks for your response.
Quoted 15 lines · Gregor Jasny
Quoted 2 lines · Ricardo Ribalda Delgado
ping?
Thank you for your the updated series.
Unfortunately I'm still partially busy with moving. I hoped the v4lconvert maintainer Hans (de Goede) will ack these patches. If this series does not get an ack by Sunday I'll double check and commit.
What hardware did you use to test this?
Thanks,
Gregor
Signature · 1 line
Ricardo Ribalda
Hans de Goede
Acked-byRe: [PATCH v2 1/2] libv4lconvert: Support for Y16 pixel format
In reply to Gregor JasnyHi,
Quoted 6 lines · Gregor Jasny
Quoted 1 line · Ricardo Ribalda Delgado
ping?
Thank you for your the updated series.
Unfortunately I'm still partially busy with moving. I hoped the v4lconvert maintainer Hans (de Goede) will ack these patches.
Series looks good to me:
Regards,
Hans
Re: [PATCH v2 1/2] libv4lconvert: Support for Y16 pixel format
Quoted 3 lines · Hans de Goede
Series looks good to me:
Acked-by Hans de Goede <[email protected]>
I submitted it yesterday.