The patch number 11004 was added via h...@rhel5-devel.localdomain to http://linuxtv.org/hg/v4l-dvb master development tree.
Kernel patches in this development tree may be modified to be backward compatible with older kernels. Compatibility modifications will be removed before inclusion into the mainstream Kernel If anyone has any objections, please let us know by sending a message to: Linux Media Mailing List <linux-me...@vger.kernel.org> ------ From: Julien BLACHE <j...@jblache.org> libv4l: add UYVY support Attached is a patch to add UYVY support to libv4lconvert. It's obviously a shameless respin of the YVYU conversion routines :P Tested on a USB Apple iSight, which only supports UYVY. Priority: normal Signed-off-by: Julien BLACHE <j...@jblache.org> Signed-off-by: Hans de Goede <hdego...@redhat.com> --- v4l2-apps/libv4l/ChangeLog | 5 v4l2-apps/libv4l/Makefile | 2 v4l2-apps/libv4l/libv4l2/log.c | 2 v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h | 9 + v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c | 18 ++ v4l2-apps/libv4l/libv4lconvert/rgbyuv.c | 91 ++++++++++++ 6 files changed, 125 insertions(+), 2 deletions(-) diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/ChangeLog --- a/v4l2-apps/libv4l/ChangeLog Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/ChangeLog Wed Mar 11 13:16:01 2009 +0100 @@ -1,3 +1,8 @@ libv4l-0.5.7 +libv4l-0.5.8 +------------ +* Add support for UYVY (for USB Apple iSight) patch by Julien BLACHE + <j...@jblache.org> + libv4l-0.5.7 ------------ * Fix a nasty (and stupid) bug in the special try_fmt handling for UVC cams diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/Makefile --- a/v4l2-apps/libv4l/Makefile Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/Makefile Wed Mar 11 13:16:01 2009 +0100 @@ -1,5 +1,5 @@ LIB_RELEASE=0 LIB_RELEASE=0 -V4L2_LIB_VERSION=$(LIB_RELEASE).5.7 +V4L2_LIB_VERSION=$(LIB_RELEASE).5.8 all clean install: $(MAKE) -C libv4lconvert V4L2_LIB_VERSION=$(V4L2_LIB_VERSION) $@ diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/libv4l2/log.c --- a/v4l2-apps/libv4l/libv4l2/log.c Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/libv4l2/log.c Wed Mar 11 13:16:01 2009 +0100 @@ -121,7 +121,7 @@ void v4l2_log_ioctl(unsigned long int re { struct v4l2_fmtdesc *fmt = arg; fprintf(v4l2_log_file, " index: %u, description: %s\n", - fmt->index, (result < 0) ? "" : fmt->description); + fmt->index, (result < 0) ? "" : (const char *)fmt->description); } break; case VIDIOC_G_FMT: diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h --- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert-priv.h Wed Mar 11 13:16:01 2009 +0100 @@ -132,6 +132,15 @@ void v4lconvert_yvyu_to_yuv420(const uns void v4lconvert_yvyu_to_yuv420(const unsigned char *src, unsigned char *dst, int width, int height, int yvu); +void v4lconvert_uyvy_to_rgb24(const unsigned char *src, unsigned char *dst, + int width, int height); + +void v4lconvert_uyvy_to_bgr24(const unsigned char *src, unsigned char *dst, + int width, int height); + +void v4lconvert_uyvy_to_yuv420(const unsigned char *src, unsigned char *dst, + int width, int height, int yvu); + void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst, int width, int height); diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c --- a/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/libv4lconvert/libv4lconvert.c Wed Mar 11 13:16:01 2009 +0100 @@ -44,6 +44,7 @@ static const struct v4lconvert_pixfmt su SUPPORTED_DST_PIXFMTS, { V4L2_PIX_FMT_YUYV, 0 }, { V4L2_PIX_FMT_YVYU, 0 }, + { V4L2_PIX_FMT_UYVY, 0 }, { V4L2_PIX_FMT_SBGGR8, 0 }, { V4L2_PIX_FMT_SGBRG8, 0 }, { V4L2_PIX_FMT_SGRBG8, 0 }, @@ -714,6 +715,23 @@ static int v4lconvert_convert_pixfmt(str break; case V4L2_PIX_FMT_YVU420: v4lconvert_yvyu_to_yuv420(src, dest, width, height, 1); + break; + } + break; + + case V4L2_PIX_FMT_UYVY: + switch (dest_pix_fmt) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_uyvy_to_rgb24(src, dest, width, height); + break; + case V4L2_PIX_FMT_BGR24: + v4lconvert_uyvy_to_bgr24(src, dest, width, height); + break; + case V4L2_PIX_FMT_YUV420: + v4lconvert_uyvy_to_yuv420(src, dest, width, height, 0); + break; + case V4L2_PIX_FMT_YVU420: + v4lconvert_uyvy_to_yuv420(src, dest, width, height, 1); break; } break; diff -r 7a76802a9780 -r f65c29638ecf v4l2-apps/libv4l/libv4lconvert/rgbyuv.c --- a/v4l2-apps/libv4l/libv4lconvert/rgbyuv.c Wed Mar 11 13:15:43 2009 +0100 +++ b/v4l2-apps/libv4l/libv4lconvert/rgbyuv.c Wed Mar 11 13:16:01 2009 +0100 @@ -378,6 +378,97 @@ void v4lconvert_yvyu_to_yuv420(const uns } } +void v4lconvert_uyvy_to_bgr24(const unsigned char *src, unsigned char *dest, + int width, int height) +{ + int j; + + while (--height >= 0) { + for (j = 0; j < width; j += 2) { + int u = src[0]; + int v = src[2]; + int u1 = (((u - 128) << 7) + (u - 128)) >> 6; + int rg = (((u - 128) << 1) + (u - 128) + + ((v - 128) << 2) + ((v - 128) << 1)) >> 3; + int v1 = (((v - 128) << 1) + (v - 128)) >> 1; + + *dest++ = CLIP(src[1] + u1); + *dest++ = CLIP(src[1] - rg); + *dest++ = CLIP(src[1] + v1); + + *dest++ = CLIP(src[3] + u1); + *dest++ = CLIP(src[3] - rg); + *dest++ = CLIP(src[3] + v1); + src += 4; + } + } +} + +void v4lconvert_uyvy_to_rgb24(const unsigned char *src, unsigned char *dest, + int width, int height) +{ + int j; + + while (--height >= 0) { + for (j = 0; j < width; j += 2) { + int u = src[0]; + int v = src[2]; + int u1 = (((u - 128) << 7) + (u - 128)) >> 6; + int rg = (((u - 128) << 1) + (u - 128) + + ((v - 128) << 2) + ((v - 128) << 1)) >> 3; + int v1 = (((v - 128) << 1) + (v - 128)) >> 1; + + *dest++ = CLIP(src[1] + v1); + *dest++ = CLIP(src[1] - rg); + *dest++ = CLIP(src[1] + u1); + + *dest++ = CLIP(src[3] + v1); + *dest++ = CLIP(src[3] - rg); + *dest++ = CLIP(src[3] + u1); + src += 4; + } + } +} + +void v4lconvert_uyvy_to_yuv420(const unsigned char *src, unsigned char *dest, + int width, int height, int yvu) +{ + int i, j; + const unsigned char *src1; + unsigned char *udest, *vdest; + + /* copy the Y values */ + src1 = src; + for (i = 0; i < height; i++) { + for (j = 0; j < width; j += 2) { + *dest++ = src1[1]; + *dest++ = src1[3]; + src1 += 4; + } + } + + /* copy the U and V values */ + src++; /* point to V */ + src1 = src + width * 2; /* next line */ + if (yvu) { + vdest = dest; + udest = dest + width * height / 4; + } else { + udest = dest; + vdest = dest + width * height / 4; + } + for (i = 0; i < height; i += 2) { + for (j = 0; j < width; j += 2) { + *udest++ = ((int) src[0] + src1[0]) / 2; /* U */ + *vdest++ = ((int) src[2] + src1[2]) / 2; /* V */ + src += 4; + src1 += 4; + } + src = src1; + src1 += width * 2; + } +} + void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst, int width, int height) { --- Patch is available at: http://linuxtv.org/hg/v4l-dvb/rev/f65c29638ecfadc683ebf6e60f90bd1fd97ad50f _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits