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