diff options
author | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 17:15:12 +0200 |
---|---|---|
committer | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 17:15:12 +0200 |
commit | 6d0c45027f9fe1891269de296adab0af9a21d214 (patch) | |
tree | 81acfd835ece236fc4cd124c44d04455247a6be8 | |
parent | b373ec3cc6f05fec60f972d8b42ddcd0f2d1c29a (diff) | |
download | mediapointer-dvb-s2-6d0c45027f9fe1891269de296adab0af9a21d214.tar.gz mediapointer-dvb-s2-6d0c45027f9fe1891269de296adab0af9a21d214.tar.bz2 |
libv4l: add rgb24 <-> bgr24 conversion
From: Hans de Goede <j.w.r.degoede@hhs.nl>
libv4l: add rgb24 <-> bgr24 conversion
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 3 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 20 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c | 15 |
3 files changed, 37 insertions, 1 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index a85121cad..bdf847186 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -77,6 +77,9 @@ void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst, void v4lconvert_yuv420_to_bgr24(const unsigned char *src, unsigned char *dst, int width, int height); +void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst, + int width, int height); + void v4lconvert_spca501_to_yuv420(const unsigned char *src, unsigned char *dst, int width, int height); diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index e19b2f05b..4c9e67d52 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -414,8 +414,26 @@ int v4lconvert_convert(struct v4lconvert_data *data, } case V4L2_PIX_FMT_RGB24: + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_BGR24: + v4lconvert_swap_rgb(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_YUV420: + printf("FIXME add rgb24 -> yuv420 conversion\n"); + break; + } + break; case V4L2_PIX_FMT_BGR24: - printf("FIXME add rgb24/bgr24 -> yuv420 conversion\n"); + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_swap_rgb(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_YUV420: + printf("FIXME add bgr24 -> yuv420 conversion\n"); + break; + } break; case V4L2_PIX_FMT_YUV420: diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c index bda4cc342..742dd06ce 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c @@ -127,3 +127,18 @@ void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dest, } } } + +void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst, + int width, int height) +{ + int i; + + for (i = 0; i < (width * height); i++) { + unsigned char tmp0, tmp1; + tmp0 = *src++; + tmp1 = *src++; + *dst++ = *src++; + *dst++ = tmp1; + *dst++ = tmp0; + } +} |