Go to the documentation of this file.
27 #ifndef AVUTIL_COLORSPACE_H
28 #define AVUTIL_COLORSPACE_H
31 #define ONE_HALF (1 << (SCALEBITS - 1))
32 #define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
34 #define YUV_TO_RGB1_CCIR(cb1, cr1)\
38 r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
39 g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
41 b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
44 #define YUV_TO_RGB2_CCIR(r, g, b, y1)\
46 y = ((y1) - 16) * FIX(255.0/219.0);\
47 r = cm[(y + r_add) >> SCALEBITS];\
48 g = cm[(y + g_add) >> SCALEBITS];\
49 b = cm[(y + b_add) >> SCALEBITS];\
52 #define YUV_TO_RGB1(cb1, cr1)\
56 r_add = FIX(1.40200) * cr + ONE_HALF;\
57 g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
58 b_add = FIX(1.77200) * cb + ONE_HALF;\
61 #define YUV_TO_RGB2(r, g, b, y1)\
63 y = (y1) << SCALEBITS;\
64 r = cm[(y + r_add) >> SCALEBITS];\
65 g = cm[(y + g_add) >> SCALEBITS];\
66 b = cm[(y + b_add) >> SCALEBITS];\
69 #define Y_CCIR_TO_JPEG(y)\
70 cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
72 #define Y_JPEG_TO_CCIR(y)\
73 (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
75 #define C_CCIR_TO_JPEG(y)\
76 cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
87 #define RGB_TO_Y(r, g, b) \
88 ((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
89 FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
91 #define RGB_TO_U(r1, g1, b1, shift)\
92 (((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
93 FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
95 #define RGB_TO_V(r1, g1, b1, shift)\
96 (((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
97 FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
99 #define RGB_TO_Y_CCIR(r, g, b) \
100 ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
101 FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
103 #define RGB_TO_U_CCIR(r1, g1, b1, shift)\
104 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
105 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
107 #define RGB_TO_V_CCIR(r1, g1, b1, shift)\
108 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
109 FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)