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