23 #include "conversions.h"
25 #include <core/exception.h>
26 #include <fvutils/color/bayer.h>
27 #include <fvutils/color/rgb.h>
28 #include <fvutils/color/rgbyuv.h>
29 #include <fvutils/color/yuv.h>
30 #include <fvutils/color/yuvrgb.h>
34 namespace firevision {
49 convert(colorspace_t from,
51 const unsigned char *src,
58 memcpy(dst, src, colorspace_buffer_size(from, width, height));
60 }
else if ((from == YUV422_PACKED) && (to == YUV422_PLANAR)) {
61 yuv422packed_to_yuv422planar(src, dst, width, height);
62 }
else if ((from == YUY2) && (to == YUV422_PLANAR_QUARTER)) {
63 yuy2_to_yuv422planar_quarter(src, dst, width, height);
64 }
else if ((from == YUY2) && (to == YUV422_PLANAR)) {
65 yuy2_to_yuv422planar(src, dst, width, height);
66 }
else if ((from == YVY2) && (to == YUV422_PLANAR)) {
67 yvy2_to_yuv422planar(src, dst, width, height);
69 #if (defined __i386__ || defined __386__ || defined __X86__ || defined _M_IX86 || defined i386)
70 }
else if ((from == YUV411_PLANAR) && (to == RGB)) {
71 yuv411planar_to_rgb_mmx(src, dst, width, height);
73 }
else if ((from == BGR) && (to == RGB)) {
74 bgr_to_rgb_plainc(src, dst, width, height);
75 }
else if ((from == RGB) && (to == YUV411_PACKED)) {
76 rgb_to_yuv411packed_plainc(src, dst, width, height);
77 }
else if ((from == RGB) && (to == YUV422_PLANAR)) {
78 rgb_to_yuv422planar_plainc(src, dst, width, height);
79 }
else if ((from == YUV420_PLANAR) && (to == YUV422_PLANAR)) {
80 yuv420planar_to_yuv422planar(src, dst, width, height);
81 }
else if ((from == RGB) && (to == YUV422_PACKED)) {
82 rgb_to_yuv422packed_plainc(src, dst, width, height);
83 }
else if ((from == RGB_PLANAR) && (to == YUV422_PACKED)) {
84 rgb_planar_to_yuv422packed_plainc(src, dst, width, height);
85 }
else if ((from == RGB) && (to == RGB_PLANAR)) {
86 rgb_to_rgb_planar_plainc(src, dst, width, height);
87 }
else if ((from == RGB_PLANAR) && (to == RGB)) {
88 rgb_planar_to_rgb_plainc(src, dst, width, height);
89 }
else if ((from == BGR) && (to == YUV422_PLANAR)) {
90 bgr_to_yuv422planar_plainc(src, dst, width, height);
91 }
else if ((from == GRAY8) && (to == YUY2)) {
92 gray8_to_yuy2(src, dst, width, height);
93 }
else if ((from == GRAY8) && (to == YUV422_PLANAR)) {
94 gray8_to_yuv422planar_plainc(src, dst, width, height);
95 }
else if ((from == MONO8) && (to == YUV422_PLANAR)) {
96 gray8_to_yuv422planar_plainc(src, dst, width, height);
97 }
else if ((from == MONO8) && (to == YUV422_PACKED)) {
98 gray8_to_yuv422packed_plainc(src, dst, width, height);
99 }
else if ((from == MONO8) && (to == RGB)) {
100 gray8_to_rgb_plainc(src, dst, width, height);
101 }
else if ((from == YUV422_PLANAR) && (to == YUV422_PACKED)) {
102 yuv422planar_to_yuv422packed(src, dst, width, height);
103 }
else if ((from == YUV422_PLANAR_QUARTER) && (to == YUV422_PACKED)) {
104 yuv422planar_quarter_to_yuv422packed(src, dst, width, height);
105 }
else if ((from == YUV422_PLANAR_QUARTER) && (to == YUV422_PLANAR)) {
106 yuv422planar_quarter_to_yuv422planar(src, dst, width, height);
107 }
else if ((from == YUV422_PLANAR) && (to == RGB)) {
108 yuv422planar_to_rgb_plainc(src, dst, width, height);
109 }
else if ((from == YUV422_PACKED) && (to == RGB)) {
110 yuv422packed_to_rgb_plainc(src, dst, width, height);
111 }
else if ((from == YUV422_PLANAR) && (to == BGR)) {
112 yuv422planar_to_bgr_plainc(src, dst, width, height);
113 }
else if ((from == YUV422_PLANAR) && (to == RGB_WITH_ALPHA)) {
114 yuv422planar_to_rgb_with_alpha_plainc(src, dst, width, height);
115 }
else if ((from == RGB) && (to == RGB_WITH_ALPHA)) {
116 rgb_to_rgb_with_alpha_plainc(src, dst, width, height);
117 }
else if ((from == RGB) && (to == BGR_WITH_ALPHA)) {
118 rgb_to_bgr_with_alpha_plainc(src, dst, width, height);
119 }
else if ((from == YUV422_PLANAR) && (to == BGR_WITH_ALPHA)) {
120 yuv422planar_to_bgr_with_alpha_plainc(src, dst, width, height);
121 }
else if ((from == YUV422_PACKED) && (to == BGR_WITH_ALPHA)) {
122 yuv422packed_to_bgr_with_alpha_plainc(src, dst, width, height);
123 }
else if ((from == BAYER_MOSAIC_GBRG) && (to == YUV422_PLANAR)) {
124 bayerGBRG_to_yuv422planar_bilinear(src, dst, width, height);
125 }
else if ((from == BAYER_MOSAIC_GRBG) && (to == YUV422_PLANAR)) {
126 bayerGRBG_to_yuv422planar_nearest_neighbour(src, dst, width, height);
127 }
else if ((from == BAYER_MOSAIC_GRBG) && (to == YUV422_PLANAR)) {
128 bayerGRBG_to_yuv422planar_bilinear(src, dst, width, height);
129 }
else if ((from == YUV444_PACKED) && (to == YUV422_PLANAR)) {
130 yuv444packed_to_yuv422planar(src, dst, width, height);
131 }
else if ((from == YUV444_PACKED) && (to == YUV422_PACKED)) {
132 yuv444packed_to_yuv422packed(src, dst, width, height);
133 }
else if ((from == YVU444_PACKED) && (to == YUV422_PLANAR)) {
134 yvu444packed_to_yuv422planar(src, dst, width, height);
135 }
else if ((from == YVU444_PACKED) && (to == YUV422_PACKED)) {
136 yvu444packed_to_yuv422packed(src, dst, width, height);
137 }
else if ((from == RGB) && (to == RGB_FLOAT)) {
138 rgb_to_rgbfloat(src, dst, width, height);
139 }
else if ((from == RGB_FLOAT) && (to == RGB)) {
140 rgbfloat_to_rgb(src, dst, width, height);
141 }
else if ((from == BGR) && (to == BGR_FLOAT)) {
142 rgb_to_rgbfloat(src, dst, width, height);
143 }
else if ((from == BGR_FLOAT) && (to == BGR)) {
150 colorspace_to_string(from),
151 colorspace_to_string(to));
156 grayscale(colorspace_t cspace,
163 case YUV422_PACKED: grayscale_yuv422packed(src, dst, width, height);
break;
164 case YUV422_PLANAR: grayscale_yuv422planar(src, dst, width, height);
break;
167 "Images from colorspace %s are not supported.",
168 colorspace_to_string(cspace));
Base class for exceptions in Fawkes.