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/attributes.h"
00028 #include "libavutil/avutil.h"
00029 #include "libavutil/avassert.h"
00030 #include "libavutil/bswap.h"
00031 #include "libavutil/cpu.h"
00032 #include "libavutil/intreadwrite.h"
00033 #include "libavutil/mathematics.h"
00034 #include "libavutil/pixdesc.h"
00035 #include "config.h"
00036 #include "rgb2rgb.h"
00037 #include "swscale.h"
00038 #include "swscale_internal.h"
00039
00040 DECLARE_ALIGNED(8, const uint8_t, dither_2x2_4)[][8]={
00041 { 1, 3, 1, 3, 1, 3, 1, 3, },
00042 { 2, 0, 2, 0, 2, 0, 2, 0, },
00043 { 1, 3, 1, 3, 1, 3, 1, 3, },
00044 };
00045
00046 DECLARE_ALIGNED(8, const uint8_t, dither_2x2_8)[][8]={
00047 { 6, 2, 6, 2, 6, 2, 6, 2, },
00048 { 0, 4, 0, 4, 0, 4, 0, 4, },
00049 { 6, 2, 6, 2, 6, 2, 6, 2, },
00050 };
00051
00052 DECLARE_ALIGNED(8, const uint8_t, dither_4x4_16)[][8]={
00053 { 8, 4, 11, 7, 8, 4, 11, 7, },
00054 { 2, 14, 1, 13, 2, 14, 1, 13, },
00055 { 10, 6, 9, 5, 10, 6, 9, 5, },
00056 { 0, 12, 3, 15, 0, 12, 3, 15, },
00057 { 8, 4, 11, 7, 8, 4, 11, 7, },
00058 };
00059
00060 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32)[][8]={
00061 { 17, 9, 23, 15, 16, 8, 22, 14, },
00062 { 5, 29, 3, 27, 4, 28, 2, 26, },
00063 { 21, 13, 19, 11, 20, 12, 18, 10, },
00064 { 0, 24, 6, 30, 1, 25, 7, 31, },
00065 { 16, 8, 22, 14, 17, 9, 23, 15, },
00066 { 4, 28, 2, 26, 5, 29, 3, 27, },
00067 { 20, 12, 18, 10, 21, 13, 19, 11, },
00068 { 1, 25, 7, 31, 0, 24, 6, 30, },
00069 { 17, 9, 23, 15, 16, 8, 22, 14, },
00070 };
00071
00072 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73)[][8]={
00073 { 0, 55, 14, 68, 3, 58, 17, 72, },
00074 { 37, 18, 50, 32, 40, 22, 54, 35, },
00075 { 9, 64, 5, 59, 13, 67, 8, 63, },
00076 { 46, 27, 41, 23, 49, 31, 44, 26, },
00077 { 2, 57, 16, 71, 1, 56, 15, 70, },
00078 { 39, 21, 52, 34, 38, 19, 51, 33, },
00079 { 11, 66, 7, 62, 10, 65, 6, 60, },
00080 { 48, 30, 43, 25, 47, 29, 42, 24, },
00081 { 0, 55, 14, 68, 3, 58, 17, 72, },
00082 };
00083
00084 #if 1
00085 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
00086 {117, 62, 158, 103, 113, 58, 155, 100, },
00087 { 34, 199, 21, 186, 31, 196, 17, 182, },
00088 {144, 89, 131, 76, 141, 86, 127, 72, },
00089 { 0, 165, 41, 206, 10, 175, 52, 217, },
00090 {110, 55, 151, 96, 120, 65, 162, 107, },
00091 { 28, 193, 14, 179, 38, 203, 24, 189, },
00092 {138, 83, 124, 69, 148, 93, 134, 79, },
00093 { 7, 172, 48, 213, 3, 168, 45, 210, },
00094 {117, 62, 158, 103, 113, 58, 155, 100, },
00095 };
00096 #elif 1
00097
00098 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
00099 { 0, 143, 18, 200, 2, 156, 25, 215, },
00100 { 78, 28, 125, 64, 89, 36, 138, 74, },
00101 { 10, 180, 3, 161, 16, 195, 8, 175, },
00102 {109, 51, 93, 38, 121, 60, 105, 47, },
00103 { 1, 152, 23, 210, 0, 147, 20, 205, },
00104 { 85, 33, 134, 71, 81, 30, 130, 67, },
00105 { 14, 190, 6, 171, 12, 185, 5, 166, },
00106 {117, 57, 101, 44, 113, 54, 97, 41, },
00107 { 0, 143, 18, 200, 2, 156, 25, 215, },
00108 };
00109 #elif 1
00110
00111 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
00112 { 0, 124, 8, 193, 0, 140, 12, 213, },
00113 { 55, 14, 104, 42, 66, 19, 119, 52, },
00114 { 3, 168, 1, 145, 6, 187, 3, 162, },
00115 { 86, 31, 70, 21, 99, 39, 82, 28, },
00116 { 0, 134, 11, 206, 0, 129, 9, 200, },
00117 { 62, 17, 114, 48, 58, 16, 109, 45, },
00118 { 5, 181, 2, 157, 4, 175, 1, 151, },
00119 { 95, 36, 78, 26, 90, 34, 74, 24, },
00120 { 0, 124, 8, 193, 0, 140, 12, 213, },
00121 };
00122 #else
00123
00124 DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
00125 { 0, 107, 3, 187, 0, 125, 6, 212, },
00126 { 39, 7, 86, 28, 49, 11, 102, 36, },
00127 { 1, 158, 0, 131, 3, 180, 1, 151, },
00128 { 68, 19, 52, 12, 81, 25, 64, 17, },
00129 { 0, 119, 5, 203, 0, 113, 4, 195, },
00130 { 45, 9, 96, 33, 42, 8, 91, 30, },
00131 { 2, 172, 1, 144, 2, 165, 0, 137, },
00132 { 77, 23, 60, 15, 72, 21, 56, 14, },
00133 { 0, 107, 3, 187, 0, 125, 6, 212, },
00134 };
00135 #endif
00136
00137 #define output_pixel(pos, val, bias, signedness) \
00138 if (big_endian) { \
00139 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
00140 } else { \
00141 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
00142 }
00143
00144 static av_always_inline void
00145 yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
00146 int big_endian, int output_bits)
00147 {
00148 int i;
00149 int shift = 3;
00150 av_assert0(output_bits == 16);
00151
00152 for (i = 0; i < dstW; i++) {
00153 int val = src[i] + (1 << (shift - 1));
00154 output_pixel(&dest[i], val, 0, uint);
00155 }
00156 }
00157
00158 static av_always_inline void
00159 yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
00160 const int32_t **src, uint16_t *dest, int dstW,
00161 int big_endian, int output_bits)
00162 {
00163 int i;
00164 int shift = 15;
00165 av_assert0(output_bits == 16);
00166
00167 for (i = 0; i < dstW; i++) {
00168 int val = 1 << (shift - 1);
00169 int j;
00170
00171
00172
00173
00174
00175
00176 val -= 0x40000000;
00177 for (j = 0; j < filterSize; j++)
00178 val += src[j][i] * (unsigned)filter[j];
00179
00180 output_pixel(&dest[i], val, 0x8000, int);
00181 }
00182 }
00183
00184 #undef output_pixel
00185
00186 #define output_pixel(pos, val) \
00187 if (big_endian) { \
00188 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
00189 } else { \
00190 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
00191 }
00192
00193 static av_always_inline void
00194 yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
00195 int big_endian, int output_bits)
00196 {
00197 int i;
00198 int shift = 15 - output_bits;
00199
00200 for (i = 0; i < dstW; i++) {
00201 int val = src[i] + (1 << (shift - 1));
00202 output_pixel(&dest[i], val);
00203 }
00204 }
00205
00206 static av_always_inline void
00207 yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
00208 const int16_t **src, uint16_t *dest, int dstW,
00209 int big_endian, int output_bits)
00210 {
00211 int i;
00212 int shift = 11 + 16 - output_bits;
00213
00214 for (i = 0; i < dstW; i++) {
00215 int val = 1 << (shift - 1);
00216 int j;
00217
00218 for (j = 0; j < filterSize; j++)
00219 val += src[j][i] * filter[j];
00220
00221 output_pixel(&dest[i], val);
00222 }
00223 }
00224
00225 #undef output_pixel
00226
00227 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
00228 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
00229 uint8_t *dest, int dstW, \
00230 const uint8_t *dither, int offset)\
00231 { \
00232 yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
00233 (uint16_t *) dest, dstW, is_be, bits); \
00234 }\
00235 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
00236 const int16_t **src, uint8_t *dest, int dstW, \
00237 const uint8_t *dither, int offset)\
00238 { \
00239 yuv2planeX_## template_size ## _c_template(filter, \
00240 filterSize, (const typeX_t **) src, \
00241 (uint16_t *) dest, dstW, is_be, bits); \
00242 }
00243 yuv2NBPS( 9, BE, 1, 10, int16_t)
00244 yuv2NBPS( 9, LE, 0, 10, int16_t)
00245 yuv2NBPS(10, BE, 1, 10, int16_t)
00246 yuv2NBPS(10, LE, 0, 10, int16_t)
00247 yuv2NBPS(12, BE, 1, 10, int16_t)
00248 yuv2NBPS(12, LE, 0, 10, int16_t)
00249 yuv2NBPS(14, BE, 1, 10, int16_t)
00250 yuv2NBPS(14, LE, 0, 10, int16_t)
00251 yuv2NBPS(16, BE, 1, 16, int32_t)
00252 yuv2NBPS(16, LE, 0, 16, int32_t)
00253
00254 static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
00255 const int16_t **src, uint8_t *dest, int dstW,
00256 const uint8_t *dither, int offset)
00257 {
00258 int i;
00259 for (i=0; i<dstW; i++) {
00260 int val = dither[(i + offset) & 7] << 12;
00261 int j;
00262 for (j=0; j<filterSize; j++)
00263 val += src[j][i] * filter[j];
00264
00265 dest[i]= av_clip_uint8(val>>19);
00266 }
00267 }
00268
00269 static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
00270 const uint8_t *dither, int offset)
00271 {
00272 int i;
00273 for (i=0; i<dstW; i++) {
00274 int val = (src[i] + dither[(i + offset) & 7]) >> 7;
00275 dest[i]= av_clip_uint8(val);
00276 }
00277 }
00278
00279 static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
00280 const int16_t **chrUSrc, const int16_t **chrVSrc,
00281 uint8_t *dest, int chrDstW)
00282 {
00283 enum AVPixelFormat dstFormat = c->dstFormat;
00284 const uint8_t *chrDither = c->chrDither8;
00285 int i;
00286
00287 if (dstFormat == AV_PIX_FMT_NV12)
00288 for (i=0; i<chrDstW; i++) {
00289 int u = chrDither[i & 7] << 12;
00290 int v = chrDither[(i + 3) & 7] << 12;
00291 int j;
00292 for (j=0; j<chrFilterSize; j++) {
00293 u += chrUSrc[j][i] * chrFilter[j];
00294 v += chrVSrc[j][i] * chrFilter[j];
00295 }
00296
00297 dest[2*i]= av_clip_uint8(u>>19);
00298 dest[2*i+1]= av_clip_uint8(v>>19);
00299 }
00300 else
00301 for (i=0; i<chrDstW; i++) {
00302 int u = chrDither[i & 7] << 12;
00303 int v = chrDither[(i + 3) & 7] << 12;
00304 int j;
00305 for (j=0; j<chrFilterSize; j++) {
00306 u += chrUSrc[j][i] * chrFilter[j];
00307 v += chrVSrc[j][i] * chrFilter[j];
00308 }
00309
00310 dest[2*i]= av_clip_uint8(v>>19);
00311 dest[2*i+1]= av_clip_uint8(u>>19);
00312 }
00313 }
00314
00315 #define accumulate_bit(acc, val) \
00316 acc <<= 1; \
00317 acc |= (val) >= (128 + 110)
00318 #define output_pixel(pos, acc) \
00319 if (target == AV_PIX_FMT_MONOBLACK) { \
00320 pos = acc; \
00321 } else { \
00322 pos = ~acc; \
00323 }
00324
00325 static av_always_inline void
00326 yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
00327 const int16_t **lumSrc, int lumFilterSize,
00328 const int16_t *chrFilter, const int16_t **chrUSrc,
00329 const int16_t **chrVSrc, int chrFilterSize,
00330 const int16_t **alpSrc, uint8_t *dest, int dstW,
00331 int y, enum AVPixelFormat target)
00332 {
00333 const uint8_t * const d128=dither_8x8_220[y&7];
00334 int i;
00335 unsigned acc = 0;
00336
00337 for (i = 0; i < dstW; i += 2) {
00338 int j;
00339 int Y1 = 1 << 18;
00340 int Y2 = 1 << 18;
00341
00342 for (j = 0; j < lumFilterSize; j++) {
00343 Y1 += lumSrc[j][i] * lumFilter[j];
00344 Y2 += lumSrc[j][i+1] * lumFilter[j];
00345 }
00346 Y1 >>= 19;
00347 Y2 >>= 19;
00348 if ((Y1 | Y2) & 0x100) {
00349 Y1 = av_clip_uint8(Y1);
00350 Y2 = av_clip_uint8(Y2);
00351 }
00352 accumulate_bit(acc, Y1 + d128[(i + 0) & 7]);
00353 accumulate_bit(acc, Y2 + d128[(i + 1) & 7]);
00354 if ((i & 7) == 6) {
00355 output_pixel(*dest++, acc);
00356 }
00357 }
00358
00359 if (i & 6) {
00360 output_pixel(*dest, acc);
00361 }
00362 }
00363
00364 static av_always_inline void
00365 yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
00366 const int16_t *ubuf[2], const int16_t *vbuf[2],
00367 const int16_t *abuf[2], uint8_t *dest, int dstW,
00368 int yalpha, int uvalpha, int y,
00369 enum AVPixelFormat target)
00370 {
00371 const int16_t *buf0 = buf[0], *buf1 = buf[1];
00372 const uint8_t * const d128 = dither_8x8_220[y & 7];
00373 int yalpha1 = 4096 - yalpha;
00374 int i;
00375
00376 for (i = 0; i < dstW; i += 8) {
00377 int Y, acc = 0;
00378
00379 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
00380 accumulate_bit(acc, Y + d128[0]);
00381 Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
00382 accumulate_bit(acc, Y + d128[1]);
00383 Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
00384 accumulate_bit(acc, Y + d128[2]);
00385 Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
00386 accumulate_bit(acc, Y + d128[3]);
00387 Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
00388 accumulate_bit(acc, Y + d128[4]);
00389 Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
00390 accumulate_bit(acc, Y + d128[5]);
00391 Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
00392 accumulate_bit(acc, Y + d128[6]);
00393 Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
00394 accumulate_bit(acc, Y + d128[7]);
00395
00396 output_pixel(*dest++, acc);
00397 }
00398 }
00399
00400 static av_always_inline void
00401 yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
00402 const int16_t *ubuf[2], const int16_t *vbuf[2],
00403 const int16_t *abuf0, uint8_t *dest, int dstW,
00404 int uvalpha, int y, enum AVPixelFormat target)
00405 {
00406 const uint8_t * const d128 = dither_8x8_220[y & 7];
00407 int i;
00408
00409 for (i = 0; i < dstW; i += 8) {
00410 int acc = 0;
00411
00412 accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
00413 accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
00414 accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
00415 accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
00416 accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
00417 accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
00418 accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
00419 accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
00420
00421 output_pixel(*dest++, acc);
00422 }
00423 }
00424
00425 #undef output_pixel
00426 #undef accumulate_bit
00427
00428 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
00429 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
00430 const int16_t **lumSrc, int lumFilterSize, \
00431 const int16_t *chrFilter, const int16_t **chrUSrc, \
00432 const int16_t **chrVSrc, int chrFilterSize, \
00433 const int16_t **alpSrc, uint8_t *dest, int dstW, \
00434 int y) \
00435 { \
00436 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
00437 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
00438 alpSrc, dest, dstW, y, fmt); \
00439 } \
00440 \
00441 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
00442 const int16_t *ubuf[2], const int16_t *vbuf[2], \
00443 const int16_t *abuf[2], uint8_t *dest, int dstW, \
00444 int yalpha, int uvalpha, int y) \
00445 { \
00446 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
00447 dest, dstW, yalpha, uvalpha, y, fmt); \
00448 } \
00449 \
00450 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
00451 const int16_t *ubuf[2], const int16_t *vbuf[2], \
00452 const int16_t *abuf0, uint8_t *dest, int dstW, \
00453 int uvalpha, int y) \
00454 { \
00455 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
00456 abuf0, dest, dstW, uvalpha, \
00457 y, fmt); \
00458 }
00459
00460 YUV2PACKEDWRAPPER(yuv2mono,, white, AV_PIX_FMT_MONOWHITE)
00461 YUV2PACKEDWRAPPER(yuv2mono,, black, AV_PIX_FMT_MONOBLACK)
00462
00463 #define output_pixels(pos, Y1, U, Y2, V) \
00464 if (target == AV_PIX_FMT_YUYV422) { \
00465 dest[pos + 0] = Y1; \
00466 dest[pos + 1] = U; \
00467 dest[pos + 2] = Y2; \
00468 dest[pos + 3] = V; \
00469 } else { \
00470 dest[pos + 0] = U; \
00471 dest[pos + 1] = Y1; \
00472 dest[pos + 2] = V; \
00473 dest[pos + 3] = Y2; \
00474 }
00475
00476 static av_always_inline void
00477 yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
00478 const int16_t **lumSrc, int lumFilterSize,
00479 const int16_t *chrFilter, const int16_t **chrUSrc,
00480 const int16_t **chrVSrc, int chrFilterSize,
00481 const int16_t **alpSrc, uint8_t *dest, int dstW,
00482 int y, enum AVPixelFormat target)
00483 {
00484 int i;
00485
00486 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00487 int j;
00488 int Y1 = 1 << 18;
00489 int Y2 = 1 << 18;
00490 int U = 1 << 18;
00491 int V = 1 << 18;
00492
00493 for (j = 0; j < lumFilterSize; j++) {
00494 Y1 += lumSrc[j][i * 2] * lumFilter[j];
00495 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
00496 }
00497 for (j = 0; j < chrFilterSize; j++) {
00498 U += chrUSrc[j][i] * chrFilter[j];
00499 V += chrVSrc[j][i] * chrFilter[j];
00500 }
00501 Y1 >>= 19;
00502 Y2 >>= 19;
00503 U >>= 19;
00504 V >>= 19;
00505 if ((Y1 | Y2 | U | V) & 0x100) {
00506 Y1 = av_clip_uint8(Y1);
00507 Y2 = av_clip_uint8(Y2);
00508 U = av_clip_uint8(U);
00509 V = av_clip_uint8(V);
00510 }
00511 output_pixels(4*i, Y1, U, Y2, V);
00512 }
00513 }
00514
00515 static av_always_inline void
00516 yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
00517 const int16_t *ubuf[2], const int16_t *vbuf[2],
00518 const int16_t *abuf[2], uint8_t *dest, int dstW,
00519 int yalpha, int uvalpha, int y,
00520 enum AVPixelFormat target)
00521 {
00522 const int16_t *buf0 = buf[0], *buf1 = buf[1],
00523 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
00524 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
00525 int yalpha1 = 4096 - yalpha;
00526 int uvalpha1 = 4096 - uvalpha;
00527 int i;
00528
00529 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00530 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
00531 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
00532 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
00533 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
00534
00535 if ((Y1 | Y2 | U | V) & 0x100) {
00536 Y1 = av_clip_uint8(Y1);
00537 Y2 = av_clip_uint8(Y2);
00538 U = av_clip_uint8(U);
00539 V = av_clip_uint8(V);
00540 }
00541
00542 output_pixels(i * 4, Y1, U, Y2, V);
00543 }
00544 }
00545
00546 static av_always_inline void
00547 yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
00548 const int16_t *ubuf[2], const int16_t *vbuf[2],
00549 const int16_t *abuf0, uint8_t *dest, int dstW,
00550 int uvalpha, int y, enum AVPixelFormat target)
00551 {
00552 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
00553 int i;
00554
00555 if (uvalpha < 2048) {
00556 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00557 int Y1 = (buf0[i * 2 ]+64) >> 7;
00558 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
00559 int U = (ubuf0[i] +64) >> 7;
00560 int V = (vbuf0[i] +64) >> 7;
00561
00562 if ((Y1 | Y2 | U | V) & 0x100) {
00563 Y1 = av_clip_uint8(Y1);
00564 Y2 = av_clip_uint8(Y2);
00565 U = av_clip_uint8(U);
00566 V = av_clip_uint8(V);
00567 }
00568
00569 Y1 = av_clip_uint8(Y1);
00570 Y2 = av_clip_uint8(Y2);
00571 U = av_clip_uint8(U);
00572 V = av_clip_uint8(V);
00573
00574 output_pixels(i * 4, Y1, U, Y2, V);
00575 }
00576 } else {
00577 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
00578 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00579 int Y1 = (buf0[i * 2 ] + 64) >> 7;
00580 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
00581 int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
00582 int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
00583
00584 if ((Y1 | Y2 | U | V) & 0x100) {
00585 Y1 = av_clip_uint8(Y1);
00586 Y2 = av_clip_uint8(Y2);
00587 U = av_clip_uint8(U);
00588 V = av_clip_uint8(V);
00589 }
00590
00591 Y1 = av_clip_uint8(Y1);
00592 Y2 = av_clip_uint8(Y2);
00593 U = av_clip_uint8(U);
00594 V = av_clip_uint8(V);
00595
00596 output_pixels(i * 4, Y1, U, Y2, V);
00597 }
00598 }
00599 }
00600
00601 #undef output_pixels
00602
00603 YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
00604 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)
00605
00606 #define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? R : B)
00607 #define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? B : R)
00608 #define output_pixel(pos, val) \
00609 if (isBE(target)) { \
00610 AV_WB16(pos, val); \
00611 } else { \
00612 AV_WL16(pos, val); \
00613 }
00614
00615 static av_always_inline void
00616 yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter,
00617 const int32_t **lumSrc, int lumFilterSize,
00618 const int16_t *chrFilter, const int32_t **chrUSrc,
00619 const int32_t **chrVSrc, int chrFilterSize,
00620 const int32_t **alpSrc, uint16_t *dest, int dstW,
00621 int y, enum AVPixelFormat target)
00622 {
00623 int i;
00624
00625 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00626 int j;
00627 int Y1 = -0x40000000;
00628 int Y2 = -0x40000000;
00629 int U = -128 << 23;
00630 int V = -128 << 23;
00631 int R, G, B;
00632
00633 for (j = 0; j < lumFilterSize; j++) {
00634 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
00635 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
00636 }
00637 for (j = 0; j < chrFilterSize; j++) {;
00638 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
00639 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
00640 }
00641
00642
00643 Y1 >>= 14;
00644 Y1 += 0x10000;
00645 Y2 >>= 14;
00646 Y2 += 0x10000;
00647 U >>= 14;
00648 V >>= 14;
00649
00650
00651 Y1 -= c->yuv2rgb_y_offset;
00652 Y2 -= c->yuv2rgb_y_offset;
00653 Y1 *= c->yuv2rgb_y_coeff;
00654 Y2 *= c->yuv2rgb_y_coeff;
00655 Y1 += 1 << 13;
00656 Y2 += 1 << 13;
00657
00658
00659 R = V * c->yuv2rgb_v2r_coeff;
00660 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00661 B = U * c->yuv2rgb_u2b_coeff;
00662
00663
00664 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00665 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00666 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00667 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00668 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00669 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00670 dest += 6;
00671 }
00672 }
00673
00674 static av_always_inline void
00675 yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
00676 const int32_t *ubuf[2], const int32_t *vbuf[2],
00677 const int32_t *abuf[2], uint16_t *dest, int dstW,
00678 int yalpha, int uvalpha, int y,
00679 enum AVPixelFormat target)
00680 {
00681 const int32_t *buf0 = buf[0], *buf1 = buf[1],
00682 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
00683 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
00684 int yalpha1 = 4096 - yalpha;
00685 int uvalpha1 = 4096 - uvalpha;
00686 int i;
00687
00688 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00689 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
00690 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
00691 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
00692 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
00693 int R, G, B;
00694
00695 Y1 -= c->yuv2rgb_y_offset;
00696 Y2 -= c->yuv2rgb_y_offset;
00697 Y1 *= c->yuv2rgb_y_coeff;
00698 Y2 *= c->yuv2rgb_y_coeff;
00699 Y1 += 1 << 13;
00700 Y2 += 1 << 13;
00701
00702 R = V * c->yuv2rgb_v2r_coeff;
00703 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00704 B = U * c->yuv2rgb_u2b_coeff;
00705
00706 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00707 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00708 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00709 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00710 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00711 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00712 dest += 6;
00713 }
00714 }
00715
00716 static av_always_inline void
00717 yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
00718 const int32_t *ubuf[2], const int32_t *vbuf[2],
00719 const int32_t *abuf0, uint16_t *dest, int dstW,
00720 int uvalpha, int y, enum AVPixelFormat target)
00721 {
00722 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
00723 int i;
00724
00725 if (uvalpha < 2048) {
00726 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00727 int Y1 = (buf0[i * 2] ) >> 2;
00728 int Y2 = (buf0[i * 2 + 1]) >> 2;
00729 int U = (ubuf0[i] + (-128 << 11)) >> 2;
00730 int V = (vbuf0[i] + (-128 << 11)) >> 2;
00731 int R, G, B;
00732
00733 Y1 -= c->yuv2rgb_y_offset;
00734 Y2 -= c->yuv2rgb_y_offset;
00735 Y1 *= c->yuv2rgb_y_coeff;
00736 Y2 *= c->yuv2rgb_y_coeff;
00737 Y1 += 1 << 13;
00738 Y2 += 1 << 13;
00739
00740 R = V * c->yuv2rgb_v2r_coeff;
00741 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00742 B = U * c->yuv2rgb_u2b_coeff;
00743
00744 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00745 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00746 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00747 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00748 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00749 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00750 dest += 6;
00751 }
00752 } else {
00753 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
00754 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00755 int Y1 = (buf0[i * 2] ) >> 2;
00756 int Y2 = (buf0[i * 2 + 1]) >> 2;
00757 int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
00758 int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3;
00759 int R, G, B;
00760
00761 Y1 -= c->yuv2rgb_y_offset;
00762 Y2 -= c->yuv2rgb_y_offset;
00763 Y1 *= c->yuv2rgb_y_coeff;
00764 Y2 *= c->yuv2rgb_y_coeff;
00765 Y1 += 1 << 13;
00766 Y2 += 1 << 13;
00767
00768 R = V * c->yuv2rgb_v2r_coeff;
00769 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00770 B = U * c->yuv2rgb_u2b_coeff;
00771
00772 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00773 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00774 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00775 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00776 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00777 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00778 dest += 6;
00779 }
00780 }
00781 }
00782
00783 #undef output_pixel
00784 #undef r_b
00785 #undef b_r
00786
00787 #define YUV2PACKED16WRAPPER(name, base, ext, fmt) \
00788 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
00789 const int16_t **_lumSrc, int lumFilterSize, \
00790 const int16_t *chrFilter, const int16_t **_chrUSrc, \
00791 const int16_t **_chrVSrc, int chrFilterSize, \
00792 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
00793 int y) \
00794 { \
00795 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
00796 **chrUSrc = (const int32_t **) _chrUSrc, \
00797 **chrVSrc = (const int32_t **) _chrVSrc, \
00798 **alpSrc = (const int32_t **) _alpSrc; \
00799 uint16_t *dest = (uint16_t *) _dest; \
00800 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
00801 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
00802 alpSrc, dest, dstW, y, fmt); \
00803 } \
00804 \
00805 static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
00806 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
00807 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
00808 int yalpha, int uvalpha, int y) \
00809 { \
00810 const int32_t **buf = (const int32_t **) _buf, \
00811 **ubuf = (const int32_t **) _ubuf, \
00812 **vbuf = (const int32_t **) _vbuf, \
00813 **abuf = (const int32_t **) _abuf; \
00814 uint16_t *dest = (uint16_t *) _dest; \
00815 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
00816 dest, dstW, yalpha, uvalpha, y, fmt); \
00817 } \
00818 \
00819 static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
00820 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
00821 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
00822 int uvalpha, int y) \
00823 { \
00824 const int32_t *buf0 = (const int32_t *) _buf0, \
00825 **ubuf = (const int32_t **) _ubuf, \
00826 **vbuf = (const int32_t **) _vbuf, \
00827 *abuf0 = (const int32_t *) _abuf0; \
00828 uint16_t *dest = (uint16_t *) _dest; \
00829 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
00830 dstW, uvalpha, y, fmt); \
00831 }
00832
00833 YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, AV_PIX_FMT_RGB48BE)
00834 YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, AV_PIX_FMT_RGB48LE)
00835 YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, AV_PIX_FMT_BGR48BE)
00836 YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, AV_PIX_FMT_BGR48LE)
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 static av_always_inline void
00847 yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
00848 unsigned A1, unsigned A2,
00849 const void *_r, const void *_g, const void *_b, int y,
00850 enum AVPixelFormat target, int hasAlpha)
00851 {
00852 if (target == AV_PIX_FMT_ARGB || target == AV_PIX_FMT_RGBA ||
00853 target == AV_PIX_FMT_ABGR || target == AV_PIX_FMT_BGRA) {
00854 uint32_t *dest = (uint32_t *) _dest;
00855 const uint32_t *r = (const uint32_t *) _r;
00856 const uint32_t *g = (const uint32_t *) _g;
00857 const uint32_t *b = (const uint32_t *) _b;
00858
00859 #if CONFIG_SMALL
00860 int sh = hasAlpha ? ((target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24) : 0;
00861
00862 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
00863 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
00864 #else
00865 if (hasAlpha) {
00866 int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
00867
00868 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
00869 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
00870 } else {
00871 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
00872 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
00873 }
00874 #endif
00875 } else if (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) {
00876 uint8_t *dest = (uint8_t *) _dest;
00877 const uint8_t *r = (const uint8_t *) _r;
00878 const uint8_t *g = (const uint8_t *) _g;
00879 const uint8_t *b = (const uint8_t *) _b;
00880
00881 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
00882 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
00883
00884 dest[i * 6 + 0] = r_b[Y1];
00885 dest[i * 6 + 1] = g[Y1];
00886 dest[i * 6 + 2] = b_r[Y1];
00887 dest[i * 6 + 3] = r_b[Y2];
00888 dest[i * 6 + 4] = g[Y2];
00889 dest[i * 6 + 5] = b_r[Y2];
00890 #undef r_b
00891 #undef b_r
00892 } else if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565 ||
00893 target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555 ||
00894 target == AV_PIX_FMT_RGB444 || target == AV_PIX_FMT_BGR444) {
00895 uint16_t *dest = (uint16_t *) _dest;
00896 const uint16_t *r = (const uint16_t *) _r;
00897 const uint16_t *g = (const uint16_t *) _g;
00898 const uint16_t *b = (const uint16_t *) _b;
00899 int dr1, dg1, db1, dr2, dg2, db2;
00900
00901 if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565) {
00902 dr1 = dither_2x2_8[ y & 1 ][0];
00903 dg1 = dither_2x2_4[ y & 1 ][0];
00904 db1 = dither_2x2_8[(y & 1) ^ 1][0];
00905 dr2 = dither_2x2_8[ y & 1 ][1];
00906 dg2 = dither_2x2_4[ y & 1 ][1];
00907 db2 = dither_2x2_8[(y & 1) ^ 1][1];
00908 } else if (target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555) {
00909 dr1 = dither_2x2_8[ y & 1 ][0];
00910 dg1 = dither_2x2_8[ y & 1 ][1];
00911 db1 = dither_2x2_8[(y & 1) ^ 1][0];
00912 dr2 = dither_2x2_8[ y & 1 ][1];
00913 dg2 = dither_2x2_8[ y & 1 ][0];
00914 db2 = dither_2x2_8[(y & 1) ^ 1][1];
00915 } else {
00916 dr1 = dither_4x4_16[ y & 3 ][0];
00917 dg1 = dither_4x4_16[ y & 3 ][1];
00918 db1 = dither_4x4_16[(y & 3) ^ 3][0];
00919 dr2 = dither_4x4_16[ y & 3 ][1];
00920 dg2 = dither_4x4_16[ y & 3 ][0];
00921 db2 = dither_4x4_16[(y & 3) ^ 3][1];
00922 }
00923
00924 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
00925 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
00926 } else {
00927 uint8_t *dest = (uint8_t *) _dest;
00928 const uint8_t *r = (const uint8_t *) _r;
00929 const uint8_t *g = (const uint8_t *) _g;
00930 const uint8_t *b = (const uint8_t *) _b;
00931 int dr1, dg1, db1, dr2, dg2, db2;
00932
00933 if (target == AV_PIX_FMT_RGB8 || target == AV_PIX_FMT_BGR8) {
00934 const uint8_t * const d64 = dither_8x8_73[y & 7];
00935 const uint8_t * const d32 = dither_8x8_32[y & 7];
00936 dr1 = dg1 = d32[(i * 2 + 0) & 7];
00937 db1 = d64[(i * 2 + 0) & 7];
00938 dr2 = dg2 = d32[(i * 2 + 1) & 7];
00939 db2 = d64[(i * 2 + 1) & 7];
00940 } else {
00941 const uint8_t * const d64 = dither_8x8_73 [y & 7];
00942 const uint8_t * const d128 = dither_8x8_220[y & 7];
00943 dr1 = db1 = d128[(i * 2 + 0) & 7];
00944 dg1 = d64[(i * 2 + 0) & 7];
00945 dr2 = db2 = d128[(i * 2 + 1) & 7];
00946 dg2 = d64[(i * 2 + 1) & 7];
00947 }
00948
00949 if (target == AV_PIX_FMT_RGB4 || target == AV_PIX_FMT_BGR4) {
00950 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
00951 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
00952 } else {
00953 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
00954 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
00955 }
00956 }
00957 }
00958
00959 static av_always_inline void
00960 yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter,
00961 const int16_t **lumSrc, int lumFilterSize,
00962 const int16_t *chrFilter, const int16_t **chrUSrc,
00963 const int16_t **chrVSrc, int chrFilterSize,
00964 const int16_t **alpSrc, uint8_t *dest, int dstW,
00965 int y, enum AVPixelFormat target, int hasAlpha)
00966 {
00967 int i;
00968
00969 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00970 int j, A1, A2;
00971 int Y1 = 1 << 18;
00972 int Y2 = 1 << 18;
00973 int U = 1 << 18;
00974 int V = 1 << 18;
00975 const void *r, *g, *b;
00976
00977 for (j = 0; j < lumFilterSize; j++) {
00978 Y1 += lumSrc[j][i * 2] * lumFilter[j];
00979 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
00980 }
00981 for (j = 0; j < chrFilterSize; j++) {
00982 U += chrUSrc[j][i] * chrFilter[j];
00983 V += chrVSrc[j][i] * chrFilter[j];
00984 }
00985 Y1 >>= 19;
00986 Y2 >>= 19;
00987 U >>= 19;
00988 V >>= 19;
00989 if (hasAlpha) {
00990 A1 = 1 << 18;
00991 A2 = 1 << 18;
00992 for (j = 0; j < lumFilterSize; j++) {
00993 A1 += alpSrc[j][i * 2 ] * lumFilter[j];
00994 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
00995 }
00996 A1 >>= 19;
00997 A2 >>= 19;
00998 if ((A1 | A2) & 0x100) {
00999 A1 = av_clip_uint8(A1);
01000 A2 = av_clip_uint8(A2);
01001 }
01002 }
01003
01004 r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
01005 g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
01006 b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01007
01008 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01009 r, g, b, y, target, hasAlpha);
01010 }
01011 }
01012
01013 static av_always_inline void
01014 yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
01015 const int16_t *ubuf[2], const int16_t *vbuf[2],
01016 const int16_t *abuf[2], uint8_t *dest, int dstW,
01017 int yalpha, int uvalpha, int y,
01018 enum AVPixelFormat target, int hasAlpha)
01019 {
01020 const int16_t *buf0 = buf[0], *buf1 = buf[1],
01021 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
01022 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
01023 *abuf0 = hasAlpha ? abuf[0] : NULL,
01024 *abuf1 = hasAlpha ? abuf[1] : NULL;
01025 int yalpha1 = 4096 - yalpha;
01026 int uvalpha1 = 4096 - uvalpha;
01027 int i;
01028
01029 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01030 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
01031 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
01032 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
01033 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
01034 int A1, A2;
01035 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01036 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01037 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01038
01039 if (hasAlpha) {
01040 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
01041 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
01042 A1 = av_clip_uint8(A1);
01043 A2 = av_clip_uint8(A2);
01044 }
01045
01046 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01047 r, g, b, y, target, hasAlpha);
01048 }
01049 }
01050
01051 static av_always_inline void
01052 yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
01053 const int16_t *ubuf[2], const int16_t *vbuf[2],
01054 const int16_t *abuf0, uint8_t *dest, int dstW,
01055 int uvalpha, int y, enum AVPixelFormat target,
01056 int hasAlpha)
01057 {
01058 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
01059 int i;
01060
01061 if (uvalpha < 2048) {
01062 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01063 int Y1 = (buf0[i * 2 ] + 64) >> 7;
01064 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
01065 int U = (ubuf0[i] + 64) >> 7;
01066 int V = (vbuf0[i] + 64) >> 7;
01067 int A1, A2;
01068 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01069 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01070 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01071
01072 if (hasAlpha) {
01073 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
01074 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
01075 A1 = av_clip_uint8(A1);
01076 A2 = av_clip_uint8(A2);
01077 }
01078
01079 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01080 r, g, b, y, target, hasAlpha);
01081 }
01082 } else {
01083 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
01084 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01085 int Y1 = (buf0[i * 2 ] + 64) >> 7;
01086 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
01087 int U = (ubuf0[i] + ubuf1[i] + 128) >> 8;
01088 int V = (vbuf0[i] + vbuf1[i] + 128) >> 8;
01089 int A1, A2;
01090 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01091 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01092 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01093
01094 if (hasAlpha) {
01095 A1 = (abuf0[i * 2 ] + 64) >> 7;
01096 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
01097 A1 = av_clip_uint8(A1);
01098 A2 = av_clip_uint8(A2);
01099 }
01100
01101 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01102 r, g, b, y, target, hasAlpha);
01103 }
01104 }
01105 }
01106
01107 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
01108 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
01109 const int16_t **lumSrc, int lumFilterSize, \
01110 const int16_t *chrFilter, const int16_t **chrUSrc, \
01111 const int16_t **chrVSrc, int chrFilterSize, \
01112 const int16_t **alpSrc, uint8_t *dest, int dstW, \
01113 int y) \
01114 { \
01115 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
01116 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
01117 alpSrc, dest, dstW, y, fmt, hasAlpha); \
01118 }
01119 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
01120 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
01121 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
01122 const int16_t *ubuf[2], const int16_t *vbuf[2], \
01123 const int16_t *abuf[2], uint8_t *dest, int dstW, \
01124 int yalpha, int uvalpha, int y) \
01125 { \
01126 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
01127 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
01128 } \
01129 \
01130 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
01131 const int16_t *ubuf[2], const int16_t *vbuf[2], \
01132 const int16_t *abuf0, uint8_t *dest, int dstW, \
01133 int uvalpha, int y) \
01134 { \
01135 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
01136 dstW, uvalpha, y, fmt, hasAlpha); \
01137 }
01138
01139 #if CONFIG_SMALL
01140 YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01141 YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01142 #else
01143 #if CONFIG_SWSCALE_ALPHA
01144 YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1)
01145 YUV2RGBWRAPPER(yuv2rgb,, a32, AV_PIX_FMT_RGB32, 1)
01146 #endif
01147 YUV2RGBWRAPPER(yuv2rgb,, x32_1, AV_PIX_FMT_RGB32_1, 0)
01148 YUV2RGBWRAPPER(yuv2rgb,, x32, AV_PIX_FMT_RGB32, 0)
01149 #endif
01150 YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
01151 YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
01152 YUV2RGBWRAPPER(yuv2rgb,, 16, AV_PIX_FMT_RGB565, 0)
01153 YUV2RGBWRAPPER(yuv2rgb,, 15, AV_PIX_FMT_RGB555, 0)
01154 YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0)
01155 YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
01156 YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
01157 YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
01158
01159 static av_always_inline void
01160 yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
01161 const int16_t **lumSrc, int lumFilterSize,
01162 const int16_t *chrFilter, const int16_t **chrUSrc,
01163 const int16_t **chrVSrc, int chrFilterSize,
01164 const int16_t **alpSrc, uint8_t *dest,
01165 int dstW, int y, enum AVPixelFormat target, int hasAlpha)
01166 {
01167 int i;
01168 int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
01169
01170 for (i = 0; i < dstW; i++) {
01171 int j;
01172 int Y = 1<<9;
01173 int U = (1<<9)-(128 << 19);
01174 int V = (1<<9)-(128 << 19);
01175 int R, G, B, A;
01176
01177 for (j = 0; j < lumFilterSize; j++) {
01178 Y += lumSrc[j][i] * lumFilter[j];
01179 }
01180 for (j = 0; j < chrFilterSize; j++) {
01181 U += chrUSrc[j][i] * chrFilter[j];
01182 V += chrVSrc[j][i] * chrFilter[j];
01183 }
01184 Y >>= 10;
01185 U >>= 10;
01186 V >>= 10;
01187 if (hasAlpha) {
01188 A = 1 << 18;
01189 for (j = 0; j < lumFilterSize; j++) {
01190 A += alpSrc[j][i] * lumFilter[j];
01191 }
01192 A >>= 19;
01193 if (A & 0x100)
01194 A = av_clip_uint8(A);
01195 }
01196 Y -= c->yuv2rgb_y_offset;
01197 Y *= c->yuv2rgb_y_coeff;
01198 Y += 1 << 21;
01199 R = Y + V*c->yuv2rgb_v2r_coeff;
01200 G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
01201 B = Y + U*c->yuv2rgb_u2b_coeff;
01202 if ((R | G | B) & 0xC0000000) {
01203 R = av_clip_uintp2(R, 30);
01204 G = av_clip_uintp2(G, 30);
01205 B = av_clip_uintp2(B, 30);
01206 }
01207
01208 switch(target) {
01209 case AV_PIX_FMT_ARGB:
01210 dest[0] = hasAlpha ? A : 255;
01211 dest[1] = R >> 22;
01212 dest[2] = G >> 22;
01213 dest[3] = B >> 22;
01214 break;
01215 case AV_PIX_FMT_RGB24:
01216 dest[0] = R >> 22;
01217 dest[1] = G >> 22;
01218 dest[2] = B >> 22;
01219 break;
01220 case AV_PIX_FMT_RGBA:
01221 dest[0] = R >> 22;
01222 dest[1] = G >> 22;
01223 dest[2] = B >> 22;
01224 dest[3] = hasAlpha ? A : 255;
01225 break;
01226 case AV_PIX_FMT_ABGR:
01227 dest[0] = hasAlpha ? A : 255;
01228 dest[1] = B >> 22;
01229 dest[2] = G >> 22;
01230 dest[3] = R >> 22;
01231 break;
01232 case AV_PIX_FMT_BGR24:
01233 dest[0] = B >> 22;
01234 dest[1] = G >> 22;
01235 dest[2] = R >> 22;
01236 break;
01237 case AV_PIX_FMT_BGRA:
01238 dest[0] = B >> 22;
01239 dest[1] = G >> 22;
01240 dest[2] = R >> 22;
01241 dest[3] = hasAlpha ? A : 255;
01242 break;
01243 }
01244 dest += step;
01245 }
01246 }
01247
01248 #if CONFIG_SMALL
01249 YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01250 YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01251 YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01252 YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01253 #else
01254 #if CONFIG_SWSCALE_ALPHA
01255 YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1)
01256 YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, 1)
01257 YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, 1)
01258 YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, 1)
01259 #endif
01260 YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
01261 YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
01262 YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
01263 YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
01264 #endif
01265 YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
01266 YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
01267
01268 av_cold void ff_sws_init_output_funcs(SwsContext *c,
01269 yuv2planar1_fn *yuv2plane1,
01270 yuv2planarX_fn *yuv2planeX,
01271 yuv2interleavedX_fn *yuv2nv12cX,
01272 yuv2packed1_fn *yuv2packed1,
01273 yuv2packed2_fn *yuv2packed2,
01274 yuv2packedX_fn *yuv2packedX)
01275 {
01276 enum AVPixelFormat dstFormat = c->dstFormat;
01277 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
01278
01279 if (is16BPS(dstFormat)) {
01280 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
01281 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
01282 } else if (is9_OR_10BPS(dstFormat)) {
01283 if (desc->comp[0].depth_minus1 == 8) {
01284 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
01285 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
01286 } else if (desc->comp[0].depth_minus1 == 9) {
01287 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
01288 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
01289 } else if (desc->comp[0].depth_minus1 == 11) {
01290 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
01291 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
01292 } else if (desc->comp[0].depth_minus1 == 13) {
01293 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
01294 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
01295 } else
01296 av_assert0(0);
01297 } else {
01298 *yuv2plane1 = yuv2plane1_8_c;
01299 *yuv2planeX = yuv2planeX_8_c;
01300 if (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)
01301 *yuv2nv12cX = yuv2nv12cX_c;
01302 }
01303
01304 if(c->flags & SWS_FULL_CHR_H_INT) {
01305 switch (dstFormat) {
01306 case AV_PIX_FMT_RGBA:
01307 #if CONFIG_SMALL
01308 *yuv2packedX = yuv2rgba32_full_X_c;
01309 #else
01310 #if CONFIG_SWSCALE_ALPHA
01311 if (c->alpPixBuf) {
01312 *yuv2packedX = yuv2rgba32_full_X_c;
01313 } else
01314 #endif
01315 {
01316 *yuv2packedX = yuv2rgbx32_full_X_c;
01317 }
01318 #endif
01319 break;
01320 case AV_PIX_FMT_ARGB:
01321 #if CONFIG_SMALL
01322 *yuv2packedX = yuv2argb32_full_X_c;
01323 #else
01324 #if CONFIG_SWSCALE_ALPHA
01325 if (c->alpPixBuf) {
01326 *yuv2packedX = yuv2argb32_full_X_c;
01327 } else
01328 #endif
01329 {
01330 *yuv2packedX = yuv2xrgb32_full_X_c;
01331 }
01332 #endif
01333 break;
01334 case AV_PIX_FMT_BGRA:
01335 #if CONFIG_SMALL
01336 *yuv2packedX = yuv2bgra32_full_X_c;
01337 #else
01338 #if CONFIG_SWSCALE_ALPHA
01339 if (c->alpPixBuf) {
01340 *yuv2packedX = yuv2bgra32_full_X_c;
01341 } else
01342 #endif
01343 {
01344 *yuv2packedX = yuv2bgrx32_full_X_c;
01345 }
01346 #endif
01347 break;
01348 case AV_PIX_FMT_ABGR:
01349 #if CONFIG_SMALL
01350 *yuv2packedX = yuv2abgr32_full_X_c;
01351 #else
01352 #if CONFIG_SWSCALE_ALPHA
01353 if (c->alpPixBuf) {
01354 *yuv2packedX = yuv2abgr32_full_X_c;
01355 } else
01356 #endif
01357 {
01358 *yuv2packedX = yuv2xbgr32_full_X_c;
01359 }
01360 #endif
01361 break;
01362 case AV_PIX_FMT_RGB24:
01363 *yuv2packedX = yuv2rgb24_full_X_c;
01364 break;
01365 case AV_PIX_FMT_BGR24:
01366 *yuv2packedX = yuv2bgr24_full_X_c;
01367 break;
01368 }
01369 if(!*yuv2packedX)
01370 goto YUV_PACKED;
01371 } else {
01372 YUV_PACKED:
01373 switch (dstFormat) {
01374 case AV_PIX_FMT_RGB48LE:
01375 *yuv2packed1 = yuv2rgb48le_1_c;
01376 *yuv2packed2 = yuv2rgb48le_2_c;
01377 *yuv2packedX = yuv2rgb48le_X_c;
01378 break;
01379 case AV_PIX_FMT_RGB48BE:
01380 *yuv2packed1 = yuv2rgb48be_1_c;
01381 *yuv2packed2 = yuv2rgb48be_2_c;
01382 *yuv2packedX = yuv2rgb48be_X_c;
01383 break;
01384 case AV_PIX_FMT_BGR48LE:
01385 *yuv2packed1 = yuv2bgr48le_1_c;
01386 *yuv2packed2 = yuv2bgr48le_2_c;
01387 *yuv2packedX = yuv2bgr48le_X_c;
01388 break;
01389 case AV_PIX_FMT_BGR48BE:
01390 *yuv2packed1 = yuv2bgr48be_1_c;
01391 *yuv2packed2 = yuv2bgr48be_2_c;
01392 *yuv2packedX = yuv2bgr48be_X_c;
01393 break;
01394 case AV_PIX_FMT_RGB32:
01395 case AV_PIX_FMT_BGR32:
01396 #if CONFIG_SMALL
01397 *yuv2packed1 = yuv2rgb32_1_c;
01398 *yuv2packed2 = yuv2rgb32_2_c;
01399 *yuv2packedX = yuv2rgb32_X_c;
01400 #else
01401 #if CONFIG_SWSCALE_ALPHA
01402 if (c->alpPixBuf) {
01403 *yuv2packed1 = yuv2rgba32_1_c;
01404 *yuv2packed2 = yuv2rgba32_2_c;
01405 *yuv2packedX = yuv2rgba32_X_c;
01406 } else
01407 #endif
01408 {
01409 *yuv2packed1 = yuv2rgbx32_1_c;
01410 *yuv2packed2 = yuv2rgbx32_2_c;
01411 *yuv2packedX = yuv2rgbx32_X_c;
01412 }
01413 #endif
01414 break;
01415 case AV_PIX_FMT_RGB32_1:
01416 case AV_PIX_FMT_BGR32_1:
01417 #if CONFIG_SMALL
01418 *yuv2packed1 = yuv2rgb32_1_1_c;
01419 *yuv2packed2 = yuv2rgb32_1_2_c;
01420 *yuv2packedX = yuv2rgb32_1_X_c;
01421 #else
01422 #if CONFIG_SWSCALE_ALPHA
01423 if (c->alpPixBuf) {
01424 *yuv2packed1 = yuv2rgba32_1_1_c;
01425 *yuv2packed2 = yuv2rgba32_1_2_c;
01426 *yuv2packedX = yuv2rgba32_1_X_c;
01427 } else
01428 #endif
01429 {
01430 *yuv2packed1 = yuv2rgbx32_1_1_c;
01431 *yuv2packed2 = yuv2rgbx32_1_2_c;
01432 *yuv2packedX = yuv2rgbx32_1_X_c;
01433 }
01434 #endif
01435 break;
01436 case AV_PIX_FMT_RGB24:
01437 *yuv2packed1 = yuv2rgb24_1_c;
01438 *yuv2packed2 = yuv2rgb24_2_c;
01439 *yuv2packedX = yuv2rgb24_X_c;
01440 break;
01441 case AV_PIX_FMT_BGR24:
01442 *yuv2packed1 = yuv2bgr24_1_c;
01443 *yuv2packed2 = yuv2bgr24_2_c;
01444 *yuv2packedX = yuv2bgr24_X_c;
01445 break;
01446 case AV_PIX_FMT_RGB565LE:
01447 case AV_PIX_FMT_RGB565BE:
01448 case AV_PIX_FMT_BGR565LE:
01449 case AV_PIX_FMT_BGR565BE:
01450 *yuv2packed1 = yuv2rgb16_1_c;
01451 *yuv2packed2 = yuv2rgb16_2_c;
01452 *yuv2packedX = yuv2rgb16_X_c;
01453 break;
01454 case AV_PIX_FMT_RGB555LE:
01455 case AV_PIX_FMT_RGB555BE:
01456 case AV_PIX_FMT_BGR555LE:
01457 case AV_PIX_FMT_BGR555BE:
01458 *yuv2packed1 = yuv2rgb15_1_c;
01459 *yuv2packed2 = yuv2rgb15_2_c;
01460 *yuv2packedX = yuv2rgb15_X_c;
01461 break;
01462 case AV_PIX_FMT_RGB444LE:
01463 case AV_PIX_FMT_RGB444BE:
01464 case AV_PIX_FMT_BGR444LE:
01465 case AV_PIX_FMT_BGR444BE:
01466 *yuv2packed1 = yuv2rgb12_1_c;
01467 *yuv2packed2 = yuv2rgb12_2_c;
01468 *yuv2packedX = yuv2rgb12_X_c;
01469 break;
01470 case AV_PIX_FMT_RGB8:
01471 case AV_PIX_FMT_BGR8:
01472 *yuv2packed1 = yuv2rgb8_1_c;
01473 *yuv2packed2 = yuv2rgb8_2_c;
01474 *yuv2packedX = yuv2rgb8_X_c;
01475 break;
01476 case AV_PIX_FMT_RGB4:
01477 case AV_PIX_FMT_BGR4:
01478 *yuv2packed1 = yuv2rgb4_1_c;
01479 *yuv2packed2 = yuv2rgb4_2_c;
01480 *yuv2packedX = yuv2rgb4_X_c;
01481 break;
01482 case AV_PIX_FMT_RGB4_BYTE:
01483 case AV_PIX_FMT_BGR4_BYTE:
01484 *yuv2packed1 = yuv2rgb4b_1_c;
01485 *yuv2packed2 = yuv2rgb4b_2_c;
01486 *yuv2packedX = yuv2rgb4b_X_c;
01487 break;
01488 }
01489 }
01490 switch (dstFormat) {
01491 case AV_PIX_FMT_MONOWHITE:
01492 *yuv2packed1 = yuv2monowhite_1_c;
01493 *yuv2packed2 = yuv2monowhite_2_c;
01494 *yuv2packedX = yuv2monowhite_X_c;
01495 break;
01496 case AV_PIX_FMT_MONOBLACK:
01497 *yuv2packed1 = yuv2monoblack_1_c;
01498 *yuv2packed2 = yuv2monoblack_2_c;
01499 *yuv2packedX = yuv2monoblack_X_c;
01500 break;
01501 case AV_PIX_FMT_YUYV422:
01502 *yuv2packed1 = yuv2yuyv422_1_c;
01503 *yuv2packed2 = yuv2yuyv422_2_c;
01504 *yuv2packedX = yuv2yuyv422_X_c;
01505 break;
01506 case AV_PIX_FMT_UYVY422:
01507 *yuv2packed1 = yuv2uyvy422_1_c;
01508 *yuv2packed2 = yuv2uyvy422_2_c;
01509 *yuv2packedX = yuv2uyvy422_X_c;
01510 break;
01511 }
01512 }