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_RGB1_CCIR_BT709(cb1, cr1) \ 48 r_add = ONE_HALF + FIX(1.5747 * 255.0 / 224.0) * cr; \ 49 g_add = ONE_HALF - FIX(0.1873 * 255.0 / 224.0) * cb - \ 50 FIX(0.4682 * 255.0 / 224.0) * cr; \ 51 b_add = ONE_HALF + FIX(1.8556 * 255.0 / 224.0) * cb; \ 55 #define YUV_TO_RGB2_CCIR(r, g, b, y1)\ 57 y = ((y1) - 16) * FIX(255.0/219.0);\ 58 r = cm[(y + r_add) >> SCALEBITS];\ 59 g = cm[(y + g_add) >> SCALEBITS];\ 60 b = cm[(y + b_add) >> SCALEBITS];\ 63 #define YUV_TO_RGB1(cb1, cr1)\ 67 r_add = FIX(1.40200) * cr + ONE_HALF;\ 68 g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\ 69 b_add = FIX(1.77200) * cb + ONE_HALF;\ 72 #define YUV_TO_RGB2(r, g, b, y1)\ 74 y = (y1) << SCALEBITS;\ 75 r = cm[(y + r_add) >> SCALEBITS];\ 76 g = cm[(y + g_add) >> SCALEBITS];\ 77 b = cm[(y + b_add) >> SCALEBITS];\ 80 #define Y_CCIR_TO_JPEG(y)\ 81 cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS] 83 #define Y_JPEG_TO_CCIR(y)\ 84 (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS) 86 #define C_CCIR_TO_JPEG(y)\ 87 cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS] 98 #define RGB_TO_Y_CCIR(r, g, b) \ 99 ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \ 100 FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS) 102 #define RGB_TO_U_CCIR(r1, g1, b1, shift)\ 103 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \ 104 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) 106 #define RGB_TO_V_CCIR(r1, g1, b1, shift)\ 107 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \ 108 FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
static int C_JPEG_TO_CCIR(int y)