diff options
author | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 12:43:49 +0200 |
---|---|---|
committer | hans@localhost.localdomain <hans@localhost.localdomain> | 2008-08-03 12:43:49 +0200 |
commit | d0280d4d77c5f7dd211cc827284347828e260ab9 (patch) | |
tree | fe85554044bd410d9a7ec3159d1adbaba11afe59 /v4l2-apps/lib/libv4l/libv4lconvert/bayer.c | |
parent | f07be0b40ae3cbb2ae809d5f4151782f68eabb42 (diff) | |
download | mediapointer-dvb-s2-d0280d4d77c5f7dd211cc827284347828e260ab9.tar.gz mediapointer-dvb-s2-d0280d4d77c5f7dd211cc827284347828e260ab9.tar.bz2 |
libv4l: add support for converting to rgb24
From: Jean-Francois Moine <moinejf@free.fr>
Add support for conversion to RGB24 (before we only support BGR24) based
on a patch by Jean-Francois Moine
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Diffstat (limited to 'v4l2-apps/lib/libv4l/libv4lconvert/bayer.c')
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/bayer.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c b/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c index 166c13011..ca7bb486f 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c @@ -163,14 +163,10 @@ static void v4lconvert_border_bayer_line_to_bgr24( } /* From libdc1394, which on turn was based on OpenCV's Bayer decoding */ -void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, - unsigned char *bgr, int width, int height, unsigned int pixfmt) +static void bayer_to_rgbbgr24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt, + int start_with_green, int blue_line) { - int blue_line = pixfmt == V4L2_PIX_FMT_SBGGR8 - || pixfmt == V4L2_PIX_FMT_SGBRG8; - int start_with_green = pixfmt == V4L2_PIX_FMT_SGBRG8 - || pixfmt == V4L2_PIX_FMT_SGRBG8; - /* render the first line */ v4lconvert_border_bayer_line_to_bgr24(bayer, bayer + width, bgr, width, start_with_green, blue_line); @@ -317,6 +313,26 @@ void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, !start_with_green, !blue_line); } +void v4lconvert_bayer_to_rgb24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt) +{ + bayer_to_rgbbgr24(bayer, bgr, width, height, pixfmt, + pixfmt == V4L2_PIX_FMT_SGBRG8 /* start with green */ + || pixfmt == V4L2_PIX_FMT_SGRBG8, + pixfmt != V4L2_PIX_FMT_SBGGR8 /* blue line */ + && pixfmt != V4L2_PIX_FMT_SGBRG8); +} + +void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt) +{ + bayer_to_rgbbgr24(bayer, bgr, width, height, pixfmt, + pixfmt == V4L2_PIX_FMT_SGBRG8 /* start with green */ + || pixfmt == V4L2_PIX_FMT_SGRBG8, + pixfmt == V4L2_PIX_FMT_SBGGR8 /* blue line */ + || pixfmt == V4L2_PIX_FMT_SGBRG8); +} + static void v4lconvert_border_bayer_line_to_y( const unsigned char* bayer, const unsigned char* adjacent_bayer, unsigned char *y, int width, int start_with_green, int blue_line) |