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(16, BE, 1, 16, int32_t)
00248 yuv2NBPS(16, LE, 0, 16, int32_t)
00249
00250 static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
00251 const int16_t **src, uint8_t *dest, int dstW,
00252 const uint8_t *dither, int offset)
00253 {
00254 int i;
00255 for (i=0; i<dstW; i++) {
00256 int val = dither[(i + offset) & 7] << 12;
00257 int j;
00258 for (j=0; j<filterSize; j++)
00259 val += src[j][i] * filter[j];
00260
00261 dest[i]= av_clip_uint8(val>>19);
00262 }
00263 }
00264
00265 static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
00266 const uint8_t *dither, int offset)
00267 {
00268 int i;
00269 for (i=0; i<dstW; i++) {
00270 int val = (src[i] + dither[(i + offset) & 7]) >> 7;
00271 dest[i]= av_clip_uint8(val);
00272 }
00273 }
00274
00275 static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
00276 const int16_t **chrUSrc, const int16_t **chrVSrc,
00277 uint8_t *dest, int chrDstW)
00278 {
00279 enum PixelFormat dstFormat = c->dstFormat;
00280 const uint8_t *chrDither = c->chrDither8;
00281 int i;
00282
00283 if (dstFormat == PIX_FMT_NV12)
00284 for (i=0; i<chrDstW; i++) {
00285 int u = chrDither[i & 7] << 12;
00286 int v = chrDither[(i + 3) & 7] << 12;
00287 int j;
00288 for (j=0; j<chrFilterSize; j++) {
00289 u += chrUSrc[j][i] * chrFilter[j];
00290 v += chrVSrc[j][i] * chrFilter[j];
00291 }
00292
00293 dest[2*i]= av_clip_uint8(u>>19);
00294 dest[2*i+1]= av_clip_uint8(v>>19);
00295 }
00296 else
00297 for (i=0; i<chrDstW; i++) {
00298 int u = chrDither[i & 7] << 12;
00299 int v = chrDither[(i + 3) & 7] << 12;
00300 int j;
00301 for (j=0; j<chrFilterSize; j++) {
00302 u += chrUSrc[j][i] * chrFilter[j];
00303 v += chrVSrc[j][i] * chrFilter[j];
00304 }
00305
00306 dest[2*i]= av_clip_uint8(v>>19);
00307 dest[2*i+1]= av_clip_uint8(u>>19);
00308 }
00309 }
00310
00311 #define accumulate_bit(acc, val) \
00312 acc <<= 1; \
00313 acc |= (val) >= (128 + 110)
00314 #define output_pixel(pos, acc) \
00315 if (target == PIX_FMT_MONOBLACK) { \
00316 pos = acc; \
00317 } else { \
00318 pos = ~acc; \
00319 }
00320
00321 static av_always_inline void
00322 yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
00323 const int16_t **lumSrc, int lumFilterSize,
00324 const int16_t *chrFilter, const int16_t **chrUSrc,
00325 const int16_t **chrVSrc, int chrFilterSize,
00326 const int16_t **alpSrc, uint8_t *dest, int dstW,
00327 int y, enum PixelFormat target)
00328 {
00329 const uint8_t * const d128=dither_8x8_220[y&7];
00330 int i;
00331 unsigned acc = 0;
00332
00333 for (i = 0; i < dstW; i += 2) {
00334 int j;
00335 int Y1 = 1 << 18;
00336 int Y2 = 1 << 18;
00337
00338 for (j = 0; j < lumFilterSize; j++) {
00339 Y1 += lumSrc[j][i] * lumFilter[j];
00340 Y2 += lumSrc[j][i+1] * lumFilter[j];
00341 }
00342 Y1 >>= 19;
00343 Y2 >>= 19;
00344 if ((Y1 | Y2) & 0x100) {
00345 Y1 = av_clip_uint8(Y1);
00346 Y2 = av_clip_uint8(Y2);
00347 }
00348 accumulate_bit(acc, Y1 + d128[(i + 0) & 7]);
00349 accumulate_bit(acc, Y2 + d128[(i + 1) & 7]);
00350 if ((i & 7) == 6) {
00351 output_pixel(*dest++, acc);
00352 }
00353 }
00354
00355 if (i & 6) {
00356 output_pixel(*dest, acc);
00357 }
00358 }
00359
00360 static av_always_inline void
00361 yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
00362 const int16_t *ubuf[2], const int16_t *vbuf[2],
00363 const int16_t *abuf[2], uint8_t *dest, int dstW,
00364 int yalpha, int uvalpha, int y,
00365 enum PixelFormat target)
00366 {
00367 const int16_t *buf0 = buf[0], *buf1 = buf[1];
00368 const uint8_t * const d128 = dither_8x8_220[y & 7];
00369 int yalpha1 = 4096 - yalpha;
00370 int i;
00371
00372 for (i = 0; i < dstW; i += 8) {
00373 int Y, acc = 0;
00374
00375 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
00376 accumulate_bit(acc, Y + d128[0]);
00377 Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
00378 accumulate_bit(acc, Y + d128[1]);
00379 Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
00380 accumulate_bit(acc, Y + d128[2]);
00381 Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
00382 accumulate_bit(acc, Y + d128[3]);
00383 Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
00384 accumulate_bit(acc, Y + d128[4]);
00385 Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
00386 accumulate_bit(acc, Y + d128[5]);
00387 Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
00388 accumulate_bit(acc, Y + d128[6]);
00389 Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
00390 accumulate_bit(acc, Y + d128[7]);
00391
00392 output_pixel(*dest++, acc);
00393 }
00394 }
00395
00396 static av_always_inline void
00397 yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
00398 const int16_t *ubuf[2], const int16_t *vbuf[2],
00399 const int16_t *abuf0, uint8_t *dest, int dstW,
00400 int uvalpha, int y, enum PixelFormat target)
00401 {
00402 const uint8_t * const d128 = dither_8x8_220[y & 7];
00403 int i;
00404
00405 for (i = 0; i < dstW; i += 8) {
00406 int acc = 0;
00407
00408 accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
00409 accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
00410 accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
00411 accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
00412 accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
00413 accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
00414 accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
00415 accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
00416
00417 output_pixel(*dest++, acc);
00418 }
00419 }
00420
00421 #undef output_pixel
00422 #undef accumulate_bit
00423
00424 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
00425 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
00426 const int16_t **lumSrc, int lumFilterSize, \
00427 const int16_t *chrFilter, const int16_t **chrUSrc, \
00428 const int16_t **chrVSrc, int chrFilterSize, \
00429 const int16_t **alpSrc, uint8_t *dest, int dstW, \
00430 int y) \
00431 { \
00432 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
00433 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
00434 alpSrc, dest, dstW, y, fmt); \
00435 } \
00436 \
00437 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
00438 const int16_t *ubuf[2], const int16_t *vbuf[2], \
00439 const int16_t *abuf[2], uint8_t *dest, int dstW, \
00440 int yalpha, int uvalpha, int y) \
00441 { \
00442 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
00443 dest, dstW, yalpha, uvalpha, y, fmt); \
00444 } \
00445 \
00446 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
00447 const int16_t *ubuf[2], const int16_t *vbuf[2], \
00448 const int16_t *abuf0, uint8_t *dest, int dstW, \
00449 int uvalpha, int y) \
00450 { \
00451 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
00452 abuf0, dest, dstW, uvalpha, \
00453 y, fmt); \
00454 }
00455
00456 YUV2PACKEDWRAPPER(yuv2mono,, white, PIX_FMT_MONOWHITE)
00457 YUV2PACKEDWRAPPER(yuv2mono,, black, PIX_FMT_MONOBLACK)
00458
00459 #define output_pixels(pos, Y1, U, Y2, V) \
00460 if (target == PIX_FMT_YUYV422) { \
00461 dest[pos + 0] = Y1; \
00462 dest[pos + 1] = U; \
00463 dest[pos + 2] = Y2; \
00464 dest[pos + 3] = V; \
00465 } else { \
00466 dest[pos + 0] = U; \
00467 dest[pos + 1] = Y1; \
00468 dest[pos + 2] = V; \
00469 dest[pos + 3] = Y2; \
00470 }
00471
00472 static av_always_inline void
00473 yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
00474 const int16_t **lumSrc, int lumFilterSize,
00475 const int16_t *chrFilter, const int16_t **chrUSrc,
00476 const int16_t **chrVSrc, int chrFilterSize,
00477 const int16_t **alpSrc, uint8_t *dest, int dstW,
00478 int y, enum PixelFormat target)
00479 {
00480 int i;
00481
00482 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00483 int j;
00484 int Y1 = 1 << 18;
00485 int Y2 = 1 << 18;
00486 int U = 1 << 18;
00487 int V = 1 << 18;
00488
00489 for (j = 0; j < lumFilterSize; j++) {
00490 Y1 += lumSrc[j][i * 2] * lumFilter[j];
00491 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
00492 }
00493 for (j = 0; j < chrFilterSize; j++) {
00494 U += chrUSrc[j][i] * chrFilter[j];
00495 V += chrVSrc[j][i] * chrFilter[j];
00496 }
00497 Y1 >>= 19;
00498 Y2 >>= 19;
00499 U >>= 19;
00500 V >>= 19;
00501 if ((Y1 | Y2 | U | V) & 0x100) {
00502 Y1 = av_clip_uint8(Y1);
00503 Y2 = av_clip_uint8(Y2);
00504 U = av_clip_uint8(U);
00505 V = av_clip_uint8(V);
00506 }
00507 output_pixels(4*i, Y1, U, Y2, V);
00508 }
00509 }
00510
00511 static av_always_inline void
00512 yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
00513 const int16_t *ubuf[2], const int16_t *vbuf[2],
00514 const int16_t *abuf[2], uint8_t *dest, int dstW,
00515 int yalpha, int uvalpha, int y,
00516 enum PixelFormat target)
00517 {
00518 const int16_t *buf0 = buf[0], *buf1 = buf[1],
00519 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
00520 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
00521 int yalpha1 = 4096 - yalpha;
00522 int uvalpha1 = 4096 - uvalpha;
00523 int i;
00524
00525 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00526 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
00527 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
00528 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
00529 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
00530
00531 if ((Y1 | Y2 | U | V) & 0x100) {
00532 Y1 = av_clip_uint8(Y1);
00533 Y2 = av_clip_uint8(Y2);
00534 U = av_clip_uint8(U);
00535 V = av_clip_uint8(V);
00536 }
00537
00538 output_pixels(i * 4, Y1, U, Y2, V);
00539 }
00540 }
00541
00542 static av_always_inline void
00543 yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
00544 const int16_t *ubuf[2], const int16_t *vbuf[2],
00545 const int16_t *abuf0, uint8_t *dest, int dstW,
00546 int uvalpha, int y, enum PixelFormat target)
00547 {
00548 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
00549 int i;
00550
00551 if (uvalpha < 2048) {
00552 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00553 int Y1 = (buf0[i * 2 ]+64) >> 7;
00554 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
00555 int U = (ubuf0[i] +64) >> 7;
00556 int V = (vbuf0[i] +64) >> 7;
00557
00558 if ((Y1 | Y2 | U | V) & 0x100) {
00559 Y1 = av_clip_uint8(Y1);
00560 Y2 = av_clip_uint8(Y2);
00561 U = av_clip_uint8(U);
00562 V = av_clip_uint8(V);
00563 }
00564
00565 Y1 = av_clip_uint8(Y1);
00566 Y2 = av_clip_uint8(Y2);
00567 U = av_clip_uint8(U);
00568 V = av_clip_uint8(V);
00569
00570 output_pixels(i * 4, Y1, U, Y2, V);
00571 }
00572 } else {
00573 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
00574 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00575 int Y1 = (buf0[i * 2 ] + 64) >> 7;
00576 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
00577 int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
00578 int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
00579
00580 if ((Y1 | Y2 | U | V) & 0x100) {
00581 Y1 = av_clip_uint8(Y1);
00582 Y2 = av_clip_uint8(Y2);
00583 U = av_clip_uint8(U);
00584 V = av_clip_uint8(V);
00585 }
00586
00587 Y1 = av_clip_uint8(Y1);
00588 Y2 = av_clip_uint8(Y2);
00589 U = av_clip_uint8(U);
00590 V = av_clip_uint8(V);
00591
00592 output_pixels(i * 4, Y1, U, Y2, V);
00593 }
00594 }
00595 }
00596
00597 #undef output_pixels
00598
00599 YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, PIX_FMT_YUYV422)
00600 YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, PIX_FMT_UYVY422)
00601
00602 #define R_B ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? R : B)
00603 #define B_R ((target == PIX_FMT_RGB48LE || target == PIX_FMT_RGB48BE) ? B : R)
00604 #define output_pixel(pos, val) \
00605 if (isBE(target)) { \
00606 AV_WB16(pos, val); \
00607 } else { \
00608 AV_WL16(pos, val); \
00609 }
00610
00611 static av_always_inline void
00612 yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter,
00613 const int32_t **lumSrc, int lumFilterSize,
00614 const int16_t *chrFilter, const int32_t **chrUSrc,
00615 const int32_t **chrVSrc, int chrFilterSize,
00616 const int32_t **alpSrc, uint16_t *dest, int dstW,
00617 int y, enum PixelFormat target)
00618 {
00619 int i;
00620
00621 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00622 int j;
00623 int Y1 = -0x40000000;
00624 int Y2 = -0x40000000;
00625 int U = -128 << 23;
00626 int V = -128 << 23;
00627 int R, G, B;
00628
00629 for (j = 0; j < lumFilterSize; j++) {
00630 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
00631 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
00632 }
00633 for (j = 0; j < chrFilterSize; j++) {;
00634 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
00635 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
00636 }
00637
00638
00639 Y1 >>= 14;
00640 Y1 += 0x10000;
00641 Y2 >>= 14;
00642 Y2 += 0x10000;
00643 U >>= 14;
00644 V >>= 14;
00645
00646
00647 Y1 -= c->yuv2rgb_y_offset;
00648 Y2 -= c->yuv2rgb_y_offset;
00649 Y1 *= c->yuv2rgb_y_coeff;
00650 Y2 *= c->yuv2rgb_y_coeff;
00651 Y1 += 1 << 13;
00652 Y2 += 1 << 13;
00653
00654
00655 R = V * c->yuv2rgb_v2r_coeff;
00656 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00657 B = U * c->yuv2rgb_u2b_coeff;
00658
00659
00660 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00661 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00662 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00663 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00664 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00665 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00666 dest += 6;
00667 }
00668 }
00669
00670 static av_always_inline void
00671 yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
00672 const int32_t *ubuf[2], const int32_t *vbuf[2],
00673 const int32_t *abuf[2], uint16_t *dest, int dstW,
00674 int yalpha, int uvalpha, int y,
00675 enum PixelFormat target)
00676 {
00677 const int32_t *buf0 = buf[0], *buf1 = buf[1],
00678 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
00679 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
00680 int yalpha1 = 4096 - yalpha;
00681 int uvalpha1 = 4096 - uvalpha;
00682 int i;
00683
00684 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00685 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
00686 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
00687 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
00688 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
00689 int R, G, B;
00690
00691 Y1 -= c->yuv2rgb_y_offset;
00692 Y2 -= c->yuv2rgb_y_offset;
00693 Y1 *= c->yuv2rgb_y_coeff;
00694 Y2 *= c->yuv2rgb_y_coeff;
00695 Y1 += 1 << 13;
00696 Y2 += 1 << 13;
00697
00698 R = V * c->yuv2rgb_v2r_coeff;
00699 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00700 B = U * c->yuv2rgb_u2b_coeff;
00701
00702 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00703 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00704 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00705 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00706 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00707 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00708 dest += 6;
00709 }
00710 }
00711
00712 static av_always_inline void
00713 yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
00714 const int32_t *ubuf[2], const int32_t *vbuf[2],
00715 const int32_t *abuf0, uint16_t *dest, int dstW,
00716 int uvalpha, int y, enum PixelFormat target)
00717 {
00718 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
00719 int i;
00720
00721 if (uvalpha < 2048) {
00722 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00723 int Y1 = (buf0[i * 2] ) >> 2;
00724 int Y2 = (buf0[i * 2 + 1]) >> 2;
00725 int U = (ubuf0[i] + (-128 << 11)) >> 2;
00726 int V = (vbuf0[i] + (-128 << 11)) >> 2;
00727 int R, G, B;
00728
00729 Y1 -= c->yuv2rgb_y_offset;
00730 Y2 -= c->yuv2rgb_y_offset;
00731 Y1 *= c->yuv2rgb_y_coeff;
00732 Y2 *= c->yuv2rgb_y_coeff;
00733 Y1 += 1 << 13;
00734 Y2 += 1 << 13;
00735
00736 R = V * c->yuv2rgb_v2r_coeff;
00737 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00738 B = U * c->yuv2rgb_u2b_coeff;
00739
00740 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00741 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00742 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00743 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00744 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00745 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00746 dest += 6;
00747 }
00748 } else {
00749 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
00750 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00751 int Y1 = (buf0[i * 2] ) >> 2;
00752 int Y2 = (buf0[i * 2 + 1]) >> 2;
00753 int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
00754 int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3;
00755 int R, G, B;
00756
00757 Y1 -= c->yuv2rgb_y_offset;
00758 Y2 -= c->yuv2rgb_y_offset;
00759 Y1 *= c->yuv2rgb_y_coeff;
00760 Y2 *= c->yuv2rgb_y_coeff;
00761 Y1 += 1 << 13;
00762 Y2 += 1 << 13;
00763
00764 R = V * c->yuv2rgb_v2r_coeff;
00765 G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
00766 B = U * c->yuv2rgb_u2b_coeff;
00767
00768 output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
00769 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
00770 output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
00771 output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
00772 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
00773 output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
00774 dest += 6;
00775 }
00776 }
00777 }
00778
00779 #undef output_pixel
00780 #undef r_b
00781 #undef b_r
00782
00783 #define YUV2PACKED16WRAPPER(name, base, ext, fmt) \
00784 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
00785 const int16_t **_lumSrc, int lumFilterSize, \
00786 const int16_t *chrFilter, const int16_t **_chrUSrc, \
00787 const int16_t **_chrVSrc, int chrFilterSize, \
00788 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
00789 int y) \
00790 { \
00791 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
00792 **chrUSrc = (const int32_t **) _chrUSrc, \
00793 **chrVSrc = (const int32_t **) _chrVSrc, \
00794 **alpSrc = (const int32_t **) _alpSrc; \
00795 uint16_t *dest = (uint16_t *) _dest; \
00796 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
00797 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
00798 alpSrc, dest, dstW, y, fmt); \
00799 } \
00800 \
00801 static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
00802 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
00803 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
00804 int yalpha, int uvalpha, int y) \
00805 { \
00806 const int32_t **buf = (const int32_t **) _buf, \
00807 **ubuf = (const int32_t **) _ubuf, \
00808 **vbuf = (const int32_t **) _vbuf, \
00809 **abuf = (const int32_t **) _abuf; \
00810 uint16_t *dest = (uint16_t *) _dest; \
00811 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
00812 dest, dstW, yalpha, uvalpha, y, fmt); \
00813 } \
00814 \
00815 static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
00816 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
00817 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
00818 int uvalpha, int y) \
00819 { \
00820 const int32_t *buf0 = (const int32_t *) _buf0, \
00821 **ubuf = (const int32_t **) _ubuf, \
00822 **vbuf = (const int32_t **) _vbuf, \
00823 *abuf0 = (const int32_t *) _abuf0; \
00824 uint16_t *dest = (uint16_t *) _dest; \
00825 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
00826 dstW, uvalpha, y, fmt); \
00827 }
00828
00829 YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, PIX_FMT_RGB48BE)
00830 YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, PIX_FMT_RGB48LE)
00831 YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, PIX_FMT_BGR48BE)
00832 YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, PIX_FMT_BGR48LE)
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842 static av_always_inline void
00843 yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
00844 unsigned A1, unsigned A2,
00845 const void *_r, const void *_g, const void *_b, int y,
00846 enum PixelFormat target, int hasAlpha)
00847 {
00848 if (target == PIX_FMT_ARGB || target == PIX_FMT_RGBA ||
00849 target == PIX_FMT_ABGR || target == PIX_FMT_BGRA) {
00850 uint32_t *dest = (uint32_t *) _dest;
00851 const uint32_t *r = (const uint32_t *) _r;
00852 const uint32_t *g = (const uint32_t *) _g;
00853 const uint32_t *b = (const uint32_t *) _b;
00854
00855 #if CONFIG_SMALL
00856 int sh = hasAlpha ? ((target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24) : 0;
00857
00858 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
00859 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
00860 #else
00861 if (hasAlpha) {
00862 int sh = (target == PIX_FMT_RGB32_1 || target == PIX_FMT_BGR32_1) ? 0 : 24;
00863
00864 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
00865 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
00866 } else {
00867 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
00868 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
00869 }
00870 #endif
00871 } else if (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) {
00872 uint8_t *dest = (uint8_t *) _dest;
00873 const uint8_t *r = (const uint8_t *) _r;
00874 const uint8_t *g = (const uint8_t *) _g;
00875 const uint8_t *b = (const uint8_t *) _b;
00876
00877 #define r_b ((target == PIX_FMT_RGB24) ? r : b)
00878 #define b_r ((target == PIX_FMT_RGB24) ? b : r)
00879
00880 dest[i * 6 + 0] = r_b[Y1];
00881 dest[i * 6 + 1] = g[Y1];
00882 dest[i * 6 + 2] = b_r[Y1];
00883 dest[i * 6 + 3] = r_b[Y2];
00884 dest[i * 6 + 4] = g[Y2];
00885 dest[i * 6 + 5] = b_r[Y2];
00886 #undef r_b
00887 #undef b_r
00888 } else if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565 ||
00889 target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555 ||
00890 target == PIX_FMT_RGB444 || target == PIX_FMT_BGR444) {
00891 uint16_t *dest = (uint16_t *) _dest;
00892 const uint16_t *r = (const uint16_t *) _r;
00893 const uint16_t *g = (const uint16_t *) _g;
00894 const uint16_t *b = (const uint16_t *) _b;
00895 int dr1, dg1, db1, dr2, dg2, db2;
00896
00897 if (target == PIX_FMT_RGB565 || target == PIX_FMT_BGR565) {
00898 dr1 = dither_2x2_8[ y & 1 ][0];
00899 dg1 = dither_2x2_4[ y & 1 ][0];
00900 db1 = dither_2x2_8[(y & 1) ^ 1][0];
00901 dr2 = dither_2x2_8[ y & 1 ][1];
00902 dg2 = dither_2x2_4[ y & 1 ][1];
00903 db2 = dither_2x2_8[(y & 1) ^ 1][1];
00904 } else if (target == PIX_FMT_RGB555 || target == PIX_FMT_BGR555) {
00905 dr1 = dither_2x2_8[ y & 1 ][0];
00906 dg1 = dither_2x2_8[ y & 1 ][1];
00907 db1 = dither_2x2_8[(y & 1) ^ 1][0];
00908 dr2 = dither_2x2_8[ y & 1 ][1];
00909 dg2 = dither_2x2_8[ y & 1 ][0];
00910 db2 = dither_2x2_8[(y & 1) ^ 1][1];
00911 } else {
00912 dr1 = dither_4x4_16[ y & 3 ][0];
00913 dg1 = dither_4x4_16[ y & 3 ][1];
00914 db1 = dither_4x4_16[(y & 3) ^ 3][0];
00915 dr2 = dither_4x4_16[ y & 3 ][1];
00916 dg2 = dither_4x4_16[ y & 3 ][0];
00917 db2 = dither_4x4_16[(y & 3) ^ 3][1];
00918 }
00919
00920 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
00921 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
00922 } else {
00923 uint8_t *dest = (uint8_t *) _dest;
00924 const uint8_t *r = (const uint8_t *) _r;
00925 const uint8_t *g = (const uint8_t *) _g;
00926 const uint8_t *b = (const uint8_t *) _b;
00927 int dr1, dg1, db1, dr2, dg2, db2;
00928
00929 if (target == PIX_FMT_RGB8 || target == PIX_FMT_BGR8) {
00930 const uint8_t * const d64 = dither_8x8_73[y & 7];
00931 const uint8_t * const d32 = dither_8x8_32[y & 7];
00932 dr1 = dg1 = d32[(i * 2 + 0) & 7];
00933 db1 = d64[(i * 2 + 0) & 7];
00934 dr2 = dg2 = d32[(i * 2 + 1) & 7];
00935 db2 = d64[(i * 2 + 1) & 7];
00936 } else {
00937 const uint8_t * const d64 = dither_8x8_73 [y & 7];
00938 const uint8_t * const d128 = dither_8x8_220[y & 7];
00939 dr1 = db1 = d128[(i * 2 + 0) & 7];
00940 dg1 = d64[(i * 2 + 0) & 7];
00941 dr2 = db2 = d128[(i * 2 + 1) & 7];
00942 dg2 = d64[(i * 2 + 1) & 7];
00943 }
00944
00945 if (target == PIX_FMT_RGB4 || target == PIX_FMT_BGR4) {
00946 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
00947 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
00948 } else {
00949 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
00950 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
00951 }
00952 }
00953 }
00954
00955 static av_always_inline void
00956 yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter,
00957 const int16_t **lumSrc, int lumFilterSize,
00958 const int16_t *chrFilter, const int16_t **chrUSrc,
00959 const int16_t **chrVSrc, int chrFilterSize,
00960 const int16_t **alpSrc, uint8_t *dest, int dstW,
00961 int y, enum PixelFormat target, int hasAlpha)
00962 {
00963 int i;
00964
00965 for (i = 0; i < ((dstW + 1) >> 1); i++) {
00966 int j, A1, A2;
00967 int Y1 = 1 << 18;
00968 int Y2 = 1 << 18;
00969 int U = 1 << 18;
00970 int V = 1 << 18;
00971 const void *r, *g, *b;
00972
00973 for (j = 0; j < lumFilterSize; j++) {
00974 Y1 += lumSrc[j][i * 2] * lumFilter[j];
00975 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
00976 }
00977 for (j = 0; j < chrFilterSize; j++) {
00978 U += chrUSrc[j][i] * chrFilter[j];
00979 V += chrVSrc[j][i] * chrFilter[j];
00980 }
00981 Y1 >>= 19;
00982 Y2 >>= 19;
00983 U >>= 19;
00984 V >>= 19;
00985 if (hasAlpha) {
00986 A1 = 1 << 18;
00987 A2 = 1 << 18;
00988 for (j = 0; j < lumFilterSize; j++) {
00989 A1 += alpSrc[j][i * 2 ] * lumFilter[j];
00990 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
00991 }
00992 A1 >>= 19;
00993 A2 >>= 19;
00994 if ((A1 | A2) & 0x100) {
00995 A1 = av_clip_uint8(A1);
00996 A2 = av_clip_uint8(A2);
00997 }
00998 }
00999
01000 r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
01001 g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
01002 b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01003
01004 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01005 r, g, b, y, target, hasAlpha);
01006 }
01007 }
01008
01009 static av_always_inline void
01010 yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
01011 const int16_t *ubuf[2], const int16_t *vbuf[2],
01012 const int16_t *abuf[2], uint8_t *dest, int dstW,
01013 int yalpha, int uvalpha, int y,
01014 enum PixelFormat target, int hasAlpha)
01015 {
01016 const int16_t *buf0 = buf[0], *buf1 = buf[1],
01017 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
01018 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
01019 *abuf0 = hasAlpha ? abuf[0] : NULL,
01020 *abuf1 = hasAlpha ? abuf[1] : NULL;
01021 int yalpha1 = 4096 - yalpha;
01022 int uvalpha1 = 4096 - uvalpha;
01023 int i;
01024
01025 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01026 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
01027 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
01028 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
01029 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
01030 int A1, A2;
01031 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01032 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01033 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01034
01035 if (hasAlpha) {
01036 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
01037 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
01038 A1 = av_clip_uint8(A1);
01039 A2 = av_clip_uint8(A2);
01040 }
01041
01042 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01043 r, g, b, y, target, hasAlpha);
01044 }
01045 }
01046
01047 static av_always_inline void
01048 yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
01049 const int16_t *ubuf[2], const int16_t *vbuf[2],
01050 const int16_t *abuf0, uint8_t *dest, int dstW,
01051 int uvalpha, int y, enum PixelFormat target,
01052 int hasAlpha)
01053 {
01054 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
01055 int i;
01056
01057 if (uvalpha < 2048) {
01058 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01059 int Y1 = (buf0[i * 2 ] + 64) >> 7;
01060 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
01061 int U = (ubuf0[i] + 64) >> 7;
01062 int V = (vbuf0[i] + 64) >> 7;
01063 int A1, A2;
01064 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01065 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01066 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01067
01068 if (hasAlpha) {
01069 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
01070 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
01071 A1 = av_clip_uint8(A1);
01072 A2 = av_clip_uint8(A2);
01073 }
01074
01075 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01076 r, g, b, y, target, hasAlpha);
01077 }
01078 } else {
01079 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
01080 for (i = 0; i < ((dstW + 1) >> 1); i++) {
01081 int Y1 = (buf0[i * 2 ] + 64) >> 7;
01082 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
01083 int U = (ubuf0[i] + ubuf1[i] + 128) >> 8;
01084 int V = (vbuf0[i] + vbuf1[i] + 128) >> 8;
01085 int A1, A2;
01086 const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
01087 *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
01088 *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
01089
01090 if (hasAlpha) {
01091 A1 = (abuf0[i * 2 ] + 64) >> 7;
01092 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
01093 A1 = av_clip_uint8(A1);
01094 A2 = av_clip_uint8(A2);
01095 }
01096
01097 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
01098 r, g, b, y, target, hasAlpha);
01099 }
01100 }
01101 }
01102
01103 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
01104 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
01105 const int16_t **lumSrc, int lumFilterSize, \
01106 const int16_t *chrFilter, const int16_t **chrUSrc, \
01107 const int16_t **chrVSrc, int chrFilterSize, \
01108 const int16_t **alpSrc, uint8_t *dest, int dstW, \
01109 int y) \
01110 { \
01111 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
01112 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
01113 alpSrc, dest, dstW, y, fmt, hasAlpha); \
01114 }
01115 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
01116 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
01117 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
01118 const int16_t *ubuf[2], const int16_t *vbuf[2], \
01119 const int16_t *abuf[2], uint8_t *dest, int dstW, \
01120 int yalpha, int uvalpha, int y) \
01121 { \
01122 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
01123 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
01124 } \
01125 \
01126 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
01127 const int16_t *ubuf[2], const int16_t *vbuf[2], \
01128 const int16_t *abuf0, uint8_t *dest, int dstW, \
01129 int uvalpha, int y) \
01130 { \
01131 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
01132 dstW, uvalpha, y, fmt, hasAlpha); \
01133 }
01134
01135 #if CONFIG_SMALL
01136 YUV2RGBWRAPPER(yuv2rgb,, 32_1, PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01137 YUV2RGBWRAPPER(yuv2rgb,, 32, PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01138 #else
01139 #if CONFIG_SWSCALE_ALPHA
01140 YUV2RGBWRAPPER(yuv2rgb,, a32_1, PIX_FMT_RGB32_1, 1)
01141 YUV2RGBWRAPPER(yuv2rgb,, a32, PIX_FMT_RGB32, 1)
01142 #endif
01143 YUV2RGBWRAPPER(yuv2rgb,, x32_1, PIX_FMT_RGB32_1, 0)
01144 YUV2RGBWRAPPER(yuv2rgb,, x32, PIX_FMT_RGB32, 0)
01145 #endif
01146 YUV2RGBWRAPPER(yuv2, rgb, rgb24, PIX_FMT_RGB24, 0)
01147 YUV2RGBWRAPPER(yuv2, rgb, bgr24, PIX_FMT_BGR24, 0)
01148 YUV2RGBWRAPPER(yuv2rgb,, 16, PIX_FMT_RGB565, 0)
01149 YUV2RGBWRAPPER(yuv2rgb,, 15, PIX_FMT_RGB555, 0)
01150 YUV2RGBWRAPPER(yuv2rgb,, 12, PIX_FMT_RGB444, 0)
01151 YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0)
01152 YUV2RGBWRAPPER(yuv2rgb,, 4, PIX_FMT_RGB4, 0)
01153 YUV2RGBWRAPPER(yuv2rgb,, 4b, PIX_FMT_RGB4_BYTE, 0)
01154
01155 static av_always_inline void
01156 yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
01157 const int16_t **lumSrc, int lumFilterSize,
01158 const int16_t *chrFilter, const int16_t **chrUSrc,
01159 const int16_t **chrVSrc, int chrFilterSize,
01160 const int16_t **alpSrc, uint8_t *dest,
01161 int dstW, int y, enum PixelFormat target, int hasAlpha)
01162 {
01163 int i;
01164 int step = (target == PIX_FMT_RGB24 || target == PIX_FMT_BGR24) ? 3 : 4;
01165
01166 for (i = 0; i < dstW; i++) {
01167 int j;
01168 int Y = 1<<9;
01169 int U = (1<<9)-(128 << 19);
01170 int V = (1<<9)-(128 << 19);
01171 int R, G, B, A;
01172
01173 for (j = 0; j < lumFilterSize; j++) {
01174 Y += lumSrc[j][i] * lumFilter[j];
01175 }
01176 for (j = 0; j < chrFilterSize; j++) {
01177 U += chrUSrc[j][i] * chrFilter[j];
01178 V += chrVSrc[j][i] * chrFilter[j];
01179 }
01180 Y >>= 10;
01181 U >>= 10;
01182 V >>= 10;
01183 if (hasAlpha) {
01184 A = 1 << 18;
01185 for (j = 0; j < lumFilterSize; j++) {
01186 A += alpSrc[j][i] * lumFilter[j];
01187 }
01188 A >>= 19;
01189 if (A & 0x100)
01190 A = av_clip_uint8(A);
01191 }
01192 Y -= c->yuv2rgb_y_offset;
01193 Y *= c->yuv2rgb_y_coeff;
01194 Y += 1 << 21;
01195 R = Y + V*c->yuv2rgb_v2r_coeff;
01196 G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
01197 B = Y + U*c->yuv2rgb_u2b_coeff;
01198 if ((R | G | B) & 0xC0000000) {
01199 R = av_clip_uintp2(R, 30);
01200 G = av_clip_uintp2(G, 30);
01201 B = av_clip_uintp2(B, 30);
01202 }
01203
01204 switch(target) {
01205 case PIX_FMT_ARGB:
01206 dest[0] = hasAlpha ? A : 255;
01207 dest[1] = R >> 22;
01208 dest[2] = G >> 22;
01209 dest[3] = B >> 22;
01210 break;
01211 case PIX_FMT_RGB24:
01212 dest[0] = R >> 22;
01213 dest[1] = G >> 22;
01214 dest[2] = B >> 22;
01215 break;
01216 case PIX_FMT_RGBA:
01217 dest[0] = R >> 22;
01218 dest[1] = G >> 22;
01219 dest[2] = B >> 22;
01220 dest[3] = hasAlpha ? A : 255;
01221 break;
01222 case PIX_FMT_ABGR:
01223 dest[0] = hasAlpha ? A : 255;
01224 dest[1] = B >> 22;
01225 dest[2] = G >> 22;
01226 dest[3] = R >> 22;
01227 break;
01228 case PIX_FMT_BGR24:
01229 dest[0] = B >> 22;
01230 dest[1] = G >> 22;
01231 dest[2] = R >> 22;
01232 break;
01233 case PIX_FMT_BGRA:
01234 dest[0] = B >> 22;
01235 dest[1] = G >> 22;
01236 dest[2] = R >> 22;
01237 dest[3] = hasAlpha ? A : 255;
01238 break;
01239 }
01240 dest += step;
01241 }
01242 }
01243
01244 #if CONFIG_SMALL
01245 YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01246 YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01247 YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01248 YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
01249 #else
01250 #if CONFIG_SWSCALE_ALPHA
01251 YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, PIX_FMT_BGRA, 1)
01252 YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, PIX_FMT_ABGR, 1)
01253 YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, PIX_FMT_RGBA, 1)
01254 YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, PIX_FMT_ARGB, 1)
01255 #endif
01256 YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, PIX_FMT_BGRA, 0)
01257 YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, PIX_FMT_ABGR, 0)
01258 YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, PIX_FMT_RGBA, 0)
01259 YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, PIX_FMT_ARGB, 0)
01260 #endif
01261 YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, PIX_FMT_BGR24, 0)
01262 YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, PIX_FMT_RGB24, 0)
01263
01264 av_cold void ff_sws_init_output_funcs(SwsContext *c,
01265 yuv2planar1_fn *yuv2plane1,
01266 yuv2planarX_fn *yuv2planeX,
01267 yuv2interleavedX_fn *yuv2nv12cX,
01268 yuv2packed1_fn *yuv2packed1,
01269 yuv2packed2_fn *yuv2packed2,
01270 yuv2packedX_fn *yuv2packedX)
01271 {
01272 enum PixelFormat dstFormat = c->dstFormat;
01273
01274 if (is16BPS(dstFormat)) {
01275 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
01276 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
01277 } else if (is9_OR_10BPS(dstFormat)) {
01278 if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) {
01279 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
01280 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
01281 } else {
01282 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
01283 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
01284 }
01285 } else {
01286 *yuv2plane1 = yuv2plane1_8_c;
01287 *yuv2planeX = yuv2planeX_8_c;
01288 if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21)
01289 *yuv2nv12cX = yuv2nv12cX_c;
01290 }
01291
01292 if(c->flags & SWS_FULL_CHR_H_INT) {
01293 switch (dstFormat) {
01294 case PIX_FMT_RGBA:
01295 #if CONFIG_SMALL
01296 *yuv2packedX = yuv2rgba32_full_X_c;
01297 #else
01298 #if CONFIG_SWSCALE_ALPHA
01299 if (c->alpPixBuf) {
01300 *yuv2packedX = yuv2rgba32_full_X_c;
01301 } else
01302 #endif
01303 {
01304 *yuv2packedX = yuv2rgbx32_full_X_c;
01305 }
01306 #endif
01307 break;
01308 case PIX_FMT_ARGB:
01309 #if CONFIG_SMALL
01310 *yuv2packedX = yuv2argb32_full_X_c;
01311 #else
01312 #if CONFIG_SWSCALE_ALPHA
01313 if (c->alpPixBuf) {
01314 *yuv2packedX = yuv2argb32_full_X_c;
01315 } else
01316 #endif
01317 {
01318 *yuv2packedX = yuv2xrgb32_full_X_c;
01319 }
01320 #endif
01321 break;
01322 case PIX_FMT_BGRA:
01323 #if CONFIG_SMALL
01324 *yuv2packedX = yuv2bgra32_full_X_c;
01325 #else
01326 #if CONFIG_SWSCALE_ALPHA
01327 if (c->alpPixBuf) {
01328 *yuv2packedX = yuv2bgra32_full_X_c;
01329 } else
01330 #endif
01331 {
01332 *yuv2packedX = yuv2bgrx32_full_X_c;
01333 }
01334 #endif
01335 break;
01336 case PIX_FMT_ABGR:
01337 #if CONFIG_SMALL
01338 *yuv2packedX = yuv2abgr32_full_X_c;
01339 #else
01340 #if CONFIG_SWSCALE_ALPHA
01341 if (c->alpPixBuf) {
01342 *yuv2packedX = yuv2abgr32_full_X_c;
01343 } else
01344 #endif
01345 {
01346 *yuv2packedX = yuv2xbgr32_full_X_c;
01347 }
01348 #endif
01349 break;
01350 case PIX_FMT_RGB24:
01351 *yuv2packedX = yuv2rgb24_full_X_c;
01352 break;
01353 case PIX_FMT_BGR24:
01354 *yuv2packedX = yuv2bgr24_full_X_c;
01355 break;
01356 }
01357 if(!*yuv2packedX)
01358 goto YUV_PACKED;
01359 } else {
01360 YUV_PACKED:
01361 switch (dstFormat) {
01362 case PIX_FMT_RGB48LE:
01363 *yuv2packed1 = yuv2rgb48le_1_c;
01364 *yuv2packed2 = yuv2rgb48le_2_c;
01365 *yuv2packedX = yuv2rgb48le_X_c;
01366 break;
01367 case PIX_FMT_RGB48BE:
01368 *yuv2packed1 = yuv2rgb48be_1_c;
01369 *yuv2packed2 = yuv2rgb48be_2_c;
01370 *yuv2packedX = yuv2rgb48be_X_c;
01371 break;
01372 case PIX_FMT_BGR48LE:
01373 *yuv2packed1 = yuv2bgr48le_1_c;
01374 *yuv2packed2 = yuv2bgr48le_2_c;
01375 *yuv2packedX = yuv2bgr48le_X_c;
01376 break;
01377 case PIX_FMT_BGR48BE:
01378 *yuv2packed1 = yuv2bgr48be_1_c;
01379 *yuv2packed2 = yuv2bgr48be_2_c;
01380 *yuv2packedX = yuv2bgr48be_X_c;
01381 break;
01382 case PIX_FMT_RGB32:
01383 case PIX_FMT_BGR32:
01384 #if CONFIG_SMALL
01385 *yuv2packed1 = yuv2rgb32_1_c;
01386 *yuv2packed2 = yuv2rgb32_2_c;
01387 *yuv2packedX = yuv2rgb32_X_c;
01388 #else
01389 #if CONFIG_SWSCALE_ALPHA
01390 if (c->alpPixBuf) {
01391 *yuv2packed1 = yuv2rgba32_1_c;
01392 *yuv2packed2 = yuv2rgba32_2_c;
01393 *yuv2packedX = yuv2rgba32_X_c;
01394 } else
01395 #endif
01396 {
01397 *yuv2packed1 = yuv2rgbx32_1_c;
01398 *yuv2packed2 = yuv2rgbx32_2_c;
01399 *yuv2packedX = yuv2rgbx32_X_c;
01400 }
01401 #endif
01402 break;
01403 case PIX_FMT_RGB32_1:
01404 case PIX_FMT_BGR32_1:
01405 #if CONFIG_SMALL
01406 *yuv2packed1 = yuv2rgb32_1_1_c;
01407 *yuv2packed2 = yuv2rgb32_1_2_c;
01408 *yuv2packedX = yuv2rgb32_1_X_c;
01409 #else
01410 #if CONFIG_SWSCALE_ALPHA
01411 if (c->alpPixBuf) {
01412 *yuv2packed1 = yuv2rgba32_1_1_c;
01413 *yuv2packed2 = yuv2rgba32_1_2_c;
01414 *yuv2packedX = yuv2rgba32_1_X_c;
01415 } else
01416 #endif
01417 {
01418 *yuv2packed1 = yuv2rgbx32_1_1_c;
01419 *yuv2packed2 = yuv2rgbx32_1_2_c;
01420 *yuv2packedX = yuv2rgbx32_1_X_c;
01421 }
01422 #endif
01423 break;
01424 case PIX_FMT_RGB24:
01425 *yuv2packed1 = yuv2rgb24_1_c;
01426 *yuv2packed2 = yuv2rgb24_2_c;
01427 *yuv2packedX = yuv2rgb24_X_c;
01428 break;
01429 case PIX_FMT_BGR24:
01430 *yuv2packed1 = yuv2bgr24_1_c;
01431 *yuv2packed2 = yuv2bgr24_2_c;
01432 *yuv2packedX = yuv2bgr24_X_c;
01433 break;
01434 case PIX_FMT_RGB565LE:
01435 case PIX_FMT_RGB565BE:
01436 case PIX_FMT_BGR565LE:
01437 case PIX_FMT_BGR565BE:
01438 *yuv2packed1 = yuv2rgb16_1_c;
01439 *yuv2packed2 = yuv2rgb16_2_c;
01440 *yuv2packedX = yuv2rgb16_X_c;
01441 break;
01442 case PIX_FMT_RGB555LE:
01443 case PIX_FMT_RGB555BE:
01444 case PIX_FMT_BGR555LE:
01445 case PIX_FMT_BGR555BE:
01446 *yuv2packed1 = yuv2rgb15_1_c;
01447 *yuv2packed2 = yuv2rgb15_2_c;
01448 *yuv2packedX = yuv2rgb15_X_c;
01449 break;
01450 case PIX_FMT_RGB444LE:
01451 case PIX_FMT_RGB444BE:
01452 case PIX_FMT_BGR444LE:
01453 case PIX_FMT_BGR444BE:
01454 *yuv2packed1 = yuv2rgb12_1_c;
01455 *yuv2packed2 = yuv2rgb12_2_c;
01456 *yuv2packedX = yuv2rgb12_X_c;
01457 break;
01458 case PIX_FMT_RGB8:
01459 case PIX_FMT_BGR8:
01460 *yuv2packed1 = yuv2rgb8_1_c;
01461 *yuv2packed2 = yuv2rgb8_2_c;
01462 *yuv2packedX = yuv2rgb8_X_c;
01463 break;
01464 case PIX_FMT_RGB4:
01465 case PIX_FMT_BGR4:
01466 *yuv2packed1 = yuv2rgb4_1_c;
01467 *yuv2packed2 = yuv2rgb4_2_c;
01468 *yuv2packedX = yuv2rgb4_X_c;
01469 break;
01470 case PIX_FMT_RGB4_BYTE:
01471 case PIX_FMT_BGR4_BYTE:
01472 *yuv2packed1 = yuv2rgb4b_1_c;
01473 *yuv2packed2 = yuv2rgb4b_2_c;
01474 *yuv2packedX = yuv2rgb4b_X_c;
01475 break;
01476 }
01477 }
01478 switch (dstFormat) {
01479 case PIX_FMT_MONOWHITE:
01480 *yuv2packed1 = yuv2monowhite_1_c;
01481 *yuv2packed2 = yuv2monowhite_2_c;
01482 *yuv2packedX = yuv2monowhite_X_c;
01483 break;
01484 case PIX_FMT_MONOBLACK:
01485 *yuv2packed1 = yuv2monoblack_1_c;
01486 *yuv2packed2 = yuv2monoblack_2_c;
01487 *yuv2packedX = yuv2monoblack_X_c;
01488 break;
01489 case PIX_FMT_YUYV422:
01490 *yuv2packed1 = yuv2yuyv422_1_c;
01491 *yuv2packed2 = yuv2yuyv422_2_c;
01492 *yuv2packedX = yuv2yuyv422_X_c;
01493 break;
01494 case PIX_FMT_UYVY422:
01495 *yuv2packed1 = yuv2uyvy422_1_c;
01496 *yuv2packed2 = yuv2uyvy422_2_c;
01497 *yuv2packedX = yuv2uyvy422_X_c;
01498 break;
01499 }
01500 }