40 { 1, 3, 1, 3, 1, 3, 1, 3, },
41 { 2, 0, 2, 0, 2, 0, 2, 0, },
42 { 1, 3, 1, 3, 1, 3, 1, 3, },
46 { 6, 2, 6, 2, 6, 2, 6, 2, },
47 { 0, 4, 0, 4, 0, 4, 0, 4, },
48 { 6, 2, 6, 2, 6, 2, 6, 2, },
52 { 8, 4, 11, 7, 8, 4, 11, 7, },
53 { 2, 14, 1, 13, 2, 14, 1, 13, },
54 { 10, 6, 9, 5, 10, 6, 9, 5, },
55 { 0, 12, 3, 15, 0, 12, 3, 15, },
56 { 8, 4, 11, 7, 8, 4, 11, 7, },
60 { 17, 9, 23, 15, 16, 8, 22, 14, },
61 { 5, 29, 3, 27, 4, 28, 2, 26, },
62 { 21, 13, 19, 11, 20, 12, 18, 10, },
63 { 0, 24, 6, 30, 1, 25, 7, 31, },
64 { 16, 8, 22, 14, 17, 9, 23, 15, },
65 { 4, 28, 2, 26, 5, 29, 3, 27, },
66 { 20, 12, 18, 10, 21, 13, 19, 11, },
67 { 1, 25, 7, 31, 0, 24, 6, 30, },
68 { 17, 9, 23, 15, 16, 8, 22, 14, },
72 { 0, 55, 14, 68, 3, 58, 17, 72, },
73 { 37, 18, 50, 32, 40, 22, 54, 35, },
74 { 9, 64, 5, 59, 13, 67, 8, 63, },
75 { 46, 27, 41, 23, 49, 31, 44, 26, },
76 { 2, 57, 16, 71, 1, 56, 15, 70, },
77 { 39, 21, 52, 34, 38, 19, 51, 33, },
78 { 11, 66, 7, 62, 10, 65, 6, 60, },
79 { 48, 30, 43, 25, 47, 29, 42, 24, },
80 { 0, 55, 14, 68, 3, 58, 17, 72, },
85 {117, 62, 158, 103, 113, 58, 155, 100, },
86 { 34, 199, 21, 186, 31, 196, 17, 182, },
87 {144, 89, 131, 76, 141, 86, 127, 72, },
88 { 0, 165, 41, 206, 10, 175, 52, 217, },
89 {110, 55, 151, 96, 120, 65, 162, 107, },
90 { 28, 193, 14, 179, 38, 203, 24, 189, },
91 {138, 83, 124, 69, 148, 93, 134, 79, },
92 { 7, 172, 48, 213, 3, 168, 45, 210, },
93 {117, 62, 158, 103, 113, 58, 155, 100, },
98 { 0, 143, 18, 200, 2, 156, 25, 215, },
99 { 78, 28, 125, 64, 89, 36, 138, 74, },
100 { 10, 180, 3, 161, 16, 195, 8, 175, },
101 {109, 51, 93, 38, 121, 60, 105, 47, },
102 { 1, 152, 23, 210, 0, 147, 20, 205, },
103 { 85, 33, 134, 71, 81, 30, 130, 67, },
104 { 14, 190, 6, 171, 12, 185, 5, 166, },
105 {117, 57, 101, 44, 113, 54, 97, 41, },
106 { 0, 143, 18, 200, 2, 156, 25, 215, },
111 { 0, 124, 8, 193, 0, 140, 12, 213, },
112 { 55, 14, 104, 42, 66, 19, 119, 52, },
113 { 3, 168, 1, 145, 6, 187, 3, 162, },
114 { 86, 31, 70, 21, 99, 39, 82, 28, },
115 { 0, 134, 11, 206, 0, 129, 9, 200, },
116 { 62, 17, 114, 48, 58, 16, 109, 45, },
117 { 5, 181, 2, 157, 4, 175, 1, 151, },
118 { 95, 36, 78, 26, 90, 34, 74, 24, },
119 { 0, 124, 8, 193, 0, 140, 12, 213, },
124 { 0, 107, 3, 187, 0, 125, 6, 212, },
125 { 39, 7, 86, 28, 49, 11, 102, 36, },
126 { 1, 158, 0, 131, 3, 180, 1, 151, },
127 { 68, 19, 52, 12, 81, 25, 64, 17, },
128 { 0, 119, 5, 203, 0, 113, 4, 195, },
129 { 45, 9, 96, 33, 42, 8, 91, 30, },
130 { 2, 172, 1, 144, 2, 165, 0, 137, },
131 { 77, 23, 60, 15, 72, 21, 56, 14, },
132 { 0, 107, 3, 187, 0, 125, 6, 212, },
139 #define IS_BE(ENDIAN_IDENTIFIER) IS_BE_ ## ENDIAN_IDENTIFIER
141 #define output_pixel(pos, val, bias, signedness) \
143 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
145 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
150 int big_endian,
int output_bits)
156 for (
i = 0;
i < dstW;
i++) {
164 const int32_t **
src, uint16_t *dest,
int dstW,
165 int big_endian,
int output_bits)
171 for (
i = 0;
i < dstW;
i++) {
181 for (j = 0; j < filterSize; j++)
190 const int16_t *chrFilter,
int chrFilterSize,
191 const int16_t **chrUSrc,
const int16_t **chrVSrc,
192 uint8_t *dest8,
int chrDstW,
int output_bits)
194 uint16_t *dest = (uint16_t*)dest8;
201 for (
i = 0;
i < chrDstW;
i++) {
203 int v = 1 << (
shift - 1);
208 for (j = 0; j < chrFilterSize; j++) {
209 u += uSrc[j][
i] * (unsigned)chrFilter[j];
210 v += vSrc[j][
i] * (unsigned)chrFilter[j];
221 static const int big_endian = HAVE_BIGENDIAN;
222 static const int shift = 3;
223 static const float float_mult = 1.0f / 65535.0f;
227 for (
i = 0;
i < dstW; ++
i){
230 dest[
i] = float_mult * (
float)val_uint;
237 static const int big_endian = HAVE_BIGENDIAN;
238 static const int shift = 3;
239 static const float float_mult = 1.0f / 65535.0f;
243 for (
i = 0;
i < dstW; ++
i){
252 float *dest,
int dstW)
254 static const int big_endian = HAVE_BIGENDIAN;
255 static const int shift = 15;
256 static const float float_mult = 1.0f / 65535.0f;
260 for (
i = 0;
i < dstW; ++
i){
261 val = (1 << (
shift - 1)) - 0x40000000;
262 for (j = 0; j < filterSize; ++j){
266 dest[
i] = float_mult * (
float)val_uint;
272 uint32_t *dest,
int dstW)
274 static const int big_endian = HAVE_BIGENDIAN;
275 static const int shift = 15;
276 static const float float_mult = 1.0f / 65535.0f;
280 for (
i = 0;
i < dstW; ++
i){
281 val = (1 << (
shift - 1)) - 0x40000000;
282 for (j = 0; j < filterSize; ++j){
290 #define yuv2plane1_float(template, dest_type, BE_LE) \
291 static void yuv2plane1_float ## BE_LE ## _c(const int16_t *src, uint8_t *dest, int dstW, \
292 const uint8_t *dither, int offset) \
294 template((const int32_t *)src, (dest_type *)dest, dstW); \
297 #define yuv2planeX_float(template, dest_type, BE_LE) \
298 static void yuv2planeX_float ## BE_LE ## _c(const int16_t *filter, int filterSize, \
299 const int16_t **src, uint8_t *dest, int dstW, \
300 const uint8_t *dither, int offset) \
302 template(filter, filterSize, (const int32_t **)src, (dest_type *)dest, dstW); \
319 #define output_pixel(pos, val) \
321 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
323 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
327 yuv2plane1_10_c_template(
const int16_t *
src, uint16_t *dest,
int dstW,
328 int big_endian,
int output_bits)
331 int shift = 15 - output_bits;
333 for (
i = 0;
i < dstW;
i++) {
341 const int16_t **
src, uint16_t *dest,
int dstW,
342 int big_endian,
int output_bits)
345 int shift = 11 + 16 - output_bits;
347 for (
i = 0;
i < dstW;
i++) {
351 for (j = 0; j < filterSize; j++)
360 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
361 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
362 uint8_t *dest, int dstW, \
363 const uint8_t *dither, int offset)\
365 yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
366 (uint16_t *) dest, dstW, is_be, bits); \
368 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
369 const int16_t **src, uint8_t *dest, int dstW, \
370 const uint8_t *dither, int offset)\
372 yuv2planeX_## template_size ## _c_template(filter, \
373 filterSize, (const typeX_t **) src, \
374 (uint16_t *) dest, dstW, is_be, bits); \
389 static void yuv2nv12cX_16LE_c(
enum AVPixelFormat dstFormat,
const uint8_t *chrDither,
390 const int16_t *chrFilter,
int chrFilterSize,
391 const int16_t **chrUSrc,
const int16_t **chrVSrc,
392 uint8_t *dest8,
int chrDstW)
398 const int16_t *chrFilter,
int chrFilterSize,
399 const int16_t **chrUSrc,
const int16_t **chrVSrc,
400 uint8_t *dest8,
int chrDstW)
406 const int16_t **
src, uint8_t *dest,
int dstW,
410 for (
i=0;
i<dstW;
i++) {
413 for (j=0; j<filterSize; j++)
424 for (
i=0;
i<dstW;
i++) {
431 const int16_t *chrFilter,
int chrFilterSize,
432 const int16_t **chrUSrc,
const int16_t **chrVSrc,
433 uint8_t *dest,
int chrDstW)
438 for (
i=0;
i<chrDstW;
i++) {
439 int u = chrDither[
i & 7] << 12;
440 int v = chrDither[(
i + 3) & 7] << 12;
442 for (j=0; j<chrFilterSize; j++) {
443 u += chrUSrc[j][
i] * chrFilter[j];
444 v += chrVSrc[j][
i] * chrFilter[j];
451 for (
i=0;
i<chrDstW;
i++) {
452 int u = chrDither[
i & 7] << 12;
453 int v = chrDither[(
i + 3) & 7] << 12;
455 for (j=0; j<chrFilterSize; j++) {
456 u += chrUSrc[j][
i] * chrFilter[j];
457 v += chrVSrc[j][
i] * chrFilter[j];
466 #define output_pixel(pos, val) \
468 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
470 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \
474 uint16_t *dest,
int dstW,
475 int big_endian,
int output_bits)
478 int shift = 15 - output_bits;
479 int output_shift = 16 - output_bits;
481 for (
i = 0;
i < dstW;
i++) {
488 const int16_t **
src, uint16_t *dest,
int dstW,
489 int big_endian,
int output_bits)
492 int shift = 11 + 16 - output_bits;
493 int output_shift = 16 - output_bits;
495 for (
i = 0;
i < dstW;
i++) {
498 for (j = 0; j < filterSize; j++)
506 const int16_t *chrFilter,
int chrFilterSize,
507 const int16_t **chrUSrc,
const int16_t **chrVSrc,
508 uint8_t *dest8,
int chrDstW,
int output_bits)
510 uint16_t *dest = (uint16_t*)dest8;
512 int shift = 11 + 16 - output_bits;
513 int output_shift = 16 - output_bits;
515 for (
i = 0;
i < chrDstW;
i++) {
517 int v = 1 << (
shift - 1);
519 for (j = 0; j < chrFilterSize; j++) {
520 u += chrUSrc[j][
i] * chrFilter[j];
521 v += chrVSrc[j][
i] * chrFilter[j];
531 #define yuv2p01x_wrapper(bits) \
532 static void yuv2p0 ## bits ## l1_LE_c(const int16_t *src, \
533 uint8_t *dest, int dstW, \
534 const uint8_t *dither, int offset) \
536 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits); \
539 static void yuv2p0 ## bits ## l1_BE_c(const int16_t *src, \
540 uint8_t *dest, int dstW, \
541 const uint8_t *dither, int offset) \
543 yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits); \
546 static void yuv2p0 ## bits ## lX_LE_c(const int16_t *filter, \
547 int filterSize, const int16_t **src, \
548 uint8_t *dest, int dstW, \
549 const uint8_t *dither, int offset) \
551 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, bits); \
554 static void yuv2p0 ## bits ## lX_BE_c(const int16_t *filter, \
555 int filterSize, const int16_t **src, \
556 uint8_t *dest, int dstW, \
557 const uint8_t *dither, int offset) \
559 yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, bits); \
562 static void yuv2p0 ## bits ## cX_LE_c(enum AVPixelFormat dstFormat, \
563 const uint8_t *chrDither, \
564 const int16_t *chrFilter, \
566 const int16_t **chrUSrc, \
567 const int16_t **chrVSrc, \
568 uint8_t *dest8, int chrDstW) \
570 yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
571 dest8, chrDstW, bits); \
574 static void yuv2p0 ## bits ## cX_BE_c(enum AVPixelFormat dstFormat, \
575 const uint8_t *chrDither, \
576 const int16_t *chrFilter, \
578 const int16_t **chrUSrc, \
579 const int16_t **chrVSrc, \
580 uint8_t *dest8, int chrDstW) \
582 yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
583 dest8, chrDstW, bits); \
589 #define accumulate_bit(acc, val) \
592 #define output_pixel(pos, acc) \
593 if (target == AV_PIX_FMT_MONOBLACK) { \
600 yuv2mono_X_c_template(
SwsContext *
c,
const int16_t *lumFilter,
601 const int16_t **lumSrc,
int lumFilterSize,
602 const int16_t *chrFilter,
const int16_t **chrUSrc,
603 const int16_t **chrVSrc,
int chrFilterSize,
604 const int16_t **alpSrc, uint8_t *dest,
int dstW,
612 for (
i = 0;
i < dstW;
i += 2) {
617 for (j = 0; j < lumFilterSize; j++) {
618 Y1 += lumSrc[j][
i] * lumFilter[j];
619 Y2 += lumSrc[j][
i+1] * lumFilter[j];
623 if ((Y1 | Y2) & 0x100) {
628 Y1 += (7*err + 1*
c->dither_error[0][
i] + 5*
c->dither_error[0][
i+1] + 3*
c->dither_error[0][
i+2] + 8 - 256)>>4;
629 c->dither_error[0][
i] = err;
630 acc = 2*acc + (Y1 >= 128);
633 err = Y2 + ((7*Y1 + 1*
c->dither_error[0][
i+1] + 5*
c->dither_error[0][
i+2] + 3*
c->dither_error[0][
i+3] + 8 - 256)>>4);
634 c->dither_error[0][
i+1] = Y1;
635 acc = 2*acc + (err >= 128);
645 c->dither_error[0][
i] = err;
654 const int16_t *ubuf[2],
const int16_t *vbuf[2],
655 const int16_t *abuf[2], uint8_t *dest,
int dstW,
656 int yalpha,
int uvalpha,
int y,
659 const int16_t *buf0 = buf[0], *buf1 = buf[1];
661 int yalpha1 = 4096 - yalpha;
668 for (
i = 0;
i < dstW;
i +=2) {
671 Y = (buf0[
i + 0] * yalpha1 + buf1[
i + 0] * yalpha) >> 19;
672 Y += (7*err + 1*
c->dither_error[0][
i] + 5*
c->dither_error[0][
i+1] + 3*
c->dither_error[0][
i+2] + 8 - 256)>>4;
673 c->dither_error[0][
i] = err;
674 acc = 2*acc + (
Y >= 128);
677 err = (buf0[
i + 1] * yalpha1 + buf1[
i + 1] * yalpha) >> 19;
678 err += (7*
Y + 1*
c->dither_error[0][
i+1] + 5*
c->dither_error[0][
i+2] + 3*
c->dither_error[0][
i+3] + 8 - 256)>>4;
679 c->dither_error[0][
i+1] =
Y;
680 acc = 2*acc + (err >= 128);
686 c->dither_error[0][
i] = err;
688 for (
i = 0;
i < dstW;
i += 8) {
692 Y = (buf0[
i + 0] * yalpha1 + buf1[
i + 0] * yalpha) >> 19;
694 Y = (buf0[
i + 1] * yalpha1 + buf1[
i + 1] * yalpha) >> 19;
696 Y = (buf0[
i + 2] * yalpha1 + buf1[
i + 2] * yalpha) >> 19;
698 Y = (buf0[
i + 3] * yalpha1 + buf1[
i + 3] * yalpha) >> 19;
700 Y = (buf0[
i + 4] * yalpha1 + buf1[
i + 4] * yalpha) >> 19;
702 Y = (buf0[
i + 5] * yalpha1 + buf1[
i + 5] * yalpha) >> 19;
704 Y = (buf0[
i + 6] * yalpha1 + buf1[
i + 6] * yalpha) >> 19;
706 Y = (buf0[
i + 7] * yalpha1 + buf1[
i + 7] * yalpha) >> 19;
716 const int16_t *ubuf[2],
const int16_t *vbuf[2],
717 const int16_t *abuf0, uint8_t *dest,
int dstW,
726 for (
i = 0;
i < dstW;
i +=2) {
729 Y = ((buf0[
i + 0] + 64) >> 7);
730 Y += (7*err + 1*
c->dither_error[0][
i] + 5*
c->dither_error[0][
i+1] + 3*
c->dither_error[0][
i+2] + 8 - 256)>>4;
731 c->dither_error[0][
i] = err;
732 acc = 2*acc + (
Y >= 128);
735 err = ((buf0[
i + 1] + 64) >> 7);
736 err += (7*
Y + 1*
c->dither_error[0][
i+1] + 5*
c->dither_error[0][
i+2] + 3*
c->dither_error[0][
i+3] + 8 - 256)>>4;
737 c->dither_error[0][
i+1] =
Y;
738 acc = 2*acc + (err >= 128);
744 c->dither_error[0][
i] = err;
746 for (
i = 0;
i < dstW;
i += 8) {
763 #undef accumulate_bit
765 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
766 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
767 const int16_t **lumSrc, int lumFilterSize, \
768 const int16_t *chrFilter, const int16_t **chrUSrc, \
769 const int16_t **chrVSrc, int chrFilterSize, \
770 const int16_t **alpSrc, uint8_t *dest, int dstW, \
773 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
774 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
775 alpSrc, dest, dstW, y, fmt); \
778 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
779 const int16_t *ubuf[2], const int16_t *vbuf[2], \
780 const int16_t *abuf[2], uint8_t *dest, int dstW, \
781 int yalpha, int uvalpha, int y) \
783 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
784 dest, dstW, yalpha, uvalpha, y, fmt); \
787 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
788 const int16_t *ubuf[2], const int16_t *vbuf[2], \
789 const int16_t *abuf0, uint8_t *dest, int dstW, \
790 int uvalpha, int y) \
792 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
793 abuf0, dest, dstW, uvalpha, \
800 #define output_pixels(pos, Y1, U, Y2, V) \
801 if (target == AV_PIX_FMT_YUYV422) { \
802 dest[pos + 0] = Y1; \
804 dest[pos + 2] = Y2; \
806 } else if (target == AV_PIX_FMT_YVYU422) { \
807 dest[pos + 0] = Y1; \
809 dest[pos + 2] = Y2; \
813 dest[pos + 1] = Y1; \
815 dest[pos + 3] = Y2; \
820 const int16_t **lumSrc,
int lumFilterSize,
821 const int16_t *chrFilter,
const int16_t **chrUSrc,
822 const int16_t **chrVSrc,
int chrFilterSize,
823 const int16_t **alpSrc, uint8_t *dest,
int dstW,
828 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
835 for (j = 0; j < lumFilterSize; j++) {
836 Y1 += lumSrc[j][
i * 2] * lumFilter[j];
837 Y2 += lumSrc[j][
i * 2 + 1] * lumFilter[j];
839 for (j = 0; j < chrFilterSize; j++) {
840 U += chrUSrc[j][
i] * chrFilter[j];
841 V += chrVSrc[j][
i] * chrFilter[j];
847 if ((Y1 | Y2 |
U |
V) & 0x100) {
859 const int16_t *ubuf[2],
const int16_t *vbuf[2],
860 const int16_t *abuf[2], uint8_t *dest,
int dstW,
861 int yalpha,
int uvalpha,
int y,
864 const int16_t *buf0 = buf[0], *buf1 = buf[1],
865 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
866 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
867 int yalpha1 = 4096 - yalpha;
868 int uvalpha1 = 4096 - uvalpha;
873 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
874 int Y1 = (buf0[
i * 2] * yalpha1 + buf1[
i * 2] * yalpha) >> 19;
875 int Y2 = (buf0[
i * 2 + 1] * yalpha1 + buf1[
i * 2 + 1] * yalpha) >> 19;
876 int U = (ubuf0[
i] * uvalpha1 + ubuf1[
i] * uvalpha) >> 19;
877 int V = (vbuf0[
i] * uvalpha1 + vbuf1[
i] * uvalpha) >> 19;
879 if ((Y1 | Y2 |
U |
V) & 0x100) {
892 const int16_t *ubuf[2],
const int16_t *vbuf[2],
893 const int16_t *abuf0, uint8_t *dest,
int dstW,
896 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
899 if (uvalpha < 2048) {
900 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
901 int Y1 = (buf0[
i * 2 ]+64) >> 7;
902 int Y2 = (buf0[
i * 2 + 1]+64) >> 7;
903 int U = (ubuf0[
i] +64) >> 7;
904 int V = (vbuf0[
i] +64) >> 7;
906 if ((Y1 | Y2 |
U |
V) & 0x100) {
916 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
917 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
918 int Y1 = (buf0[
i * 2 ] + 64) >> 7;
919 int Y2 = (buf0[
i * 2 + 1] + 64) >> 7;
920 int U = (ubuf0[
i] + ubuf1[
i]+128) >> 8;
921 int V = (vbuf0[
i] + vbuf1[
i]+128) >> 8;
923 if ((Y1 | Y2 |
U |
V) & 0x100) {
941 #define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? R : B)
942 #define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? B : R)
943 #define output_pixel(pos, val) \
952 const int32_t **lumSrc,
int lumFilterSize,
953 const int16_t *chrFilter,
const int32_t **unused_chrUSrc,
954 const int32_t **unused_chrVSrc,
int unused_chrFilterSize,
955 const int32_t **alpSrc, uint16_t *dest,
int dstW,
957 int unused_hasAlpha,
int unused_eightbytes,
int is_be)
959 int hasAlpha = !!alpSrc;
962 for (
i = 0;
i < dstW;
i++) {
967 for (j = 0; j < lumFilterSize; j++)
968 Y += lumSrc[j][
i] * lumFilter[j];
971 Y += (1<<3) + 0x8000;
975 A = -0x40000000 + (1<<14);
976 for (j = 0; j < lumFilterSize; j++)
977 A += alpSrc[j][
i] * lumFilter[j];
992 const int32_t *abuf[2], uint16_t *dest,
int dstW,
993 int yalpha,
int unused_uvalpha,
int y,
995 int unused_eightbytes,
int is_be)
997 int hasAlpha = abuf && abuf[0] && abuf[1];
998 const int32_t *buf0 = buf[0], *buf1 = buf[1],
999 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1000 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1001 int yalpha1 = 4096 - yalpha;
1006 for (
i = 0;
i < dstW;
i++) {
1007 int Y = (buf0[
i] * yalpha1 + buf1[
i] * yalpha) >> 15;
1013 A = (abuf0[
i] * yalpha1 + abuf1[
i] * yalpha) >> 15;
1025 const int32_t *abuf0, uint16_t *dest,
int dstW,
1027 int unused_hasAlpha,
int unused_eightbytes,
int is_be)
1029 int hasAlpha = !!abuf0;
1032 for (
i = 0;
i < dstW;
i++) {
1033 int Y = buf0[
i] >> 3;
1051 const int32_t **lumSrc,
int lumFilterSize,
1052 const int16_t *chrFilter,
const int32_t **chrUSrc,
1053 const int32_t **chrVSrc,
int chrFilterSize,
1054 const int32_t **alpSrc, uint16_t *dest,
int dstW,
1055 int y,
enum AVPixelFormat target,
int hasAlpha,
int eightbytes,
1059 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
1061 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1063 unsigned Y1 = -0x40000000;
1064 unsigned Y2 = -0x40000000;
1065 int U = -(128 << 23);
1066 int V = -(128 << 23);
1069 for (j = 0; j < lumFilterSize; j++) {
1070 Y1 += lumSrc[j][
i * 2] * (unsigned)lumFilter[j];
1071 Y2 += lumSrc[j][
i * 2 + 1] * (unsigned)lumFilter[j];
1073 for (j = 0; j < chrFilterSize; j++) {;
1074 U += chrUSrc[j][
i] * (unsigned)chrFilter[j];
1075 V += chrVSrc[j][
i] * (unsigned)chrFilter[j];
1081 for (j = 0; j < lumFilterSize; j++) {
1082 A1 += alpSrc[j][
i * 2] * (unsigned)lumFilter[j];
1083 A2 += alpSrc[j][
i * 2 + 1] * (unsigned)lumFilter[j];
1100 Y1 -=
c->yuv2rgb_y_offset;
1101 Y2 -=
c->yuv2rgb_y_offset;
1102 Y1 *=
c->yuv2rgb_y_coeff;
1103 Y2 *=
c->yuv2rgb_y_coeff;
1104 Y1 += (1 << 13) - (1 << 29);
1105 Y2 += (1 << 13) - (1 << 29);
1108 R =
V *
c->yuv2rgb_v2r_coeff;
1109 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1110 B =
U *
c->yuv2rgb_u2b_coeff;
1135 const int32_t *abuf[2], uint16_t *dest,
int dstW,
1136 int yalpha,
int uvalpha,
int y,
1140 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1141 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1142 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1143 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1144 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1145 int yalpha1 = 4096 - yalpha;
1146 int uvalpha1 = 4096 - uvalpha;
1148 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
1153 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1154 unsigned Y1 = (buf0[
i * 2] * yalpha1 + buf1[
i * 2] * yalpha) >> 14;
1155 unsigned Y2 = (buf0[
i * 2 + 1] * yalpha1 + buf1[
i * 2 + 1] * yalpha) >> 14;
1156 int U = (ubuf0[
i] * uvalpha1 + ubuf1[
i] * uvalpha - (128 << 23)) >> 14;
1157 int V = (vbuf0[
i] * uvalpha1 + vbuf1[
i] * uvalpha - (128 << 23)) >> 14;
1160 Y1 -=
c->yuv2rgb_y_offset;
1161 Y2 -=
c->yuv2rgb_y_offset;
1162 Y1 *=
c->yuv2rgb_y_coeff;
1163 Y2 *=
c->yuv2rgb_y_coeff;
1164 Y1 += (1 << 13) - (1 << 29);
1165 Y2 += (1 << 13) - (1 << 29);
1167 R =
V *
c->yuv2rgb_v2r_coeff;
1168 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1169 B =
U *
c->yuv2rgb_u2b_coeff;
1172 A1 = (abuf0[
i * 2 ] * yalpha1 + abuf1[
i * 2 ] * yalpha) >> 1;
1173 A2 = (abuf0[
i * 2 + 1] * yalpha1 + abuf1[
i * 2 + 1] * yalpha) >> 1;
1201 const int32_t *abuf0, uint16_t *dest,
int dstW,
1203 int hasAlpha,
int eightbytes,
int is_be)
1205 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1207 int A1 = 0xffff<<14,
A2= 0xffff<<14;
1209 if (uvalpha < 2048) {
1210 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1211 SUINT Y1 = (buf0[
i * 2] ) >> 2;
1212 SUINT Y2 = (buf0[
i * 2 + 1]) >> 2;
1213 int U = (ubuf0[
i] - (128 << 11)) >> 2;
1214 int V = (vbuf0[
i] - (128 << 11)) >> 2;
1217 Y1 -=
c->yuv2rgb_y_offset;
1218 Y2 -=
c->yuv2rgb_y_offset;
1219 Y1 *=
c->yuv2rgb_y_coeff;
1220 Y2 *=
c->yuv2rgb_y_coeff;
1221 Y1 += (1 << 13) - (1 << 29);
1222 Y2 += (1 << 13) - (1 << 29);
1225 A1 = abuf0[
i * 2 ] * (1 << 11);
1226 A2 = abuf0[
i * 2 + 1] * (1 << 11);
1232 R =
V *
c->yuv2rgb_v2r_coeff;
1233 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1234 B =
U *
c->yuv2rgb_u2b_coeff;
1254 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1255 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
1256 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1257 SUINT Y1 = (buf0[
i * 2] ) >> 2;
1258 SUINT Y2 = (buf0[
i * 2 + 1]) >> 2;
1259 int U = (ubuf0[
i] + ubuf1[
i] - (128 << 12)) >> 3;
1260 int V = (vbuf0[
i] + vbuf1[
i] - (128 << 12)) >> 3;
1263 Y1 -=
c->yuv2rgb_y_offset;
1264 Y2 -=
c->yuv2rgb_y_offset;
1265 Y1 *=
c->yuv2rgb_y_coeff;
1266 Y2 *=
c->yuv2rgb_y_coeff;
1267 Y1 += (1 << 13) - (1 << 29);
1268 Y2 += (1 << 13) - (1 << 29);
1271 A1 = abuf0[
i * 2 ] * (1 << 11);
1272 A2 = abuf0[
i * 2 + 1] * (1 << 11);
1278 R =
V *
c->yuv2rgb_v2r_coeff;
1279 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1280 B =
U *
c->yuv2rgb_u2b_coeff;
1304 const int32_t **lumSrc,
int lumFilterSize,
1305 const int16_t *chrFilter,
const int32_t **chrUSrc,
1306 const int32_t **chrVSrc,
int chrFilterSize,
1307 const int32_t **alpSrc, uint16_t *dest,
int dstW,
1309 int eightbytes,
int is_be)
1314 for (
i = 0;
i < dstW;
i++) {
1316 int Y = -0x40000000;
1317 int U = -(128 << 23);
1318 int V = -(128 << 23);
1321 for (j = 0; j < lumFilterSize; j++) {
1322 Y += lumSrc[j][
i] * (unsigned)lumFilter[j];
1324 for (j = 0; j < chrFilterSize; j++) {;
1325 U += chrUSrc[j][
i] * (unsigned)chrFilter[j];
1326 V += chrVSrc[j][
i] * (unsigned)chrFilter[j];
1331 for (j = 0; j < lumFilterSize; j++) {
1332 A += alpSrc[j][
i] * (unsigned)lumFilter[j];
1345 Y -=
c->yuv2rgb_y_offset;
1346 Y *=
c->yuv2rgb_y_coeff;
1347 Y += (1 << 13) - (1<<29);
1350 R =
V *
c->yuv2rgb_v2r_coeff;
1351 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1352 B =
U *
c->yuv2rgb_u2b_coeff;
1370 const int32_t *abuf[2], uint16_t *dest,
int dstW,
1371 int yalpha,
int uvalpha,
int y,
1375 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1376 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1377 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1378 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1379 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1380 int yalpha1 = 4096 - yalpha;
1381 int uvalpha1 = 4096 - uvalpha;
1388 for (
i = 0;
i < dstW;
i++) {
1389 int Y = (buf0[
i] * yalpha1 + buf1[
i] * yalpha) >> 14;
1390 int U = (ubuf0[
i] * uvalpha1 + ubuf1[
i] * uvalpha - (128 << 23)) >> 14;
1391 int V = (vbuf0[
i] * uvalpha1 + vbuf1[
i] * uvalpha - (128 << 23)) >> 14;
1394 Y -=
c->yuv2rgb_y_offset;
1395 Y *=
c->yuv2rgb_y_coeff;
1396 Y += (1 << 13) - (1 << 29);
1398 R =
V *
c->yuv2rgb_v2r_coeff;
1399 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1400 B =
U *
c->yuv2rgb_u2b_coeff;
1403 A = (abuf0[
i] * yalpha1 + abuf1[
i] * yalpha) >> 1;
1423 const int32_t *abuf0, uint16_t *dest,
int dstW,
1425 int hasAlpha,
int eightbytes,
int is_be)
1427 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1431 if (uvalpha < 2048) {
1432 for (
i = 0;
i < dstW;
i++) {
1434 int U = (ubuf0[
i] - (128 << 11)) >> 2;
1435 int V = (vbuf0[
i] - (128 << 11)) >> 2;
1438 Y -=
c->yuv2rgb_y_offset;
1439 Y *=
c->yuv2rgb_y_coeff;
1440 Y += (1 << 13) - (1 << 29);
1443 A = abuf0[
i] * (1 << 11);
1448 R =
V *
c->yuv2rgb_v2r_coeff;
1449 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1450 B =
U *
c->yuv2rgb_u2b_coeff;
1463 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1465 for (
i = 0;
i < dstW;
i++) {
1467 int U = (ubuf0[
i] + ubuf1[
i] - (128 << 12)) >> 3;
1468 int V = (vbuf0[
i] + vbuf1[
i] - (128 << 12)) >> 3;
1471 Y -=
c->yuv2rgb_y_offset;
1472 Y *=
c->yuv2rgb_y_coeff;
1473 Y += (1 << 13) - (1 << 29);
1476 A = abuf0[
i] * (1 << 11);
1481 R =
V *
c->yuv2rgb_v2r_coeff;
1482 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
1483 B =
U *
c->yuv2rgb_u2b_coeff;
1502 #define YUV2PACKED16WRAPPER_EXT(name, base, ext, fmt, is_be, hasAlpha, eightbytes) \
1503 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
1504 const int16_t **_lumSrc, int lumFilterSize, \
1505 const int16_t *chrFilter, const int16_t **_chrUSrc, \
1506 const int16_t **_chrVSrc, int chrFilterSize, \
1507 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
1510 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
1511 **chrUSrc = (const int32_t **) _chrUSrc, \
1512 **chrVSrc = (const int32_t **) _chrVSrc, \
1513 **alpSrc = (const int32_t **) _alpSrc; \
1514 uint16_t *dest = (uint16_t *) _dest; \
1515 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1516 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1517 alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes, is_be); \
1520 static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
1521 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1522 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
1523 int yalpha, int uvalpha, int y) \
1525 const int32_t **buf = (const int32_t **) _buf, \
1526 **ubuf = (const int32_t **) _ubuf, \
1527 **vbuf = (const int32_t **) _vbuf, \
1528 **abuf = (const int32_t **) _abuf; \
1529 uint16_t *dest = (uint16_t *) _dest; \
1530 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1531 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1534 static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
1535 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1536 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
1537 int uvalpha, int y) \
1539 const int32_t *buf0 = (const int32_t *) _buf0, \
1540 **ubuf = (const int32_t **) _ubuf, \
1541 **vbuf = (const int32_t **) _vbuf, \
1542 *abuf0 = (const int32_t *) _abuf0; \
1543 uint16_t *dest = (uint16_t *) _dest; \
1544 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1545 dstW, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \
1547 #define YUV2PACKED16WRAPPER(name, base, ext, base_fmt, endianness, hasAlpha, eightbytes) \
1548 YUV2PACKED16WRAPPER_EXT(name, base, ext, base_fmt ## endianness, IS_BE(endianness), hasAlpha, eightbytes)
1588 unsigned A1,
unsigned A2,
1589 const
void *_r, const
void *_g, const
void *_b,
int y,
1594 uint32_t *dest = (uint32_t *) _dest;
1595 const uint32_t *
r = (
const uint32_t *) _r;
1596 const uint32_t *
g = (
const uint32_t *) _g;
1597 const uint32_t *
b = (
const uint32_t *) _b;
1602 dest[
i * 2 + 0] =
r[Y1] +
g[Y1] +
b[Y1] + (hasAlpha ?
A1 << sh : 0);
1603 dest[
i * 2 + 1] =
r[Y2] +
g[Y2] +
b[Y2] + (hasAlpha ?
A2 << sh : 0);
1609 dest[
i * 2 + 0] =
r[Y1] +
g[Y1] +
b[Y1] + (
A1 << sh);
1610 dest[
i * 2 + 1] =
r[Y2] +
g[Y2] +
b[Y2] + (
A2 << sh);
1612 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
1615 av_assert2((((
r[Y1] +
g[Y1] +
b[Y1]) >> sh) & 0xFF) == 0xFF);
1617 dest[
i * 2 + 0] =
r[Y1] +
g[Y1] +
b[Y1];
1618 dest[
i * 2 + 1] =
r[Y2] +
g[Y2] +
b[Y2];
1622 uint8_t *dest = (uint8_t *) _dest;
1623 const uint8_t *
r = (
const uint8_t *) _r;
1624 const uint8_t *
g = (
const uint8_t *) _g;
1625 const uint8_t *
b = (
const uint8_t *) _b;
1627 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
1628 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
1630 dest[
i * 6 + 0] =
r_b[Y1];
1631 dest[
i * 6 + 1] =
g[Y1];
1632 dest[
i * 6 + 2] =
b_r[Y1];
1633 dest[
i * 6 + 3] =
r_b[Y2];
1634 dest[
i * 6 + 4] =
g[Y2];
1635 dest[
i * 6 + 5] =
b_r[Y2];
1641 uint16_t *dest = (uint16_t *) _dest;
1642 const uint16_t *
r = (
const uint16_t *) _r;
1643 const uint16_t *
g = (
const uint16_t *) _g;
1644 const uint16_t *
b = (
const uint16_t *) _b;
1645 int dr1, dg1, db1, dr2, dg2, db2;
1670 dest[
i * 2 + 0] =
r[Y1 + dr1] +
g[Y1 + dg1] +
b[Y1 + db1];
1671 dest[
i * 2 + 1] =
r[Y2 + dr2] +
g[Y2 + dg2] +
b[Y2 + db2];
1673 uint32_t *dest = (uint32_t *) _dest;
1674 const uint32_t *
r = (
const uint32_t *) _r;
1675 const uint32_t *
g = (
const uint32_t *) _g;
1676 const uint32_t *
b = (
const uint32_t *) _b;
1677 dest[
i * 2 + 0] =
r[Y1] +
g[Y1] +
b[Y1];
1678 dest[
i * 2 + 1] =
r[Y2] +
g[Y2] +
b[Y2];
1680 uint8_t *dest = (uint8_t *) _dest;
1681 const uint8_t *
r = (
const uint8_t *) _r;
1682 const uint8_t *
g = (
const uint8_t *) _g;
1683 const uint8_t *
b = (
const uint8_t *) _b;
1684 int dr1, dg1, db1, dr2, dg2, db2;
1689 dr1 = dg1 = d32[(
i * 2 + 0) & 7];
1690 db1 = d64[(
i * 2 + 0) & 7];
1691 dr2 = dg2 = d32[(
i * 2 + 1) & 7];
1692 db2 = d64[(
i * 2 + 1) & 7];
1696 dr1 = db1 =
d128[(
i * 2 + 0) & 7];
1697 dg1 = d64[(
i * 2 + 0) & 7];
1698 dr2 = db2 =
d128[(
i * 2 + 1) & 7];
1699 dg2 = d64[(
i * 2 + 1) & 7];
1703 dest[
i] =
r[Y1 + dr1] +
g[Y1 + dg1] +
b[Y1 + db1] +
1704 ((
r[Y2 + dr2] +
g[Y2 + dg2] +
b[Y2 + db2]) << 4);
1706 dest[
i * 2 + 0] =
r[Y1 + dr1] +
g[Y1 + dg1] +
b[Y1 + db1];
1707 dest[
i * 2 + 1] =
r[Y2 + dr2] +
g[Y2 + dg2] +
b[Y2 + db2];
1714 const int16_t **lumSrc,
int lumFilterSize,
1715 const int16_t *chrFilter,
const int16_t **chrUSrc,
1716 const int16_t **chrVSrc,
int chrFilterSize,
1717 const int16_t **alpSrc, uint8_t *dest,
int dstW,
1722 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1728 const void *
r, *
g, *
b;
1730 for (j = 0; j < lumFilterSize; j++) {
1731 Y1 += lumSrc[j][
i * 2] * lumFilter[j];
1732 Y2 += lumSrc[j][
i * 2 + 1] * lumFilter[j];
1734 for (j = 0; j < chrFilterSize; j++) {
1735 U += chrUSrc[j][
i] * chrFilter[j];
1736 V += chrVSrc[j][
i] * chrFilter[j];
1745 for (j = 0; j < lumFilterSize; j++) {
1746 A1 += alpSrc[j][
i * 2 ] * lumFilter[j];
1747 A2 += alpSrc[j][
i * 2 + 1] * lumFilter[j];
1751 if ((
A1 |
A2) & 0x100) {
1762 r,
g,
b, y, target, hasAlpha);
1768 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1769 const int16_t *abuf[2], uint8_t *dest,
int dstW,
1770 int yalpha,
int uvalpha,
int y,
1773 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1774 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1775 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1776 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1777 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1778 int yalpha1 = 4096 - yalpha;
1779 int uvalpha1 = 4096 - uvalpha;
1784 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1785 int Y1 = (buf0[
i * 2] * yalpha1 + buf1[
i * 2] * yalpha) >> 19;
1786 int Y2 = (buf0[
i * 2 + 1] * yalpha1 + buf1[
i * 2 + 1] * yalpha) >> 19;
1787 int U = (ubuf0[
i] * uvalpha1 + ubuf1[
i] * uvalpha) >> 19;
1788 int V = (vbuf0[
i] * uvalpha1 + vbuf1[
i] * uvalpha) >> 19;
1795 A1 = (abuf0[
i * 2 ] * yalpha1 + abuf1[
i * 2 ] * yalpha) >> 19;
1796 A2 = (abuf0[
i * 2 + 1] * yalpha1 + abuf1[
i * 2 + 1] * yalpha) >> 19;
1802 r,
g,
b, y, target, hasAlpha);
1808 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1809 const int16_t *abuf0, uint8_t *dest,
int dstW,
1813 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1816 if (uvalpha < 2048) {
1817 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1818 int Y1 = (buf0[
i * 2 ] + 64) >> 7;
1819 int Y2 = (buf0[
i * 2 + 1] + 64) >> 7;
1820 int U = (ubuf0[
i] + 64) >> 7;
1821 int V = (vbuf0[
i] + 64) >> 7;
1828 A1 = abuf0[
i * 2 ] * 255 + 16384 >> 15;
1829 A2 = abuf0[
i * 2 + 1] * 255 + 16384 >> 15;
1835 r,
g,
b, y, target, hasAlpha);
1838 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1839 for (
i = 0;
i < ((dstW + 1) >> 1);
i++) {
1840 int Y1 = (buf0[
i * 2 ] + 64) >> 7;
1841 int Y2 = (buf0[
i * 2 + 1] + 64) >> 7;
1842 int U = (ubuf0[
i] + ubuf1[
i] + 128) >> 8;
1843 int V = (vbuf0[
i] + vbuf1[
i] + 128) >> 8;
1850 A1 = (abuf0[
i * 2 ] + 64) >> 7;
1851 A2 = (abuf0[
i * 2 + 1] + 64) >> 7;
1857 r,
g,
b, y, target, hasAlpha);
1862 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1863 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
1864 const int16_t **lumSrc, int lumFilterSize, \
1865 const int16_t *chrFilter, const int16_t **chrUSrc, \
1866 const int16_t **chrVSrc, int chrFilterSize, \
1867 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1870 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1871 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1872 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1875 #define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1876 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1877 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
1878 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1879 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1880 int yalpha, int uvalpha, int y) \
1882 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1883 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1886 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1887 YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1888 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
1889 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1890 const int16_t *abuf0, uint8_t *dest, int dstW, \
1891 int uvalpha, int y) \
1893 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1894 dstW, uvalpha, y, fmt, hasAlpha); \
1901 #if CONFIG_SWSCALE_ALPHA
1920 uint8_t *dest,
int i,
int Y,
int A,
int U,
int V,
1926 Y -=
c->yuv2rgb_y_offset;
1927 Y *=
c->yuv2rgb_y_coeff;
1929 R = (unsigned)
Y +
V*(
unsigned)
c->yuv2rgb_v2r_coeff;
1930 G = (unsigned)
Y +
V*(
unsigned)
c->yuv2rgb_v2g_coeff +
U*(unsigned)
c->yuv2rgb_u2g_coeff;
1931 B = (
unsigned)
Y +
U*(unsigned)
c->yuv2rgb_u2b_coeff;
1932 if ((
R |
G |
B) & 0xC0000000) {
1940 dest[0] = hasAlpha ?
A : 255;
1954 dest[3] = hasAlpha ?
A : 255;
1957 dest[0] = hasAlpha ?
A : 255;
1971 dest[3] = hasAlpha ?
A : 255;
1980 switch (
c->dither) {
1998 R += (7*err[0] + 1*
c->dither_error[0][
i] + 5*
c->dither_error[0][
i+1] + 3*
c->dither_error[0][
i+2])>>4;
1999 G += (7*err[1] + 1*
c->dither_error[1][
i] + 5*
c->dither_error[1][
i+1] + 3*
c->dither_error[1][
i+2])>>4;
2000 B += (7*err[2] + 1*
c->dither_error[2][
i] + 5*
c->dither_error[2][
i+1] + 3*
c->dither_error[2][
i+2])>>4;
2001 c->dither_error[0][
i] = err[0];
2002 c->dither_error[1][
i] = err[1];
2003 c->dither_error[2][
i] = err[2];
2004 r =
R >> (isrgb8 ? 5 : 7);
2005 g =
G >> (isrgb8 ? 5 : 6);
2006 b =
B >> (isrgb8 ? 6 : 7);
2010 err[0] =
R -
r*(isrgb8 ? 36 : 255);
2011 err[1] =
G -
g*(isrgb8 ? 36 : 85);
2012 err[2] =
B -
b*(isrgb8 ? 85 : 255);
2017 #define A_DITHER(u,v) (((((u)+((v)*236))*119)&0xff))
2036 #define X_DITHER(u,v) (((((u)^((v)*237))*181)&0x1ff)/2)
2056 dest[0] =
r + 2*
g + 8*
b;
2058 dest[0] =
b + 2*
g + 8*
r;
2060 dest[0] =
r + 8*
g + 64*
b;
2062 dest[0] =
b + 4*
g + 32*
r;
2071 const int16_t **lumSrc,
int lumFilterSize,
2072 const int16_t *chrFilter,
const int16_t **chrUSrc,
2073 const int16_t **chrVSrc,
int chrFilterSize,
2074 const int16_t **alpSrc, uint8_t *dest,
2086 for (
i = 0;
i < dstW;
i++) {
2089 int U = (1<<9)-(128 << 19);
2090 int V = (1<<9)-(128 << 19);
2092 for (j = 0; j < lumFilterSize; j++) {
2093 Y += lumSrc[j][
i] * lumFilter[j];
2095 for (j = 0; j < chrFilterSize; j++) {
2096 U += chrUSrc[j][
i] * chrFilter[j];
2097 V += chrVSrc[j][
i] * chrFilter[j];
2104 for (j = 0; j < lumFilterSize; j++) {
2105 A += alpSrc[j][
i] * lumFilter[j];
2111 yuv2rgb_write_full(
c, dest,
i,
Y,
A,
U,
V, y, target, hasAlpha, err);
2114 c->dither_error[0][
i] = err[0];
2115 c->dither_error[1][
i] = err[1];
2116 c->dither_error[2][
i] = err[2];
2121 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2122 const int16_t *abuf[2], uint8_t *dest,
int dstW,
2123 int yalpha,
int uvalpha,
int y,
2126 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2127 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
2128 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
2129 *abuf0 = hasAlpha ? abuf[0] :
NULL,
2130 *abuf1 = hasAlpha ? abuf[1] :
NULL;
2131 int yalpha1 = 4096 - yalpha;
2132 int uvalpha1 = 4096 - uvalpha;
2145 for (
i = 0;
i < dstW;
i++) {
2146 int Y = ( buf0[
i] * yalpha1 + buf1[
i] * yalpha ) >> 10;
2147 int U = (ubuf0[
i] * uvalpha1 + ubuf1[
i] * uvalpha-(128 << 19)) >> 10;
2148 int V = (vbuf0[
i] * uvalpha1 + vbuf1[
i] * uvalpha-(128 << 19)) >> 10;
2151 A = (abuf0[
i] * yalpha1 + abuf1[
i] * yalpha + (1<<18)) >> 19;
2156 yuv2rgb_write_full(
c, dest,
i,
Y,
A,
U,
V, y, target, hasAlpha, err);
2159 c->dither_error[0][
i] = err[0];
2160 c->dither_error[1][
i] = err[1];
2161 c->dither_error[2][
i] = err[2];
2166 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2167 const int16_t *abuf0, uint8_t *dest,
int dstW,
2171 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
2180 if (uvalpha < 2048) {
2182 for (
i = 0;
i < dstW;
i++) {
2183 int Y = buf0[
i] * 4;
2184 int U = (ubuf0[
i] - (128<<7)) * 4;
2185 int V = (vbuf0[
i] - (128<<7)) * 4;
2188 A = (abuf0[
i] + 64) >> 7;
2193 yuv2rgb_write_full(
c, dest,
i,
Y,
A,
U,
V, y, target, hasAlpha, err);
2197 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
2199 for (
i = 0;
i < dstW;
i++) {
2200 int Y = buf0[
i] * 4;
2201 int U = (ubuf0[
i] + ubuf1[
i] - (128<<8)) * 2;
2202 int V = (vbuf0[
i] + vbuf1[
i] - (128<<8)) * 2;
2205 A = (abuf0[
i] + 64) >> 7;
2210 yuv2rgb_write_full(
c, dest,
i,
Y,
A,
U,
V, y, target, hasAlpha, err);
2215 c->dither_error[0][
i] = err[0];
2216 c->dither_error[1][
i] = err[1];
2217 c->dither_error[2][
i] = err[2];
2226 #if CONFIG_SWSCALE_ALPHA
2247 const int16_t **lumSrc,
int lumFilterSize,
2248 const int16_t *chrFilter, const int16_t **chrUSrc,
2249 const int16_t **chrVSrc,
int chrFilterSize,
2250 const int16_t **alpSrc, uint8_t **dest,
2256 uint16_t **dest16 = (uint16_t**)dest;
2257 int SH = 22 + 8 -
desc->comp[0].depth;
2260 for (
i = 0;
i < dstW;
i++) {
2263 int U = (1 << 9) - (128 << 19);
2264 int V = (1 << 9) - (128 << 19);
2267 for (j = 0; j < lumFilterSize; j++)
2268 Y += lumSrc[j][
i] * lumFilter[j];
2270 for (j = 0; j < chrFilterSize; j++) {
2271 U += chrUSrc[j][
i] * chrFilter[j];
2272 V += chrVSrc[j][
i] * chrFilter[j];
2282 for (j = 0; j < lumFilterSize; j++)
2283 A += alpSrc[j][
i] * lumFilter[j];
2289 Y -=
c->yuv2rgb_y_offset;
2290 Y *=
c->yuv2rgb_y_coeff;
2292 R =
Y +
V * (unsigned)
c->yuv2rgb_v2r_coeff;
2293 G =
Y +
V * (
unsigned)
c->yuv2rgb_v2g_coeff +
U * (unsigned)
c->yuv2rgb_u2g_coeff;
2294 B =
Y +
U * (
unsigned)
c->yuv2rgb_u2b_coeff;
2296 if ((
R |
G |
B) & 0xC0000000) {
2303 dest16[0][
i] =
G >>
SH;
2304 dest16[1][
i] =
B >>
SH;
2305 dest16[2][
i] =
R >>
SH;
2307 dest16[3][
i] =
A >> (
SH - 3);
2309 dest[0][
i] =
G >> 22;
2310 dest[1][
i] =
B >> 22;
2311 dest[2][
i] =
R >> 22;
2313 dest[3][
i] =
A >> 19;
2316 if (
SH != 22 && (!
isBE(
c->dstFormat)) != (!HAVE_BIGENDIAN)) {
2317 for (
i = 0;
i < dstW;
i++) {
2329 const int16_t **lumSrcx,
int lumFilterSize,
2330 const int16_t *chrFilter,
const int16_t **chrUSrcx,
2331 const int16_t **chrVSrcx,
int chrFilterSize,
2332 const int16_t **alpSrcx, uint8_t **dest,
2338 uint16_t **dest16 = (uint16_t**)dest;
2344 for (
i = 0;
i < dstW;
i++) {
2346 int Y = -0x40000000;
2347 int U = -(128 << 23);
2348 int V = -(128 << 23);
2351 for (j = 0; j < lumFilterSize; j++)
2352 Y += lumSrc[j][
i] * (
unsigned)lumFilter[j];
2354 for (j = 0; j < chrFilterSize; j++) {
2355 U += chrUSrc[j][
i] * (unsigned)chrFilter[j];
2356 V += chrVSrc[j][
i] * (unsigned)chrFilter[j];
2367 for (j = 0; j < lumFilterSize; j++)
2368 A += alpSrc[j][
i] * (
unsigned)lumFilter[j];
2374 Y -=
c->yuv2rgb_y_offset;
2375 Y *=
c->yuv2rgb_y_coeff;
2376 Y += (1 << 13) - (1 << 29);
2377 R =
V *
c->yuv2rgb_v2r_coeff;
2378 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
2379 B =
U *
c->yuv2rgb_u2b_coeff;
2388 if ((!
isBE(
c->dstFormat)) != (!HAVE_BIGENDIAN)) {
2389 for (
i = 0;
i < dstW;
i++) {
2401 const int16_t **lumSrcx,
int lumFilterSize,
2402 const int16_t *chrFilter,
const int16_t **chrUSrcx,
2403 const int16_t **chrVSrcx,
int chrFilterSize,
2404 const int16_t **alpSrcx, uint8_t **dest,
2410 uint32_t **dest32 = (uint32_t**)dest;
2415 static const float float_mult = 1.0f / 65535.0f;
2417 for (
i = 0;
i < dstW;
i++) {
2419 int Y = -0x40000000;
2420 int U = -(128 << 23);
2421 int V = -(128 << 23);
2424 for (j = 0; j < lumFilterSize; j++)
2425 Y += lumSrc[j][
i] * (
unsigned)lumFilter[j];
2427 for (j = 0; j < chrFilterSize; j++) {
2428 U += chrUSrc[j][
i] * (unsigned)chrFilter[j];
2429 V += chrVSrc[j][
i] * (unsigned)chrFilter[j];
2440 for (j = 0; j < lumFilterSize; j++)
2441 A += alpSrc[j][
i] * (
unsigned)lumFilter[j];
2447 Y -=
c->yuv2rgb_y_offset;
2448 Y *=
c->yuv2rgb_y_coeff;
2449 Y += (1 << 13) - (1 << 29);
2450 R =
V *
c->yuv2rgb_v2r_coeff;
2451 G =
V *
c->yuv2rgb_v2g_coeff +
U *
c->yuv2rgb_u2g_coeff;
2452 B =
U *
c->yuv2rgb_u2b_coeff;
2464 if ((!
isBE(
c->dstFormat)) != (!HAVE_BIGENDIAN)) {
2465 for (
i = 0;
i < dstW;
i++) {
2477 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2478 const int16_t *abuf0, uint8_t *dest,
int dstW,
2481 int hasAlpha = !!abuf0;
2484 for (
i = 0;
i < dstW;
i++) {
2485 int Y = (buf0[
i] + 64) >> 7;
2491 A = (abuf0[
i] + 64) >> 7;
2497 dest[
i * 2 + 1] = hasAlpha ?
A : 255;
2503 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2504 const int16_t *abuf[2], uint8_t *dest,
int dstW,
2505 int yalpha,
int uvalpha,
int y)
2507 int hasAlpha = abuf && abuf[0] && abuf[1];
2508 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2509 *abuf0 = hasAlpha ? abuf[0] :
NULL,
2510 *abuf1 = hasAlpha ? abuf[1] :
NULL;
2511 int yalpha1 = 4096 - yalpha;
2516 for (
i = 0;
i < dstW;
i++) {
2517 int Y = (buf0[
i] * yalpha1 + buf1[
i] * yalpha) >> 19;
2523 A = (abuf0[
i] * yalpha1 + abuf1[
i] * yalpha) >> 19;
2528 dest[
i * 2 + 1] = hasAlpha ?
A : 255;
2534 const int16_t **lumSrc,
int lumFilterSize,
2535 const int16_t *chrFilter,
const int16_t **chrUSrc,
2536 const int16_t **chrVSrc,
int chrFilterSize,
2537 const int16_t **alpSrc, uint8_t *dest,
int dstW,
int y)
2539 int hasAlpha = !!alpSrc;
2542 for (
i = 0;
i < dstW;
i++) {
2544 int Y = 1 << 18,
A = 1 << 18;
2546 for (j = 0; j < lumFilterSize; j++)
2547 Y += lumSrc[j][
i] * lumFilter[j];
2554 for (j = 0; j < lumFilterSize; j++)
2555 A += alpSrc[j][
i] * lumFilter[j];
2564 dest[2 *
i + 1] = hasAlpha ?
A : 255;
2570 const int16_t **_lumSrc,
int lumFilterSize,
2571 const int16_t *chrFilter,
const int16_t **_chrUSrc,
2572 const int16_t **_chrVSrc,
int chrFilterSize,
2573 const int16_t **_alpSrc, uint8_t *dest,
int dstW,
int y)
2576 **chrUSrc = (
const int32_t **) _chrUSrc,
2577 **chrVSrc = (
const int32_t **) _chrVSrc,
2578 **alpSrc = (
const int32_t **) _alpSrc;
2579 int hasAlpha = !!alpSrc;
2582 for (
i = 0;
i < dstW;
i++) {
2583 int Y = 1 << 14,
U = 1 << 14;
2584 int V = 1 << 14,
A = 1 << 14;
2592 for (j = 0; j < lumFilterSize; j++)
2593 Y += lumSrc[j][
i] * (
unsigned)lumFilter[j];
2595 for (j = 0; j < chrFilterSize; j++)
2596 U += chrUSrc[j][
i] * (
unsigned)chrFilter[j];
2598 for (j = 0; j < chrFilterSize; j++)
2599 V += chrVSrc[j][
i] * (
unsigned)chrFilter[j];
2602 for (j = 0; j < lumFilterSize; j++)
2603 A += alpSrc[j][
i] * (
unsigned)lumFilter[j];
2610 AV_WL16(dest + 8 *
i, hasAlpha ?
A : 65535);
2619 const int16_t **lumSrc,
int lumFilterSize,
2620 const int16_t *chrFilter,
const int16_t **chrUSrc,
2621 const int16_t **chrVSrc,
int chrFilterSize,
2622 const int16_t **alpSrc, uint8_t *dest,
int dstW,
int y)
2625 for (
i = 0;
i < dstW;
i++) {
2626 int Y = 1 << 16,
U = 1 << 16,
V = 1 << 16;
2629 for (j = 0; j < lumFilterSize; j++)
2630 Y += lumSrc[j][
i] * lumFilter[j];
2632 for (j = 0; j < chrFilterSize; j++) {
2633 U += chrUSrc[j][
i] * chrFilter[j];
2634 V += chrVSrc[j][
i] * chrFilter[j];
2647 const int16_t **lumSrc,
int lumFilterSize,
2648 const int16_t *chrFilter,
const int16_t **chrUSrc,
2649 const int16_t **chrVSrc,
int chrFilterSize,
2650 const int16_t **alpSrc, uint8_t *dest,
int dstW,
int y)
2653 for (
i = 0;
i < dstW;
i++) {
2654 int Y = 1 << 14,
U = 1 << 14,
V = 1 << 14,
A = 255;
2657 for (j = 0; j < lumFilterSize; j++)
2658 Y += lumSrc[j][
i] * lumFilter[j];
2660 for (j = 0; j < chrFilterSize; j++) {
2661 U += chrUSrc[j][
i] * chrFilter[j];
2662 V += chrVSrc[j][
i] * chrFilter[j];
2674 const int16_t **lumSrc,
int lumFilterSize,
2675 const int16_t *chrFilter,
const int16_t **chrUSrc,
2676 const int16_t **chrVSrc,
int chrFilterSize,
2677 const int16_t **alpSrc, uint8_t *dest,
int dstW,
int y)
2681 for (
i = 0;
i < dstW;
i++) {
2683 int Y = 1 << 18,
U = 1 << 18;
2684 int V = 1 << 18,
A = 255;
2686 for (j = 0; j < lumFilterSize; j++)
2687 Y += lumSrc[j][
i] * lumFilter[j];
2689 for (j = 0; j < chrFilterSize; j++)
2690 U += chrUSrc[j][
i] * chrFilter[j];
2692 for (j = 0; j < chrFilterSize; j++)
2693 V += chrVSrc[j][
i] * chrFilter[j];
2709 for (j = 0; j < lumFilterSize; j++)
2710 A += alpSrc[j][
i] * lumFilter[j];
2719 dest[4 *
i + 1] =
U;
2720 dest[4 *
i + 2] =
Y;
2721 dest[4 *
i + 3] =
A;
2725 #define output_pixel(pos, val, bits) \
2726 AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
2728 #define yuv2y2xx_wrapper(bits) \
2730 yuv2y2 ## bits ## le_X_c(SwsContext *c, const int16_t *lumFilter, \
2731 const int16_t **lumSrc, int lumFilterSize, \
2732 const int16_t *chrFilter, \
2733 const int16_t **chrUSrc, \
2734 const int16_t **chrVSrc, int chrFilterSize, \
2735 const int16_t **alpSrc, \
2736 uint8_t *dest, int dstW, int y) \
2739 int shift = 11 + 16 - bits; \
2740 int output_shift = 16 - bits; \
2741 for (i = 0; i < ((dstW + 1) >> 1); i++) { \
2742 int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1); \
2743 int U = 1 << (shift - 1), V = 1 << (shift - 1); \
2745 for (j = 0; j < lumFilterSize; j++) { \
2746 Y1 += lumSrc[j][i * 2] * lumFilter[j]; \
2747 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; \
2750 for (j = 0; j < chrFilterSize; j++) { \
2751 U += chrUSrc[j][i] * chrFilter[j]; \
2752 V += chrVSrc[j][i] * chrFilter[j]; \
2755 output_pixel(dest + 8 * i + 0, Y1, bits); \
2756 output_pixel(dest + 8 * i + 2, U, bits); \
2757 output_pixel(dest + 8 * i + 4, Y2, bits); \
2758 output_pixel(dest + 8 * i + 6, V, bits); \
2780 if (
desc->comp[0].depth == 10) {
2781 *yuv2plane1 =
isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c;
2782 *
yuv2planeX =
isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c;
2783 *yuv2nv12cX =
isBE(dstFormat) ? yuv2p010cX_BE_c : yuv2p010cX_LE_c;
2784 }
else if (
desc->comp[0].depth == 12) {
2785 *yuv2plane1 =
isBE(dstFormat) ? yuv2p012l1_BE_c : yuv2p012l1_LE_c;
2786 *
yuv2planeX =
isBE(dstFormat) ? yuv2p012lX_BE_c : yuv2p012lX_LE_c;
2787 *yuv2nv12cX =
isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c;
2790 }
else if (
is16BPS(dstFormat)) {
2791 *
yuv2planeX =
isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
2792 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
2796 }
else if (
isNBPS(dstFormat)) {
2797 if (
desc->comp[0].depth == 9) {
2798 *
yuv2planeX =
isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
2799 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
2800 }
else if (
desc->comp[0].depth == 10) {
2801 *
yuv2planeX =
isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
2802 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
2803 }
else if (
desc->comp[0].depth == 12) {
2804 *
yuv2planeX =
isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
2805 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
2806 }
else if (
desc->comp[0].depth == 14) {
2807 *
yuv2planeX =
isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
2808 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
2813 *yuv2plane1 = yuv2plane1_floatBE_c;
2816 *yuv2plane1 = yuv2plane1_floatLE_c;
2825 switch (dstFormat) {
2828 *yuv2packedX = yuv2rgba32_full_X_c;
2829 *yuv2packed2 = yuv2rgba32_full_2_c;
2830 *yuv2packed1 = yuv2rgba32_full_1_c;
2832 #if CONFIG_SWSCALE_ALPHA
2834 *yuv2packedX = yuv2rgba32_full_X_c;
2835 *yuv2packed2 = yuv2rgba32_full_2_c;
2836 *yuv2packed1 = yuv2rgba32_full_1_c;
2840 *yuv2packedX = yuv2rgbx32_full_X_c;
2841 *yuv2packed2 = yuv2rgbx32_full_2_c;
2842 *yuv2packed1 = yuv2rgbx32_full_1_c;
2848 *yuv2packedX = yuv2argb32_full_X_c;
2849 *yuv2packed2 = yuv2argb32_full_2_c;
2850 *yuv2packed1 = yuv2argb32_full_1_c;
2852 #if CONFIG_SWSCALE_ALPHA
2854 *yuv2packedX = yuv2argb32_full_X_c;
2855 *yuv2packed2 = yuv2argb32_full_2_c;
2856 *yuv2packed1 = yuv2argb32_full_1_c;
2860 *yuv2packedX = yuv2xrgb32_full_X_c;
2861 *yuv2packed2 = yuv2xrgb32_full_2_c;
2862 *yuv2packed1 = yuv2xrgb32_full_1_c;
2868 *yuv2packedX = yuv2bgra32_full_X_c;
2869 *yuv2packed2 = yuv2bgra32_full_2_c;
2870 *yuv2packed1 = yuv2bgra32_full_1_c;
2872 #if CONFIG_SWSCALE_ALPHA
2874 *yuv2packedX = yuv2bgra32_full_X_c;
2875 *yuv2packed2 = yuv2bgra32_full_2_c;
2876 *yuv2packed1 = yuv2bgra32_full_1_c;
2880 *yuv2packedX = yuv2bgrx32_full_X_c;
2881 *yuv2packed2 = yuv2bgrx32_full_2_c;
2882 *yuv2packed1 = yuv2bgrx32_full_1_c;
2888 *yuv2packedX = yuv2abgr32_full_X_c;
2889 *yuv2packed2 = yuv2abgr32_full_2_c;
2890 *yuv2packed1 = yuv2abgr32_full_1_c;
2892 #if CONFIG_SWSCALE_ALPHA
2894 *yuv2packedX = yuv2abgr32_full_X_c;
2895 *yuv2packed2 = yuv2abgr32_full_2_c;
2896 *yuv2packed1 = yuv2abgr32_full_1_c;
2900 *yuv2packedX = yuv2xbgr32_full_X_c;
2901 *yuv2packed2 = yuv2xbgr32_full_2_c;
2902 *yuv2packed1 = yuv2xbgr32_full_1_c;
2907 #if CONFIG_SWSCALE_ALPHA
2909 *yuv2packedX = yuv2rgba64le_full_X_c;
2910 *yuv2packed2 = yuv2rgba64le_full_2_c;
2911 *yuv2packed1 = yuv2rgba64le_full_1_c;
2915 *yuv2packedX = yuv2rgbx64le_full_X_c;
2916 *yuv2packed2 = yuv2rgbx64le_full_2_c;
2917 *yuv2packed1 = yuv2rgbx64le_full_1_c;
2921 #if CONFIG_SWSCALE_ALPHA
2923 *yuv2packedX = yuv2rgba64be_full_X_c;
2924 *yuv2packed2 = yuv2rgba64be_full_2_c;
2925 *yuv2packed1 = yuv2rgba64be_full_1_c;
2929 *yuv2packedX = yuv2rgbx64be_full_X_c;
2930 *yuv2packed2 = yuv2rgbx64be_full_2_c;
2931 *yuv2packed1 = yuv2rgbx64be_full_1_c;
2935 #if CONFIG_SWSCALE_ALPHA
2937 *yuv2packedX = yuv2bgra64le_full_X_c;
2938 *yuv2packed2 = yuv2bgra64le_full_2_c;
2939 *yuv2packed1 = yuv2bgra64le_full_1_c;
2943 *yuv2packedX = yuv2bgrx64le_full_X_c;
2944 *yuv2packed2 = yuv2bgrx64le_full_2_c;
2945 *yuv2packed1 = yuv2bgrx64le_full_1_c;
2949 #if CONFIG_SWSCALE_ALPHA
2951 *yuv2packedX = yuv2bgra64be_full_X_c;
2952 *yuv2packed2 = yuv2bgra64be_full_2_c;
2953 *yuv2packed1 = yuv2bgra64be_full_1_c;
2957 *yuv2packedX = yuv2bgrx64be_full_X_c;
2958 *yuv2packed2 = yuv2bgrx64be_full_2_c;
2959 *yuv2packed1 = yuv2bgrx64be_full_1_c;
2964 *yuv2packedX = yuv2rgb24_full_X_c;
2965 *yuv2packed2 = yuv2rgb24_full_2_c;
2966 *yuv2packed1 = yuv2rgb24_full_1_c;
2969 *yuv2packedX = yuv2bgr24_full_X_c;
2970 *yuv2packed2 = yuv2bgr24_full_2_c;
2971 *yuv2packed1 = yuv2bgr24_full_1_c;
2974 *yuv2packedX = yuv2rgb48le_full_X_c;
2975 *yuv2packed2 = yuv2rgb48le_full_2_c;
2976 *yuv2packed1 = yuv2rgb48le_full_1_c;
2979 *yuv2packedX = yuv2bgr48le_full_X_c;
2980 *yuv2packed2 = yuv2bgr48le_full_2_c;
2981 *yuv2packed1 = yuv2bgr48le_full_1_c;
2984 *yuv2packedX = yuv2rgb48be_full_X_c;
2985 *yuv2packed2 = yuv2rgb48be_full_2_c;
2986 *yuv2packed1 = yuv2rgb48be_full_1_c;
2989 *yuv2packedX = yuv2bgr48be_full_X_c;
2990 *yuv2packed2 = yuv2bgr48be_full_2_c;
2991 *yuv2packed1 = yuv2bgr48be_full_1_c;
2994 *yuv2packedX = yuv2bgr4_byte_full_X_c;
2995 *yuv2packed2 = yuv2bgr4_byte_full_2_c;
2996 *yuv2packed1 = yuv2bgr4_byte_full_1_c;
2999 *yuv2packedX = yuv2rgb4_byte_full_X_c;
3000 *yuv2packed2 = yuv2rgb4_byte_full_2_c;
3001 *yuv2packed1 = yuv2rgb4_byte_full_1_c;
3004 *yuv2packedX = yuv2bgr8_full_X_c;
3005 *yuv2packed2 = yuv2bgr8_full_2_c;
3006 *yuv2packed1 = yuv2bgr8_full_1_c;
3009 *yuv2packedX = yuv2rgb8_full_X_c;
3010 *yuv2packed2 = yuv2rgb8_full_2_c;
3011 *yuv2packed1 = yuv2rgb8_full_1_c;
3044 if (!*yuv2packedX && !*yuv2anyX)
3048 switch (dstFormat) {
3050 #if CONFIG_SWSCALE_ALPHA
3052 *yuv2packed1 = yuv2rgba64le_1_c;
3053 *yuv2packed2 = yuv2rgba64le_2_c;
3054 *yuv2packedX = yuv2rgba64le_X_c;
3058 *yuv2packed1 = yuv2rgbx64le_1_c;
3059 *yuv2packed2 = yuv2rgbx64le_2_c;
3060 *yuv2packedX = yuv2rgbx64le_X_c;
3064 #if CONFIG_SWSCALE_ALPHA
3066 *yuv2packed1 = yuv2rgba64be_1_c;
3067 *yuv2packed2 = yuv2rgba64be_2_c;
3068 *yuv2packedX = yuv2rgba64be_X_c;
3072 *yuv2packed1 = yuv2rgbx64be_1_c;
3073 *yuv2packed2 = yuv2rgbx64be_2_c;
3074 *yuv2packedX = yuv2rgbx64be_X_c;
3078 #if CONFIG_SWSCALE_ALPHA
3080 *yuv2packed1 = yuv2bgra64le_1_c;
3081 *yuv2packed2 = yuv2bgra64le_2_c;
3082 *yuv2packedX = yuv2bgra64le_X_c;
3086 *yuv2packed1 = yuv2bgrx64le_1_c;
3087 *yuv2packed2 = yuv2bgrx64le_2_c;
3088 *yuv2packedX = yuv2bgrx64le_X_c;
3092 #if CONFIG_SWSCALE_ALPHA
3094 *yuv2packed1 = yuv2bgra64be_1_c;
3095 *yuv2packed2 = yuv2bgra64be_2_c;
3096 *yuv2packedX = yuv2bgra64be_X_c;
3100 *yuv2packed1 = yuv2bgrx64be_1_c;
3101 *yuv2packed2 = yuv2bgrx64be_2_c;
3102 *yuv2packedX = yuv2bgrx64be_X_c;
3106 *yuv2packed1 = yuv2rgb48le_1_c;
3107 *yuv2packed2 = yuv2rgb48le_2_c;
3108 *yuv2packedX = yuv2rgb48le_X_c;
3111 *yuv2packed1 = yuv2rgb48be_1_c;
3112 *yuv2packed2 = yuv2rgb48be_2_c;
3113 *yuv2packedX = yuv2rgb48be_X_c;
3116 *yuv2packed1 = yuv2bgr48le_1_c;
3117 *yuv2packed2 = yuv2bgr48le_2_c;
3118 *yuv2packedX = yuv2bgr48le_X_c;
3121 *yuv2packed1 = yuv2bgr48be_1_c;
3122 *yuv2packed2 = yuv2bgr48be_2_c;
3123 *yuv2packedX = yuv2bgr48be_X_c;
3128 *yuv2packed1 = yuv2rgb32_1_c;
3129 *yuv2packed2 = yuv2rgb32_2_c;
3130 *yuv2packedX = yuv2rgb32_X_c;
3132 #if CONFIG_SWSCALE_ALPHA
3134 *yuv2packed1 = yuv2rgba32_1_c;
3135 *yuv2packed2 = yuv2rgba32_2_c;
3136 *yuv2packedX = yuv2rgba32_X_c;
3140 *yuv2packed1 = yuv2rgbx32_1_c;
3141 *yuv2packed2 = yuv2rgbx32_2_c;
3142 *yuv2packedX = yuv2rgbx32_X_c;
3149 *yuv2packed1 = yuv2rgb32_1_1_c;
3150 *yuv2packed2 = yuv2rgb32_1_2_c;
3151 *yuv2packedX = yuv2rgb32_1_X_c;
3153 #if CONFIG_SWSCALE_ALPHA
3155 *yuv2packed1 = yuv2rgba32_1_1_c;
3156 *yuv2packed2 = yuv2rgba32_1_2_c;
3157 *yuv2packedX = yuv2rgba32_1_X_c;
3161 *yuv2packed1 = yuv2rgbx32_1_1_c;
3162 *yuv2packed2 = yuv2rgbx32_1_2_c;
3163 *yuv2packedX = yuv2rgbx32_1_X_c;
3168 *yuv2packed1 = yuv2rgb24_1_c;
3169 *yuv2packed2 = yuv2rgb24_2_c;
3170 *yuv2packedX = yuv2rgb24_X_c;
3173 *yuv2packed1 = yuv2bgr24_1_c;
3174 *yuv2packed2 = yuv2bgr24_2_c;
3175 *yuv2packedX = yuv2bgr24_X_c;
3181 *yuv2packed1 = yuv2rgb16_1_c;
3182 *yuv2packed2 = yuv2rgb16_2_c;
3183 *yuv2packedX = yuv2rgb16_X_c;
3189 *yuv2packed1 = yuv2rgb15_1_c;
3190 *yuv2packed2 = yuv2rgb15_2_c;
3191 *yuv2packedX = yuv2rgb15_X_c;
3197 *yuv2packed1 = yuv2rgb12_1_c;
3198 *yuv2packed2 = yuv2rgb12_2_c;
3199 *yuv2packedX = yuv2rgb12_X_c;
3203 *yuv2packed1 = yuv2rgb8_1_c;
3204 *yuv2packed2 = yuv2rgb8_2_c;
3205 *yuv2packedX = yuv2rgb8_X_c;
3209 *yuv2packed1 = yuv2rgb4_1_c;
3210 *yuv2packed2 = yuv2rgb4_2_c;
3211 *yuv2packedX = yuv2rgb4_X_c;
3215 *yuv2packed1 = yuv2rgb4b_1_c;
3216 *yuv2packed2 = yuv2rgb4b_2_c;
3217 *yuv2packedX = yuv2rgb4b_X_c;
3221 *yuv2packed1 = yuv2x2rgb10_1_c;
3222 *yuv2packed2 = yuv2x2rgb10_2_c;
3223 *yuv2packedX = yuv2x2rgb10_X_c;
3227 *yuv2packed1 = yuv2x2bgr10_1_c;
3228 *yuv2packed2 = yuv2x2bgr10_2_c;
3229 *yuv2packedX = yuv2x2bgr10_X_c;
3233 switch (dstFormat) {
3235 *yuv2packed1 = yuv2monowhite_1_c;
3236 *yuv2packed2 = yuv2monowhite_2_c;
3237 *yuv2packedX = yuv2monowhite_X_c;
3240 *yuv2packed1 = yuv2monoblack_1_c;
3241 *yuv2packed2 = yuv2monoblack_2_c;
3242 *yuv2packedX = yuv2monoblack_X_c;
3245 *yuv2packed1 = yuv2yuyv422_1_c;
3246 *yuv2packed2 = yuv2yuyv422_2_c;
3247 *yuv2packedX = yuv2yuyv422_X_c;
3250 *yuv2packed1 = yuv2yvyu422_1_c;
3251 *yuv2packed2 = yuv2yvyu422_2_c;
3252 *yuv2packedX = yuv2yvyu422_X_c;
3255 *yuv2packed1 = yuv2uyvy422_1_c;
3256 *yuv2packed2 = yuv2uyvy422_2_c;
3257 *yuv2packedX = yuv2uyvy422_X_c;
3265 *yuv2packed1 = yuv2ya16le_1_c;
3266 *yuv2packed2 = yuv2ya16le_2_c;
3267 *yuv2packedX = yuv2ya16le_X_c;
3270 *yuv2packed1 = yuv2ya16be_1_c;
3271 *yuv2packed2 = yuv2ya16be_2_c;
3272 *yuv2packedX = yuv2ya16be_X_c;
3288 *yuv2packedX = yuv2y210le_X_c;
3291 *yuv2packedX = yuv2y212le_X_c;