00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <assert.h>
00022 #include <math.h>
00023 #include <stdint.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026
00027 #include "libavutil/avutil.h"
00028 #include "libavutil/bswap.h"
00029 #include "libavutil/cpu.h"
00030 #include "libavutil/intreadwrite.h"
00031 #include "libavutil/mathematics.h"
00032 #include "libavutil/pixdesc.h"
00033 #include "libavutil/avassert.h"
00034 #include "config.h"
00035 #include "rgb2rgb.h"
00036 #include "swscale.h"
00037 #include "swscale_internal.h"
00038
00039 #define RGB2YUV_SHIFT 15
00040 #define BY ((int)(0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00041 #define BV (-(int)(0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00042 #define BU ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00043 #define GY ((int)(0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00044 #define GV (-(int)(0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00045 #define GU (-(int)(0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00046 #define RY ((int)(0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00047 #define RV ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00048 #define RU (-(int)(0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
00049
00050 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
00051
00052 #define r ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? b_r : r_b)
00053 #define b ((origin == PIX_FMT_BGR48BE || origin == PIX_FMT_BGR48LE) ? r_b : b_r)
00054
00055 static av_always_inline void
00056 rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
00057 enum PixelFormat origin)
00058 {
00059 int i;
00060 for (i = 0; i < width; i++) {
00061 unsigned int r_b = input_pixel(&src[i*4+0]);
00062 unsigned int g = input_pixel(&src[i*4+1]);
00063 unsigned int b_r = input_pixel(&src[i*4+2]);
00064
00065 dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
00066 }
00067 }
00068
00069 static av_always_inline void
00070 rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
00071 const uint16_t *src1, const uint16_t *src2,
00072 int width, enum PixelFormat origin)
00073 {
00074 int i;
00075 av_assert1(src1==src2);
00076 for (i = 0; i < width; i++) {
00077 int r_b = input_pixel(&src1[i*4+0]);
00078 int g = input_pixel(&src1[i*4+1]);
00079 int b_r = input_pixel(&src1[i*4+2]);
00080
00081 dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
00082 dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
00083 }
00084 }
00085
00086 static av_always_inline void
00087 rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
00088 const uint16_t *src1, const uint16_t *src2,
00089 int width, enum PixelFormat origin)
00090 {
00091 int i;
00092 av_assert1(src1==src2);
00093 for (i = 0; i < width; i++) {
00094 int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
00095 int g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
00096 int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
00097
00098 dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
00099 dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
00100 }
00101 }
00102
00103 #define rgb64funcs(pattern, BE_LE, origin) \
00104 static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
00105 int width, uint32_t *unused) \
00106 { \
00107 const uint16_t *src = (const uint16_t *) _src; \
00108 uint16_t *dst = (uint16_t *) _dst; \
00109 rgb64ToY_c_template(dst, src, width, origin); \
00110 } \
00111 \
00112 static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
00113 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
00114 int width, uint32_t *unused) \
00115 { \
00116 const uint16_t *src1 = (const uint16_t *) _src1, \
00117 *src2 = (const uint16_t *) _src2; \
00118 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
00119 rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
00120 } \
00121 \
00122 static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
00123 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
00124 int width, uint32_t *unused) \
00125 { \
00126 const uint16_t *src1 = (const uint16_t *) _src1, \
00127 *src2 = (const uint16_t *) _src2; \
00128 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
00129 rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
00130 }
00131
00132 rgb64funcs(rgb, LE, PIX_FMT_RGBA64LE)
00133 rgb64funcs(rgb, BE, PIX_FMT_RGBA64BE)
00134
00135 static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
00136 const uint16_t *src, int width,
00137 enum PixelFormat origin)
00138 {
00139 int i;
00140 for (i = 0; i < width; i++) {
00141 unsigned int r_b = input_pixel(&src[i * 3 + 0]);
00142 unsigned int g = input_pixel(&src[i * 3 + 1]);
00143 unsigned int b_r = input_pixel(&src[i * 3 + 2]);
00144
00145 dst[i] = (RY * r + GY * g + BY * b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
00146 }
00147 }
00148
00149 static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
00150 uint16_t *dstV,
00151 const uint16_t *src1,
00152 const uint16_t *src2,
00153 int width,
00154 enum PixelFormat origin)
00155 {
00156 int i;
00157 av_assert1(src1 == src2);
00158 for (i = 0; i < width; i++) {
00159 int r_b = input_pixel(&src1[i * 3 + 0]);
00160 int g = input_pixel(&src1[i * 3 + 1]);
00161 int b_r = input_pixel(&src1[i * 3 + 2]);
00162
00163 dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
00164 dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
00165 }
00166 }
00167
00168 static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
00169 uint16_t *dstV,
00170 const uint16_t *src1,
00171 const uint16_t *src2,
00172 int width,
00173 enum PixelFormat origin)
00174 {
00175 int i;
00176 av_assert1(src1 == src2);
00177 for (i = 0; i < width; i++) {
00178 int r_b = (input_pixel(&src1[6 * i + 0]) +
00179 input_pixel(&src1[6 * i + 3]) + 1) >> 1;
00180 int g = (input_pixel(&src1[6 * i + 1]) +
00181 input_pixel(&src1[6 * i + 4]) + 1) >> 1;
00182 int b_r = (input_pixel(&src1[6 * i + 2]) +
00183 input_pixel(&src1[6 * i + 5]) + 1) >> 1;
00184
00185 dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
00186 dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
00187 }
00188 }
00189
00190 #undef r
00191 #undef b
00192 #undef input_pixel
00193
00194 #define rgb48funcs(pattern, BE_LE, origin) \
00195 static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
00196 const uint8_t *_src, \
00197 const uint8_t *unused0, const uint8_t *unused1,\
00198 int width, \
00199 uint32_t *unused) \
00200 { \
00201 const uint16_t *src = (const uint16_t *)_src; \
00202 uint16_t *dst = (uint16_t *)_dst; \
00203 rgb48ToY_c_template(dst, src, width, origin); \
00204 } \
00205 \
00206 static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
00207 uint8_t *_dstV, \
00208 const uint8_t *unused0, \
00209 const uint8_t *_src1, \
00210 const uint8_t *_src2, \
00211 int width, \
00212 uint32_t *unused) \
00213 { \
00214 const uint16_t *src1 = (const uint16_t *)_src1, \
00215 *src2 = (const uint16_t *)_src2; \
00216 uint16_t *dstU = (uint16_t *)_dstU, \
00217 *dstV = (uint16_t *)_dstV; \
00218 rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
00219 } \
00220 \
00221 static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
00222 uint8_t *_dstV, \
00223 const uint8_t *unused0, \
00224 const uint8_t *_src1, \
00225 const uint8_t *_src2, \
00226 int width, \
00227 uint32_t *unused) \
00228 { \
00229 const uint16_t *src1 = (const uint16_t *)_src1, \
00230 *src2 = (const uint16_t *)_src2; \
00231 uint16_t *dstU = (uint16_t *)_dstU, \
00232 *dstV = (uint16_t *)_dstV; \
00233 rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
00234 }
00235
00236 rgb48funcs(rgb, LE, PIX_FMT_RGB48LE)
00237 rgb48funcs(rgb, BE, PIX_FMT_RGB48BE)
00238 rgb48funcs(bgr, LE, PIX_FMT_BGR48LE)
00239 rgb48funcs(bgr, BE, PIX_FMT_BGR48BE)
00240
00241 #define input_pixel(i) ((origin == PIX_FMT_RGBA || \
00242 origin == PIX_FMT_BGRA || \
00243 origin == PIX_FMT_ARGB || \
00244 origin == PIX_FMT_ABGR) \
00245 ? AV_RN32A(&src[(i) * 4]) \
00246 : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
00247 : AV_RL16(&src[(i) * 2])))
00248
00249 static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
00250 const uint8_t *src,
00251 int width,
00252 enum PixelFormat origin,
00253 int shr, int shg,
00254 int shb, int shp,
00255 int maskr, int maskg,
00256 int maskb, int rsh,
00257 int gsh, int bsh, int S)
00258 {
00259 const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
00260 const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
00261 int i;
00262
00263 for (i = 0; i < width; i++) {
00264 int px = input_pixel(i) >> shp;
00265 int b = (px & maskb) >> shb;
00266 int g = (px & maskg) >> shg;
00267 int r = (px & maskr) >> shr;
00268
00269 dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
00270 }
00271 }
00272
00273 static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
00274 int16_t *dstV,
00275 const uint8_t *src,
00276 int width,
00277 enum PixelFormat origin,
00278 int shr, int shg,
00279 int shb, int shp,
00280 int maskr, int maskg,
00281 int maskb, int rsh,
00282 int gsh, int bsh, int S)
00283 {
00284 const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
00285 rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
00286 const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
00287 int i;
00288
00289 for (i = 0; i < width; i++) {
00290 int px = input_pixel(i) >> shp;
00291 int b = (px & maskb) >> shb;
00292 int g = (px & maskg) >> shg;
00293 int r = (px & maskr) >> shr;
00294
00295 dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
00296 dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
00297 }
00298 }
00299
00300 static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
00301 int16_t *dstV,
00302 const uint8_t *src,
00303 int width,
00304 enum PixelFormat origin,
00305 int shr, int shg,
00306 int shb, int shp,
00307 int maskr, int maskg,
00308 int maskb, int rsh,
00309 int gsh, int bsh, int S)
00310 {
00311 const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
00312 rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
00313 maskgx = ~(maskr | maskb);
00314 const unsigned rnd = (256U<<(S)) + (1<<(S-6));
00315 int i;
00316
00317 maskr |= maskr << 1;
00318 maskb |= maskb << 1;
00319 maskg |= maskg << 1;
00320 for (i = 0; i < width; i++) {
00321 int px0 = input_pixel(2 * i + 0) >> shp;
00322 int px1 = input_pixel(2 * i + 1) >> shp;
00323 int b, r, g = (px0 & maskgx) + (px1 & maskgx);
00324 int rb = px0 + px1 - g;
00325
00326 b = (rb & maskb) >> shb;
00327 if (shp ||
00328 origin == PIX_FMT_BGR565LE || origin == PIX_FMT_BGR565BE ||
00329 origin == PIX_FMT_RGB565LE || origin == PIX_FMT_RGB565BE) {
00330 g >>= shg;
00331 } else {
00332 g = (g & maskg) >> shg;
00333 }
00334 r = (rb & maskr) >> shr;
00335
00336 dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
00337 dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
00338 }
00339 }
00340
00341 #undef input_pixel
00342
00343 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
00344 maskg, maskb, rsh, gsh, bsh, S) \
00345 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
00346 int width, uint32_t *unused) \
00347 { \
00348 rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
00349 maskr, maskg, maskb, rsh, gsh, bsh, S); \
00350 } \
00351 \
00352 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
00353 const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
00354 int width, uint32_t *unused) \
00355 { \
00356 rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
00357 shr, shg, shb, shp, \
00358 maskr, maskg, maskb, rsh, gsh, bsh, S); \
00359 } \
00360 \
00361 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
00362 const uint8_t *unused0, const uint8_t *src, \
00363 const uint8_t *dummy, \
00364 int width, uint32_t *unused) \
00365 { \
00366 rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
00367 shr, shg, shb, shp, \
00368 maskr, maskg, maskb, \
00369 rsh, gsh, bsh, S); \
00370 }
00371
00372 rgb16_32_wrapper(PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
00373 rgb16_32_wrapper(PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
00374 rgb16_32_wrapper(PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
00375 rgb16_32_wrapper(PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
00376 rgb16_32_wrapper(PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
00377 rgb16_32_wrapper(PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
00378 rgb16_32_wrapper(PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
00379 rgb16_32_wrapper(PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
00380 rgb16_32_wrapper(PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
00381 rgb16_32_wrapper(PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
00382 rgb16_32_wrapper(PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
00383 rgb16_32_wrapper(PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
00384 rgb16_32_wrapper(PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
00385 rgb16_32_wrapper(PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
00386 rgb16_32_wrapper(PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
00387 rgb16_32_wrapper(PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
00388
00389 static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
00390 const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
00391 int width, uint32_t *unused)
00392 {
00393 uint16_t *dstU = (uint16_t *)_dstU;
00394 uint16_t *dstV = (uint16_t *)_dstV;
00395 int i;
00396 for (i = 0; i < width; i++) {
00397 unsigned int g = gsrc[2*i] + gsrc[2*i+1];
00398 unsigned int b = bsrc[2*i] + bsrc[2*i+1];
00399 unsigned int r = rsrc[2*i] + rsrc[2*i+1];
00400
00401 dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
00402 dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
00403 }
00404 }
00405
00406 static void rgba64ToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
00407 const uint8_t *unused2, int width, uint32_t *unused)
00408 {
00409 int16_t *dst = (int16_t *)_dst;
00410 const uint16_t *src = (const uint16_t *)_src;
00411 int i;
00412 for (i = 0; i < width; i++)
00413 dst[i] = src[4 * i + 3];
00414 }
00415
00416 static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
00417 {
00418 int16_t *dst = (int16_t *)_dst;
00419 int i;
00420 for (i=0; i<width; i++) {
00421 dst[i]= src[4*i]<<6;
00422 }
00423 }
00424
00425 static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
00426 {
00427 int16_t *dst = (int16_t *)_dst;
00428 int i;
00429 for (i=0; i<width; i++) {
00430 dst[i]= src[4*i+3]<<6;
00431 }
00432 }
00433
00434 static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
00435 {
00436 int16_t *dst = (int16_t *)_dst;
00437 int i;
00438 for (i=0; i<width; i++) {
00439 int d= src[i];
00440
00441 dst[i]= (pal[d] >> 24)<<6;
00442 }
00443 }
00444
00445 static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
00446 {
00447 int16_t *dst = (int16_t *)_dst;
00448 int i;
00449 for (i = 0; i < width; i++) {
00450 int d = src[i];
00451
00452 dst[i] = (pal[d] & 0xFF)<<6;
00453 }
00454 }
00455
00456 static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
00457 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
00458 int width, uint32_t *pal)
00459 {
00460 uint16_t *dstU = (uint16_t *)_dstU;
00461 int16_t *dstV = (int16_t *)_dstV;
00462 int i;
00463 av_assert1(src1 == src2);
00464 for (i = 0; i < width; i++) {
00465 int p = pal[src1[i]];
00466
00467 dstU[i] = (uint8_t)(p>> 8)<<6;
00468 dstV[i] = (uint8_t)(p>>16)<<6;
00469 }
00470 }
00471
00472 static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
00473 {
00474 int16_t *dst = (int16_t *)_dst;
00475 int i, j;
00476 width = (width + 7) >> 3;
00477 for (i = 0; i < width; i++) {
00478 int d = ~src[i];
00479 for (j = 0; j < 8; j++)
00480 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
00481 }
00482 if(width&7){
00483 int d= ~src[i];
00484 for (j = 0; j < (width&7); j++)
00485 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
00486 }
00487 }
00488
00489 static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
00490 {
00491 int16_t *dst = (int16_t *)_dst;
00492 int i, j;
00493 width = (width + 7) >> 3;
00494 for (i = 0; i < width; i++) {
00495 int d = src[i];
00496 for (j = 0; j < 8; j++)
00497 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
00498 }
00499 if(width&7){
00500 int d = src[i];
00501 for (j = 0; j < (width&7); j++)
00502 dst[8*i+j] = ((d>>(7-j))&1) * 16383;
00503 }
00504 }
00505
00506 static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
00507 uint32_t *unused)
00508 {
00509 int i;
00510 for (i = 0; i < width; i++)
00511 dst[i] = src[2 * i];
00512 }
00513
00514 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
00515 const uint8_t *src2, int width, uint32_t *unused)
00516 {
00517 int i;
00518 for (i = 0; i < width; i++) {
00519 dstU[i] = src1[4 * i + 1];
00520 dstV[i] = src1[4 * i + 3];
00521 }
00522 av_assert1(src1 == src2);
00523 }
00524
00525 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
00526 uint32_t *unused)
00527 {
00528 int i;
00529 const uint16_t *src = (const uint16_t *)_src;
00530 uint16_t *dst = (uint16_t *)_dst;
00531 for (i = 0; i < width; i++)
00532 dst[i] = av_bswap16(src[i]);
00533 }
00534
00535 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
00536 const uint8_t *_src2, int width, uint32_t *unused)
00537 {
00538 int i;
00539 const uint16_t *src1 = (const uint16_t *)_src1,
00540 *src2 = (const uint16_t *)_src2;
00541 uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
00542 for (i = 0; i < width; i++) {
00543 dstU[i] = av_bswap16(src1[i]);
00544 dstV[i] = av_bswap16(src2[i]);
00545 }
00546 }
00547
00548
00549
00550 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
00551 uint32_t *unused)
00552 {
00553 int i;
00554 for (i = 0; i < width; i++)
00555 dst[i] = src[2 * i + 1];
00556 }
00557
00558 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
00559 const uint8_t *src2, int width, uint32_t *unused)
00560 {
00561 int i;
00562 for (i = 0; i < width; i++) {
00563 dstU[i] = src1[4 * i + 0];
00564 dstV[i] = src1[4 * i + 2];
00565 }
00566 av_assert1(src1 == src2);
00567 }
00568
00569 static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
00570 const uint8_t *src, int width)
00571 {
00572 int i;
00573 for (i = 0; i < width; i++) {
00574 dst1[i] = src[2 * i + 0];
00575 dst2[i] = src[2 * i + 1];
00576 }
00577 }
00578
00579 static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
00580 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
00581 int width, uint32_t *unused)
00582 {
00583 nvXXtoUV_c(dstU, dstV, src1, width);
00584 }
00585
00586 static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
00587 const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
00588 int width, uint32_t *unused)
00589 {
00590 nvXXtoUV_c(dstV, dstU, src1, width);
00591 }
00592
00593 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
00594
00595 static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
00596 int width, uint32_t *unused)
00597 {
00598 int16_t *dst = (int16_t *)_dst;
00599 int i;
00600 for (i = 0; i < width; i++) {
00601 int b = src[i * 3 + 0];
00602 int g = src[i * 3 + 1];
00603 int r = src[i * 3 + 2];
00604
00605 dst[i] = ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
00606 }
00607 }
00608
00609 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
00610 const uint8_t *src2, int width, uint32_t *unused)
00611 {
00612 int16_t *dstU = (int16_t *)_dstU;
00613 int16_t *dstV = (int16_t *)_dstV;
00614 int i;
00615 for (i = 0; i < width; i++) {
00616 int b = src1[3 * i + 0];
00617 int g = src1[3 * i + 1];
00618 int r = src1[3 * i + 2];
00619
00620 dstU[i] = (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
00621 dstV[i] = (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
00622 }
00623 av_assert1(src1 == src2);
00624 }
00625
00626 static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
00627 const uint8_t *src2, int width, uint32_t *unused)
00628 {
00629 int16_t *dstU = (int16_t *)_dstU;
00630 int16_t *dstV = (int16_t *)_dstV;
00631 int i;
00632 for (i = 0; i < width; i++) {
00633 int b = src1[6 * i + 0] + src1[6 * i + 3];
00634 int g = src1[6 * i + 1] + src1[6 * i + 4];
00635 int r = src1[6 * i + 2] + src1[6 * i + 5];
00636
00637 dstU[i] = (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
00638 dstV[i] = (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
00639 }
00640 av_assert1(src1 == src2);
00641 }
00642
00643 static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
00644 uint32_t *unused)
00645 {
00646 int16_t *dst = (int16_t *)_dst;
00647 int i;
00648 for (i = 0; i < width; i++) {
00649 int r = src[i * 3 + 0];
00650 int g = src[i * 3 + 1];
00651 int b = src[i * 3 + 2];
00652
00653 dst[i] = ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
00654 }
00655 }
00656
00657 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
00658 const uint8_t *src2, int width, uint32_t *unused)
00659 {
00660 int16_t *dstU = (int16_t *)_dstU;
00661 int16_t *dstV = (int16_t *)_dstV;
00662 int i;
00663 av_assert1(src1 == src2);
00664 for (i = 0; i < width; i++) {
00665 int r = src1[3 * i + 0];
00666 int g = src1[3 * i + 1];
00667 int b = src1[3 * i + 2];
00668
00669 dstU[i] = (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
00670 dstV[i] = (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
00671 }
00672 }
00673
00674 static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
00675 const uint8_t *src2, int width, uint32_t *unused)
00676 {
00677 int16_t *dstU = (int16_t *)_dstU;
00678 int16_t *dstV = (int16_t *)_dstV;
00679 int i;
00680 av_assert1(src1 == src2);
00681 for (i = 0; i < width; i++) {
00682 int r = src1[6 * i + 0] + src1[6 * i + 3];
00683 int g = src1[6 * i + 1] + src1[6 * i + 4];
00684 int b = src1[6 * i + 2] + src1[6 * i + 5];
00685
00686 dstU[i] = (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
00687 dstV[i] = (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
00688 }
00689 }
00690
00691 static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width)
00692 {
00693 uint16_t *dst = (uint16_t *)_dst;
00694 int i;
00695 for (i = 0; i < width; i++) {
00696 int g = src[0][i];
00697 int b = src[1][i];
00698 int r = src[2][i];
00699
00700 dst[i] = (RY*r + GY*g + BY*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
00701 }
00702 }
00703
00704 static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width)
00705 {
00706 uint16_t *dstU = (uint16_t *)_dstU;
00707 uint16_t *dstV = (uint16_t *)_dstV;
00708 int i;
00709 for (i = 0; i < width; i++) {
00710 int g = src[0][i];
00711 int b = src[1][i];
00712 int r = src[2][i];
00713
00714 dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
00715 dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
00716 }
00717 }
00718
00719 #define rdpx(src) \
00720 is_be ? AV_RB16(src) : AV_RL16(src)
00721 static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
00722 int width, int bpc, int is_be)
00723 {
00724 int i;
00725 const uint16_t **src = (const uint16_t **)_src;
00726 uint16_t *dst = (uint16_t *)_dst;
00727 for (i = 0; i < width; i++) {
00728 int g = rdpx(src[0] + i);
00729 int b = rdpx(src[1] + i);
00730 int r = rdpx(src[2] + i);
00731
00732 dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT);
00733 }
00734 }
00735
00736 static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00737 {
00738 planar_rgb16_to_y(dst, src, w, 9, 0);
00739 }
00740
00741 static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00742 {
00743 planar_rgb16_to_y(dst, src, w, 9, 1);
00744 }
00745
00746 static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00747 {
00748 planar_rgb16_to_y(dst, src, w, 10, 0);
00749 }
00750
00751 static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00752 {
00753 planar_rgb16_to_y(dst, src, w, 10, 1);
00754 }
00755
00756 static void planar_rgb12le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00757 {
00758 planar_rgb16_to_y(dst, src, w, 12, 0);
00759 }
00760
00761 static void planar_rgb12be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00762 {
00763 planar_rgb16_to_y(dst, src, w, 12, 1);
00764 }
00765
00766 static void planar_rgb14le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00767 {
00768 planar_rgb16_to_y(dst, src, w, 14, 0);
00769 }
00770
00771 static void planar_rgb14be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00772 {
00773 planar_rgb16_to_y(dst, src, w, 14, 1);
00774 }
00775
00776 static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00777 {
00778 planar_rgb16_to_y(dst, src, w, 16, 0);
00779 }
00780
00781 static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
00782 {
00783 planar_rgb16_to_y(dst, src, w, 16, 1);
00784 }
00785
00786 static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
00787 const uint8_t *_src[4], int width,
00788 int bpc, int is_be)
00789 {
00790 int i;
00791 const uint16_t **src = (const uint16_t **)_src;
00792 uint16_t *dstU = (uint16_t *)_dstU;
00793 uint16_t *dstV = (uint16_t *)_dstV;
00794 for (i = 0; i < width; i++) {
00795 int g = rdpx(src[0] + i);
00796 int b = rdpx(src[1] + i);
00797 int r = rdpx(src[2] + i);
00798
00799 dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
00800 dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
00801 }
00802 }
00803 #undef rdpx
00804
00805 static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV,
00806 const uint8_t *src[4], int w)
00807 {
00808 planar_rgb16_to_uv(dstU, dstV, src, w, 9, 0);
00809 }
00810
00811 static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV,
00812 const uint8_t *src[4], int w)
00813 {
00814 planar_rgb16_to_uv(dstU, dstV, src, w, 9, 1);
00815 }
00816
00817 static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV,
00818 const uint8_t *src[4], int w)
00819 {
00820 planar_rgb16_to_uv(dstU, dstV, src, w, 10, 0);
00821 }
00822
00823 static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
00824 const uint8_t *src[4], int w)
00825 {
00826 planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1);
00827 }
00828
00829 static void planar_rgb12le_to_uv(uint8_t *dstU, uint8_t *dstV,
00830 const uint8_t *src[4], int w)
00831 {
00832 planar_rgb16_to_uv(dstU, dstV, src, w, 12, 0);
00833 }
00834
00835 static void planar_rgb12be_to_uv(uint8_t *dstU, uint8_t *dstV,
00836 const uint8_t *src[4], int w)
00837 {
00838 planar_rgb16_to_uv(dstU, dstV, src, w, 12, 1);
00839 }
00840
00841 static void planar_rgb14le_to_uv(uint8_t *dstU, uint8_t *dstV,
00842 const uint8_t *src[4], int w)
00843 {
00844 planar_rgb16_to_uv(dstU, dstV, src, w, 14, 0);
00845 }
00846
00847 static void planar_rgb14be_to_uv(uint8_t *dstU, uint8_t *dstV,
00848 const uint8_t *src[4], int w)
00849 {
00850 planar_rgb16_to_uv(dstU, dstV, src, w, 14, 1);
00851 }
00852
00853 static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
00854 const uint8_t *src[4], int w)
00855 {
00856 planar_rgb16_to_uv(dstU, dstV, src, w, 16, 0);
00857 }
00858
00859 static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV,
00860 const uint8_t *src[4], int w)
00861 {
00862 planar_rgb16_to_uv(dstU, dstV, src, w, 16, 1);
00863 }
00864
00865 av_cold void ff_sws_init_input_funcs(SwsContext *c)
00866 {
00867 enum PixelFormat srcFormat = c->srcFormat;
00868
00869 c->chrToYV12 = NULL;
00870 switch (srcFormat) {
00871 case PIX_FMT_YUYV422:
00872 c->chrToYV12 = yuy2ToUV_c;
00873 break;
00874 case PIX_FMT_UYVY422:
00875 c->chrToYV12 = uyvyToUV_c;
00876 break;
00877 case PIX_FMT_NV12:
00878 c->chrToYV12 = nv12ToUV_c;
00879 break;
00880 case PIX_FMT_NV21:
00881 c->chrToYV12 = nv21ToUV_c;
00882 break;
00883 case PIX_FMT_RGB8:
00884 case PIX_FMT_BGR8:
00885 case PIX_FMT_PAL8:
00886 case PIX_FMT_BGR4_BYTE:
00887 case PIX_FMT_RGB4_BYTE:
00888 c->chrToYV12 = palToUV_c;
00889 break;
00890 case PIX_FMT_GBRP9LE:
00891 c->readChrPlanar = planar_rgb9le_to_uv;
00892 break;
00893 case PIX_FMT_GBRP10LE:
00894 c->readChrPlanar = planar_rgb10le_to_uv;
00895 break;
00896 case PIX_FMT_GBRP12LE:
00897 c->readChrPlanar = planar_rgb12le_to_uv;
00898 break;
00899 case PIX_FMT_GBRP14LE:
00900 c->readChrPlanar = planar_rgb14le_to_uv;
00901 break;
00902 case PIX_FMT_GBRP16LE:
00903 c->readChrPlanar = planar_rgb16le_to_uv;
00904 break;
00905 case PIX_FMT_GBRP9BE:
00906 c->readChrPlanar = planar_rgb9be_to_uv;
00907 break;
00908 case PIX_FMT_GBRP10BE:
00909 c->readChrPlanar = planar_rgb10be_to_uv;
00910 break;
00911 case PIX_FMT_GBRP12BE:
00912 c->readChrPlanar = planar_rgb12be_to_uv;
00913 break;
00914 case PIX_FMT_GBRP14BE:
00915 c->readChrPlanar = planar_rgb14be_to_uv;
00916 break;
00917 case PIX_FMT_GBRP16BE:
00918 c->readChrPlanar = planar_rgb16be_to_uv;
00919 break;
00920 case PIX_FMT_GBRP:
00921 c->readChrPlanar = planar_rgb_to_uv;
00922 break;
00923 #if HAVE_BIGENDIAN
00924 case PIX_FMT_YUV444P9LE:
00925 case PIX_FMT_YUV422P9LE:
00926 case PIX_FMT_YUV420P9LE:
00927 case PIX_FMT_YUV422P10LE:
00928 case PIX_FMT_YUV444P10LE:
00929 case PIX_FMT_YUV420P10LE:
00930 case PIX_FMT_YUV422P12LE:
00931 case PIX_FMT_YUV444P12LE:
00932 case PIX_FMT_YUV420P12LE:
00933 case PIX_FMT_YUV422P14LE:
00934 case PIX_FMT_YUV444P14LE:
00935 case PIX_FMT_YUV420P14LE:
00936 case PIX_FMT_YUV420P16LE:
00937 case PIX_FMT_YUV422P16LE:
00938 case PIX_FMT_YUV444P16LE:
00939 c->chrToYV12 = bswap16UV_c;
00940 break;
00941 #else
00942 case PIX_FMT_YUV444P9BE:
00943 case PIX_FMT_YUV422P9BE:
00944 case PIX_FMT_YUV420P9BE:
00945 case PIX_FMT_YUV444P10BE:
00946 case PIX_FMT_YUV422P10BE:
00947 case PIX_FMT_YUV420P10BE:
00948 case PIX_FMT_YUV444P12BE:
00949 case PIX_FMT_YUV422P12BE:
00950 case PIX_FMT_YUV420P12BE:
00951 case PIX_FMT_YUV444P14BE:
00952 case PIX_FMT_YUV422P14BE:
00953 case PIX_FMT_YUV420P14BE:
00954 case PIX_FMT_YUV420P16BE:
00955 case PIX_FMT_YUV422P16BE:
00956 case PIX_FMT_YUV444P16BE:
00957 c->chrToYV12 = bswap16UV_c;
00958 break;
00959 #endif
00960 }
00961 if (c->chrSrcHSubSample) {
00962 switch (srcFormat) {
00963 case PIX_FMT_RGBA64BE:
00964 c->chrToYV12 = rgb64BEToUV_half_c;
00965 break;
00966 case PIX_FMT_RGBA64LE:
00967 c->chrToYV12 = rgb64LEToUV_half_c;
00968 break;
00969 case PIX_FMT_RGB48BE:
00970 c->chrToYV12 = rgb48BEToUV_half_c;
00971 break;
00972 case PIX_FMT_RGB48LE:
00973 c->chrToYV12 = rgb48LEToUV_half_c;
00974 break;
00975 case PIX_FMT_BGR48BE:
00976 c->chrToYV12 = bgr48BEToUV_half_c;
00977 break;
00978 case PIX_FMT_BGR48LE:
00979 c->chrToYV12 = bgr48LEToUV_half_c;
00980 break;
00981 case PIX_FMT_RGB32:
00982 c->chrToYV12 = bgr32ToUV_half_c;
00983 break;
00984 case PIX_FMT_RGB32_1:
00985 c->chrToYV12 = bgr321ToUV_half_c;
00986 break;
00987 case PIX_FMT_BGR24:
00988 c->chrToYV12 = bgr24ToUV_half_c;
00989 break;
00990 case PIX_FMT_BGR565LE:
00991 c->chrToYV12 = bgr16leToUV_half_c;
00992 break;
00993 case PIX_FMT_BGR565BE:
00994 c->chrToYV12 = bgr16beToUV_half_c;
00995 break;
00996 case PIX_FMT_BGR555LE:
00997 c->chrToYV12 = bgr15leToUV_half_c;
00998 break;
00999 case PIX_FMT_BGR555BE:
01000 c->chrToYV12 = bgr15beToUV_half_c;
01001 break;
01002 case PIX_FMT_GBR24P :
01003 c->chrToYV12 = gbr24pToUV_half_c;
01004 break;
01005 case PIX_FMT_BGR444LE:
01006 c->chrToYV12 = bgr12leToUV_half_c;
01007 break;
01008 case PIX_FMT_BGR444BE:
01009 c->chrToYV12 = bgr12beToUV_half_c;
01010 break;
01011 case PIX_FMT_BGR32:
01012 c->chrToYV12 = rgb32ToUV_half_c;
01013 break;
01014 case PIX_FMT_BGR32_1:
01015 c->chrToYV12 = rgb321ToUV_half_c;
01016 break;
01017 case PIX_FMT_RGB24:
01018 c->chrToYV12 = rgb24ToUV_half_c;
01019 break;
01020 case PIX_FMT_RGB565LE:
01021 c->chrToYV12 = rgb16leToUV_half_c;
01022 break;
01023 case PIX_FMT_RGB565BE:
01024 c->chrToYV12 = rgb16beToUV_half_c;
01025 break;
01026 case PIX_FMT_RGB555LE:
01027 c->chrToYV12 = rgb15leToUV_half_c;
01028 break;
01029 case PIX_FMT_RGB555BE:
01030 c->chrToYV12 = rgb15beToUV_half_c;
01031 break;
01032 case PIX_FMT_RGB444LE:
01033 c->chrToYV12 = rgb12leToUV_half_c;
01034 break;
01035 case PIX_FMT_RGB444BE:
01036 c->chrToYV12 = rgb12beToUV_half_c;
01037 break;
01038 }
01039 } else {
01040 switch (srcFormat) {
01041 case PIX_FMT_RGBA64BE:
01042 c->chrToYV12 = rgb64BEToUV_c;
01043 break;
01044 case PIX_FMT_RGBA64LE:
01045 c->chrToYV12 = rgb64LEToUV_c;
01046 break;
01047 case PIX_FMT_RGB48BE:
01048 c->chrToYV12 = rgb48BEToUV_c;
01049 break;
01050 case PIX_FMT_RGB48LE:
01051 c->chrToYV12 = rgb48LEToUV_c;
01052 break;
01053 case PIX_FMT_BGR48BE:
01054 c->chrToYV12 = bgr48BEToUV_c;
01055 break;
01056 case PIX_FMT_BGR48LE:
01057 c->chrToYV12 = bgr48LEToUV_c;
01058 break;
01059 case PIX_FMT_RGB32:
01060 c->chrToYV12 = bgr32ToUV_c;
01061 break;
01062 case PIX_FMT_RGB32_1:
01063 c->chrToYV12 = bgr321ToUV_c;
01064 break;
01065 case PIX_FMT_BGR24:
01066 c->chrToYV12 = bgr24ToUV_c;
01067 break;
01068 case PIX_FMT_BGR565LE:
01069 c->chrToYV12 = bgr16leToUV_c;
01070 break;
01071 case PIX_FMT_BGR565BE:
01072 c->chrToYV12 = bgr16beToUV_c;
01073 break;
01074 case PIX_FMT_BGR555LE:
01075 c->chrToYV12 = bgr15leToUV_c;
01076 break;
01077 case PIX_FMT_BGR555BE:
01078 c->chrToYV12 = bgr15beToUV_c;
01079 break;
01080 case PIX_FMT_BGR444LE:
01081 c->chrToYV12 = bgr12leToUV_c;
01082 break;
01083 case PIX_FMT_BGR444BE:
01084 c->chrToYV12 = bgr12beToUV_c;
01085 break;
01086 case PIX_FMT_BGR32:
01087 c->chrToYV12 = rgb32ToUV_c;
01088 break;
01089 case PIX_FMT_BGR32_1:
01090 c->chrToYV12 = rgb321ToUV_c;
01091 break;
01092 case PIX_FMT_RGB24:
01093 c->chrToYV12 = rgb24ToUV_c;
01094 break;
01095 case PIX_FMT_RGB565LE:
01096 c->chrToYV12 = rgb16leToUV_c;
01097 break;
01098 case PIX_FMT_RGB565BE:
01099 c->chrToYV12 = rgb16beToUV_c;
01100 break;
01101 case PIX_FMT_RGB555LE:
01102 c->chrToYV12 = rgb15leToUV_c;
01103 break;
01104 case PIX_FMT_RGB555BE:
01105 c->chrToYV12 = rgb15beToUV_c;
01106 break;
01107 case PIX_FMT_RGB444LE:
01108 c->chrToYV12 = rgb12leToUV_c;
01109 break;
01110 case PIX_FMT_RGB444BE:
01111 c->chrToYV12 = rgb12beToUV_c;
01112 break;
01113 }
01114 }
01115
01116 c->lumToYV12 = NULL;
01117 c->alpToYV12 = NULL;
01118 switch (srcFormat) {
01119 case PIX_FMT_GBRP9LE:
01120 c->readLumPlanar = planar_rgb9le_to_y;
01121 break;
01122 case PIX_FMT_GBRP10LE:
01123 c->readLumPlanar = planar_rgb10le_to_y;
01124 break;
01125 case PIX_FMT_GBRP12LE:
01126 c->readLumPlanar = planar_rgb12le_to_y;
01127 break;
01128 case PIX_FMT_GBRP14LE:
01129 c->readLumPlanar = planar_rgb14le_to_y;
01130 break;
01131 case PIX_FMT_GBRP16LE:
01132 c->readLumPlanar = planar_rgb16le_to_y;
01133 break;
01134 case PIX_FMT_GBRP9BE:
01135 c->readLumPlanar = planar_rgb9be_to_y;
01136 break;
01137 case PIX_FMT_GBRP10BE:
01138 c->readLumPlanar = planar_rgb10be_to_y;
01139 break;
01140 case PIX_FMT_GBRP12BE:
01141 c->readLumPlanar = planar_rgb12be_to_y;
01142 break;
01143 case PIX_FMT_GBRP14BE:
01144 c->readLumPlanar = planar_rgb14be_to_y;
01145 break;
01146 case PIX_FMT_GBRP16BE:
01147 c->readLumPlanar = planar_rgb16be_to_y;
01148 break;
01149 case PIX_FMT_GBRP:
01150 c->readLumPlanar = planar_rgb_to_y;
01151 break;
01152 #if HAVE_BIGENDIAN
01153 case PIX_FMT_YUV444P9LE:
01154 case PIX_FMT_YUV422P9LE:
01155 case PIX_FMT_YUV420P9LE:
01156 case PIX_FMT_YUV444P10LE:
01157 case PIX_FMT_YUV422P10LE:
01158 case PIX_FMT_YUV420P10LE:
01159 case PIX_FMT_YUV444P12LE:
01160 case PIX_FMT_YUV422P12LE:
01161 case PIX_FMT_YUV420P12LE:
01162 case PIX_FMT_YUV444P14LE:
01163 case PIX_FMT_YUV422P14LE:
01164 case PIX_FMT_YUV420P14LE:
01165 case PIX_FMT_YUV420P16LE:
01166 case PIX_FMT_YUV422P16LE:
01167 case PIX_FMT_YUV444P16LE:
01168 case PIX_FMT_GRAY16LE:
01169 c->lumToYV12 = bswap16Y_c;
01170 break;
01171 #else
01172 case PIX_FMT_YUV444P9BE:
01173 case PIX_FMT_YUV422P9BE:
01174 case PIX_FMT_YUV420P9BE:
01175 case PIX_FMT_YUV444P10BE:
01176 case PIX_FMT_YUV422P10BE:
01177 case PIX_FMT_YUV420P10BE:
01178 case PIX_FMT_YUV444P12BE:
01179 case PIX_FMT_YUV422P12BE:
01180 case PIX_FMT_YUV420P12BE:
01181 case PIX_FMT_YUV444P14BE:
01182 case PIX_FMT_YUV422P14BE:
01183 case PIX_FMT_YUV420P14BE:
01184 case PIX_FMT_YUV420P16BE:
01185 case PIX_FMT_YUV422P16BE:
01186 case PIX_FMT_YUV444P16BE:
01187 case PIX_FMT_GRAY16BE:
01188 c->lumToYV12 = bswap16Y_c;
01189 break;
01190 #endif
01191 case PIX_FMT_YUYV422:
01192 case PIX_FMT_Y400A:
01193 c->lumToYV12 = yuy2ToY_c;
01194 break;
01195 case PIX_FMT_UYVY422:
01196 c->lumToYV12 = uyvyToY_c;
01197 break;
01198 case PIX_FMT_BGR24:
01199 c->lumToYV12 = bgr24ToY_c;
01200 break;
01201 case PIX_FMT_BGR565LE:
01202 c->lumToYV12 = bgr16leToY_c;
01203 break;
01204 case PIX_FMT_BGR565BE:
01205 c->lumToYV12 = bgr16beToY_c;
01206 break;
01207 case PIX_FMT_BGR555LE:
01208 c->lumToYV12 = bgr15leToY_c;
01209 break;
01210 case PIX_FMT_BGR555BE:
01211 c->lumToYV12 = bgr15beToY_c;
01212 break;
01213 case PIX_FMT_BGR444LE:
01214 c->lumToYV12 = bgr12leToY_c;
01215 break;
01216 case PIX_FMT_BGR444BE:
01217 c->lumToYV12 = bgr12beToY_c;
01218 break;
01219 case PIX_FMT_RGB24:
01220 c->lumToYV12 = rgb24ToY_c;
01221 break;
01222 case PIX_FMT_RGB565LE:
01223 c->lumToYV12 = rgb16leToY_c;
01224 break;
01225 case PIX_FMT_RGB565BE:
01226 c->lumToYV12 = rgb16beToY_c;
01227 break;
01228 case PIX_FMT_RGB555LE:
01229 c->lumToYV12 = rgb15leToY_c;
01230 break;
01231 case PIX_FMT_RGB555BE:
01232 c->lumToYV12 = rgb15beToY_c;
01233 break;
01234 case PIX_FMT_RGB444LE:
01235 c->lumToYV12 = rgb12leToY_c;
01236 break;
01237 case PIX_FMT_RGB444BE:
01238 c->lumToYV12 = rgb12beToY_c;
01239 break;
01240 case PIX_FMT_RGB8:
01241 case PIX_FMT_BGR8:
01242 case PIX_FMT_PAL8:
01243 case PIX_FMT_BGR4_BYTE:
01244 case PIX_FMT_RGB4_BYTE:
01245 c->lumToYV12 = palToY_c;
01246 break;
01247 case PIX_FMT_MONOBLACK:
01248 c->lumToYV12 = monoblack2Y_c;
01249 break;
01250 case PIX_FMT_MONOWHITE:
01251 c->lumToYV12 = monowhite2Y_c;
01252 break;
01253 case PIX_FMT_RGB32:
01254 c->lumToYV12 = bgr32ToY_c;
01255 break;
01256 case PIX_FMT_RGB32_1:
01257 c->lumToYV12 = bgr321ToY_c;
01258 break;
01259 case PIX_FMT_BGR32:
01260 c->lumToYV12 = rgb32ToY_c;
01261 break;
01262 case PIX_FMT_BGR32_1:
01263 c->lumToYV12 = rgb321ToY_c;
01264 break;
01265 case PIX_FMT_RGB48BE:
01266 c->lumToYV12 = rgb48BEToY_c;
01267 break;
01268 case PIX_FMT_RGB48LE:
01269 c->lumToYV12 = rgb48LEToY_c;
01270 break;
01271 case PIX_FMT_BGR48BE:
01272 c->lumToYV12 = bgr48BEToY_c;
01273 break;
01274 case PIX_FMT_BGR48LE:
01275 c->lumToYV12 = bgr48LEToY_c;
01276 break;
01277 case PIX_FMT_RGBA64BE:
01278 c->lumToYV12 = rgb64BEToY_c;
01279 break;
01280 case PIX_FMT_RGBA64LE:
01281 c->lumToYV12 = rgb64LEToY_c;
01282 break;
01283 }
01284 if (c->alpPixBuf) {
01285 switch (srcFormat) {
01286 case PIX_FMT_RGBA64LE:
01287 case PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
01288 case PIX_FMT_BGRA:
01289 case PIX_FMT_RGBA:
01290 c->alpToYV12 = rgbaToA_c;
01291 break;
01292 case PIX_FMT_ABGR:
01293 case PIX_FMT_ARGB:
01294 c->alpToYV12 = abgrToA_c;
01295 break;
01296 case PIX_FMT_Y400A:
01297 c->alpToYV12 = uyvyToY_c;
01298 break;
01299 case PIX_FMT_PAL8 :
01300 c->alpToYV12 = palToA_c;
01301 break;
01302 }
01303 }
01304 }