25 #ifndef FIREVISION_UTILS_COLOR_YUVRGB_H_ 26 #define FIREVISION_UTILS_COLOR_YUVRGB_H_ 28 #include <fvutils/color/rgb.h> 29 #include <fvutils/color/yuv.h> 31 namespace firevision {
33 #define YUV2RGB(y, u, v, r, g, b) \ 35 r = y + ((v * 1436) >> 10); \ 36 g = y - ((u * 352 + v * 731) >> 10); \ 37 b = y + ((u * 1814) >> 10); \ 41 r = r > 255 ? 255 : r; \ 42 g = g > 255 ? 255 : g; \ 43 b = b > 255 ? 255 : b; \ 46 #define clip(x) (unsigned char)((x) < 0 ? 0 : ((x) > 255 ? 255 : (x))) 48 #define yuv411packed_to_rgb(YUV, RGB, width, height) \ 49 yuv411packed_to_rgb_plainc(YUV, RGB, width, height) 66 void yuv411packed_to_rgb_plainc(
const unsigned char *YUV,
86 void yuv422planar_to_rgb_plainc(
const unsigned char *planar,
91 void yuv422packed_to_rgb_plainc(
const unsigned char *planar,
93 const unsigned int width,
94 const unsigned int height);
96 void yuv422planar_to_bgr_plainc(
const unsigned char *planar,
101 void yuv422planar_to_rgb_with_alpha_plainc(
const unsigned char *planar,
104 unsigned int height);
106 void yuv422planar_to_bgr_with_alpha_plainc(
const unsigned char *planar,
109 unsigned int height);
111 void yuv422packed_to_bgr_with_alpha_plainc(
const unsigned char *YUV,
114 unsigned int height);
116 #if (defined __i386__ || defined __386__ || defined __X86__ || defined _M_IX86 || defined i386) 117 void yuv411planar_to_rgb_mmx(
const unsigned char *yuv,
124 pixel_yuv_to_rgb(
const unsigned char y,
137 *r = clip((76284 * yt + 104595 * vt) >> 16);
138 *g = clip((76284 * yt - 25625 * ut - 53281 * vt) >> 16);
139 *b = clip((76284 * yt + 132252 * ut) >> 16);
154 convert_line_yuv422planar_to_rgb(
const unsigned char *YUV,
158 unsigned int yuv_line,
159 unsigned int rgb_line)
163 const unsigned char *yp, *up, *vp;
165 yp = YUV + (width * yuv_line);
166 up = YUV422_PLANAR_U_PLANE(YUV, width, height) + (width * yuv_line / 2);
167 vp = YUV422_PLANAR_V_PLANE(YUV, width, height) + (width * yuv_line / 2);
169 RGB += 3 * width * rgb_line;
177 pixel_yuv_to_rgb(*yp++, *up, *vp, &(r1->R), &(r1->G), &(r1->B));
178 pixel_yuv_to_rgb(*yp++, *up++, *vp++, &(r2->R), &(r2->G), &(r2->B));