36 #include "libavutil/avconfig.h"
40 { 0, 1, 0, 1, 0, 1, 0, 1,},
41 { 1, 0, 1, 0, 1, 0, 1, 0,},
42 { 0, 1, 0, 1, 0, 1, 0, 1,},
43 { 1, 0, 1, 0, 1, 0, 1, 0,},
44 { 0, 1, 0, 1, 0, 1, 0, 1,},
45 { 1, 0, 1, 0, 1, 0, 1, 0,},
46 { 0, 1, 0, 1, 0, 1, 0, 1,},
47 { 1, 0, 1, 0, 1, 0, 1, 0,},
49 { 1, 2, 1, 2, 1, 2, 1, 2,},
50 { 3, 0, 3, 0, 3, 0, 3, 0,},
51 { 1, 2, 1, 2, 1, 2, 1, 2,},
52 { 3, 0, 3, 0, 3, 0, 3, 0,},
53 { 1, 2, 1, 2, 1, 2, 1, 2,},
54 { 3, 0, 3, 0, 3, 0, 3, 0,},
55 { 1, 2, 1, 2, 1, 2, 1, 2,},
56 { 3, 0, 3, 0, 3, 0, 3, 0,},
58 { 2, 4, 3, 5, 2, 4, 3, 5,},
59 { 6, 0, 7, 1, 6, 0, 7, 1,},
60 { 3, 5, 2, 4, 3, 5, 2, 4,},
61 { 7, 1, 6, 0, 7, 1, 6, 0,},
62 { 2, 4, 3, 5, 2, 4, 3, 5,},
63 { 6, 0, 7, 1, 6, 0, 7, 1,},
64 { 3, 5, 2, 4, 3, 5, 2, 4,},
65 { 7, 1, 6, 0, 7, 1, 6, 0,},
67 { 4, 8, 7, 11, 4, 8, 7, 11,},
68 { 12, 0, 15, 3, 12, 0, 15, 3,},
69 { 6, 10, 5, 9, 6, 10, 5, 9,},
70 { 14, 2, 13, 1, 14, 2, 13, 1,},
71 { 4, 8, 7, 11, 4, 8, 7, 11,},
72 { 12, 0, 15, 3, 12, 0, 15, 3,},
73 { 6, 10, 5, 9, 6, 10, 5, 9,},
74 { 14, 2, 13, 1, 14, 2, 13, 1,},
76 { 9, 17, 15, 23, 8, 16, 14, 22,},
77 { 25, 1, 31, 7, 24, 0, 30, 6,},
78 { 13, 21, 11, 19, 12, 20, 10, 18,},
79 { 29, 5, 27, 3, 28, 4, 26, 2,},
80 { 8, 16, 14, 22, 9, 17, 15, 23,},
81 { 24, 0, 30, 6, 25, 1, 31, 7,},
82 { 12, 20, 10, 18, 13, 21, 11, 19,},
83 { 28, 4, 26, 2, 29, 5, 27, 3,},
85 { 18, 34, 30, 46, 17, 33, 29, 45,},
86 { 50, 2, 62, 14, 49, 1, 61, 13,},
87 { 26, 42, 22, 38, 25, 41, 21, 37,},
88 { 58, 10, 54, 6, 57, 9, 53, 5,},
89 { 16, 32, 28, 44, 19, 35, 31, 47,},
90 { 48, 0, 60, 12, 51, 3, 63, 15,},
91 { 24, 40, 20, 36, 27, 43, 23, 39,},
92 { 56, 8, 52, 4, 59, 11, 55, 7,},
94 { 18, 34, 30, 46, 17, 33, 29, 45,},
95 { 50, 2, 62, 14, 49, 1, 61, 13,},
96 { 26, 42, 22, 38, 25, 41, 21, 37,},
97 { 58, 10, 54, 6, 57, 9, 53, 5,},
98 { 16, 32, 28, 44, 19, 35, 31, 47,},
99 { 48, 0, 60, 12, 51, 3, 63, 15,},
100 { 24, 40, 20, 36, 27, 43, 23, 39,},
101 { 56, 8, 52, 4, 59, 11, 55, 7,},
103 { 36, 68, 60, 92, 34, 66, 58, 90,},
104 { 100, 4,124, 28, 98, 2,122, 26,},
105 { 52, 84, 44, 76, 50, 82, 42, 74,},
106 { 116, 20,108, 12,114, 18,106, 10,},
107 { 32, 64, 56, 88, 38, 70, 62, 94,},
108 { 96, 0,120, 24,102, 6,126, 30,},
109 { 48, 80, 40, 72, 54, 86, 46, 78,},
110 { 112, 16,104, 8,118, 22,110, 14,},
114 { 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,},
115 { 2, 3, 7, 7, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,},
116 { 3, 3, 4, 15, 15, 29, 57, 57, 57, 113, 113, 113, 113, 113, 113, 113,},
117 { 3, 4, 4, 5, 31, 31, 61, 121, 241, 241, 241, 241, 481, 481, 481, 481,},
118 { 3, 4, 5, 5, 6, 63, 63, 125, 249, 497, 993, 993, 993, 993, 993, 1985,},
119 { 3, 5, 6, 6, 6, 7, 127, 127, 253, 505, 1009, 2017, 4033, 4033, 4033, 4033,},
120 { 3, 5, 6, 7, 7, 7, 8, 255, 255, 509, 1017, 2033, 4065, 8129,16257,16257,},
121 { 3, 5, 6, 8, 8, 8, 8, 9, 511, 511, 1021, 2041, 4081, 8161,16321,32641,},
122 { 3, 5, 7, 8, 9, 9, 9, 9, 10, 1023, 1023, 2045, 4089, 8177,16353,32705,},
123 { 3, 5, 7, 8, 10, 10, 10, 10, 10, 11, 2047, 2047, 4093, 8185,16369,32737,},
124 { 3, 5, 7, 8, 10, 11, 11, 11, 11, 11, 12, 4095, 4095, 8189,16377,32753,},
125 { 3, 5, 7, 9, 10, 12, 12, 12, 12, 12, 12, 13, 8191, 8191,16381,32761,},
126 { 3, 5, 7, 9, 10, 12, 13, 13, 13, 13, 13, 13, 14,16383,16383,32765,},
127 { 3, 5, 7, 9, 10, 12, 14, 14, 14, 14, 14, 14, 14, 15,32767,32767,},
128 { 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,},
136 uint8_t *ptr = plane + stride * y;
137 for (i = 0; i <
height; i++) {
138 memset(ptr, val, width);
144 int srcSliceY,
int srcSliceH,
int width,
147 dst += dstStride * srcSliceY;
148 if (dstStride == srcStride && srcStride > 0) {
149 memcpy(dst, src, srcSliceH * dstStride);
152 for (i = 0; i < srcSliceH; i++) {
153 memcpy(dst, src, width);
161 int srcStride[],
int srcSliceY,
162 int srcSliceH,
uint8_t *dstParam[],
165 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
167 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
168 dstParam[0], dstStride[0]);
172 srcStride[1], srcStride[2], dstStride[1]);
175 srcStride[2], srcStride[1], dstStride[1]);
181 int srcStride[],
int srcSliceY,
182 int srcSliceH,
uint8_t *dstParam[],
185 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
186 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
188 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
189 dstParam[0], dstStride[0]);
193 srcStride[1], dstStride[1], dstStride[2]);
196 srcStride[1], dstStride[2], dstStride[1]);
202 int srcStride[],
int srcSliceY,
203 int srcSliceH,
uint8_t *dstParam8[],
206 const uint16_t **
src = (
const uint16_t**)src8;
207 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
208 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
211 av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
212 dstStride[0] % 2 || dstStride[1] % 2));
214 for (y = 0; y < srcSliceH; y++) {
215 uint16_t *tdstY =
dstY;
216 const uint16_t *tsrc0 = src[0];
217 for (x = c->
srcW; x > 0; x--) {
218 *tdstY++ = *tsrc0++ << 6;
220 src[0] += srcStride[0] / 2;
221 dstY += dstStride[0] / 2;
224 uint16_t *tdstUV = dstUV;
225 const uint16_t *tsrc1 = src[1];
226 const uint16_t *tsrc2 = src[2];
227 for (x = c->
srcW / 2; x > 0; x--) {
228 *tdstUV++ = *tsrc1++ << 6;
229 *tdstUV++ = *tsrc2++ << 6;
231 src[1] += srcStride[1] / 2;
232 src[2] += srcStride[2] / 2;
233 dstUV += dstStride[1] / 2;
240 #if AV_HAVE_BIGENDIAN
241 #define output_pixel(p, v) do { \
242 uint16_t *pp = (p); \
246 #define output_pixel(p, v) (*p) = (v)
250 int srcStride[],
int srcSliceY,
251 int srcSliceH,
uint8_t *dstParam8[],
254 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
255 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
258 av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
260 for (y = 0; y < srcSliceH; y++) {
261 uint16_t *tdstY =
dstY;
263 for (x = c->
srcW; x > 0; x--) {
267 src[0] += srcStride[0];
268 dstY += dstStride[0] / 2;
271 uint16_t *tdstUV = dstUV;
274 for (x = c->
srcW / 2; x > 0; x--) {
280 src[1] += srcStride[1];
281 src[2] += srcStride[2];
282 dstUV += dstStride[1] / 2;
292 int srcStride[],
int srcSliceY,
int srcSliceH,
293 uint8_t *dstParam[],
int dstStride[])
295 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
297 yv12toyuy2(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
298 srcStride[1], dstStride[0]);
304 int srcStride[],
int srcSliceY,
int srcSliceH,
305 uint8_t *dstParam[],
int dstStride[])
307 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
309 yv12touyvy(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
310 srcStride[1], dstStride[0]);
316 int srcStride[],
int srcSliceY,
int srcSliceH,
317 uint8_t *dstParam[],
int dstStride[])
319 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
322 srcStride[1], dstStride[0]);
328 int srcStride[],
int srcSliceY,
int srcSliceH,
329 uint8_t *dstParam[],
int dstStride[])
331 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
334 srcStride[1], dstStride[0]);
340 int srcStride[],
int srcSliceY,
int srcSliceH,
341 uint8_t *dstParam[],
int dstStride[])
343 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
344 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
345 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
348 dstStride[1], srcStride[0]);
351 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
357 int srcStride[],
int srcSliceY,
int srcSliceH,
358 uint8_t *dstParam[],
int dstStride[])
360 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
361 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
362 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
365 dstStride[1], srcStride[0]);
371 int srcStride[],
int srcSliceY,
int srcSliceH,
372 uint8_t *dstParam[],
int dstStride[])
374 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
375 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
376 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
379 dstStride[1], srcStride[0]);
382 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
388 int srcStride[],
int srcSliceY,
int srcSliceH,
389 uint8_t *dstParam[],
int dstStride[])
391 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
392 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
393 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
396 dstStride[1], srcStride[0]);
405 for (i = 0; i < num_pixels; i++)
406 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
414 for (i = 0; i < num_pixels; i++)
415 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
423 for (i = 0; i < num_pixels; i++) {
425 dst[0] = palette[src[i << 1] * 4 + 0];
426 dst[1] = palette[src[i << 1] * 4 + 1];
427 dst[2] = palette[src[i << 1] * 4 + 2];
433 int srcStride[],
int srcSliceY,
int srcSliceH,
434 uint8_t *dst[],
int dstStride[])
438 for (p = 0; p < 4; p++) {
439 int srcstr = srcStride[p] / 2;
440 int dststr = dstStride[p] / 2;
441 uint16_t *dstPtr = (uint16_t *) dst[p];
442 const uint16_t *srcPtr = (
const uint16_t *) src[p];
444 if(!dstPtr || !srcPtr)
448 for (j = 0; j < min_stride; j++) {
460 int srcSliceY,
int srcSliceH,
uint8_t *dst[],
468 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
469 const uint8_t *srcPtr = src[0];
480 }
else if (
usePal(srcFormat)) {
495 for (i = 0; i < srcSliceH; i++) {
497 srcPtr += srcStride[0];
498 dstPtr += dstStride[0];
506 uint16_t *dst[],
int dstStride[],
int srcSliceH,
507 int src_alpha,
int swap,
int shift,
int width)
510 int dst_alpha = dst[3] !=
NULL;
511 for (h = 0; h < srcSliceH; h++) {
512 uint16_t *src_line = (uint16_t *)(src + srcStride * h);
515 if (src_alpha && dst_alpha) {
516 for (x = 0; x <
width; x++) {
522 }
else if (dst_alpha) {
523 for (x = 0; x <
width; x++) {
529 }
else if (src_alpha) {
530 for (x = 0; x <
width; x++) {
537 for (x = 0; x <
width; x++) {
545 if (src_alpha && dst_alpha) {
546 for (x = 0; x <
width; x++) {
552 }
else if (dst_alpha) {
553 for (x = 0; x <
width; x++) {
559 }
else if (src_alpha) {
560 for (x = 0; x <
width; x++) {
567 for (x = 0; x <
width; x++) {
575 if (src_alpha && dst_alpha) {
576 for (x = 0; x <
width; x++) {
582 }
else if (dst_alpha) {
583 for (x = 0; x <
width; x++) {
589 }
else if (src_alpha) {
590 for (x = 0; x <
width; x++) {
597 for (x = 0; x <
width; x++) {
605 if (src_alpha && dst_alpha) {
606 for (x = 0; x <
width; x++) {
607 dst[0][x] = *src_line++ >>
shift;
608 dst[1][x] = *src_line++ >>
shift;
609 dst[2][x] = *src_line++ >>
shift;
610 dst[3][x] = *src_line++ >>
shift;
612 }
else if (dst_alpha) {
613 for (x = 0; x <
width; x++) {
614 dst[0][x] = *src_line++ >>
shift;
615 dst[1][x] = *src_line++ >>
shift;
616 dst[2][x] = *src_line++ >>
shift;
619 }
else if (src_alpha) {
620 for (x = 0; x <
width; x++) {
621 dst[0][x] = *src_line++ >>
shift;
622 dst[1][x] = *src_line++ >>
shift;
623 dst[2][x] = *src_line++ >>
shift;
627 for (x = 0; x <
width; x++) {
628 dst[0][x] = *src_line++ >>
shift;
629 dst[1][x] = *src_line++ >>
shift;
630 dst[2][x] = *src_line++ >>
shift;
634 for (i = 0; i < 4; i++)
635 dst[i] += dstStride[i] >> 1;
640 int srcStride[],
int srcSliceY,
int srcSliceH,
641 uint8_t *dst[],
int dstStride[])
643 uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
644 uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
645 int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
646 int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
664 src_format->
name, dst_format->
name);
669 dst2013[i] += stride2013[i] * srcSliceY / 2;
670 dst1023[i] += stride1023[i] * srcSliceY / 2;
679 dst2013, stride2013, srcSliceH, alpha, swap,
687 dst1023, stride1023, srcSliceH, alpha, swap,
692 "unsupported conversion to planar RGB %s -> %s\n",
693 src_format->
name, dst_format->
name);
700 uint8_t *dst,
int dstStride,
int srcSliceH,
704 int src_alpha = src[3] !=
NULL;
705 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
706 for (h = 0; h < srcSliceH; h++) {
707 uint16_t *dest = (uint16_t *)(dst + dstStride * h);
712 if (alpha && !src_alpha) {
713 for (x = 0; x <
width; x++) {
715 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
717 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
719 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
722 }
else if (alpha && src_alpha) {
723 for (x = 0; x <
width; x++) {
725 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
727 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
729 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
731 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
734 for (x = 0; x <
width; x++) {
736 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
738 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
740 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
745 if (alpha && !src_alpha) {
746 for (x = 0; x <
width; x++) {
747 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
748 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
749 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
752 }
else if (alpha && src_alpha) {
753 for (x = 0; x <
width; x++) {
754 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
755 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
756 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
757 *dest++ =
av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
760 for (x = 0; x <
width; x++) {
761 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
762 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
763 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
768 if (alpha && !src_alpha) {
769 for (x = 0; x <
width; x++) {
775 }
else if (alpha && src_alpha) {
776 for (x = 0; x <
width; x++) {
783 for (x = 0; x <
width; x++) {
791 if (alpha && !src_alpha) {
792 for (x = 0; x <
width; x++) {
793 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
794 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
795 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
798 }
else if (alpha && src_alpha) {
799 for (x = 0; x <
width; x++) {
800 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
801 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
802 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
803 *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
806 for (x = 0; x <
width; x++) {
807 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
808 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
809 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
813 for (i = 0; i < 3 + src_alpha; i++)
814 src[i] += srcStride[i] >> 1;
819 int srcStride[],
int srcSliceY,
int srcSliceH,
820 uint8_t *dst[],
int dstStride[])
822 const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
823 const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
824 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
825 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
828 int bits_per_sample = src_format->
comp[0].
depth;
839 bits_per_sample <= 8) {
841 src_format->
name, dst_format->
name);
848 dst[0] + srcSliceY * dstStride[0], dstStride[0],
849 srcSliceH, 0, swap, bits_per_sample, c->
srcW);
854 dst[0] + srcSliceY * dstStride[0], dstStride[0],
855 srcSliceH, 0, swap, bits_per_sample, c->
srcW);
860 dst[0] + srcSliceY * dstStride[0], dstStride[0],
861 srcSliceH, 1, swap, bits_per_sample, c->
srcW);
866 dst[0] + srcSliceY * dstStride[0], dstStride[0],
867 srcSliceH, 1, swap, bits_per_sample, c->
srcW);
871 "unsupported planar RGB conversion %s -> %s\n",
872 src_format->
name, dst_format->
name);
879 uint8_t *dst,
int dstStride,
int srcSliceH,
883 for (h = 0; h < srcSliceH; h++) {
884 uint8_t *dest = dst + dstStride *
h;
885 for (x = 0; x <
width; x++) {
891 for (i = 0; i < 3; i++)
892 src[i] += srcStride[i];
897 uint8_t *dst,
int dstStride,
int srcSliceH,
898 int alpha_first,
int width)
901 for (h = 0; h < srcSliceH; h++) {
902 uint8_t *dest = dst + dstStride *
h;
905 for (x = 0; x <
width; x++) {
912 for (x = 0; x <
width; x++) {
920 for (i = 0; i < 3; i++)
921 src[i] += srcStride[i];
926 int srcStride[],
int srcSliceY,
int srcSliceH,
927 uint8_t *dst[],
int dstStride[])
930 const uint8_t *src102[] = { src[1], src[0], src[2] };
931 const uint8_t *src201[] = { src[2], src[0], src[1] };
932 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
933 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
945 dst[0] + srcSliceY * dstStride[0], dstStride[0],
951 dst[0] + srcSliceY * dstStride[0], dstStride[0],
959 dst[0] + srcSliceY * dstStride[0], dstStride[0],
960 srcSliceH, alpha_first, c->
srcW);
967 dst[0] + srcSliceY * dstStride[0], dstStride[0],
968 srcSliceH, alpha_first, c->
srcW);
973 "unsupported planar RGB conversion %s -> %s\n",
983 int srcSliceY,
int srcSliceH,
984 uint8_t *dst[],
int dstStride[])
986 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
987 dst[0], dstStride[0]);
988 copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->
srcW,
989 dst[1], dstStride[1]);
990 copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->
srcW,
991 dst[2], dstStride[2]);
993 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
999 uint8_t *dst[],
int dstStride[],
int srcSliceH,
1000 int alpha_first,
int inc_size,
int width)
1012 for (h = 0; h < srcSliceH; h++) {
1013 for (x = 0; x <
width; x++) {
1014 dest[0][x] = src[0];
1015 dest[1][x] = src[1];
1016 dest[2][x] = src[2];
1020 src += srcStride - width * inc_size;
1021 dest[0] += dstStride[0];
1022 dest[1] += dstStride[1];
1023 dest[2] += dstStride[2];
1028 int srcStride[],
int srcSliceY,
int srcSliceH,
1029 uint8_t *dst[],
int dstStride[])
1031 int alpha_first = 0;
1032 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1033 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1034 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1035 dst[0] + srcSliceY * dstStride[0],
1036 dst[2] + srcSliceY * dstStride[2] };
1037 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1038 dst[0] + srcSliceY * dstStride[0],
1039 dst[1] + srcSliceY * dstStride[1] };
1044 stride201, srcSliceH, alpha_first, 3, c->
srcW);
1048 stride102, srcSliceH, alpha_first, 3, c->
srcW);
1054 stride201, srcSliceH, alpha_first, 4, c->
srcW);
1060 stride102, srcSliceH, alpha_first, 4, c->
srcW);
1064 "unsupported planar RGB conversion %s -> %s\n",
1074 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1079 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1084 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1089 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1094 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1099 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1104 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1109 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1114 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1119 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1124 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1129 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1133 int srcSliceH,
uint8_t* dst[],
int dstStride[])
1135 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1136 const uint8_t *srcPtr= src[0];
1142 #define CASE(pixfmt, prefix) \
1143 case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1144 interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1164 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->
srcW);
1165 srcPtr += 2 * srcStride[0];
1166 dstPtr += 2 * dstStride[0];
1168 for (i = 2; i < srcSliceH - 2; i += 2) {
1170 srcPtr += 2 * srcStride[0];
1171 dstPtr += 2 * dstStride[0];
1174 if (i + 1 == srcSliceH) {
1175 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->
srcW);
1176 }
else if (i < srcSliceH)
1177 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->
srcW);
1182 int srcSliceH,
uint8_t* dst[],
int dstStride[])
1184 const uint8_t *srcPtr= src[0];
1186 uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1187 uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1193 #define CASE(pixfmt, prefix) \
1194 case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1195 interpolate = bayer_##prefix##_to_yv12_interpolate; \
1216 srcPtr += 2 * srcStride[0];
1217 dstY += 2 * dstStride[0];
1218 dstU += dstStride[1];
1219 dstV += dstStride[1];
1221 for (i = 2; i < srcSliceH - 2; i += 2) {
1223 srcPtr += 2 * srcStride[0];
1224 dstY += 2 * dstStride[0];
1225 dstU += dstStride[1];
1226 dstV += dstStride[1];
1229 if (i + 1 == srcSliceH) {
1231 }
else if (i < srcSliceH)
1236 #define isRGBA32(x) ( \
1237 (x) == AV_PIX_FMT_ARGB \
1238 || (x) == AV_PIX_FMT_RGBA \
1239 || (x) == AV_PIX_FMT_BGRA \
1240 || (x) == AV_PIX_FMT_ABGR \
1243 #define isRGBA64(x) ( \
1244 (x) == AV_PIX_FMT_RGBA64LE \
1245 || (x) == AV_PIX_FMT_RGBA64BE \
1246 || (x) == AV_PIX_FMT_BGRA64LE \
1247 || (x) == AV_PIX_FMT_BGRA64BE \
1250 #define isRGB48(x) ( \
1251 (x) == AV_PIX_FMT_RGB48LE \
1252 || (x) == AV_PIX_FMT_RGB48BE \
1253 || (x) == AV_PIX_FMT_BGR48LE \
1254 || (x) == AV_PIX_FMT_BGR48BE \
1267 #define IS_NOT_NE(bpp, desc) \
1268 (((bpp + 7) >> 3) == 2 && \
1269 (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1271 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1291 else if (
CONV_IS(RGB48LE, BGR48BE)
1296 if (
CONV_IS(RGBA64LE, BGR48LE)
1300 else if (
CONV_IS(RGBA64LE, BGR48BE)
1304 else if (
CONV_IS(RGBA64LE, RGB48LE)
1308 else if (
CONV_IS(RGBA64LE, RGB48BE)
1316 switch (srcId | (dstId << 16)) {
1317 case 0x000F000C: conv =
rgb12to15;
break;
1318 case 0x000F0010: conv =
rgb16to15;
break;
1319 case 0x000F0018: conv =
rgb24to15;
break;
1320 case 0x000F0020: conv =
rgb32to15;
break;
1321 case 0x0010000F: conv =
rgb15to16;
break;
1322 case 0x00100018: conv =
rgb24to16;
break;
1323 case 0x00100020: conv =
rgb32to16;
break;
1324 case 0x0018000F: conv =
rgb15to24;
break;
1325 case 0x00180010: conv =
rgb16to24;
break;
1326 case 0x00180020: conv =
rgb32to24;
break;
1327 case 0x0020000F: conv =
rgb15to32;
break;
1328 case 0x00200010: conv =
rgb16to32;
break;
1329 case 0x00200018: conv =
rgb24to32;
break;
1333 switch (srcId | (dstId << 16)) {
1366 int srcSliceY,
int srcSliceH,
uint8_t *dst[],
1382 const uint8_t *srcPtr = src[0];
1395 for (i = 0; i < srcSliceH; i++)
1396 dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
1400 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
1401 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
1402 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
1403 (srcSliceH - 1) * srcStride[0] + c->
srcW * srcBpp);
1406 dstPtr += dstStride[0] * srcSliceY;
1408 for (i = 0; i < srcSliceH; i++) {
1410 for(j=0; j<c->
srcW; j++)
1414 conv(srcPtr, dstPtr, c->
srcW * srcBpp);
1416 for(j=0; j<c->
srcW; j++)
1417 ((uint16_t*)dstPtr)[j] =
av_bswap16(((uint16_t*)dstPtr)[j]);
1418 srcPtr += srcStride[0];
1419 dstPtr += dstStride[0];
1427 int srcStride[],
int srcSliceY,
int srcSliceH,
1428 uint8_t *dst[],
int dstStride[])
1432 dst[0] + srcSliceY * dstStride[0],
1433 dst[1] + (srcSliceY >> 1) * dstStride[1],
1434 dst[2] + (srcSliceY >> 1) * dstStride[2],
1436 dstStride[0], dstStride[1], srcStride[0],
1439 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
1444 int srcStride[],
int srcSliceY,
int srcSliceH,
1445 uint8_t *dst[],
int dstStride[])
1447 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
1448 dst[0], dstStride[0]);
1450 planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->
chrSrcW,
1451 srcSliceH >> 2, srcStride[1], dstStride[1]);
1452 planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->
chrSrcW,
1453 srcSliceH >> 2, srcStride[2], dstStride[2]);
1455 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
1461 int srcStride[],
int srcSliceY,
int srcSliceH,
1462 uint8_t *dst[],
int dstStride[])
1464 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
1465 memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
1468 const uint8_t *srcPtr = src[0];
1469 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
1473 while (length + c->
srcW <=
FFABS(dstStride[0]) &&
1474 length + c->
srcW <=
FFABS(srcStride[0]))
1478 for (i = 0; i < srcSliceH; i++) {
1479 memcpy(dstPtr, srcPtr, length);
1480 srcPtr += srcStride[0];
1481 dstPtr += dstStride[0];
1487 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
1488 uint16_t scale= dither_scale[dst_depth-1][src_depth-1];\
1489 int shift= src_depth-dst_depth + dither_scale[src_depth-2][dst_depth-1];\
1490 for (i = 0; i < height; i++) {\
1491 const uint8_t *dither= dithers[src_depth-9][i&7];\
1492 for (j = 0; j < length-7; j+=8){\
1493 dst[j+0] = dbswap((bswap(src[j+0]) + dither[0])*scale>>shift);\
1494 dst[j+1] = dbswap((bswap(src[j+1]) + dither[1])*scale>>shift);\
1495 dst[j+2] = dbswap((bswap(src[j+2]) + dither[2])*scale>>shift);\
1496 dst[j+3] = dbswap((bswap(src[j+3]) + dither[3])*scale>>shift);\
1497 dst[j+4] = dbswap((bswap(src[j+4]) + dither[4])*scale>>shift);\
1498 dst[j+5] = dbswap((bswap(src[j+5]) + dither[5])*scale>>shift);\
1499 dst[j+6] = dbswap((bswap(src[j+6]) + dither[6])*scale>>shift);\
1500 dst[j+7] = dbswap((bswap(src[j+7]) + dither[7])*scale>>shift);\
1502 for (; j < length; j++)\
1503 dst[j] = dbswap((bswap(src[j]) + dither[j&7])*scale>>shift);\
1509 int srcStride[],
int srcSliceY,
int srcSliceH,
1510 uint8_t *dst[],
int dstStride[])
1515 for (plane = 0; plane < 4; plane++) {
1521 int shiftonly = plane == 1 || plane == 2 || (!c->
srcRange && plane == 0);
1526 if (plane == 1 && !dst[2])
continue;
1527 if (!src[plane] || (plane == 1 && !src[2])) {
1529 fillPlane16(dst[plane], dstStride[plane], length, height, y,
1530 plane == 3, desc_dst->
comp[plane].
depth,
1533 fillPlane(dst[plane], dstStride[plane], length, height, y,
1534 (plane == 3) ? 255 : 128);
1542 const uint16_t *srcPtr2 = (
const uint16_t *) srcPtr;
1543 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1545 if (dst_depth == 8) {
1547 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
1551 }
else if (src_depth == 8) {
1552 for (i = 0; i <
height; i++) {
1555 for (j = 0; j < length; j++)\
1556 w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
1558 for (j = 0; j < length; j++)\
1559 w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
1560 (srcPtr[j]>>(2*8-dst_depth)));\
1567 dstPtr2 += dstStride[
plane]/2;
1568 srcPtr += srcStride[
plane];
1570 }
else if (src_depth <= dst_depth) {
1571 for (i = 0; i <
height; i++) {
1576 unsigned shift = dst_depth - src_depth;
1578 #define FAST_COPY_UP(shift) \
1579 for (; j < length - 3; j += 4) { \
1580 uint64_t v = AV_RN64A(srcPtr2 + j); \
1581 AV_WN64A(dstPtr2 + j, v << shift); \
1584 #define FAST_COPY_UP(shift) \
1585 for (; j < length - 1; j += 2) { \
1586 uint32_t v = AV_RN32A(srcPtr2 + j); \
1587 AV_WN32A(dstPtr2 + j, v << shift); \
1596 #define COPY_UP(r,w) \
1598 for (; j < length; j++){ \
1599 unsigned int v= r(&srcPtr2[j]);\
1600 w(&dstPtr2[j], v<<(dst_depth-src_depth));\
1603 for (; j < length; j++){ \
1604 unsigned int v= r(&srcPtr2[j]);\
1605 w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
1606 (v>>(2*src_depth-dst_depth)));\
1622 dstPtr2 += dstStride[
plane]/2;
1623 srcPtr2 += srcStride[
plane]/2;
1628 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
1643 for (i = 0; i <
height; i++) {
1644 for (j = 0; j <
length; j++)
1645 ((uint16_t *) dstPtr)[j] =
av_bswap16(((
const uint16_t *) srcPtr)[j]);
1646 srcPtr += srcStride[
plane];
1647 dstPtr += dstStride[
plane];
1649 }
else if (dstStride[plane] == srcStride[plane] &&
1650 srcStride[plane] > 0 && srcStride[plane] == length) {
1651 memcpy(dst[plane] + dstStride[plane] * y, src[plane],
1652 height * dstStride[plane]);
1658 for (i = 0; i <
height; i++) {
1659 memcpy(dstPtr, srcPtr, length);
1660 srcPtr += srcStride[
plane];
1661 dstPtr += dstStride[
plane];
1670 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
1671 ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
1672 (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
1683 needsDither =
isAnyRGB(dstFormat) &&
1736 #define isByteRGB(f) ( \
1737 f == AV_PIX_FMT_RGB32 || \
1738 f == AV_PIX_FMT_RGB32_1 || \
1739 f == AV_PIX_FMT_RGB24 || \
1740 f == AV_PIX_FMT_BGR32 || \
1741 f == AV_PIX_FMT_BGR32_1 || \
1742 f == AV_PIX_FMT_BGR24)
1782 else if (!
isBayer(dstFormat)) {
1868 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
1870 if ( srcFormat == dstFormat ||
1906 for (i = 0; i < num_pixels; i++)
1907 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i]];
1916 for (i = 0; i < num_pixels; i++) {
1918 dst[0] = palette[src[i] * 4 + 0];
1919 dst[1] = palette[src[i] * 4 + 1];
1920 dst[2] = palette[src[i] * 4 + 2];
#define IS_NOT_NE(bpp, desc)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size)
static const uint16_t dither_scale[15][16]
const char const char void * val
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
static int shift(int a, int b)
#define AV_PIX_FMT_YUV440P10
static void copy(const float *p1, float *p2, const int length)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
#define AV_PIX_FMT_YUVA420P10
static int conv(int samples, float **pcm, char *buf, int channels)
void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
#define AV_PIX_FMT_YUV444P14
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...
static void fn() rgb2yuv(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t s, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
void(* ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size)
packed RGB 8:8:8, 24bpp, RGBRGB...
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)
static void packed16togbra16(const uint8_t *src, int srcStride, uint16_t *dst[], int dstStride[], int srcSliceH, int src_alpha, int swap, int shift, int width)
#define AV_PIX_FMT_RGBA64
void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size)
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples */
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples */
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_GBRP10
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */
static void gbr24ptopacked32(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
void(* yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define AV_PIX_FMT_BGRA64
void(* yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
Convenience header that includes libavutil's core.
planar GBR 4:4:4 36bpp, little-endian
static void gbr24ptopacked24(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
#define AV_PIX_FMT_YUV420P12
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples */
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_RGB444
#define CASE(pixfmt, prefix)
int dstY
Last destination vertical line output from last slice.
planar GBR 4:4:4 36bpp, big-endian
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_GRAY10
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
void(* uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
#define AV_PIX_FMT_GRAY12
void(* uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
planar GBRA 4:4:4:4 64bpp, big-endian
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
void(* yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
static int rgbToPlanarRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian */
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-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...
void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static void interpolate(float *out, float v1, float v2, int size)
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
#define SWS_FAST_BILINEAR
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
planar GBR 4:4:4 48bpp, big-endian
static int planarRgbToplanarRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_YUV444P16
enum AVPixelFormat dstFormat
Destination pixel format.
#define AV_PIX_FMT_YUV422P12
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian */
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
#define AV_PIX_FMT_BAYER_GRBG16
void(* yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
int dstH
Height of destination luma/alpha planes.
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swscale to an unscaled converter if one exists for the specific source and destination formats...
static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
planar GBR 4:4:4 27bpp, big-endian
void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
#define CONV_IS(src, dst)
static double alpha(void *priv, double x, double y)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PIX_FMT_BGR32_1
static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
static rgbConvFn findRgbConvFn(SwsContext *c)
static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
like NV12, with 16bpp per component, big-endian
#define output_pixel(p, v)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
#define FAST_COPY_UP(shift)
static int planarRgb16ToRgb16Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
#define AV_PIX_FMT_GBRAP12
simple assert() macros that are a bit more flexible than ISO C assert().
like NV12, with 16bpp per component, little-endian
static void fillPlane(uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
#define AV_PIX_FMT_YUV444P10
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian
static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
static const uint8_t dithers[8][8][8]
#define AV_PIX_FMT_GBRAP16
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...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
#define AV_PIX_FMT_YUV422P9
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
as above, but U and V bytes are swapped
planar GBR 4:4:4:4 48bpp, big-endian
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GRAY16
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
uint8_t * formatConvBuffer
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void(* rgbConvFn)(const uint8_t *, uint8_t *, int)
packed RGB 8:8:8, 24bpp, BGRBGR...
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
#define AV_PIX_FMT_BAYER_BGGR16
#define AV_PIX_FMT_YUV444P9
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
#define AV_PIX_FMT_GBRP14
void ff_get_unscaled_swscale_aarch64(SwsContext *c)
static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
planar GBR 4:4:4:4 48bpp, little-endian
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_BGR555
#define AV_PIX_FMT_BAYER_GBRG16
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_YUV420P14
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int planar8ToP01xleWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam8[], int dstStride[])
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian */
planar GBR 4:4:4 30bpp, big-endian
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
planar GBR 4:4:4 42bpp, little-endian
static void gbr16ptopacked16(const uint16_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha, int swap, int bpp, int width)
void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_YUV420P10
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static av_always_inline int isRGBinInt(enum AVPixelFormat pix_fmt)
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
#define AV_PIX_FMT_YUV440P12
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
planar GBR 4:4:4 42bpp, big-endian
static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
#define AV_PIX_FMT_YUV420P9
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian */
static void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian)
static int Rgb16ToPlanarRgb16Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int planarCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_BGR565
#define AV_PIX_FMT_AYUV64
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV422P10
static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_YUV444P12
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian */
void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
void ff_get_unscaled_swscale_arm(SwsContext *c)
#define AV_PIX_FMT_BAYER_RGGB16
void(* yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
GLint GLenum GLboolean GLsizei stride
static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar GBRA 4:4:4:4 32bpp
planar GBR 4:4:4 27bpp, little-endian
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
void(* yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_BGR444
enum AVPixelFormat srcFormat
Source pixel format.
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples */
static void packedtogbr24p(const uint8_t *src, int srcStride, uint8_t *dst[], int dstStride[], int srcSliceH, int alpha_first, int inc_size, int width)
#define AV_PIX_FMT_RGB555
void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
static int planarToP010Wrapper(SwsContext *c, const uint8_t *src8[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam8[], int dstStride[])
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
static void copyPlane(const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
SwsFunc swscale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_PIX_FMT_RGB32_1
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static av_always_inline int isBGRinInt(enum AVPixelFormat pix_fmt)
int srcFormatBpp
Number of bits per pixel of the source pixel format.
void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
av_cold void ff_get_unscaled_swscale_ppc(SwsContext *c)
static int packedCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_RGB565
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
int32_t input_rgb2yuv_table[16+40 *4]
planar GBR 4:4:4 48bpp, little-endian
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
int chrDstHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination...
int chrSrcW
Width of source chroma planes.
int depth
Number of bits in the component.
planar GBRA 4:4:4:4 64bpp, little-endian
int srcW
Width of source luma/alpha planes.
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
int chrSrcVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image...
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
AVPixelFormat
Pixel format.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_YUV422P16
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
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...
#define AV_CEIL_RSHIFT(a, b)
void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)