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, },
136 #define output_pixel(pos, val, bias, signedness) \
138 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
140 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
145 int big_endian,
int output_bits)
151 for (i = 0; i < dstW; i++) {
152 int val = src[i] + (1 << (shift - 1));
159 const int32_t **
src, uint16_t *dest,
int dstW,
160 int big_endian,
int output_bits)
166 for (i = 0; i < dstW; i++) {
167 int val = 1 << (shift - 1);
176 for (j = 0; j < filterSize; j++)
177 val += src[j][i] * (
unsigned)filter[j];
185 #define output_pixel(pos, val) \
187 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
189 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
194 int big_endian,
int output_bits)
197 int shift = 15 - output_bits;
199 for (i = 0; i < dstW; i++) {
200 int val = src[i] + (1 << (shift - 1));
207 const int16_t **
src, uint16_t *dest,
int dstW,
208 int big_endian,
int output_bits)
211 int shift = 11 + 16 - output_bits;
213 for (i = 0; i < dstW; i++) {
214 int val = 1 << (shift - 1);
217 for (j = 0; j < filterSize; j++)
218 val += src[j][i] * filter[j];
226 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
227 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
228 uint8_t *dest, int dstW, \
229 const uint8_t *dither, int offset)\
231 yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
232 (uint16_t *) dest, dstW, is_be, bits); \
234 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
235 const int16_t **src, uint8_t *dest, int dstW, \
236 const uint8_t *dither, int offset)\
238 yuv2planeX_## template_size ## _c_template(filter, \
239 filterSize, (const typeX_t **) src, \
240 (uint16_t *) dest, dstW, is_be, bits); \
244 yuv2NBPS(10, BE, 1, 10, int16_t)
245 yuv2NBPS(10, LE, 0, 10, int16_t)
246 yuv2NBPS(12, BE, 1, 10, int16_t)
247 yuv2NBPS(12, LE, 0, 10, int16_t)
248 yuv2NBPS(14, BE, 1, 10, int16_t)
249 yuv2NBPS(14, LE, 0, 10, int16_t)
250 yuv2NBPS(16, BE, 1, 16,
int32_t)
251 yuv2NBPS(16, LE, 0, 16,
int32_t)
253 static
void yuv2planeX_8_c(const int16_t *
filter,
int filterSize,
258 for (i=0; i<dstW; i++) {
259 int val = dither[(i +
offset) & 7] << 12;
261 for (j=0; j<filterSize; j++)
262 val += src[j][i] * filter[j];
264 dest[i]= av_clip_uint8(val>>19);
272 for (i=0; i<dstW; i++) {
273 int val = (src[i] + dither[(i +
offset) & 7]) >> 7;
274 dest[i]= av_clip_uint8(val);
279 const int16_t **chrUSrc,
const int16_t **chrVSrc,
287 for (i=0; i<chrDstW; i++) {
288 int u = chrDither[i & 7] << 12;
289 int v = chrDither[(i + 3) & 7] << 12;
291 for (j=0; j<chrFilterSize; j++) {
292 u += chrUSrc[j][i] * chrFilter[j];
293 v += chrVSrc[j][i] * chrFilter[j];
296 dest[2*i]= av_clip_uint8(u>>19);
297 dest[2*i+1]= av_clip_uint8(v>>19);
300 for (i=0; i<chrDstW; i++) {
301 int u = chrDither[i & 7] << 12;
302 int v = chrDither[(i + 3) & 7] << 12;
304 for (j=0; j<chrFilterSize; j++) {
305 u += chrUSrc[j][i] * chrFilter[j];
306 v += chrVSrc[j][i] * chrFilter[j];
309 dest[2*i]= av_clip_uint8(v>>19);
310 dest[2*i+1]= av_clip_uint8(u>>19);
315 #define output_pixel(pos, val) \
317 AV_WB16(pos, av_clip_uintp2(val >> shift, 10) << 6); \
319 AV_WL16(pos, av_clip_uintp2(val >> shift, 10) << 6); \
323 uint16_t *dest,
int dstW,
329 for (i = 0; i < dstW; i++) {
330 int val = src[i] + (1 << (shift - 1));
336 const int16_t **
src, uint16_t *dest,
int dstW,
342 for (i = 0; i < dstW; i++) {
343 int val = 1 << (shift - 1);
345 for (j = 0; j < filterSize; j++)
346 val += src[j][i] * filter[j];
353 const int16_t **chrUSrc,
const int16_t **chrVSrc,
356 uint16_t *dest = (uint16_t*)dest8;
361 for (i = 0; i < chrDstW; i++) {
362 int u = 1 << (shift - 1);
363 int v = 1 << (shift - 1);
365 for (j = 0; j < chrFilterSize; j++) {
366 u += chrUSrc[j][i] * chrFilter[j];
367 v += chrVSrc[j][i] * chrFilter[j];
393 yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0);
400 yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1);
406 #define accumulate_bit(acc, val) \
409 #define output_pixel(pos, acc) \
410 if (target == AV_PIX_FMT_MONOBLACK) { \
418 const int16_t **lumSrc,
int lumFilterSize,
419 const int16_t *chrFilter,
const int16_t **chrUSrc,
420 const int16_t **chrVSrc,
int chrFilterSize,
421 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
429 for (i = 0; i < dstW; i += 2) {
434 for (j = 0; j < lumFilterSize; j++) {
435 Y1 += lumSrc[j][i] * lumFilter[j];
436 Y2 += lumSrc[j][i+1] * lumFilter[j];
440 if ((Y1 | Y2) & 0x100) {
441 Y1 = av_clip_uint8(Y1);
442 Y2 = av_clip_uint8(Y2);
447 acc = 2*acc + (Y1 >= 128);
452 acc = 2*acc + (err >= 128);
471 const int16_t *ubuf[2],
const int16_t *vbuf[2],
472 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
473 int yalpha,
int uvalpha,
int y,
476 const int16_t *buf0 = buf[0], *buf1 = buf[1];
478 int yalpha1 = 4096 - yalpha;
485 for (i = 0; i < dstW; i +=2) {
488 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
491 acc = 2*acc + (Y >= 128);
494 err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
497 acc = 2*acc + (err >= 128);
505 for (i = 0; i < dstW; i += 8) {
508 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
510 Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
512 Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
514 Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
516 Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
518 Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
520 Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
522 Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
532 const int16_t *ubuf[2],
const int16_t *vbuf[2],
533 const int16_t *abuf0,
uint8_t *dest,
int dstW,
542 for (i = 0; i < dstW; i +=2) {
545 Y = ((buf0[i + 0] + 64) >> 7);
548 acc = 2*acc + (Y >= 128);
551 err = ((buf0[i + 1] + 64) >> 7);
554 acc = 2*acc + (err >= 128);
562 for (i = 0; i < dstW; i += 8) {
579 #undef accumulate_bit
581 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
582 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
583 const int16_t **lumSrc, int lumFilterSize, \
584 const int16_t *chrFilter, const int16_t **chrUSrc, \
585 const int16_t **chrVSrc, int chrFilterSize, \
586 const int16_t **alpSrc, uint8_t *dest, int dstW, \
589 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
590 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
591 alpSrc, dest, dstW, y, fmt); \
594 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
595 const int16_t *ubuf[2], const int16_t *vbuf[2], \
596 const int16_t *abuf[2], uint8_t *dest, int dstW, \
597 int yalpha, int uvalpha, int y) \
599 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
600 dest, dstW, yalpha, uvalpha, y, fmt); \
603 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
604 const int16_t *ubuf[2], const int16_t *vbuf[2], \
605 const int16_t *abuf0, uint8_t *dest, int dstW, \
606 int uvalpha, int y) \
608 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
609 abuf0, dest, dstW, uvalpha, \
616 #define output_pixels(pos, Y1, U, Y2, V) \
617 if (target == AV_PIX_FMT_YUYV422) { \
618 dest[pos + 0] = Y1; \
620 dest[pos + 2] = Y2; \
622 } else if (target == AV_PIX_FMT_YVYU422) { \
623 dest[pos + 0] = Y1; \
625 dest[pos + 2] = Y2; \
629 dest[pos + 1] = Y1; \
631 dest[pos + 3] = Y2; \
636 const int16_t **lumSrc,
int lumFilterSize,
637 const int16_t *chrFilter,
const int16_t **chrUSrc,
638 const int16_t **chrVSrc,
int chrFilterSize,
639 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
644 for (i = 0; i < ((dstW + 1) >> 1); i++) {
651 for (j = 0; j < lumFilterSize; j++) {
652 Y1 += lumSrc[j][i * 2] * lumFilter[j];
653 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
655 for (j = 0; j < chrFilterSize; j++) {
656 U += chrUSrc[j][i] * chrFilter[j];
657 V += chrVSrc[j][i] * chrFilter[j];
663 if ((Y1 | Y2 | U | V) & 0x100) {
664 Y1 = av_clip_uint8(Y1);
665 Y2 = av_clip_uint8(Y2);
666 U = av_clip_uint8(U);
667 V = av_clip_uint8(V);
675 const int16_t *ubuf[2],
const int16_t *vbuf[2],
676 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
677 int yalpha,
int uvalpha,
int y,
680 const int16_t *buf0 = buf[0], *buf1 = buf[1],
681 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
682 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
683 int yalpha1 = 4096 - yalpha;
684 int uvalpha1 = 4096 - uvalpha;
689 for (i = 0; i < ((dstW + 1) >> 1); i++) {
690 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
691 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
692 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
693 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
695 if ((Y1 | Y2 | U | V) & 0x100) {
696 Y1 = av_clip_uint8(Y1);
697 Y2 = av_clip_uint8(Y2);
698 U = av_clip_uint8(U);
699 V = av_clip_uint8(V);
708 const int16_t *ubuf[2],
const int16_t *vbuf[2],
709 const int16_t *abuf0,
uint8_t *dest,
int dstW,
712 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
715 if (uvalpha < 2048) {
716 for (i = 0; i < ((dstW + 1) >> 1); i++) {
717 int Y1 = (buf0[i * 2 ]+64) >> 7;
718 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
719 int U = (ubuf0[i] +64) >> 7;
720 int V = (vbuf0[i] +64) >> 7;
722 if ((Y1 | Y2 | U | V) & 0x100) {
723 Y1 = av_clip_uint8(Y1);
724 Y2 = av_clip_uint8(Y2);
725 U = av_clip_uint8(U);
726 V = av_clip_uint8(V);
729 Y1 = av_clip_uint8(Y1);
730 Y2 = av_clip_uint8(Y2);
731 U = av_clip_uint8(U);
732 V = av_clip_uint8(V);
737 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
738 for (i = 0; i < ((dstW + 1) >> 1); i++) {
739 int Y1 = (buf0[i * 2 ] + 64) >> 7;
740 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
741 int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
742 int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
744 if ((Y1 | Y2 | U | V) & 0x100) {
745 Y1 = av_clip_uint8(Y1);
746 Y2 = av_clip_uint8(Y2);
747 U = av_clip_uint8(U);
748 V = av_clip_uint8(V);
751 Y1 = av_clip_uint8(Y1);
752 Y2 = av_clip_uint8(Y2);
753 U = av_clip_uint8(U);
754 V = av_clip_uint8(V);
767 #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)
768 #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)
769 #define output_pixel(pos, val) \
770 if (isBE(target)) { \
778 const int32_t **lumSrc,
int lumFilterSize,
779 const int16_t *chrFilter,
const int32_t **chrUSrc,
780 const int32_t **chrVSrc,
int chrFilterSize,
781 const int32_t **alpSrc, uint16_t *dest,
int dstW,
782 int y,
enum AVPixelFormat target,
int hasAlpha,
int eightbytes)
785 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
787 for (i = 0; i < ((dstW + 1) >> 1); i++) {
789 int Y1 = -0x40000000;
790 int Y2 = -0x40000000;
791 int U = -(128 << 23);
792 int V = -(128 << 23);
795 for (j = 0; j < lumFilterSize; j++) {
796 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
797 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
799 for (j = 0; j < chrFilterSize; j++) {;
800 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
801 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
807 for (j = 0; j < lumFilterSize; j++) {
808 A1 += alpSrc[j][i * 2] * (unsigned)lumFilter[j];
809 A2 += alpSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
840 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
845 output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
851 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
861 const int32_t *abuf[2], uint16_t *dest,
int dstW,
862 int yalpha,
int uvalpha,
int y,
865 const int32_t *buf0 = buf[0], *buf1 = buf[1],
866 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
867 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
868 *abuf0 = hasAlpha ? abuf[0] :
NULL,
869 *abuf1 = hasAlpha ? abuf[1] :
NULL;
870 int yalpha1 = 4096 - yalpha;
871 int uvalpha1 = 4096 - uvalpha;
873 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
878 for (i = 0; i < ((dstW + 1) >> 1); i++) {
879 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
880 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
881 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
882 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
897 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1;
898 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1;
905 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
910 output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
916 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
926 const int32_t *abuf0, uint16_t *dest,
int dstW,
927 int uvalpha,
int y,
enum AVPixelFormat target,
int hasAlpha,
int eightbytes)
929 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
931 int A1 = 0xffff<<14,
A2= 0xffff<<14;
933 if (uvalpha < 2048) {
934 for (i = 0; i < ((dstW + 1) >> 1); i++) {
935 int Y1 = (buf0[i * 2] ) >> 2;
936 int Y2 = (buf0[i * 2 + 1]) >> 2;
937 int U = (ubuf0[i] - (128 << 11)) >> 2;
938 int V = (vbuf0[i] - (128 << 11)) >> 2;
949 A1 = abuf0[i * 2 ] << 11;
950 A2 = abuf0[i * 2 + 1] << 11;
961 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
966 output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
972 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
978 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
979 int A1 = 0xffff<<14,
A2 = 0xffff<<14;
980 for (i = 0; i < ((dstW + 1) >> 1); i++) {
981 int Y1 = (buf0[i * 2] ) >> 2;
982 int Y2 = (buf0[i * 2 + 1]) >> 2;
983 int U = (ubuf0[i] + ubuf1[i] - (128 << 12)) >> 3;
984 int V = (vbuf0[i] + vbuf1[i] - (128 << 12)) >> 3;
995 A1 = abuf0[i * 2 ] << 11;
996 A2 = abuf0[i * 2 + 1] << 11;
1007 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
1012 output_pixel(&dest[5], av_clip_uintp2( G + Y2, 30) >> 14);
1018 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
1028 const int32_t **lumSrc,
int lumFilterSize,
1029 const int16_t *chrFilter,
const int32_t **chrUSrc,
1030 const int32_t **chrVSrc,
int chrFilterSize,
1031 const int32_t **alpSrc, uint16_t *dest,
int dstW,
1032 int y,
enum AVPixelFormat target,
int hasAlpha,
int eightbytes)
1037 for (i = 0; i < dstW; i++) {
1039 int Y = -0x40000000;
1040 int U = -(128 << 23);
1041 int V = -(128 << 23);
1044 for (j = 0; j < lumFilterSize; j++) {
1045 Y += lumSrc[j][i] * (unsigned)lumFilter[j];
1047 for (j = 0; j < chrFilterSize; j++) {;
1048 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
1049 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
1054 for (j = 0; j < lumFilterSize; j++) {
1055 A += alpSrc[j][i] * (unsigned)lumFilter[j];
1079 output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14);
1093 const int32_t *abuf[2], uint16_t *dest,
int dstW,
1094 int yalpha,
int uvalpha,
int y,
1097 const int32_t *buf0 = buf[0], *buf1 = buf[1],
1098 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1099 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1100 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1101 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1102 int yalpha1 = 4096 - yalpha;
1103 int uvalpha1 = 4096 - uvalpha;
1110 for (i = 0; i < dstW; i++) {
1111 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14;
1112 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14;
1113 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14;
1125 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1;
1131 output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14);
1145 const int32_t *abuf0, uint16_t *dest,
int dstW,
1146 int uvalpha,
int y,
enum AVPixelFormat target,
int hasAlpha,
int eightbytes)
1148 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1152 if (uvalpha < 2048) {
1153 for (i = 0; i < dstW; i++) {
1154 int Y = (buf0[i]) >> 2;
1155 int U = (ubuf0[i] - (128 << 11)) >> 2;
1156 int V = (vbuf0[i] - (128 << 11)) >> 2;
1174 output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14);
1184 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1186 for (i = 0; i < dstW; i++) {
1187 int Y = (buf0[i] ) >> 2;
1188 int U = (ubuf0[i] + ubuf1[i] - (128 << 12)) >> 3;
1189 int V = (vbuf0[i] + vbuf1[i] - (128 << 12)) >> 3;
1207 output_pixel(&dest[1], av_clip_uintp2( G + Y, 30) >> 14);
1223 #define YUV2PACKED16WRAPPER(name, base, ext, fmt, hasAlpha, eightbytes) \
1224 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
1225 const int16_t **_lumSrc, int lumFilterSize, \
1226 const int16_t *chrFilter, const int16_t **_chrUSrc, \
1227 const int16_t **_chrVSrc, int chrFilterSize, \
1228 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
1231 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
1232 **chrUSrc = (const int32_t **) _chrUSrc, \
1233 **chrVSrc = (const int32_t **) _chrVSrc, \
1234 **alpSrc = (const int32_t **) _alpSrc; \
1235 uint16_t *dest = (uint16_t *) _dest; \
1236 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1237 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1238 alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes); \
1241 static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
1242 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1243 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
1244 int yalpha, int uvalpha, int y) \
1246 const int32_t **buf = (const int32_t **) _buf, \
1247 **ubuf = (const int32_t **) _ubuf, \
1248 **vbuf = (const int32_t **) _vbuf, \
1249 **abuf = (const int32_t **) _abuf; \
1250 uint16_t *dest = (uint16_t *) _dest; \
1251 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1252 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes); \
1255 static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
1256 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
1257 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
1258 int uvalpha, int y) \
1260 const int32_t *buf0 = (const int32_t *) _buf0, \
1261 **ubuf = (const int32_t **) _ubuf, \
1262 **vbuf = (const int32_t **) _vbuf, \
1263 *abuf0 = (const int32_t *) _abuf0; \
1264 uint16_t *dest = (uint16_t *) _dest; \
1265 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1266 dstW, uvalpha, y, fmt, hasAlpha, eightbytes); \
1305 unsigned A1,
unsigned A2,
1306 const
void *_r, const
void *_g, const
void *_b,
int y,
1311 uint32_t *dest = (uint32_t *) _dest;
1312 const uint32_t *
r = (
const uint32_t *) _r;
1313 const uint32_t *
g = (
const uint32_t *) _g;
1314 const uint32_t *
b = (
const uint32_t *) _b;
1319 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
1320 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
1325 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0);
1326 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
1327 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
1329 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
1332 av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0xFF);
1334 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
1335 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
1344 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
1345 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
1347 dest[i * 6 + 0] =
r_b[Y1];
1348 dest[i * 6 + 1] = g[Y1];
1349 dest[i * 6 + 2] =
b_r[Y1];
1350 dest[i * 6 + 3] =
r_b[Y2];
1351 dest[i * 6 + 4] = g[Y2];
1352 dest[i * 6 + 5] =
b_r[Y2];
1358 uint16_t *dest = (uint16_t *) _dest;
1359 const uint16_t *
r = (
const uint16_t *) _r;
1360 const uint16_t *
g = (
const uint16_t *) _g;
1361 const uint16_t *
b = (
const uint16_t *) _b;
1362 int dr1, dg1, db1, dr2, dg2, db2;
1387 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1388 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1394 int dr1, dg1, db1, dr2, dg2, db2;
1399 dr1 = dg1 = d32[(i * 2 + 0) & 7];
1400 db1 = d64[(i * 2 + 0) & 7];
1401 dr2 = dg2 = d32[(i * 2 + 1) & 7];
1402 db2 = d64[(i * 2 + 1) & 7];
1406 dr1 = db1 = d128[(i * 2 + 0) & 7];
1407 dg1 = d64[(i * 2 + 0) & 7];
1408 dr2 = db2 = d128[(i * 2 + 1) & 7];
1409 dg2 = d64[(i * 2 + 1) & 7];
1413 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
1414 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
1416 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
1417 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
1424 const int16_t **lumSrc,
int lumFilterSize,
1425 const int16_t *chrFilter,
const int16_t **chrUSrc,
1426 const int16_t **chrVSrc,
int chrFilterSize,
1427 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
1432 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1438 const void *
r, *
g, *
b;
1440 for (j = 0; j < lumFilterSize; j++) {
1441 Y1 += lumSrc[j][i * 2] * lumFilter[j];
1442 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
1444 for (j = 0; j < chrFilterSize; j++) {
1445 U += chrUSrc[j][i] * chrFilter[j];
1446 V += chrVSrc[j][i] * chrFilter[j];
1455 for (j = 0; j < lumFilterSize; j++) {
1456 A1 += alpSrc[j][i * 2 ] * lumFilter[j];
1457 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
1461 if ((A1 | A2) & 0x100) {
1462 A1 = av_clip_uint8(A1);
1463 A2 = av_clip_uint8(A2);
1471 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1472 r, g, b, y, target, hasAlpha);
1478 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1479 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
1480 int yalpha,
int uvalpha,
int y,
1483 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1484 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1485 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1486 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1487 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1488 int yalpha1 = 4096 - yalpha;
1489 int uvalpha1 = 4096 - uvalpha;
1494 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1495 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
1496 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
1497 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
1498 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
1505 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
1506 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
1507 A1 = av_clip_uint8(A1);
1508 A2 = av_clip_uint8(A2);
1511 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1512 r,
g,
b, y, target, hasAlpha);
1518 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1519 const int16_t *abuf0,
uint8_t *dest,
int dstW,
1523 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1526 if (uvalpha < 2048) {
1527 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1528 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1529 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1530 int U = (ubuf0[i] + 64) >> 7;
1531 int V = (vbuf0[i] + 64) >> 7;
1538 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
1539 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
1540 A1 = av_clip_uint8(A1);
1541 A2 = av_clip_uint8(A2);
1544 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1545 r,
g,
b, y, target, hasAlpha);
1548 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1549 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1550 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1551 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1552 int U = (ubuf0[i] + ubuf1[i] + 128) >> 8;
1553 int V = (vbuf0[i] + vbuf1[i] + 128) >> 8;
1560 A1 = (abuf0[i * 2 ] + 64) >> 7;
1561 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
1562 A1 = av_clip_uint8(A1);
1563 A2 = av_clip_uint8(A2);
1566 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1567 r,
g,
b, y, target, hasAlpha);
1572 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1573 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
1574 const int16_t **lumSrc, int lumFilterSize, \
1575 const int16_t *chrFilter, const int16_t **chrUSrc, \
1576 const int16_t **chrVSrc, int chrFilterSize, \
1577 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1580 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1581 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1582 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1585 #define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1586 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1587 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
1588 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1589 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1590 int yalpha, int uvalpha, int y) \
1592 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1593 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1596 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1597 YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \
1598 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
1599 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1600 const int16_t *abuf0, uint8_t *dest, int dstW, \
1601 int uvalpha, int y) \
1603 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1604 dstW, uvalpha, y, fmt, hasAlpha); \
1611 #if CONFIG_SWSCALE_ALPHA
1634 Y -= c->yuv2rgb_y_offset;
1635 Y *= c->yuv2rgb_y_coeff;
1637 R = Y + V*c->yuv2rgb_v2r_coeff;
1638 G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
1639 B = Y + U*c->yuv2rgb_u2b_coeff;
1640 if ((R | G | B) & 0xC0000000) {
1641 R = av_clip_uintp2(R, 30);
1642 G = av_clip_uintp2(G, 30);
1643 B = av_clip_uintp2(B, 30);
1648 dest[0] = hasAlpha ? A : 255;
1662 dest[3] = hasAlpha ? A : 255;
1665 dest[0] = hasAlpha ? A : 255;
1670 case AV_PIX_FMT_BGR24:
1679 dest[3] = hasAlpha ? A : 255;
1682 case AV_PIX_FMT_RGB4_BYTE:
1684 case AV_PIX_FMT_RGB8:
1688 switch (c->dither) {
1695 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;
1696 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;
1697 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;
1698 c->dither_error[0][i] = err[0];
1699 c->dither_error[1][i] = err[1];
1700 c->dither_error[2][i] = err[2];
1701 r = R >> (isrgb8 ? 5 : 7);
1702 g = G >> (isrgb8 ? 5 : 6);
1703 b = B >> (isrgb8 ? 6 : 7);
1704 r = av_clip(r, 0, isrgb8 ? 7 : 1);
1705 g = av_clip(g, 0, isrgb8 ? 7 : 3);
1706 b = av_clip(b, 0, isrgb8 ? 3 : 1);
1707 err[0] = R - r*(isrgb8 ? 36 : 255);
1708 err[1] = G - g*(isrgb8 ? 36 : 85);
1709 err[2] = B - b*(isrgb8 ? 85 : 255);
1714 #define A_DITHER(u,v) (((((u)+((v)*236))*119)&0xff))
1715 r = (((R >> 19) +
A_DITHER(i,y) -96)>>8);
1716 g = (((G >> 19) +
A_DITHER(i + 17,y) - 96)>>8);
1717 b = (((B >> 20) +
A_DITHER(i + 17*2,y) -96)>>8);
1718 r = av_clip_uintp2(r, 3);
1719 g = av_clip_uintp2(g, 3);
1720 b = av_clip_uintp2(b, 2);
1722 r = (((R >> 21) +
A_DITHER(i,y)-256)>>8);
1723 g = (((G >> 19) +
A_DITHER(i + 17,y)-256)>>8);
1724 b = (((B >> 21) +
A_DITHER(i + 17*2,y)-256)>>8);
1725 r = av_clip_uintp2(r, 1);
1726 g = av_clip_uintp2(g, 2);
1727 b = av_clip_uintp2(b, 1);
1733 #define X_DITHER(u,v) (((((u)^((v)*237))*181)&0x1ff)/2)
1734 r = (((R >> 19) +
X_DITHER(i,y) - 96)>>8);
1735 g = (((G >> 19) +
X_DITHER(i + 17,y) - 96)>>8);
1736 b = (((B >> 20) +
X_DITHER(i + 17*2,y) - 96)>>8);
1737 r = av_clip_uintp2(r, 3);
1738 g = av_clip_uintp2(g, 3);
1739 b = av_clip_uintp2(b, 2);
1741 r = (((R >> 21) +
X_DITHER(i,y)-256)>>8);
1742 g = (((G >> 19) +
X_DITHER(i + 17,y)-256)>>8);
1743 b = (((B >> 21) +
X_DITHER(i + 17*2,y)-256)>>8);
1744 r = av_clip_uintp2(r, 1);
1745 g = av_clip_uintp2(g, 2);
1746 b = av_clip_uintp2(b, 1);
1753 dest[0] = r + 2*g + 8*
b;
1754 }
else if(target == AV_PIX_FMT_RGB4_BYTE) {
1755 dest[0] = b + 2*g + 8*
r;
1757 dest[0] = r + 8*g + 64*
b;
1758 }
else if(target == AV_PIX_FMT_RGB8) {
1759 dest[0] = b + 4*g + 32*
r;
1768 const int16_t **lumSrc,
int lumFilterSize,
1769 const int16_t *chrFilter,
const int16_t **chrUSrc,
1770 const int16_t **chrVSrc,
int chrFilterSize,
1771 const int16_t **alpSrc,
uint8_t *dest,
1783 for (i = 0; i < dstW; i++) {
1786 int U = (1<<9)-(128 << 19);
1787 int V = (1<<9)-(128 << 19);
1789 for (j = 0; j < lumFilterSize; j++) {
1790 Y += lumSrc[j][i] * lumFilter[j];
1792 for (j = 0; j < chrFilterSize; j++) {
1793 U += chrUSrc[j][i] * chrFilter[j];
1794 V += chrVSrc[j][i] * chrFilter[j];
1801 for (j = 0; j < lumFilterSize; j++) {
1802 A += alpSrc[j][i] * lumFilter[j];
1806 A = av_clip_uint8(A);
1808 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
1818 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1819 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
1820 int yalpha,
int uvalpha,
int y,
1823 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1824 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1825 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1826 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1827 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1828 int yalpha1 = 4096 - yalpha;
1829 int uvalpha1 = 4096 - uvalpha;
1842 for (i = 0; i < dstW; i++) {
1843 int Y = ( buf0[i] * yalpha1 + buf1[i] * yalpha ) >> 10;
1844 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha-(128 << 19)) >> 10;
1845 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha-(128 << 19)) >> 10;
1848 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha + (1<<18)) >> 19;
1850 A = av_clip_uint8(A);
1853 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
1863 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1864 const int16_t *abuf0,
uint8_t *dest,
int dstW,
1868 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1877 if (uvalpha < 2048) {
1879 for (i = 0; i < dstW; i++) {
1880 int Y = buf0[i] << 2;
1881 int U = (ubuf0[i] - (128<<7)) * 4;
1882 int V = (vbuf0[i] - (128<<7)) * 4;
1885 A = (abuf0[i] + 64) >> 7;
1887 A = av_clip_uint8(A);
1890 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
1894 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1896 for (i = 0; i < dstW; i++) {
1897 int Y = buf0[i] << 2;
1898 int U = (ubuf0[i] + ubuf1[i] - (128<<8)) << 1;
1899 int V = (vbuf0[i] + vbuf1[i] - (128<<8)) << 1;
1902 A = (abuf0[i] + 64) >> 7;
1904 A = av_clip_uint8(A);
1907 yuv2rgb_write_full(c, dest, i, Y, A, U, V, y, target, hasAlpha, err);
1923 #if CONFIG_SWSCALE_ALPHA
1944 const int16_t **lumSrc,
int lumFilterSize,
1945 const int16_t *chrFilter, const int16_t **chrUSrc,
1946 const int16_t **chrVSrc,
int chrFilterSize,
1947 const int16_t **alpSrc,
uint8_t **dest,
1953 uint16_t **dest16 = (uint16_t**)dest;
1957 for (i = 0; i < dstW; i++) {
1960 int U = (1 << 9) - (128 << 19);
1961 int V = (1 << 9) - (128 << 19);
1964 for (j = 0; j < lumFilterSize; j++)
1965 Y += lumSrc[j][i] * lumFilter[j];
1967 for (j = 0; j < chrFilterSize; j++) {
1968 U += chrUSrc[j][i] * chrFilter[j];
1969 V += chrVSrc[j][i] * chrFilter[j];
1979 for (j = 0; j < lumFilterSize; j++)
1980 A += alpSrc[j][i] * lumFilter[j];
1983 A = av_clip_uintp2(A, 27);
1986 Y -= c->yuv2rgb_y_offset;
1987 Y *= c->yuv2rgb_y_coeff;
1989 R = Y + V * c->yuv2rgb_v2r_coeff;
1990 G = Y + V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
1991 B = Y + U * c->yuv2rgb_u2b_coeff;
1993 if ((R | G | B) & 0xC0000000) {
1994 R = av_clip_uintp2(R, 30);
1995 G = av_clip_uintp2(G, 30);
1996 B = av_clip_uintp2(B, 30);
2000 dest16[0][i] = G >>
SH;
2001 dest16[1][i] = B >>
SH;
2002 dest16[2][i] = R >>
SH;
2004 dest16[3][i] = A >> (SH - 3);
2006 dest[0][i] = G >> 22;
2007 dest[1][i] = B >> 22;
2008 dest[2][i] = R >> 22;
2010 dest[3][i] = A >> 19;
2013 if (SH != 22 && (!
isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
2014 for (i = 0; i < dstW; i++) {
2026 const int16_t **lumSrcx,
int lumFilterSize,
2027 const int16_t *chrFilter,
const int16_t **chrUSrcx,
2028 const int16_t **chrVSrcx,
int chrFilterSize,
2029 const int16_t **alpSrcx,
uint8_t **dest,
2035 uint16_t **dest16 = (uint16_t**)dest;
2041 for (i = 0; i < dstW; i++) {
2043 int Y = -0x40000000;
2044 int U = -(128 << 23);
2045 int V = -(128 << 23);
2048 for (j = 0; j < lumFilterSize; j++)
2049 Y += lumSrc[j][i] * (
unsigned)lumFilter[j];
2051 for (j = 0; j < chrFilterSize; j++) {
2052 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
2053 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
2064 for (j = 0; j < lumFilterSize; j++)
2065 A += alpSrc[j][i] * lumFilter[j];
2078 R = av_clip_uintp2(Y + R, 30);
2079 G = av_clip_uintp2(Y + G, 30);
2080 B = av_clip_uintp2(Y + B, 30);
2082 dest16[0][i] = G >> 14;
2083 dest16[1][i] = B >> 14;
2084 dest16[2][i] = R >> 14;
2086 dest16[3][i] = av_clip_uintp2(A, 30) >> 14;
2089 for (i = 0; i < dstW; i++) {
2101 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2102 const int16_t *abuf0,
uint8_t *dest,
int dstW,
2105 int hasAlpha = !!abuf0;
2108 for (i = 0; i < dstW; i++) {
2109 int Y = (buf0[i] + 64) >> 7;
2112 Y = av_clip_uint8(Y);
2115 A = (abuf0[i] + 64) >> 7;
2117 A = av_clip_uint8(A);
2121 dest[i * 2 + 1] = hasAlpha ? A : 255;
2127 const int16_t *ubuf[2],
const int16_t *vbuf[2],
2128 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
2129 int yalpha,
int uvalpha,
int y)
2131 int hasAlpha = abuf && abuf[0] && abuf[1];
2132 const int16_t *buf0 = buf[0], *buf1 = buf[1],
2133 *abuf0 = hasAlpha ? abuf[0] :
NULL,
2134 *abuf1 = hasAlpha ? abuf[1] :
NULL;
2135 int yalpha1 = 4096 - yalpha;
2140 for (i = 0; i < dstW; i++) {
2141 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
2144 Y = av_clip_uint8(Y);
2147 A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19;
2148 A = av_clip_uint8(A);
2152 dest[i * 2 + 1] = hasAlpha ? A : 255;
2158 const int16_t **lumSrc,
int lumFilterSize,
2159 const int16_t *chrFilter,
const int16_t **chrUSrc,
2160 const int16_t **chrVSrc,
int chrFilterSize,
2161 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
int y)
2163 int hasAlpha = !!alpSrc;
2166 for (i = 0; i < dstW; i++) {
2168 int Y = 1 << 18,
A = 1 << 18;
2170 for (j = 0; j < lumFilterSize; j++)
2171 Y += lumSrc[j][i] * lumFilter[j];
2175 Y = av_clip_uint8(Y);
2178 for (j = 0; j < lumFilterSize; j++)
2179 A += alpSrc[j][i] * lumFilter[j];
2184 A = av_clip_uint8(
A);
2188 dest[2 * i + 1] = hasAlpha ?
A : 255;
2194 const int16_t **_lumSrc,
int lumFilterSize,
2195 const int16_t *chrFilter,
const int16_t **_chrUSrc,
2196 const int16_t **_chrVSrc,
int chrFilterSize,
2197 const int16_t **_alpSrc,
uint8_t *dest,
int dstW,
int y)
2200 **chrUSrc = (
const int32_t **) _chrUSrc,
2201 **chrVSrc = (
const int32_t **) _chrVSrc,
2202 **alpSrc = (
const int32_t **) _alpSrc;
2203 int hasAlpha = !!alpSrc;
2206 for (i = 0; i < dstW; i++) {
2207 int Y = 1 << 14,
U = 1 << 14;
2208 int V = 1 << 14,
A = 1 << 14;
2216 for (j = 0; j < lumFilterSize; j++)
2217 Y += lumSrc[j][i] * (
unsigned)lumFilter[j];
2219 for (j = 0; j < chrFilterSize; j++)
2220 U += chrUSrc[j][i] * (
unsigned)chrFilter[j];
2222 for (j = 0; j < chrFilterSize; j++)
2223 V += chrVSrc[j][i] * (
unsigned)chrFilter[j];
2226 for (j = 0; j < lumFilterSize; j++)
2227 A += alpSrc[j][i] * (
unsigned)lumFilter[j];
2229 Y = 0x8000 + av_clip_int16(Y >> 15);
2230 U = 0x8000 + av_clip_int16(
U >> 15);
2231 V = 0x8000 + av_clip_int16(V >> 15);
2232 A = 0x8000 + av_clip_int16(
A >> 15);
2234 AV_WL16(dest + 8 * i, hasAlpha ?
A : 65535);
2257 }
else if (
is16BPS(dstFormat)) {
2258 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
2259 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
2260 }
else if (
isNBPS(dstFormat)) {
2262 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
2263 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
2265 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
2266 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
2268 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
2269 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
2271 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
2272 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
2277 *yuv2planeX = yuv2planeX_8_c;
2283 switch (dstFormat) {
2284 case AV_PIX_FMT_RGBA:
2286 *yuv2packedX = yuv2rgba32_full_X_c;
2287 *yuv2packed2 = yuv2rgba32_full_2_c;
2288 *yuv2packed1 = yuv2rgba32_full_1_c;
2290 #if CONFIG_SWSCALE_ALPHA
2292 *yuv2packedX = yuv2rgba32_full_X_c;
2293 *yuv2packed2 = yuv2rgba32_full_2_c;
2294 *yuv2packed1 = yuv2rgba32_full_1_c;
2298 *yuv2packedX = yuv2rgbx32_full_X_c;
2299 *yuv2packed2 = yuv2rgbx32_full_2_c;
2300 *yuv2packed1 = yuv2rgbx32_full_1_c;
2304 case AV_PIX_FMT_ARGB:
2306 *yuv2packedX = yuv2argb32_full_X_c;
2307 *yuv2packed2 = yuv2argb32_full_2_c;
2308 *yuv2packed1 = yuv2argb32_full_1_c;
2310 #if CONFIG_SWSCALE_ALPHA
2312 *yuv2packedX = yuv2argb32_full_X_c;
2313 *yuv2packed2 = yuv2argb32_full_2_c;
2314 *yuv2packed1 = yuv2argb32_full_1_c;
2318 *yuv2packedX = yuv2xrgb32_full_X_c;
2319 *yuv2packed2 = yuv2xrgb32_full_2_c;
2320 *yuv2packed1 = yuv2xrgb32_full_1_c;
2326 *yuv2packedX = yuv2bgra32_full_X_c;
2327 *yuv2packed2 = yuv2bgra32_full_2_c;
2328 *yuv2packed1 = yuv2bgra32_full_1_c;
2330 #if CONFIG_SWSCALE_ALPHA
2332 *yuv2packedX = yuv2bgra32_full_X_c;
2333 *yuv2packed2 = yuv2bgra32_full_2_c;
2334 *yuv2packed1 = yuv2bgra32_full_1_c;
2338 *yuv2packedX = yuv2bgrx32_full_X_c;
2339 *yuv2packed2 = yuv2bgrx32_full_2_c;
2340 *yuv2packed1 = yuv2bgrx32_full_1_c;
2344 case AV_PIX_FMT_ABGR:
2346 *yuv2packedX = yuv2abgr32_full_X_c;
2347 *yuv2packed2 = yuv2abgr32_full_2_c;
2348 *yuv2packed1 = yuv2abgr32_full_1_c;
2350 #if CONFIG_SWSCALE_ALPHA
2352 *yuv2packedX = yuv2abgr32_full_X_c;
2353 *yuv2packed2 = yuv2abgr32_full_2_c;
2354 *yuv2packed1 = yuv2abgr32_full_1_c;
2358 *yuv2packedX = yuv2xbgr32_full_X_c;
2359 *yuv2packed2 = yuv2xbgr32_full_2_c;
2360 *yuv2packed1 = yuv2xbgr32_full_1_c;
2365 #if CONFIG_SWSCALE_ALPHA
2367 *yuv2packedX = yuv2rgba64le_full_X_c;
2368 *yuv2packed2 = yuv2rgba64le_full_2_c;
2369 *yuv2packed1 = yuv2rgba64le_full_1_c;
2373 *yuv2packedX = yuv2rgbx64le_full_X_c;
2374 *yuv2packed2 = yuv2rgbx64le_full_2_c;
2375 *yuv2packed1 = yuv2rgbx64le_full_1_c;
2379 #if CONFIG_SWSCALE_ALPHA
2381 *yuv2packedX = yuv2rgba64be_full_X_c;
2382 *yuv2packed2 = yuv2rgba64be_full_2_c;
2383 *yuv2packed1 = yuv2rgba64be_full_1_c;
2387 *yuv2packedX = yuv2rgbx64be_full_X_c;
2388 *yuv2packed2 = yuv2rgbx64be_full_2_c;
2389 *yuv2packed1 = yuv2rgbx64be_full_1_c;
2393 #if CONFIG_SWSCALE_ALPHA
2395 *yuv2packedX = yuv2bgra64le_full_X_c;
2396 *yuv2packed2 = yuv2bgra64le_full_2_c;
2397 *yuv2packed1 = yuv2bgra64le_full_1_c;
2401 *yuv2packedX = yuv2bgrx64le_full_X_c;
2402 *yuv2packed2 = yuv2bgrx64le_full_2_c;
2403 *yuv2packed1 = yuv2bgrx64le_full_1_c;
2407 #if CONFIG_SWSCALE_ALPHA
2409 *yuv2packedX = yuv2bgra64be_full_X_c;
2410 *yuv2packed2 = yuv2bgra64be_full_2_c;
2411 *yuv2packed1 = yuv2bgra64be_full_1_c;
2415 *yuv2packedX = yuv2bgrx64be_full_X_c;
2416 *yuv2packed2 = yuv2bgrx64be_full_2_c;
2417 *yuv2packed1 = yuv2bgrx64be_full_1_c;
2422 *yuv2packedX = yuv2rgb24_full_X_c;
2423 *yuv2packed2 = yuv2rgb24_full_2_c;
2424 *yuv2packed1 = yuv2rgb24_full_1_c;
2427 *yuv2packedX = yuv2bgr24_full_X_c;
2428 *yuv2packed2 = yuv2bgr24_full_2_c;
2429 *yuv2packed1 = yuv2bgr24_full_1_c;
2432 *yuv2packedX = yuv2rgb48le_full_X_c;
2433 *yuv2packed2 = yuv2rgb48le_full_2_c;
2434 *yuv2packed1 = yuv2rgb48le_full_1_c;
2437 *yuv2packedX = yuv2bgr48le_full_X_c;
2438 *yuv2packed2 = yuv2bgr48le_full_2_c;
2439 *yuv2packed1 = yuv2bgr48le_full_1_c;
2442 *yuv2packedX = yuv2rgb48be_full_X_c;
2443 *yuv2packed2 = yuv2rgb48be_full_2_c;
2444 *yuv2packed1 = yuv2rgb48be_full_1_c;
2447 *yuv2packedX = yuv2bgr48be_full_X_c;
2448 *yuv2packed2 = yuv2bgr48be_full_2_c;
2449 *yuv2packed1 = yuv2bgr48be_full_1_c;
2452 *yuv2packedX = yuv2bgr4_byte_full_X_c;
2453 *yuv2packed2 = yuv2bgr4_byte_full_2_c;
2454 *yuv2packed1 = yuv2bgr4_byte_full_1_c;
2457 *yuv2packedX = yuv2rgb4_byte_full_X_c;
2458 *yuv2packed2 = yuv2rgb4_byte_full_2_c;
2459 *yuv2packed1 = yuv2rgb4_byte_full_1_c;
2462 *yuv2packedX = yuv2bgr8_full_X_c;
2463 *yuv2packed2 = yuv2bgr8_full_2_c;
2464 *yuv2packed1 = yuv2bgr8_full_1_c;
2467 *yuv2packedX = yuv2rgb8_full_X_c;
2468 *yuv2packed2 = yuv2rgb8_full_2_c;
2469 *yuv2packed1 = yuv2rgb8_full_1_c;
2494 if (!*yuv2packedX && !*yuv2anyX)
2498 switch (dstFormat) {
2500 #if CONFIG_SWSCALE_ALPHA
2502 *yuv2packed1 = yuv2rgba64le_1_c;
2503 *yuv2packed2 = yuv2rgba64le_2_c;
2504 *yuv2packedX = yuv2rgba64le_X_c;
2508 *yuv2packed1 = yuv2rgbx64le_1_c;
2509 *yuv2packed2 = yuv2rgbx64le_2_c;
2510 *yuv2packedX = yuv2rgbx64le_X_c;
2514 #if CONFIG_SWSCALE_ALPHA
2516 *yuv2packed1 = yuv2rgba64be_1_c;
2517 *yuv2packed2 = yuv2rgba64be_2_c;
2518 *yuv2packedX = yuv2rgba64be_X_c;
2522 *yuv2packed1 = yuv2rgbx64be_1_c;
2523 *yuv2packed2 = yuv2rgbx64be_2_c;
2524 *yuv2packedX = yuv2rgbx64be_X_c;
2528 #if CONFIG_SWSCALE_ALPHA
2530 *yuv2packed1 = yuv2bgra64le_1_c;
2531 *yuv2packed2 = yuv2bgra64le_2_c;
2532 *yuv2packedX = yuv2bgra64le_X_c;
2536 *yuv2packed1 = yuv2bgrx64le_1_c;
2537 *yuv2packed2 = yuv2bgrx64le_2_c;
2538 *yuv2packedX = yuv2bgrx64le_X_c;
2542 #if CONFIG_SWSCALE_ALPHA
2544 *yuv2packed1 = yuv2bgra64be_1_c;
2545 *yuv2packed2 = yuv2bgra64be_2_c;
2546 *yuv2packedX = yuv2bgra64be_X_c;
2550 *yuv2packed1 = yuv2bgrx64be_1_c;
2551 *yuv2packed2 = yuv2bgrx64be_2_c;
2552 *yuv2packedX = yuv2bgrx64be_X_c;
2556 *yuv2packed1 = yuv2rgb48le_1_c;
2557 *yuv2packed2 = yuv2rgb48le_2_c;
2558 *yuv2packedX = yuv2rgb48le_X_c;
2561 *yuv2packed1 = yuv2rgb48be_1_c;
2562 *yuv2packed2 = yuv2rgb48be_2_c;
2563 *yuv2packedX = yuv2rgb48be_X_c;
2566 *yuv2packed1 = yuv2bgr48le_1_c;
2567 *yuv2packed2 = yuv2bgr48le_2_c;
2568 *yuv2packedX = yuv2bgr48le_X_c;
2571 *yuv2packed1 = yuv2bgr48be_1_c;
2572 *yuv2packed2 = yuv2bgr48be_2_c;
2573 *yuv2packedX = yuv2bgr48be_X_c;
2575 case AV_PIX_FMT_RGB32:
2578 *yuv2packed1 = yuv2rgb32_1_c;
2579 *yuv2packed2 = yuv2rgb32_2_c;
2580 *yuv2packedX = yuv2rgb32_X_c;
2582 #if CONFIG_SWSCALE_ALPHA
2584 *yuv2packed1 = yuv2rgba32_1_c;
2585 *yuv2packed2 = yuv2rgba32_2_c;
2586 *yuv2packedX = yuv2rgba32_X_c;
2590 *yuv2packed1 = yuv2rgbx32_1_c;
2591 *yuv2packed2 = yuv2rgbx32_2_c;
2592 *yuv2packedX = yuv2rgbx32_X_c;
2599 *yuv2packed1 = yuv2rgb32_1_1_c;
2600 *yuv2packed2 = yuv2rgb32_1_2_c;
2601 *yuv2packedX = yuv2rgb32_1_X_c;
2603 #if CONFIG_SWSCALE_ALPHA
2605 *yuv2packed1 = yuv2rgba32_1_1_c;
2606 *yuv2packed2 = yuv2rgba32_1_2_c;
2607 *yuv2packedX = yuv2rgba32_1_X_c;
2611 *yuv2packed1 = yuv2rgbx32_1_1_c;
2612 *yuv2packed2 = yuv2rgbx32_1_2_c;
2613 *yuv2packedX = yuv2rgbx32_1_X_c;
2618 *yuv2packed1 = yuv2rgb24_1_c;
2619 *yuv2packed2 = yuv2rgb24_2_c;
2620 *yuv2packedX = yuv2rgb24_X_c;
2623 *yuv2packed1 = yuv2bgr24_1_c;
2624 *yuv2packed2 = yuv2bgr24_2_c;
2625 *yuv2packedX = yuv2bgr24_X_c;
2631 *yuv2packed1 = yuv2rgb16_1_c;
2632 *yuv2packed2 = yuv2rgb16_2_c;
2633 *yuv2packedX = yuv2rgb16_X_c;
2639 *yuv2packed1 = yuv2rgb15_1_c;
2640 *yuv2packed2 = yuv2rgb15_2_c;
2641 *yuv2packedX = yuv2rgb15_X_c;
2647 *yuv2packed1 = yuv2rgb12_1_c;
2648 *yuv2packed2 = yuv2rgb12_2_c;
2649 *yuv2packedX = yuv2rgb12_X_c;
2653 *yuv2packed1 = yuv2rgb8_1_c;
2654 *yuv2packed2 = yuv2rgb8_2_c;
2655 *yuv2packedX = yuv2rgb8_X_c;
2659 *yuv2packed1 = yuv2rgb4_1_c;
2660 *yuv2packed2 = yuv2rgb4_2_c;
2661 *yuv2packedX = yuv2rgb4_X_c;
2665 *yuv2packed1 = yuv2rgb4b_1_c;
2666 *yuv2packed2 = yuv2rgb4b_2_c;
2667 *yuv2packedX = yuv2rgb4b_X_c;
2671 switch (dstFormat) {
2673 *yuv2packed1 = yuv2monowhite_1_c;
2674 *yuv2packed2 = yuv2monowhite_2_c;
2675 *yuv2packedX = yuv2monowhite_X_c;
2678 *yuv2packed1 = yuv2monoblack_1_c;
2679 *yuv2packed2 = yuv2monoblack_2_c;
2680 *yuv2packedX = yuv2monoblack_X_c;
2683 *yuv2packed1 = yuv2yuyv422_1_c;
2684 *yuv2packed2 = yuv2yuyv422_2_c;
2685 *yuv2packedX = yuv2yuyv422_X_c;
2688 *yuv2packed1 = yuv2yvyu422_1_c;
2689 *yuv2packed2 = yuv2yvyu422_2_c;
2690 *yuv2packedX = yuv2yvyu422_X_c;
2693 *yuv2packed1 = yuv2uyvy422_1_c;
2694 *yuv2packed2 = yuv2uyvy422_2_c;
2695 *yuv2packedX = yuv2uyvy422_X_c;
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
planar GBR 4:4:4:4 40bpp, little-endian
const char const char void * val
static av_always_inline void yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
static void yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **_lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **_chrUSrc, const int16_t **_chrVSrc, int chrFilterSize, const int16_t **_alpSrc, uint8_t *dest, int dstW, int y)
av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, yuv2interleavedX_fn *yuv2nv12cX, yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX, yuv2anyX_fn *yuv2anyX)
static void yuv2gbrp16_full_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrcx, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrcx, const int16_t **chrVSrcx, int chrFilterSize, const int16_t **alpSrcx, uint8_t **dest, int dstW, int y)
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define YUVRGB_TABLE_HEADROOM
static void yuv2p010lX_BE_c(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
8 bits gray, 8 bits alpha
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
packed RGB 8:8:8, 24bpp, RGBRGB...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
#define accumulate_bit(acc, val)
static void yuv2rgb(uint8_t *out, int ridx, int Y, int U, int V)
const uint8_t ff_dither_2x2_8[][8]
static av_always_inline void yuv2rgb_full_1_c_template(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
static void yuv2p010l1_LE_c(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
uint8_t * table_bU[256+2 *YUVRGB_TABLE_HEADROOM]
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
Convenience header that includes libavutil's core.
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
planar GBR 4:4:4 36bpp, little-endian
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
#define AV_PIX_FMT_RGB444
planar GBR 4:4:4 36bpp, big-endian
const uint8_t ff_dither_8x8_220[][8]
static av_always_inline void yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW, int big_endian, int output_bits)
static av_always_inline void yuv2planeX_16_c_template(const int16_t *filter, int filterSize, const int32_t **src, uint16_t *dest, int dstW, int big_endian, int output_bits)
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
#define output_pixels(pos, Y1, U, Y2, V)
Macro definitions for various function/variable attributes.
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
const uint8_t ff_dither_8x8_32[][8]
planar GBRA 4:4:4:4 64bpp, big-endian
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const uint8_t ff_dither_2x2_4[][8]
void(* yuv2interleavedX_fn)(struct SwsContext *c, const int16_t *chrFilter, int chrFilterSize, const int16_t **chrUSrc, const int16_t **chrVSrc, uint8_t *dest, int dstW)
Write one line of horizontally scaled chroma to interleaved output with multi-point vertical scaling ...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
const uint8_t ff_dither_4x4_16[][8]
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
void(* yuv2anyX_fn)(struct SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t **dest, int dstW, int y)
Write one line of horizontally scaled Y/U/V/A to YUV/RGB output by doing multi-point vertical scaling...
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
static void yuv2ya8_2_c(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined ...
#define SWS_FULL_CHR_H_INT
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static void yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t **dest, int dstW, int y)
static av_always_inline void yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
planar GBR 4:4:4 48bpp, big-endian
static av_always_inline void yuv2rgb_full_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
static av_always_inline void yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y, enum AVPixelFormat target, int hasAlpha)
enum AVPixelFormat dstFormat
Destination pixel format.
uint8_t * table_gU[256+2 *YUVRGB_TABLE_HEADROOM]
static void yuv2p010cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize, const int16_t **chrUSrc, const int16_t **chrVSrc, uint8_t *dest8, int chrDstW)
static void yuv2p010l1_c(const int16_t *src, uint16_t *dest, int dstW, int big_endian)
void(* yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc, uint8_t *dest, int dstW, int uvalpha, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output without any additional v...
planar GBR 4:4:4 27bpp, big-endian
#define AV_PIX_FMT_BGR32_1
static av_always_inline void yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
static void yuv2p010l1_BE_c(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static const uint8_t dither[8][8]
static av_always_inline void yuv2rgba64_X_c_template(SwsContext *c, const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
static void yuv2p010lX_LE_c(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
simple assert() macros that are a bit more flexible than ISO C assert().
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian
static av_always_inline void yuv2planeX_10_c_template(const int16_t *filter, int filterSize, const int16_t **src, uint16_t *dest, int dstW, int big_endian, int output_bits)
static const uint8_t offset[127][2]
#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static av_always_inline void yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target)
static av_always_inline void yuv2422_1_c_template(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target)
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
as above, but U and V bytes are swapped
planar GBR 4:4:4:4 48bpp, big-endian
void(* yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Write one line of horizontally scaled data to planar output without any additional vertical scaling (...
planar GBR 4:4:4:4 40bpp, big-endian
static void yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
static av_always_inline void yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target)
static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
int table_gV[256+2 *YUVRGB_TABLE_HEADROOM]
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t * table_rV[256+2 *YUVRGB_TABLE_HEADROOM]
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
planar GBR 4:4:4:4 48bpp, little-endian
#define AV_PIX_FMT_BGR555
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
#define YUV2PACKED16WRAPPER(name, base, ext, fmt, hasAlpha, eightbytes)
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
static av_always_inline void yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y, enum AVPixelFormat target)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static void yuv2ya8_1_c(SwsContext *c, const int16_t *buf0, const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int y)
planar GBR 4:4:4 30bpp, big-endian
static av_always_inline void yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2], const int16_t *ubuf[2], const int16_t *vbuf[2], const int16_t *abuf[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha)
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
planar GBR 4:4:4 42bpp, little-endian
const uint8_t ff_dither_8x8_73[][8]
static av_always_inline void yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y, enum AVPixelFormat target)
planar GBR 4:4:4 42bpp, big-endian
static av_always_inline void yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, unsigned A1, unsigned A2, const void *_r, const void *_g, const void *_b, int y, enum AVPixelFormat target, int hasAlpha)
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined ...
static av_always_inline void yuv2rgba64_full_X_c_template(SwsContext *c, const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
static void yuv2p010lX_c(const int16_t *filter, int filterSize, const int16_t **src, uint16_t *dest, int dstW, int big_endian)
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha)
#define AV_PIX_FMT_BGR565
const uint8_t * chrDither8
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
void(* yuv2planarX_fn)(const int16_t *filter, int filterSize, const int16_t **src, uint8_t *dest, int dstW, const uint8_t *dither, int offset)
Write one line of horizontally scaled data to planar output with multi-point vertical scaling between...
void(* yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2], const int16_t *chrUSrc[2], const int16_t *chrVSrc[2], const int16_t *alpSrc[2], uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output by doing bilinear scalin...
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
planar GBRA 4:4:4:4 32bpp
static av_always_inline void yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y, enum AVPixelFormat target, int hasAlpha)
planar GBR 4:4:4 27bpp, little-endian
void(* yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, int dstW, int y)
Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB output by doing multi-point ver...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define AV_PIX_FMT_BGR444
#define output_pixel(pos, val, bias, signedness)
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
#define AV_PIX_FMT_RGB555
static av_always_inline void yuv2rgb_write_full(SwsContext *c, uint8_t *dest, int i, int Y, int A, int U, int V, int y, enum AVPixelFormat target, int hasAlpha, int err[4])
static av_always_inline void yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
static av_always_inline void yuv2rgba64_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
#define AV_PIX_FMT_RGB32_1
static av_always_inline void yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW, int big_endian, int output_bits)
static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize, const int16_t **chrUSrc, const int16_t **chrVSrc, uint8_t *dest, int chrDstW)
static av_always_inline void yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes)
#define AV_PIX_FMT_RGB565
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
planar GBR 4:4:4 48bpp, little-endian
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined ...
int depth
Number of bits in the component.
planar GBRA 4:4:4:4 64bpp, little-endian
#define YUV2PACKEDWRAPPER(name, base, ext, fmt)
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
AVPixelFormat
Pixel format.
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
planar GBR 4:4:4 30bpp, little-endian
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian