41 { 1, 3, 1, 3, 1, 3, 1, 3, },
42 { 2, 0, 2, 0, 2, 0, 2, 0, },
43 { 1, 3, 1, 3, 1, 3, 1, 3, },
47 { 6, 2, 6, 2, 6, 2, 6, 2, },
48 { 0, 4, 0, 4, 0, 4, 0, 4, },
49 { 6, 2, 6, 2, 6, 2, 6, 2, },
53 { 8, 4, 11, 7, 8, 4, 11, 7, },
54 { 2, 14, 1, 13, 2, 14, 1, 13, },
55 { 10, 6, 9, 5, 10, 6, 9, 5, },
56 { 0, 12, 3, 15, 0, 12, 3, 15, },
57 { 8, 4, 11, 7, 8, 4, 11, 7, },
61 { 17, 9, 23, 15, 16, 8, 22, 14, },
62 { 5, 29, 3, 27, 4, 28, 2, 26, },
63 { 21, 13, 19, 11, 20, 12, 18, 10, },
64 { 0, 24, 6, 30, 1, 25, 7, 31, },
65 { 16, 8, 22, 14, 17, 9, 23, 15, },
66 { 4, 28, 2, 26, 5, 29, 3, 27, },
67 { 20, 12, 18, 10, 21, 13, 19, 11, },
68 { 1, 25, 7, 31, 0, 24, 6, 30, },
69 { 17, 9, 23, 15, 16, 8, 22, 14, },
73 { 0, 55, 14, 68, 3, 58, 17, 72, },
74 { 37, 18, 50, 32, 40, 22, 54, 35, },
75 { 9, 64, 5, 59, 13, 67, 8, 63, },
76 { 46, 27, 41, 23, 49, 31, 44, 26, },
77 { 2, 57, 16, 71, 1, 56, 15, 70, },
78 { 39, 21, 52, 34, 38, 19, 51, 33, },
79 { 11, 66, 7, 62, 10, 65, 6, 60, },
80 { 48, 30, 43, 25, 47, 29, 42, 24, },
81 { 0, 55, 14, 68, 3, 58, 17, 72, },
86 {117, 62, 158, 103, 113, 58, 155, 100, },
87 { 34, 199, 21, 186, 31, 196, 17, 182, },
88 {144, 89, 131, 76, 141, 86, 127, 72, },
89 { 0, 165, 41, 206, 10, 175, 52, 217, },
90 {110, 55, 151, 96, 120, 65, 162, 107, },
91 { 28, 193, 14, 179, 38, 203, 24, 189, },
92 {138, 83, 124, 69, 148, 93, 134, 79, },
93 { 7, 172, 48, 213, 3, 168, 45, 210, },
94 {117, 62, 158, 103, 113, 58, 155, 100, },
99 { 0, 143, 18, 200, 2, 156, 25, 215, },
100 { 78, 28, 125, 64, 89, 36, 138, 74, },
101 { 10, 180, 3, 161, 16, 195, 8, 175, },
102 {109, 51, 93, 38, 121, 60, 105, 47, },
103 { 1, 152, 23, 210, 0, 147, 20, 205, },
104 { 85, 33, 134, 71, 81, 30, 130, 67, },
105 { 14, 190, 6, 171, 12, 185, 5, 166, },
106 {117, 57, 101, 44, 113, 54, 97, 41, },
107 { 0, 143, 18, 200, 2, 156, 25, 215, },
112 { 0, 124, 8, 193, 0, 140, 12, 213, },
113 { 55, 14, 104, 42, 66, 19, 119, 52, },
114 { 3, 168, 1, 145, 6, 187, 3, 162, },
115 { 86, 31, 70, 21, 99, 39, 82, 28, },
116 { 0, 134, 11, 206, 0, 129, 9, 200, },
117 { 62, 17, 114, 48, 58, 16, 109, 45, },
118 { 5, 181, 2, 157, 4, 175, 1, 151, },
119 { 95, 36, 78, 26, 90, 34, 74, 24, },
120 { 0, 124, 8, 193, 0, 140, 12, 213, },
125 { 0, 107, 3, 187, 0, 125, 6, 212, },
126 { 39, 7, 86, 28, 49, 11, 102, 36, },
127 { 1, 158, 0, 131, 3, 180, 1, 151, },
128 { 68, 19, 52, 12, 81, 25, 64, 17, },
129 { 0, 119, 5, 203, 0, 113, 4, 195, },
130 { 45, 9, 96, 33, 42, 8, 91, 30, },
131 { 2, 172, 1, 144, 2, 165, 0, 137, },
132 { 77, 23, 60, 15, 72, 21, 56, 14, },
133 { 0, 107, 3, 187, 0, 125, 6, 212, },
137 #define output_pixel(pos, val, bias, signedness) \
139 AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
141 AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
146 int big_endian,
int output_bits)
152 for (i = 0; i < dstW; i++) {
153 int val = src[i] + (1 << (shift - 1));
160 const int32_t **src, uint16_t *dest,
int dstW,
161 int big_endian,
int output_bits)
167 for (i = 0; i < dstW; i++) {
168 int val = 1 << (shift - 1);
177 for (j = 0; j < filterSize; j++)
178 val += src[j][i] * (
unsigned)filter[j];
186 #define output_pixel(pos, val) \
188 AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
190 AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
195 int big_endian,
int output_bits)
198 int shift = 15 - output_bits;
200 for (i = 0; i < dstW; i++) {
201 int val = src[i] + (1 << (shift - 1));
208 const int16_t **src, uint16_t *dest,
int dstW,
209 int big_endian,
int output_bits)
212 int shift = 11 + 16 - output_bits;
214 for (i = 0; i < dstW; i++) {
215 int val = 1 << (shift - 1);
218 for (j = 0; j < filterSize; j++)
219 val += src[j][i] * filter[j];
227 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
228 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
229 uint8_t *dest, int dstW, \
230 const uint8_t *dither, int offset)\
232 yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
233 (uint16_t *) dest, dstW, is_be, bits); \
235 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
236 const int16_t **src, uint8_t *dest, int dstW, \
237 const uint8_t *dither, int offset)\
239 yuv2planeX_## template_size ## _c_template(filter, \
240 filterSize, (const typeX_t **) src, \
241 (uint16_t *) dest, dstW, is_be, bits); \
245 yuv2NBPS(10, BE, 1, 10, int16_t)
246 yuv2NBPS(10, LE, 0, 10, int16_t)
247 yuv2NBPS(12, BE, 1, 10, int16_t)
248 yuv2NBPS(12, LE, 0, 10, int16_t)
249 yuv2NBPS(14, BE, 1, 10, int16_t)
250 yuv2NBPS(14, LE, 0, 10, int16_t)
251 yuv2NBPS(16, BE, 1, 16,
int32_t)
252 yuv2NBPS(16, LE, 0, 16,
int32_t)
254 static
void yuv2planeX_8_c(const int16_t *
filter,
int filterSize,
255 const int16_t **src,
uint8_t *dest,
int dstW,
259 for (i=0; i<dstW; i++) {
260 int val = dither[(i +
offset) & 7] << 12;
262 for (j=0; j<filterSize; j++)
263 val += src[j][i] * filter[j];
265 dest[i]= av_clip_uint8(val>>19);
273 for (i=0; i<dstW; i++) {
274 int val = (src[i] + dither[(i +
offset) & 7]) >> 7;
275 dest[i]= av_clip_uint8(val);
280 const int16_t **chrUSrc,
const int16_t **chrVSrc,
288 for (i=0; i<chrDstW; i++) {
289 int u = chrDither[i & 7] << 12;
290 int v = chrDither[(i + 3) & 7] << 12;
292 for (j=0; j<chrFilterSize; j++) {
293 u += chrUSrc[j][i] * chrFilter[j];
294 v += chrVSrc[j][i] * chrFilter[j];
297 dest[2*i]= av_clip_uint8(u>>19);
298 dest[2*i+1]= av_clip_uint8(v>>19);
301 for (i=0; i<chrDstW; i++) {
302 int u = chrDither[i & 7] << 12;
303 int v = chrDither[(i + 3) & 7] << 12;
305 for (j=0; j<chrFilterSize; j++) {
306 u += chrUSrc[j][i] * chrFilter[j];
307 v += chrVSrc[j][i] * chrFilter[j];
310 dest[2*i]= av_clip_uint8(v>>19);
311 dest[2*i+1]= av_clip_uint8(u>>19);
315 #define accumulate_bit(acc, val) \
317 acc |= (val) >= (128 + 110)
318 #define output_pixel(pos, acc) \
319 if (target == AV_PIX_FMT_MONOBLACK) { \
327 const int16_t **lumSrc,
int lumFilterSize,
328 const int16_t *chrFilter,
const int16_t **chrUSrc,
329 const int16_t **chrVSrc,
int chrFilterSize,
330 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
337 for (i = 0; i < dstW; i += 2) {
342 for (j = 0; j < lumFilterSize; j++) {
343 Y1 += lumSrc[j][i] * lumFilter[j];
344 Y2 += lumSrc[j][i+1] * lumFilter[j];
348 if ((Y1 | Y2) & 0x100) {
349 Y1 = av_clip_uint8(Y1);
350 Y2 = av_clip_uint8(Y2);
366 const int16_t *ubuf[2],
const int16_t *vbuf[2],
367 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
368 int yalpha,
int uvalpha,
int y,
371 const int16_t *buf0 = buf[0], *buf1 = buf[1];
373 int yalpha1 = 4096 - yalpha;
376 for (i = 0; i < dstW; i += 8) {
379 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
381 Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
383 Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
385 Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
387 Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
389 Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
391 Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
393 Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
402 const int16_t *ubuf[2],
const int16_t *vbuf[2],
403 const int16_t *abuf0,
uint8_t *dest,
int dstW,
409 for (i = 0; i < dstW; i += 8) {
426 #undef accumulate_bit
428 #define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
429 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
430 const int16_t **lumSrc, int lumFilterSize, \
431 const int16_t *chrFilter, const int16_t **chrUSrc, \
432 const int16_t **chrVSrc, int chrFilterSize, \
433 const int16_t **alpSrc, uint8_t *dest, int dstW, \
436 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
437 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
438 alpSrc, dest, dstW, y, fmt); \
441 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
442 const int16_t *ubuf[2], const int16_t *vbuf[2], \
443 const int16_t *abuf[2], uint8_t *dest, int dstW, \
444 int yalpha, int uvalpha, int y) \
446 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
447 dest, dstW, yalpha, uvalpha, y, fmt); \
450 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
451 const int16_t *ubuf[2], const int16_t *vbuf[2], \
452 const int16_t *abuf0, uint8_t *dest, int dstW, \
453 int uvalpha, int y) \
455 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
456 abuf0, dest, dstW, uvalpha, \
463 #define output_pixels(pos, Y1, U, Y2, V) \
464 if (target == AV_PIX_FMT_YUYV422) { \
465 dest[pos + 0] = Y1; \
467 dest[pos + 2] = Y2; \
471 dest[pos + 1] = Y1; \
473 dest[pos + 3] = Y2; \
478 const int16_t **lumSrc,
int lumFilterSize,
479 const int16_t *chrFilter,
const int16_t **chrUSrc,
480 const int16_t **chrVSrc,
int chrFilterSize,
481 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
486 for (i = 0; i < ((dstW + 1) >> 1); i++) {
493 for (j = 0; j < lumFilterSize; j++) {
494 Y1 += lumSrc[j][i * 2] * lumFilter[j];
495 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
497 for (j = 0; j < chrFilterSize; j++) {
498 U += chrUSrc[j][i] * chrFilter[j];
499 V += chrVSrc[j][i] * chrFilter[j];
505 if ((Y1 | Y2 | U | V) & 0x100) {
506 Y1 = av_clip_uint8(Y1);
507 Y2 = av_clip_uint8(Y2);
508 U = av_clip_uint8(U);
509 V = av_clip_uint8(V);
517 const int16_t *ubuf[2],
const int16_t *vbuf[2],
518 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
519 int yalpha,
int uvalpha,
int y,
522 const int16_t *buf0 = buf[0], *buf1 = buf[1],
523 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
524 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
525 int yalpha1 = 4096 - yalpha;
526 int uvalpha1 = 4096 - uvalpha;
529 for (i = 0; i < ((dstW + 1) >> 1); i++) {
530 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
531 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
532 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
533 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
535 if ((Y1 | Y2 | U | V) & 0x100) {
536 Y1 = av_clip_uint8(Y1);
537 Y2 = av_clip_uint8(Y2);
538 U = av_clip_uint8(U);
539 V = av_clip_uint8(V);
548 const int16_t *ubuf[2],
const int16_t *vbuf[2],
549 const int16_t *abuf0,
uint8_t *dest,
int dstW,
552 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
555 if (uvalpha < 2048) {
556 for (i = 0; i < ((dstW + 1) >> 1); i++) {
557 int Y1 = (buf0[i * 2 ]+64) >> 7;
558 int Y2 = (buf0[i * 2 + 1]+64) >> 7;
559 int U = (ubuf0[i] +64) >> 7;
560 int V = (vbuf0[i] +64) >> 7;
562 if ((Y1 | Y2 | U | V) & 0x100) {
563 Y1 = av_clip_uint8(Y1);
564 Y2 = av_clip_uint8(Y2);
565 U = av_clip_uint8(U);
566 V = av_clip_uint8(V);
569 Y1 = av_clip_uint8(Y1);
570 Y2 = av_clip_uint8(Y2);
571 U = av_clip_uint8(U);
572 V = av_clip_uint8(V);
577 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
578 for (i = 0; i < ((dstW + 1) >> 1); i++) {
579 int Y1 = (buf0[i * 2 ] + 64) >> 7;
580 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
581 int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
582 int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
584 if ((Y1 | Y2 | U | V) & 0x100) {
585 Y1 = av_clip_uint8(Y1);
586 Y2 = av_clip_uint8(Y2);
587 U = av_clip_uint8(U);
588 V = av_clip_uint8(V);
591 Y1 = av_clip_uint8(Y1);
592 Y2 = av_clip_uint8(Y2);
593 U = av_clip_uint8(U);
594 V = av_clip_uint8(V);
606 #define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? R : B)
607 #define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? B : R)
608 #define output_pixel(pos, val) \
609 if (isBE(target)) { \
617 const int32_t **lumSrc,
int lumFilterSize,
618 const int16_t *chrFilter,
const int32_t **chrUSrc,
619 const int32_t **chrVSrc,
int chrFilterSize,
620 const int32_t **alpSrc, uint16_t *dest,
int dstW,
625 for (i = 0; i < ((dstW + 1) >> 1); i++) {
627 int Y1 = -0x40000000;
628 int Y2 = -0x40000000;
633 for (j = 0; j < lumFilterSize; j++) {
634 Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
635 Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
637 for (j = 0; j < chrFilterSize; j++) {;
638 U += chrUSrc[j][i] * (unsigned)chrFilter[j];
639 V += chrVSrc[j][i] * (unsigned)chrFilter[j];
665 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
668 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
677 const int32_t *abuf[2], uint16_t *dest,
int dstW,
678 int yalpha,
int uvalpha,
int y,
681 const int32_t *buf0 = buf[0], *buf1 = buf[1],
682 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
683 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
684 int yalpha1 = 4096 - yalpha;
685 int uvalpha1 = 4096 - uvalpha;
688 for (i = 0; i < ((dstW + 1) >> 1); i++) {
689 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
690 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
691 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
692 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
707 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
710 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
719 const int32_t *abuf0, uint16_t *dest,
int dstW,
722 const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
725 if (uvalpha < 2048) {
726 for (i = 0; i < ((dstW + 1) >> 1); i++) {
727 int Y1 = (buf0[i * 2] ) >> 2;
728 int Y2 = (buf0[i * 2 + 1]) >> 2;
729 int U = (ubuf0[i] + (-128 << 11)) >> 2;
730 int V = (vbuf0[i] + (-128 << 11)) >> 2;
745 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
748 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
753 const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
754 for (i = 0; i < ((dstW + 1) >> 1); i++) {
755 int Y1 = (buf0[i * 2] ) >> 2;
756 int Y2 = (buf0[i * 2 + 1]) >> 2;
757 int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
758 int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3;
773 output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
776 output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
787 #define YUV2PACKED16WRAPPER(name, base, ext, fmt) \
788 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
789 const int16_t **_lumSrc, int lumFilterSize, \
790 const int16_t *chrFilter, const int16_t **_chrUSrc, \
791 const int16_t **_chrVSrc, int chrFilterSize, \
792 const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
795 const int32_t **lumSrc = (const int32_t **) _lumSrc, \
796 **chrUSrc = (const int32_t **) _chrUSrc, \
797 **chrVSrc = (const int32_t **) _chrVSrc, \
798 **alpSrc = (const int32_t **) _alpSrc; \
799 uint16_t *dest = (uint16_t *) _dest; \
800 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
801 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
802 alpSrc, dest, dstW, y, fmt); \
805 static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
806 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
807 const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
808 int yalpha, int uvalpha, int y) \
810 const int32_t **buf = (const int32_t **) _buf, \
811 **ubuf = (const int32_t **) _ubuf, \
812 **vbuf = (const int32_t **) _vbuf, \
813 **abuf = (const int32_t **) _abuf; \
814 uint16_t *dest = (uint16_t *) _dest; \
815 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
816 dest, dstW, yalpha, uvalpha, y, fmt); \
819 static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
820 const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
821 const int16_t *_abuf0, uint8_t *_dest, int dstW, \
822 int uvalpha, int y) \
824 const int32_t *buf0 = (const int32_t *) _buf0, \
825 **ubuf = (const int32_t **) _ubuf, \
826 **vbuf = (const int32_t **) _vbuf, \
827 *abuf0 = (const int32_t *) _abuf0; \
828 uint16_t *dest = (uint16_t *) _dest; \
829 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
830 dstW, uvalpha, y, fmt); \
848 unsigned A1,
unsigned A2,
849 const
void *_r, const
void *_g, const
void *_b,
int y,
854 uint32_t *dest = (uint32_t *) _dest;
855 const uint32_t *
r = (
const uint32_t *) _r;
856 const uint32_t *
g = (
const uint32_t *) _g;
857 const uint32_t *
b = (
const uint32_t *) _b;
862 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
863 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
868 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
869 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
871 dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
872 dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
881 #define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
882 #define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
884 dest[i * 6 + 0] =
r_b[Y1];
885 dest[i * 6 + 1] = g[Y1];
886 dest[i * 6 + 2] =
b_r[Y1];
887 dest[i * 6 + 3] =
r_b[Y2];
888 dest[i * 6 + 4] = g[Y2];
889 dest[i * 6 + 5] =
b_r[Y2];
895 uint16_t *dest = (uint16_t *) _dest;
896 const uint16_t *
r = (
const uint16_t *) _r;
897 const uint16_t *
g = (
const uint16_t *) _g;
898 const uint16_t *
b = (
const uint16_t *) _b;
899 int dr1, dg1, db1, dr2, dg2, db2;
924 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
925 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
931 int dr1, dg1, db1, dr2, dg2, db2;
936 dr1 = dg1 = d32[(i * 2 + 0) & 7];
937 db1 = d64[(i * 2 + 0) & 7];
938 dr2 = dg2 = d32[(i * 2 + 1) & 7];
939 db2 = d64[(i * 2 + 1) & 7];
943 dr1 = db1 = d128[(i * 2 + 0) & 7];
944 dg1 = d64[(i * 2 + 0) & 7];
945 dr2 = db2 = d128[(i * 2 + 1) & 7];
946 dg2 = d64[(i * 2 + 1) & 7];
950 dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
951 ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
953 dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
954 dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
961 const int16_t **lumSrc,
int lumFilterSize,
962 const int16_t *chrFilter,
const int16_t **chrUSrc,
963 const int16_t **chrVSrc,
int chrFilterSize,
964 const int16_t **alpSrc,
uint8_t *dest,
int dstW,
969 for (i = 0; i < ((dstW + 1) >> 1); i++) {
975 const void *
r, *
g, *
b;
977 for (j = 0; j < lumFilterSize; j++) {
978 Y1 += lumSrc[j][i * 2] * lumFilter[j];
979 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
981 for (j = 0; j < chrFilterSize; j++) {
982 U += chrUSrc[j][i] * chrFilter[j];
983 V += chrVSrc[j][i] * chrFilter[j];
992 for (j = 0; j < lumFilterSize; j++) {
993 A1 += alpSrc[j][i * 2 ] * lumFilter[j];
994 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
998 if ((A1 | A2) & 0x100) {
999 A1 = av_clip_uint8(A1);
1000 A2 = av_clip_uint8(A2);
1008 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1009 r, g, b, y, target, hasAlpha);
1015 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1016 const int16_t *abuf[2],
uint8_t *dest,
int dstW,
1017 int yalpha,
int uvalpha,
int y,
1020 const int16_t *buf0 = buf[0], *buf1 = buf[1],
1021 *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
1022 *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
1023 *abuf0 = hasAlpha ? abuf[0] :
NULL,
1024 *abuf1 = hasAlpha ? abuf[1] :
NULL;
1025 int yalpha1 = 4096 - yalpha;
1026 int uvalpha1 = 4096 - uvalpha;
1029 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1030 int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
1031 int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
1032 int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
1033 int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
1040 A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
1041 A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
1042 A1 = av_clip_uint8(A1);
1043 A2 = av_clip_uint8(A2);
1046 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1047 r,
g,
b, y, target, hasAlpha);
1053 const int16_t *ubuf[2],
const int16_t *vbuf[2],
1054 const int16_t *abuf0,
uint8_t *dest,
int dstW,
1058 const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
1061 if (uvalpha < 2048) {
1062 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1063 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1064 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1065 int U = (ubuf0[i] + 64) >> 7;
1066 int V = (vbuf0[i] + 64) >> 7;
1073 A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
1074 A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
1075 A1 = av_clip_uint8(A1);
1076 A2 = av_clip_uint8(A2);
1079 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1080 r,
g,
b, y, target, hasAlpha);
1083 const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
1084 for (i = 0; i < ((dstW + 1) >> 1); i++) {
1085 int Y1 = (buf0[i * 2 ] + 64) >> 7;
1086 int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
1087 int U = (ubuf0[i] + ubuf1[i] + 128) >> 8;
1088 int V = (vbuf0[i] + vbuf1[i] + 128) >> 8;
1095 A1 = (abuf0[i * 2 ] + 64) >> 7;
1096 A2 = (abuf0[i * 2 + 1] + 64) >> 7;
1097 A1 = av_clip_uint8(A1);
1098 A2 = av_clip_uint8(A2);
1101 yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
1102 r,
g,
b, y, target, hasAlpha);
1107 #define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1108 static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
1109 const int16_t **lumSrc, int lumFilterSize, \
1110 const int16_t *chrFilter, const int16_t **chrUSrc, \
1111 const int16_t **chrVSrc, int chrFilterSize, \
1112 const int16_t **alpSrc, uint8_t *dest, int dstW, \
1115 name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
1116 chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
1117 alpSrc, dest, dstW, y, fmt, hasAlpha); \
1119 #define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
1120 YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
1121 static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
1122 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1123 const int16_t *abuf[2], uint8_t *dest, int dstW, \
1124 int yalpha, int uvalpha, int y) \
1126 name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
1127 dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
1130 static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
1131 const int16_t *ubuf[2], const int16_t *vbuf[2], \
1132 const int16_t *abuf0, uint8_t *dest, int dstW, \
1133 int uvalpha, int y) \
1135 name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
1136 dstW, uvalpha, y, fmt, hasAlpha); \
1143 #if CONFIG_SWSCALE_ALPHA
1161 const int16_t **lumSrc,
int lumFilterSize,
1162 const int16_t *chrFilter, const int16_t **chrUSrc,
1163 const int16_t **chrVSrc,
int chrFilterSize,
1164 const int16_t **alpSrc,
uint8_t *dest,
1170 for (i = 0; i < dstW; i++) {
1173 int U = (1<<9)-(128 << 19);
1174 int V = (1<<9)-(128 << 19);
1177 for (j = 0; j < lumFilterSize; j++) {
1178 Y += lumSrc[j][i] * lumFilter[j];
1180 for (j = 0; j < chrFilterSize; j++) {
1181 U += chrUSrc[j][i] * chrFilter[j];
1182 V += chrVSrc[j][i] * chrFilter[j];
1189 for (j = 0; j < lumFilterSize; j++) {
1190 A += alpSrc[j][i] * lumFilter[j];
1194 A = av_clip_uint8(A);
1196 Y -= c->yuv2rgb_y_offset;
1197 Y *= c->yuv2rgb_y_coeff;
1199 R = Y + V*c->yuv2rgb_v2r_coeff;
1200 G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
1201 B = Y + U*c->yuv2rgb_u2b_coeff;
1202 if ((R | G | B) & 0xC0000000) {
1203 R = av_clip_uintp2(R, 30);
1204 G = av_clip_uintp2(G, 30);
1205 B = av_clip_uintp2(B, 30);
1210 dest[0] = hasAlpha ? A : 255;
1224 dest[3] = hasAlpha ? A : 255;
1227 dest[0] = hasAlpha ? A : 255;
1232 case AV_PIX_FMT_BGR24:
1241 dest[3] = hasAlpha ? A : 255;
1254 #if CONFIG_SWSCALE_ALPHA
1280 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
1281 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
1284 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
1285 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
1287 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
1288 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
1290 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
1291 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
1293 *yuv2planeX =
isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
1294 *yuv2plane1 =
isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
1299 *yuv2planeX = yuv2planeX_8_c;
1305 switch (dstFormat) {
1306 case AV_PIX_FMT_RGBA:
1308 *yuv2packedX = yuv2rgba32_full_X_c;
1310 #if CONFIG_SWSCALE_ALPHA
1312 *yuv2packedX = yuv2rgba32_full_X_c;
1316 *yuv2packedX = yuv2rgbx32_full_X_c;
1320 case AV_PIX_FMT_ARGB:
1322 *yuv2packedX = yuv2argb32_full_X_c;
1324 #if CONFIG_SWSCALE_ALPHA
1326 *yuv2packedX = yuv2argb32_full_X_c;
1330 *yuv2packedX = yuv2xrgb32_full_X_c;
1336 *yuv2packedX = yuv2bgra32_full_X_c;
1338 #if CONFIG_SWSCALE_ALPHA
1340 *yuv2packedX = yuv2bgra32_full_X_c;
1344 *yuv2packedX = yuv2bgrx32_full_X_c;
1348 case AV_PIX_FMT_ABGR:
1350 *yuv2packedX = yuv2abgr32_full_X_c;
1352 #if CONFIG_SWSCALE_ALPHA
1354 *yuv2packedX = yuv2abgr32_full_X_c;
1358 *yuv2packedX = yuv2xbgr32_full_X_c;
1362 case AV_PIX_FMT_RGB24:
1363 *yuv2packedX = yuv2rgb24_full_X_c;
1366 *yuv2packedX = yuv2bgr24_full_X_c;
1373 switch (dstFormat) {
1375 *yuv2packed1 = yuv2rgb48le_1_c;
1376 *yuv2packed2 = yuv2rgb48le_2_c;
1377 *yuv2packedX = yuv2rgb48le_X_c;
1380 *yuv2packed1 = yuv2rgb48be_1_c;
1381 *yuv2packed2 = yuv2rgb48be_2_c;
1382 *yuv2packedX = yuv2rgb48be_X_c;
1385 *yuv2packed1 = yuv2bgr48le_1_c;
1386 *yuv2packed2 = yuv2bgr48le_2_c;
1387 *yuv2packedX = yuv2bgr48le_X_c;
1390 *yuv2packed1 = yuv2bgr48be_1_c;
1391 *yuv2packed2 = yuv2bgr48be_2_c;
1392 *yuv2packedX = yuv2bgr48be_X_c;
1394 case AV_PIX_FMT_RGB32:
1397 *yuv2packed1 = yuv2rgb32_1_c;
1398 *yuv2packed2 = yuv2rgb32_2_c;
1399 *yuv2packedX = yuv2rgb32_X_c;
1401 #if CONFIG_SWSCALE_ALPHA
1403 *yuv2packed1 = yuv2rgba32_1_c;
1404 *yuv2packed2 = yuv2rgba32_2_c;
1405 *yuv2packedX = yuv2rgba32_X_c;
1409 *yuv2packed1 = yuv2rgbx32_1_c;
1410 *yuv2packed2 = yuv2rgbx32_2_c;
1411 *yuv2packedX = yuv2rgbx32_X_c;
1418 *yuv2packed1 = yuv2rgb32_1_1_c;
1419 *yuv2packed2 = yuv2rgb32_1_2_c;
1420 *yuv2packedX = yuv2rgb32_1_X_c;
1422 #if CONFIG_SWSCALE_ALPHA
1424 *yuv2packed1 = yuv2rgba32_1_1_c;
1425 *yuv2packed2 = yuv2rgba32_1_2_c;
1426 *yuv2packedX = yuv2rgba32_1_X_c;
1430 *yuv2packed1 = yuv2rgbx32_1_1_c;
1431 *yuv2packed2 = yuv2rgbx32_1_2_c;
1432 *yuv2packedX = yuv2rgbx32_1_X_c;
1436 case AV_PIX_FMT_RGB24:
1437 *yuv2packed1 = yuv2rgb24_1_c;
1438 *yuv2packed2 = yuv2rgb24_2_c;
1439 *yuv2packedX = yuv2rgb24_X_c;
1442 *yuv2packed1 = yuv2bgr24_1_c;
1443 *yuv2packed2 = yuv2bgr24_2_c;
1444 *yuv2packedX = yuv2bgr24_X_c;
1450 *yuv2packed1 = yuv2rgb16_1_c;
1451 *yuv2packed2 = yuv2rgb16_2_c;
1452 *yuv2packedX = yuv2rgb16_X_c;
1458 *yuv2packed1 = yuv2rgb15_1_c;
1459 *yuv2packed2 = yuv2rgb15_2_c;
1460 *yuv2packedX = yuv2rgb15_X_c;
1466 *yuv2packed1 = yuv2rgb12_1_c;
1467 *yuv2packed2 = yuv2rgb12_2_c;
1468 *yuv2packedX = yuv2rgb12_X_c;
1472 *yuv2packed1 = yuv2rgb8_1_c;
1473 *yuv2packed2 = yuv2rgb8_2_c;
1474 *yuv2packedX = yuv2rgb8_X_c;
1478 *yuv2packed1 = yuv2rgb4_1_c;
1479 *yuv2packed2 = yuv2rgb4_2_c;
1480 *yuv2packedX = yuv2rgb4_X_c;
1484 *yuv2packed1 = yuv2rgb4b_1_c;
1485 *yuv2packed2 = yuv2rgb4b_2_c;
1486 *yuv2packedX = yuv2rgb4b_X_c;
1490 switch (dstFormat) {
1492 *yuv2packed1 = yuv2monowhite_1_c;
1493 *yuv2packed2 = yuv2monowhite_2_c;
1494 *yuv2packedX = yuv2monowhite_X_c;
1497 *yuv2packed1 = yuv2monoblack_1_c;
1498 *yuv2packed2 = yuv2monoblack_2_c;
1499 *yuv2packedX = yuv2monoblack_X_c;
1502 *yuv2packed1 = yuv2yuyv422_1_c;
1503 *yuv2packed2 = yuv2yuyv422_2_c;
1504 *yuv2packedX = yuv2yuyv422_X_c;
1507 *yuv2packed1 = yuv2uyvy422_1_c;
1508 *yuv2packed2 = yuv2uyvy422_2_c;
1509 *yuv2packedX = yuv2uyvy422_X_c;