From f6499d7a84deb81d7bd73521c5d4bc3a448bc830 Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Sun, 12 Jun 2022 16:10:34 -0600 Subject: [PATCH] Add BGR color conversion --- src/video_common.cpp | 27 +++++++++++++++++++++++---- src/video_common.hpp | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/video_common.cpp b/src/video_common.cpp index 94002f2d..976efa33 100644 --- a/src/video_common.cpp +++ b/src/video_common.cpp @@ -364,15 +364,22 @@ void vid_uyvyto420p(unsigned char *img_dst, unsigned char *img_src, int width, i } } -void vid_rgb24toyuv420p(unsigned char *img_dst, unsigned char *img_src, int width, int height) +static void vid_rgb_bgr(unsigned char *img_dst, unsigned char *img_src + , int width, int height, int rgb) { unsigned char *y, *u, *v; unsigned char *r, *g, *b; int i, loop; - r = img_src; - g = r + 1; - b = g + 1; + if (rgb == 1) { + r = img_src; + g = r + 1; + b = g + 1; + } else { + b = img_src; + g = b + 1; + r = g + 1; + } y = img_dst; u = y + width * height; @@ -405,6 +412,18 @@ void vid_rgb24toyuv420p(unsigned char *img_dst, unsigned char *img_src, int widt } } +void vid_rgb24toyuv420p(unsigned char *img_dst, unsigned char *img_src + , int width, int height) +{ + vid_rgb_bgr(img_dst, img_src, width, height, 1); +} + +void vid_bgr24toyuv420p(unsigned char *img_dst, unsigned char *img_src + , int width, int height) +{ + vid_rgb_bgr(img_dst, img_src, width, height, 0); +} + /** * mjpegtoyuv420p * diff --git a/src/video_common.hpp b/src/video_common.hpp index 6be1df64..711d82a0 100644 --- a/src/video_common.hpp +++ b/src/video_common.hpp @@ -24,6 +24,7 @@ void vid_yuv422to420p(unsigned char *img_dest, unsigned char *img_src, int width void vid_yuv422pto420p(unsigned char *img_dest, unsigned char *img_src, int width, int height); void vid_uyvyto420p(unsigned char *img_dest, unsigned char *img_src, int width, int height); void vid_rgb24toyuv420p(unsigned char *img_dest, unsigned char *img_src, int width, int height); +void vid_bgr24toyuv420p(unsigned char *img_dest, unsigned char *img_src, int width, int height); void vid_bayer2rgb24(unsigned char *img_dst, unsigned char *img_src, long int width, long int height); void vid_y10torgb24(unsigned char *img_dest, unsigned char *img_src, int width, int height, int shift); void vid_greytoyuv420p(unsigned char *img_dest, unsigned char *img_src, int width, int height);