25 #ifndef __FIREVISION_UTILS_COLOR_CONVERSIONS_H 26 #define __FIREVISION_UTILS_COLOR_CONVERSIONS_H 28 #include <fvutils/color/yuv.h> 29 #include <fvutils/color/rgb.h> 30 #include <fvutils/color/yuvrgb.h> 31 #include <fvutils/color/rgbyuv.h> 32 #include <fvutils/color/bayer.h> 33 #include <fvutils/color/colorspaces.h> 35 #include <core/exception.h> 56 convert(colorspace_t from, colorspace_t to,
57 const unsigned char *src,
unsigned char *dst,
58 unsigned int width,
unsigned int height)
62 memcpy(dst, src, colorspace_buffer_size(from, width, height));
64 }
else if ( (from == YUV422_PACKED) && (to == YUV422_PLANAR) ) {
65 yuv422packed_to_yuv422planar(src, dst, width, height);
66 }
else if ( (from == YUY2) && (to == YUV422_PLANAR_QUARTER) ) {
67 yuy2_to_yuv422planar_quarter(src, dst, width, height);
68 }
else if ( (from == YUY2) && (to == YUV422_PLANAR) ) {
69 yuy2_to_yuv422planar(src, dst, width, height);
70 }
else if ( (from == YVY2) && (to == YUV422_PLANAR) ) {
71 yvy2_to_yuv422planar(src, dst, width, height);
80 }
else if ( (from == YUV411_PLANAR) && (to == RGB) ) {
81 yuv411planar_to_rgb_mmx(src, dst, width, height);
83 }
else if ( (from == BGR) && (to == RGB) ) {
84 bgr_to_rgb_plainc(src, dst, width, height);
85 }
else if ( (from == RGB) && (to == YUV411_PACKED) ) {
86 rgb_to_yuv411packed_plainc(src, dst, width, height);
87 }
else if ( (from == RGB) && (to == YUV422_PLANAR) ) {
88 rgb_to_yuv422planar_plainc(src, dst, width, height);
89 }
else if ( (from == YUV420_PLANAR) && (to == YUV422_PLANAR) ) {
90 yuv420planar_to_yuv422planar(src, dst, width, height);
91 }
else if ( (from == RGB) && (to == YUV422_PACKED) ) {
92 rgb_to_yuv422packed_plainc(src, dst, width, height);
93 }
else if ( (from == RGB_PLANAR) && (to == YUV422_PACKED) ) {
94 rgb_planar_to_yuv422packed_plainc(src, dst, width, height);
95 }
else if ( (from == RGB) && (to == RGB_PLANAR) ) {
96 rgb_to_rgb_planar_plainc(src, dst, width, height);
97 }
else if ( (from == RGB_PLANAR) && (to == RGB) ) {
98 rgb_planar_to_rgb_plainc(src, dst, width, height);
99 }
else if ( (from == BGR) && (to == YUV422_PLANAR) ) {
100 bgr_to_yuv422planar_plainc(src, dst, width, height);
101 }
else if ( (from == GRAY8) && (to == YUY2) ) {
102 gray8_to_yuy2(src, dst, width, height);
103 }
else if ( (from == GRAY8) && (to == YUV422_PLANAR) ) {
104 gray8_to_yuv422planar_plainc(src, dst, width, height);
105 }
else if ( (from == MONO8) && (to == YUV422_PLANAR) ) {
106 gray8_to_yuv422planar_plainc(src, dst, width, height);
107 }
else if ( (from == MONO8) && (to == YUV422_PACKED) ) {
108 gray8_to_yuv422packed_plainc(src, dst, width, height);
109 }
else if ( (from == MONO8) && (to == RGB) ) {
110 gray8_to_rgb_plainc(src, dst, width, height);
111 }
else if ( (from == YUV422_PLANAR) && (to == YUV422_PACKED) ) {
112 yuv422planar_to_yuv422packed(src, dst, width, height);
113 }
else if ( (from == YUV422_PLANAR_QUARTER) && (to == YUV422_PACKED) ) {
114 yuv422planar_quarter_to_yuv422packed(src, dst, width, height);
115 }
else if ( (from == YUV422_PLANAR_QUARTER) && (to == YUV422_PLANAR) ) {
116 yuv422planar_quarter_to_yuv422planar(src, dst, width, height);
117 }
else if ( (from == YUV422_PLANAR) && (to == RGB) ) {
118 yuv422planar_to_rgb_plainc(src, dst, width, height);
119 }
else if ( (from == YUV422_PACKED) && (to == RGB) ) {
120 yuv422packed_to_rgb_plainc(src, dst, width, height);
121 }
else if ( (from == YUV422_PLANAR) && (to == BGR) ) {
122 yuv422planar_to_bgr_plainc(src, dst, width, height);
123 }
else if ( (from == YUV422_PLANAR) && (to == RGB_WITH_ALPHA) ) {
124 yuv422planar_to_rgb_with_alpha_plainc(src, dst, width, height);
125 }
else if ( (from == RGB) && (to == RGB_WITH_ALPHA) ) {
126 rgb_to_rgb_with_alpha_plainc(src, dst, width, height);
127 }
else if ( (from == RGB) && (to == BGR_WITH_ALPHA) ) {
128 rgb_to_bgr_with_alpha_plainc(src, dst, width, height);
129 }
else if ( (from == YUV422_PLANAR) && (to == BGR_WITH_ALPHA) ) {
130 yuv422planar_to_bgr_with_alpha_plainc(src, dst, width, height);
131 }
else if ( (from == YUV422_PACKED) && (to == BGR_WITH_ALPHA) ) {
132 yuv422packed_to_bgr_with_alpha_plainc(src, dst, width, height);
133 }
else if ( (from == BAYER_MOSAIC_GBRG) && (to == YUV422_PLANAR) ) {
134 bayerGBRG_to_yuv422planar_bilinear(src, dst, width, height);
135 }
else if ( (from == BAYER_MOSAIC_GRBG) && (to == YUV422_PLANAR) ) {
136 bayerGRBG_to_yuv422planar_nearest_neighbour(src, dst, width, height);
137 }
else if ( (from == BAYER_MOSAIC_GRBG) && (to == YUV422_PLANAR) ) {
138 bayerGRBG_to_yuv422planar_bilinear(src, dst, width, height);
139 }
else if ( (from == YUV444_PACKED) && (to == YUV422_PLANAR) ) {
140 yuv444packed_to_yuv422planar(src, dst, width, height);
141 }
else if ( (from == YUV444_PACKED) && (to == YUV422_PACKED) ) {
142 yuv444packed_to_yuv422packed(src, dst, width, height);
143 }
else if ( (from == YVU444_PACKED) && (to == YUV422_PLANAR) ) {
144 yvu444packed_to_yuv422planar(src, dst, width, height);
145 }
else if ( (from == YVU444_PACKED) && (to == YUV422_PACKED) ) {
146 yvu444packed_to_yuv422packed(src, dst, width, height);
149 colorspace_to_string(from),
150 colorspace_to_string(to));
156 grayscale(colorspace_t cspace,
157 unsigned char *src,
unsigned char *dst,
158 unsigned int width,
unsigned int height)
162 grayscale_yuv422packed(src, dst, width, height);
165 grayscale_yuv422planar(src, dst, width, height);
169 "Images from colorspace %s are not supported.",
170 colorspace_to_string(cspace));
Base class for exceptions in Fawkes.