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,},
118 uint8_t *ptr = plane + stride * y;
119 for (i = 0; i <
height; i++) {
120 memset(ptr, val, width);
126 int srcSliceY,
int srcSliceH,
int width,
129 dst += dstStride * srcSliceY;
130 if (dstStride == srcStride && srcStride > 0) {
131 memcpy(dst, src, srcSliceH * dstStride);
134 for (i = 0; i < srcSliceH; i++) {
135 memcpy(dst, src, width);
143 int srcStride[],
int srcSliceY,
144 int srcSliceH,
uint8_t *dstParam[],
147 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
149 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
150 dstParam[0], dstStride[0]);
154 srcStride[1], srcStride[2], dstStride[1]);
157 srcStride[2], srcStride[1], dstStride[1]);
163 int srcStride[],
int srcSliceY,
164 int srcSliceH,
uint8_t *dstParam[],
167 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
168 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
170 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
171 dstParam[0], dstStride[0]);
175 srcStride[1], dstStride[1], dstStride[2]);
178 srcStride[1], dstStride[2], dstStride[1]);
184 int srcStride[],
int srcSliceY,
185 int srcSliceH,
uint8_t *dstParam8[],
190 const uint16_t **
src = (
const uint16_t**)src8;
191 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
192 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
196 const int shift[3] = {
205 av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
206 dstStride[0] % 2 || dstStride[1] % 2));
208 for (y = 0; y < srcSliceH; y++) {
209 uint16_t *tdstY =
dstY;
210 const uint16_t *tsrc0 = src[0];
211 for (x = c->
srcW; x > 0; x--) {
212 *tdstY++ = *tsrc0++ << shift[0];
214 src[0] += srcStride[0] / 2;
215 dstY += dstStride[0] / 2;
218 uint16_t *tdstUV = dstUV;
219 const uint16_t *tsrc1 = src[1];
220 const uint16_t *tsrc2 = src[2];
221 for (x = c->
srcW / 2; x > 0; x--) {
222 *tdstUV++ = *tsrc1++ << shift[1];
223 *tdstUV++ = *tsrc2++ << shift[2];
225 src[1] += srcStride[1] / 2;
226 src[2] += srcStride[2] / 2;
227 dstUV += dstStride[1] / 2;
234 #if AV_HAVE_BIGENDIAN
235 #define output_pixel(p, v) do { \
236 uint16_t *pp = (p); \
240 #define output_pixel(p, v) (*p) = (v)
244 int srcStride[],
int srcSliceY,
245 int srcSliceH,
uint8_t *dstParam8[],
248 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
249 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
252 av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
254 for (y = 0; y < srcSliceH; y++) {
255 uint16_t *tdstY =
dstY;
257 for (x = c->
srcW; x > 0; x--) {
261 src[0] += srcStride[0];
262 dstY += dstStride[0] / 2;
265 uint16_t *tdstUV = dstUV;
268 for (x = c->
srcW / 2; x > 0; x--) {
274 src[1] += srcStride[1];
275 src[2] += srcStride[2];
276 dstUV += dstStride[1] / 2;
286 int srcStride[],
int srcSliceY,
int srcSliceH,
287 uint8_t *dstParam[],
int dstStride[])
289 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
291 yv12toyuy2(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
292 srcStride[1], dstStride[0]);
298 int srcStride[],
int srcSliceY,
int srcSliceH,
299 uint8_t *dstParam[],
int dstStride[])
301 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
303 yv12touyvy(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
304 srcStride[1], dstStride[0]);
310 int srcStride[],
int srcSliceY,
int srcSliceH,
311 uint8_t *dstParam[],
int dstStride[])
313 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
316 srcStride[1], dstStride[0]);
322 int srcStride[],
int srcSliceY,
int srcSliceH,
323 uint8_t *dstParam[],
int dstStride[])
325 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
328 srcStride[1], dstStride[0]);
334 int srcStride[],
int srcSliceY,
int srcSliceH,
335 uint8_t *dstParam[],
int dstStride[])
337 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
338 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
339 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
342 dstStride[1], srcStride[0]);
345 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
351 int srcStride[],
int srcSliceY,
int srcSliceH,
352 uint8_t *dstParam[],
int dstStride[])
354 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
355 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
356 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
359 dstStride[1], srcStride[0]);
365 int srcStride[],
int srcSliceY,
int srcSliceH,
366 uint8_t *dstParam[],
int dstStride[])
368 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
369 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
370 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
373 dstStride[1], srcStride[0]);
376 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
382 int srcStride[],
int srcSliceY,
int srcSliceH,
383 uint8_t *dstParam[],
int dstStride[])
385 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
386 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
387 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
390 dstStride[1], srcStride[0]);
399 for (i = 0; i < num_pixels; i++)
400 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
408 for (i = 0; i < num_pixels; i++)
409 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
417 for (i = 0; i < num_pixels; i++) {
419 dst[0] = palette[src[i << 1] * 4 + 0];
420 dst[1] = palette[src[i << 1] * 4 + 1];
421 dst[2] = palette[src[i << 1] * 4 + 2];
427 int srcStride[],
int srcSliceY,
int srcSliceH,
428 uint8_t *dst[],
int dstStride[])
432 for (p = 0; p < 4; p++) {
433 int srcstr = srcStride[p] / 2;
434 int dststr = dstStride[p] / 2;
435 uint16_t *dstPtr = (uint16_t *) dst[p];
436 const uint16_t *srcPtr = (
const uint16_t *) src[p];
438 if(!dstPtr || !srcPtr)
442 for (j = 0; j < min_stride; j++) {
454 int srcSliceY,
int srcSliceH,
uint8_t *dst[],
462 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
463 const uint8_t *srcPtr = src[0];
474 }
else if (
usePal(srcFormat)) {
489 for (i = 0; i < srcSliceH; i++) {
491 srcPtr += srcStride[0];
492 dstPtr += dstStride[0];
500 uint16_t *dst[],
int dstStride[],
int srcSliceH,
501 int src_alpha,
int swap,
int shift,
int width)
504 int dst_alpha = dst[3] !=
NULL;
505 for (h = 0; h < srcSliceH; h++) {
506 uint16_t *src_line = (uint16_t *)(src + srcStride * h);
509 if (src_alpha && dst_alpha) {
510 for (x = 0; x <
width; x++) {
516 }
else if (dst_alpha) {
517 for (x = 0; x <
width; x++) {
523 }
else if (src_alpha) {
524 for (x = 0; x <
width; x++) {
531 for (x = 0; x <
width; x++) {
539 if (src_alpha && dst_alpha) {
540 for (x = 0; x <
width; x++) {
546 }
else if (dst_alpha) {
547 for (x = 0; x <
width; x++) {
553 }
else if (src_alpha) {
554 for (x = 0; x <
width; x++) {
561 for (x = 0; x <
width; x++) {
569 if (src_alpha && dst_alpha) {
570 for (x = 0; x <
width; x++) {
576 }
else if (dst_alpha) {
577 for (x = 0; x <
width; x++) {
583 }
else if (src_alpha) {
584 for (x = 0; x <
width; x++) {
591 for (x = 0; x <
width; x++) {
599 if (src_alpha && dst_alpha) {
600 for (x = 0; x <
width; x++) {
601 dst[0][x] = *src_line++ >>
shift;
602 dst[1][x] = *src_line++ >>
shift;
603 dst[2][x] = *src_line++ >>
shift;
604 dst[3][x] = *src_line++ >>
shift;
606 }
else if (dst_alpha) {
607 for (x = 0; x <
width; x++) {
608 dst[0][x] = *src_line++ >>
shift;
609 dst[1][x] = *src_line++ >>
shift;
610 dst[2][x] = *src_line++ >>
shift;
613 }
else if (src_alpha) {
614 for (x = 0; x <
width; x++) {
615 dst[0][x] = *src_line++ >>
shift;
616 dst[1][x] = *src_line++ >>
shift;
617 dst[2][x] = *src_line++ >>
shift;
621 for (x = 0; x <
width; x++) {
622 dst[0][x] = *src_line++ >>
shift;
623 dst[1][x] = *src_line++ >>
shift;
624 dst[2][x] = *src_line++ >>
shift;
628 for (i = 0; i < 4; i++)
629 dst[i] += dstStride[i] >> 1;
634 int srcStride[],
int srcSliceY,
int srcSliceH,
635 uint8_t *dst[],
int dstStride[])
637 uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
638 uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
639 int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
640 int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
658 src_format->
name, dst_format->
name);
663 dst2013[i] += stride2013[i] * srcSliceY / 2;
664 dst1023[i] += stride1023[i] * srcSliceY / 2;
673 dst2013, stride2013, srcSliceH, alpha, swap,
681 dst1023, stride1023, srcSliceH, alpha, swap,
686 "unsupported conversion to planar RGB %s -> %s\n",
687 src_format->
name, dst_format->
name);
694 uint8_t *dst,
int dstStride,
int srcSliceH,
698 int src_alpha = src[3] !=
NULL;
699 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
700 for (h = 0; h < srcSliceH; h++) {
701 uint16_t *dest = (uint16_t *)(dst + dstStride * h);
706 if (alpha && !src_alpha) {
707 for (x = 0; x <
width; x++) {
709 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
711 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
713 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
716 }
else if (alpha && src_alpha) {
717 for (x = 0; x <
width; x++) {
719 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
721 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
723 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
725 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
728 for (x = 0; x <
width; x++) {
730 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
732 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
734 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
739 if (alpha && !src_alpha) {
740 for (x = 0; x <
width; x++) {
741 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
742 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
743 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
746 }
else if (alpha && src_alpha) {
747 for (x = 0; x <
width; x++) {
748 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
749 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
750 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
751 *dest++ =
av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
754 for (x = 0; x <
width; x++) {
755 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
756 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
757 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
762 if (alpha && !src_alpha) {
763 for (x = 0; x <
width; x++) {
769 }
else if (alpha && src_alpha) {
770 for (x = 0; x <
width; x++) {
777 for (x = 0; x <
width; x++) {
785 if (alpha && !src_alpha) {
786 for (x = 0; x <
width; x++) {
787 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
788 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
789 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
792 }
else if (alpha && src_alpha) {
793 for (x = 0; x <
width; x++) {
794 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
795 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
796 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
797 *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
800 for (x = 0; x <
width; x++) {
801 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
802 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
803 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
807 for (i = 0; i < 3 + src_alpha; i++)
808 src[i] += srcStride[i] >> 1;
813 int srcStride[],
int srcSliceY,
int srcSliceH,
814 uint8_t *dst[],
int dstStride[])
816 const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
817 const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
818 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
819 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
822 int bits_per_sample = src_format->
comp[0].
depth;
833 bits_per_sample <= 8) {
835 src_format->
name, dst_format->
name);
842 dst[0] + srcSliceY * dstStride[0], dstStride[0],
843 srcSliceH, 0, swap, bits_per_sample, c->
srcW);
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, 1, swap, bits_per_sample, c->
srcW);
860 dst[0] + srcSliceY * dstStride[0], dstStride[0],
861 srcSliceH, 1, swap, bits_per_sample, c->
srcW);
865 "unsupported planar RGB conversion %s -> %s\n",
866 src_format->
name, dst_format->
name);
873 uint8_t *dst,
int dstStride,
int srcSliceH,
877 for (h = 0; h < srcSliceH; h++) {
878 uint8_t *dest = dst + dstStride *
h;
879 for (x = 0; x <
width; x++) {
885 for (i = 0; i < 3; i++)
886 src[i] += srcStride[i];
891 uint8_t *dst,
int dstStride,
int srcSliceH,
892 int alpha_first,
int width)
895 for (h = 0; h < srcSliceH; h++) {
896 uint8_t *dest = dst + dstStride *
h;
899 for (x = 0; x <
width; x++) {
906 for (x = 0; x <
width; x++) {
914 for (i = 0; i < 3; i++)
915 src[i] += srcStride[i];
920 int srcStride[],
int srcSliceY,
int srcSliceH,
921 uint8_t *dst[],
int dstStride[])
924 const uint8_t *src102[] = { src[1], src[0], src[2] };
925 const uint8_t *src201[] = { src[2], src[0], src[1] };
926 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
927 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
939 dst[0] + srcSliceY * dstStride[0], dstStride[0],
945 dst[0] + srcSliceY * dstStride[0], dstStride[0],
953 dst[0] + srcSliceY * dstStride[0], dstStride[0],
954 srcSliceH, alpha_first, c->
srcW);
961 dst[0] + srcSliceY * dstStride[0], dstStride[0],
962 srcSliceH, alpha_first, c->
srcW);
967 "unsupported planar RGB conversion %s -> %s\n",
977 int srcSliceY,
int srcSliceH,
978 uint8_t *dst[],
int dstStride[])
980 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
981 dst[0], dstStride[0]);
982 copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->
srcW,
983 dst[1], dstStride[1]);
984 copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->
srcW,
985 dst[2], dstStride[2]);
987 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
993 uint8_t *dst[],
int dstStride[],
int srcSliceH,
994 int alpha_first,
int inc_size,
int width)
1006 for (h = 0; h < srcSliceH; h++) {
1007 for (x = 0; x <
width; x++) {
1008 dest[0][x] = src[0];
1009 dest[1][x] = src[1];
1010 dest[2][x] = src[2];
1014 src += srcStride - width * inc_size;
1015 dest[0] += dstStride[0];
1016 dest[1] += dstStride[1];
1017 dest[2] += dstStride[2];
1022 int srcStride[],
int srcSliceY,
int srcSliceH,
1023 uint8_t *dst[],
int dstStride[])
1025 int alpha_first = 0;
1026 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1027 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1028 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1029 dst[0] + srcSliceY * dstStride[0],
1030 dst[2] + srcSliceY * dstStride[2] };
1031 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1032 dst[0] + srcSliceY * dstStride[0],
1033 dst[1] + srcSliceY * dstStride[1] };
1038 stride201, srcSliceH, alpha_first, 3, c->
srcW);
1042 stride102, srcSliceH, alpha_first, 3, c->
srcW);
1048 stride201, srcSliceH, alpha_first, 4, c->
srcW);
1054 stride102, srcSliceH, alpha_first, 4, c->
srcW);
1058 "unsupported planar RGB conversion %s -> %s\n",
1068 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1073 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1078 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1083 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1088 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1093 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1098 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1103 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1108 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1113 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1118 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1123 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1127 int srcSliceH,
uint8_t* dst[],
int dstStride[])
1129 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1130 const uint8_t *srcPtr= src[0];
1136 #define CASE(pixfmt, prefix) \
1137 case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1138 interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1158 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->
srcW);
1159 srcPtr += 2 * srcStride[0];
1160 dstPtr += 2 * dstStride[0];
1162 for (i = 2; i < srcSliceH - 2; i += 2) {
1164 srcPtr += 2 * srcStride[0];
1165 dstPtr += 2 * dstStride[0];
1168 if (i + 1 == srcSliceH) {
1169 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->
srcW);
1170 }
else if (i < srcSliceH)
1171 copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->
srcW);
1176 int srcSliceH,
uint8_t* dst[],
int dstStride[])
1178 const uint8_t *srcPtr= src[0];
1180 uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1181 uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1187 #define CASE(pixfmt, prefix) \
1188 case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1189 interpolate = bayer_##prefix##_to_yv12_interpolate; \
1210 srcPtr += 2 * srcStride[0];
1211 dstY += 2 * dstStride[0];
1212 dstU += dstStride[1];
1213 dstV += dstStride[1];
1215 for (i = 2; i < srcSliceH - 2; i += 2) {
1217 srcPtr += 2 * srcStride[0];
1218 dstY += 2 * dstStride[0];
1219 dstU += dstStride[1];
1220 dstV += dstStride[1];
1223 if (i + 1 == srcSliceH) {
1225 }
else if (i < srcSliceH)
1230 #define isRGBA32(x) ( \
1231 (x) == AV_PIX_FMT_ARGB \
1232 || (x) == AV_PIX_FMT_RGBA \
1233 || (x) == AV_PIX_FMT_BGRA \
1234 || (x) == AV_PIX_FMT_ABGR \
1237 #define isRGBA64(x) ( \
1238 (x) == AV_PIX_FMT_RGBA64LE \
1239 || (x) == AV_PIX_FMT_RGBA64BE \
1240 || (x) == AV_PIX_FMT_BGRA64LE \
1241 || (x) == AV_PIX_FMT_BGRA64BE \
1244 #define isRGB48(x) ( \
1245 (x) == AV_PIX_FMT_RGB48LE \
1246 || (x) == AV_PIX_FMT_RGB48BE \
1247 || (x) == AV_PIX_FMT_BGR48LE \
1248 || (x) == AV_PIX_FMT_BGR48BE \
1261 #define IS_NOT_NE(bpp, desc) \
1262 (((bpp + 7) >> 3) == 2 && \
1263 (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1265 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1285 else if (
CONV_IS(RGB48LE, BGR48BE)
1290 if (
CONV_IS(RGB48LE, BGRA64LE)
1294 else if (
CONV_IS(RGB48LE, BGRA64BE)
1298 if (
CONV_IS(RGB48LE, RGBA64LE)
1302 else if (
CONV_IS(RGB48LE, RGBA64BE)
1307 if (
CONV_IS(RGBA64LE, BGR48LE)
1311 else if (
CONV_IS(RGBA64LE, BGR48BE)
1315 else if (
CONV_IS(RGBA64LE, RGB48LE)
1319 else if (
CONV_IS(RGBA64LE, RGB48BE)
1327 switch (srcId | (dstId << 16)) {
1328 case 0x000F000C: conv =
rgb12to15;
break;
1329 case 0x000F0010: conv =
rgb16to15;
break;
1330 case 0x000F0018: conv =
rgb24to15;
break;
1331 case 0x000F0020: conv =
rgb32to15;
break;
1332 case 0x0010000F: conv =
rgb15to16;
break;
1333 case 0x00100018: conv =
rgb24to16;
break;
1334 case 0x00100020: conv =
rgb32to16;
break;
1335 case 0x0018000F: conv =
rgb15to24;
break;
1336 case 0x00180010: conv =
rgb16to24;
break;
1337 case 0x00180020: conv =
rgb32to24;
break;
1338 case 0x0020000F: conv =
rgb15to32;
break;
1339 case 0x00200010: conv =
rgb16to32;
break;
1340 case 0x00200018: conv =
rgb24to32;
break;
1344 switch (srcId | (dstId << 16)) {
1377 int srcSliceY,
int srcSliceH,
uint8_t *dst[],
1393 const uint8_t *srcPtr = src[0];
1406 for (i = 0; i < srcSliceH; i++)
1407 dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
1411 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
1412 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
1413 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
1414 (srcSliceH - 1) * srcStride[0] + c->
srcW * srcBpp);
1417 dstPtr += dstStride[0] * srcSliceY;
1419 for (i = 0; i < srcSliceH; i++) {
1421 for(j=0; j<c->
srcW; j++)
1425 conv(srcPtr, dstPtr, c->
srcW * srcBpp);
1427 for(j=0; j<c->
srcW; j++)
1428 ((uint16_t*)dstPtr)[j] =
av_bswap16(((uint16_t*)dstPtr)[j]);
1429 srcPtr += srcStride[0];
1430 dstPtr += dstStride[0];
1438 int srcStride[],
int srcSliceY,
int srcSliceH,
1439 uint8_t *dst[],
int dstStride[])
1443 dst[0] + srcSliceY * dstStride[0],
1444 dst[1] + (srcSliceY >> 1) * dstStride[1],
1445 dst[2] + (srcSliceY >> 1) * dstStride[2],
1447 dstStride[0], dstStride[1], srcStride[0],
1450 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
1455 int srcStride[],
int srcSliceY,
int srcSliceH,
1456 uint8_t *dst[],
int dstStride[])
1458 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
1459 dst[0], dstStride[0]);
1461 planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->
chrSrcW,
1462 srcSliceH >> 2, srcStride[1], dstStride[1]);
1463 planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->
chrSrcW,
1464 srcSliceH >> 2, srcStride[2], dstStride[2]);
1466 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
1472 int srcStride[],
int srcSliceY,
int srcSliceH,
1473 uint8_t *dst[],
int dstStride[])
1475 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
1476 memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
1479 const uint8_t *srcPtr = src[0];
1480 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
1484 while (length + c->
srcW <=
FFABS(dstStride[0]) &&
1485 length + c->
srcW <=
FFABS(srcStride[0]))
1489 for (i = 0; i < srcSliceH; i++) {
1490 memcpy(dstPtr, srcPtr, length);
1491 srcPtr += srcStride[0];
1492 dstPtr += dstStride[0];
1498 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
1499 unsigned shift= src_depth-dst_depth, tmp;\
1500 if (c->dither == SWS_DITHER_NONE) {\
1501 for (i = 0; i < height; i++) {\
1502 for (j = 0; j < length-7; j+=8) {\
1503 dst[j+0] = dbswap(bswap(src[j+0])>>shift);\
1504 dst[j+1] = dbswap(bswap(src[j+1])>>shift);\
1505 dst[j+2] = dbswap(bswap(src[j+2])>>shift);\
1506 dst[j+3] = dbswap(bswap(src[j+3])>>shift);\
1507 dst[j+4] = dbswap(bswap(src[j+4])>>shift);\
1508 dst[j+5] = dbswap(bswap(src[j+5])>>shift);\
1509 dst[j+6] = dbswap(bswap(src[j+6])>>shift);\
1510 dst[j+7] = dbswap(bswap(src[j+7])>>shift);\
1512 for (; j < length; j++) {\
1513 dst[j] = dbswap(bswap(src[j])>>shift);\
1518 } else if (shiftonly) {\
1519 for (i = 0; i < height; i++) {\
1520 const uint8_t *dither= dithers[shift-1][i&7];\
1521 for (j = 0; j < length-7; j+=8) {\
1522 tmp = (bswap(src[j+0]) + dither[0])>>shift; dst[j+0] = dbswap(tmp - (tmp>>dst_depth));\
1523 tmp = (bswap(src[j+1]) + dither[1])>>shift; dst[j+1] = dbswap(tmp - (tmp>>dst_depth));\
1524 tmp = (bswap(src[j+2]) + dither[2])>>shift; dst[j+2] = dbswap(tmp - (tmp>>dst_depth));\
1525 tmp = (bswap(src[j+3]) + dither[3])>>shift; dst[j+3] = dbswap(tmp - (tmp>>dst_depth));\
1526 tmp = (bswap(src[j+4]) + dither[4])>>shift; dst[j+4] = dbswap(tmp - (tmp>>dst_depth));\
1527 tmp = (bswap(src[j+5]) + dither[5])>>shift; dst[j+5] = dbswap(tmp - (tmp>>dst_depth));\
1528 tmp = (bswap(src[j+6]) + dither[6])>>shift; dst[j+6] = dbswap(tmp - (tmp>>dst_depth));\
1529 tmp = (bswap(src[j+7]) + dither[7])>>shift; dst[j+7] = dbswap(tmp - (tmp>>dst_depth));\
1531 for (; j < length; j++) {\
1532 tmp = (bswap(src[j]) + dither[j&7])>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth));\
1538 for (i = 0; i < height; i++) {\
1539 const uint8_t *dither= dithers[shift-1][i&7];\
1540 for (j = 0; j < length-7; j+=8) {\
1541 tmp = bswap(src[j+0]); dst[j+0] = dbswap((tmp - (tmp>>dst_depth) + dither[0])>>shift);\
1542 tmp = bswap(src[j+1]); dst[j+1] = dbswap((tmp - (tmp>>dst_depth) + dither[1])>>shift);\
1543 tmp = bswap(src[j+2]); dst[j+2] = dbswap((tmp - (tmp>>dst_depth) + dither[2])>>shift);\
1544 tmp = bswap(src[j+3]); dst[j+3] = dbswap((tmp - (tmp>>dst_depth) + dither[3])>>shift);\
1545 tmp = bswap(src[j+4]); dst[j+4] = dbswap((tmp - (tmp>>dst_depth) + dither[4])>>shift);\
1546 tmp = bswap(src[j+5]); dst[j+5] = dbswap((tmp - (tmp>>dst_depth) + dither[5])>>shift);\
1547 tmp = bswap(src[j+6]); dst[j+6] = dbswap((tmp - (tmp>>dst_depth) + dither[6])>>shift);\
1548 tmp = bswap(src[j+7]); dst[j+7] = dbswap((tmp - (tmp>>dst_depth) + dither[7])>>shift);\
1550 for (; j < length; j++) {\
1551 tmp = bswap(src[j]); dst[j] = dbswap((tmp - (tmp>>dst_depth) + dither[j&7])>>shift);\
1559 int srcStride[],
int srcSliceY,
int srcSliceH,
1560 uint8_t *dst[],
int dstStride[])
1565 for (plane = 0; plane < 4; plane++) {
1571 int shiftonly = plane == 1 || plane == 2 || (!c->
srcRange && plane == 0);
1576 if (plane == 1 && !dst[2])
continue;
1577 if (!src[plane] || (plane == 1 && !src[2])) {
1579 fillPlane16(dst[plane], dstStride[plane], length, height, y,
1580 plane == 3, desc_dst->
comp[plane].
depth,
1583 fillPlane(dst[plane], dstStride[plane], length, height, y,
1584 (plane == 3) ? 255 : 128);
1592 const uint16_t *srcPtr2 = (
const uint16_t *) srcPtr;
1593 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1595 if (dst_depth == 8) {
1597 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
1601 }
else if (src_depth == 8) {
1602 for (i = 0; i <
height; i++) {
1605 for (j = 0; j < length; j++)\
1606 w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
1608 for (j = 0; j < length; j++)\
1609 w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
1610 (srcPtr[j]>>(2*8-dst_depth)));\
1617 dstPtr2 += dstStride[
plane]/2;
1618 srcPtr += srcStride[
plane];
1620 }
else if (src_depth <= dst_depth) {
1621 for (i = 0; i <
height; i++) {
1626 unsigned shift = dst_depth - src_depth;
1628 #define FAST_COPY_UP(shift) \
1629 for (; j < length - 3; j += 4) { \
1630 uint64_t v = AV_RN64A(srcPtr2 + j); \
1631 AV_WN64A(dstPtr2 + j, v << shift); \
1634 #define FAST_COPY_UP(shift) \
1635 for (; j < length - 1; j += 2) { \
1636 uint32_t v = AV_RN32A(srcPtr2 + j); \
1637 AV_WN32A(dstPtr2 + j, v << shift); \
1646 #define COPY_UP(r,w) \
1648 for (; j < length; j++){ \
1649 unsigned int v= r(&srcPtr2[j]);\
1650 w(&dstPtr2[j], v<<(dst_depth-src_depth));\
1653 for (; j < length; j++){ \
1654 unsigned int v= r(&srcPtr2[j]);\
1655 w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
1656 (v>>(2*src_depth-dst_depth)));\
1672 dstPtr2 += dstStride[
plane]/2;
1673 srcPtr2 += srcStride[
plane]/2;
1678 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
1693 for (i = 0; i <
height; i++) {
1694 for (j = 0; j <
length; j++)
1695 ((uint16_t *) dstPtr)[j] =
av_bswap16(((
const uint16_t *) srcPtr)[j]);
1696 srcPtr += srcStride[
plane];
1697 dstPtr += dstStride[
plane];
1699 }
else if (dstStride[plane] == srcStride[plane] &&
1700 srcStride[plane] > 0 && srcStride[plane] == length) {
1701 memcpy(dst[plane] + dstStride[plane] * y, src[plane],
1702 height * dstStride[plane]);
1708 for (i = 0; i <
height; i++) {
1709 memcpy(dstPtr, srcPtr, length);
1710 srcPtr += srcStride[
plane];
1711 dstPtr += dstStride[
plane];
1720 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
1721 ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
1722 (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
1733 needsDither =
isAnyRGB(dstFormat) &&
1789 #define isByteRGB(f) ( \
1790 f == AV_PIX_FMT_RGB32 || \
1791 f == AV_PIX_FMT_RGB32_1 || \
1792 f == AV_PIX_FMT_RGB24 || \
1793 f == AV_PIX_FMT_BGR32 || \
1794 f == AV_PIX_FMT_BGR32_1 || \
1795 f == AV_PIX_FMT_BGR24)
1835 else if (!
isBayer(dstFormat)) {
1922 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
1924 if ( srcFormat == dstFormat ||
1951 int num_pixels,
const uint8_t *palette)
1955 for (i = 0; i < num_pixels; i++)
1956 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i]];
1961 int num_pixels,
const uint8_t *palette)
1965 for (i = 0; i < num_pixels; i++) {
1967 dst[0] = palette[src[i] * 4 + 0];
1968 dst[1] = palette[src[i] * 4 + 1];
1969 dst[2] = palette[src[i] * 4 + 2];
#define IS_NOT_NE(bpp, desc)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
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)
static float alpha(float a)
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.
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
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.
void rgb48tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
#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
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
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
#define AV_PIX_FMT_YUVA420P16
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 rgb48to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
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)
#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)
#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
static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
static const uint8_t dithers[8][8][8]
static int planarToP01xWrapper(SwsContext *c, const uint8_t *src8[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam8[], int dstStride[])
#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)
void(* shuffle_bytes_1230)(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 rgb48to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
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
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
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)
int shift
Number of least significant bits that must be shifted away to get the value.
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)
#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 rgb48tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
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)