summaryrefslogtreecommitdiff
path: root/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps/lib/libv4l/libv4lconvert/bayer.c')
-rw-r--r--v4l2-apps/lib/libv4l/libv4lconvert/bayer.c30
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)