39 { 0, 1, 0, 1, 0, 1, 0, 1,},
40 { 1, 0, 1, 0, 1, 0, 1, 0,},
41 { 0, 1, 0, 1, 0, 1, 0, 1,},
42 { 1, 0, 1, 0, 1, 0, 1, 0,},
43 { 0, 1, 0, 1, 0, 1, 0, 1,},
44 { 1, 0, 1, 0, 1, 0, 1, 0,},
45 { 0, 1, 0, 1, 0, 1, 0, 1,},
46 { 1, 0, 1, 0, 1, 0, 1, 0,},
48 { 1, 2, 1, 2, 1, 2, 1, 2,},
49 { 3, 0, 3, 0, 3, 0, 3, 0,},
50 { 1, 2, 1, 2, 1, 2, 1, 2,},
51 { 3, 0, 3, 0, 3, 0, 3, 0,},
52 { 1, 2, 1, 2, 1, 2, 1, 2,},
53 { 3, 0, 3, 0, 3, 0, 3, 0,},
54 { 1, 2, 1, 2, 1, 2, 1, 2,},
55 { 3, 0, 3, 0, 3, 0, 3, 0,},
57 { 2, 4, 3, 5, 2, 4, 3, 5,},
58 { 6, 0, 7, 1, 6, 0, 7, 1,},
59 { 3, 5, 2, 4, 3, 5, 2, 4,},
60 { 7, 1, 6, 0, 7, 1, 6, 0,},
61 { 2, 4, 3, 5, 2, 4, 3, 5,},
62 { 6, 0, 7, 1, 6, 0, 7, 1,},
63 { 3, 5, 2, 4, 3, 5, 2, 4,},
64 { 7, 1, 6, 0, 7, 1, 6, 0,},
66 { 4, 8, 7, 11, 4, 8, 7, 11,},
67 { 12, 0, 15, 3, 12, 0, 15, 3,},
68 { 6, 10, 5, 9, 6, 10, 5, 9,},
69 { 14, 2, 13, 1, 14, 2, 13, 1,},
70 { 4, 8, 7, 11, 4, 8, 7, 11,},
71 { 12, 0, 15, 3, 12, 0, 15, 3,},
72 { 6, 10, 5, 9, 6, 10, 5, 9,},
73 { 14, 2, 13, 1, 14, 2, 13, 1,},
75 { 9, 17, 15, 23, 8, 16, 14, 22,},
76 { 25, 1, 31, 7, 24, 0, 30, 6,},
77 { 13, 21, 11, 19, 12, 20, 10, 18,},
78 { 29, 5, 27, 3, 28, 4, 26, 2,},
79 { 8, 16, 14, 22, 9, 17, 15, 23,},
80 { 24, 0, 30, 6, 25, 1, 31, 7,},
81 { 12, 20, 10, 18, 13, 21, 11, 19,},
82 { 28, 4, 26, 2, 29, 5, 27, 3,},
84 { 18, 34, 30, 46, 17, 33, 29, 45,},
85 { 50, 2, 62, 14, 49, 1, 61, 13,},
86 { 26, 42, 22, 38, 25, 41, 21, 37,},
87 { 58, 10, 54, 6, 57, 9, 53, 5,},
88 { 16, 32, 28, 44, 19, 35, 31, 47,},
89 { 48, 0, 60, 12, 51, 3, 63, 15,},
90 { 24, 40, 20, 36, 27, 43, 23, 39,},
91 { 56, 8, 52, 4, 59, 11, 55, 7,},
93 { 18, 34, 30, 46, 17, 33, 29, 45,},
94 { 50, 2, 62, 14, 49, 1, 61, 13,},
95 { 26, 42, 22, 38, 25, 41, 21, 37,},
96 { 58, 10, 54, 6, 57, 9, 53, 5,},
97 { 16, 32, 28, 44, 19, 35, 31, 47,},
98 { 48, 0, 60, 12, 51, 3, 63, 15,},
99 { 24, 40, 20, 36, 27, 43, 23, 39,},
100 { 56, 8, 52, 4, 59, 11, 55, 7,},
102 { 36, 68, 60, 92, 34, 66, 58, 90,},
103 { 100, 4,124, 28, 98, 2,122, 26,},
104 { 52, 84, 44, 76, 50, 82, 42, 74,},
105 { 116, 20,108, 12,114, 18,106, 10,},
106 { 32, 64, 56, 88, 38, 70, 62, 94,},
107 { 96, 0,120, 24,102, 6,126, 30,},
108 { 48, 80, 40, 72, 54, 86, 46, 78,},
109 { 112, 16,104, 8,118, 22,110, 14,},
113 { 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,},
114 { 2, 3, 7, 7, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,},
115 { 3, 3, 4, 15, 15, 29, 57, 57, 57, 113, 113, 113, 113, 113, 113, 113,},
116 { 3, 4, 4, 5, 31, 31, 61, 121, 241, 241, 241, 241, 481, 481, 481, 481,},
117 { 3, 4, 5, 5, 6, 63, 63, 125, 249, 497, 993, 993, 993, 993, 993, 1985,},
118 { 3, 5, 6, 6, 6, 7, 127, 127, 253, 505, 1009, 2017, 4033, 4033, 4033, 4033,},
119 { 3, 5, 6, 7, 7, 7, 8, 255, 255, 509, 1017, 2033, 4065, 8129,16257,16257,},
120 { 3, 5, 6, 8, 8, 8, 8, 9, 511, 511, 1021, 2041, 4081, 8161,16321,32641,},
121 { 3, 5, 7, 8, 9, 9, 9, 9, 10, 1023, 1023, 2045, 4089, 8177,16353,32705,},
122 { 3, 5, 7, 8, 10, 10, 10, 10, 10, 11, 2047, 2047, 4093, 8185,16369,32737,},
123 { 3, 5, 7, 8, 10, 11, 11, 11, 11, 11, 12, 4095, 4095, 8189,16377,32753,},
124 { 3, 5, 7, 9, 10, 12, 12, 12, 12, 12, 12, 13, 8191, 8191,16381,32761,},
125 { 3, 5, 7, 9, 10, 12, 13, 13, 13, 13, 13, 13, 14,16383,16383,32765,},
126 { 3, 5, 7, 9, 10, 12, 14, 14, 14, 14, 14, 14, 14, 15,32767,32767,},
127 { 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,},
136 for (i = 0; i <
height; i++) {
137 memset(ptr, val, width);
143 int srcSliceY,
int srcSliceH,
int width,
146 dst += dstStride * srcSliceY;
147 if (dstStride == srcStride && srcStride > 0) {
148 memcpy(dst, src, srcSliceH * dstStride);
151 for (i = 0; i < srcSliceH; i++) {
152 memcpy(dst, src, width);
160 int srcStride[],
int srcSliceY,
161 int srcSliceH,
uint8_t *dstParam[],
164 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
166 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
167 dstParam[0], dstStride[0]);
171 srcStride[1], srcStride[2], dstStride[0]);
174 srcStride[2], srcStride[1], dstStride[0]);
180 int srcStride[],
int srcSliceY,
int srcSliceH,
181 uint8_t *dstParam[],
int dstStride[])
183 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
185 yv12toyuy2(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
186 srcStride[1], dstStride[0]);
192 int srcStride[],
int srcSliceY,
int srcSliceH,
193 uint8_t *dstParam[],
int dstStride[])
195 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
197 yv12touyvy(src[0], src[1], src[2], dst, c->
srcW, srcSliceH, srcStride[0],
198 srcStride[1], dstStride[0]);
204 int srcStride[],
int srcSliceY,
int srcSliceH,
205 uint8_t *dstParam[],
int dstStride[])
207 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
210 srcStride[1], dstStride[0]);
216 int srcStride[],
int srcSliceY,
int srcSliceH,
217 uint8_t *dstParam[],
int dstStride[])
219 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
222 srcStride[1], dstStride[0]);
228 int srcStride[],
int srcSliceY,
int srcSliceH,
229 uint8_t *dstParam[],
int dstStride[])
231 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
232 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
233 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
236 dstStride[1], srcStride[0]);
239 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
245 int srcStride[],
int srcSliceY,
int srcSliceH,
246 uint8_t *dstParam[],
int dstStride[])
248 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
249 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
250 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
253 dstStride[1], srcStride[0]);
259 int srcStride[],
int srcSliceY,
int srcSliceH,
260 uint8_t *dstParam[],
int dstStride[])
262 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
263 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
264 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
267 dstStride[1], srcStride[0]);
270 fillPlane(dstParam[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
276 int srcStride[],
int srcSliceY,
int srcSliceH,
277 uint8_t *dstParam[],
int dstStride[])
279 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
280 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
281 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
284 dstStride[1], srcStride[0]);
293 for (i = 0; i < num_pixels; i++)
294 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
302 for (i = 0; i < num_pixels; i++)
303 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
311 for (i = 0; i < num_pixels; i++) {
313 dst[0] = palette[src[i << 1] * 4 + 0];
314 dst[1] = palette[src[i << 1] * 4 + 1];
315 dst[2] = palette[src[i << 1] * 4 + 2];
321 int srcStride[],
int srcSliceY,
int srcSliceH,
322 uint8_t *dst[],
int dstStride[])
326 for (p = 0; p < 4; p++) {
327 int srcstr = srcStride[p] / 2;
328 int dststr = dstStride[p] / 2;
329 uint16_t *dstPtr = (uint16_t *) dst[p];
330 const uint16_t *srcPtr = (
const uint16_t *) src[p];
332 if(!dstPtr || !srcPtr)
335 for (j = 0; j < min_stride; j++) {
347 int srcSliceY,
int srcSliceH,
uint8_t *dst[],
355 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
356 const uint8_t *srcPtr = src[0];
367 }
else if (
usePal(srcFormat)) {
382 for (i = 0; i < srcSliceH; i++) {
384 srcPtr += srcStride[0];
385 dstPtr += dstStride[0];
393 uint8_t *dst,
int dstStride,
int srcSliceH,
397 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
398 for (h = 0; h < srcSliceH; h++) {
399 uint16_t *dest = (uint16_t *)(dst + dstStride * h);
405 for (x = 0; x <
width; x++) {
407 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
409 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
411 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
415 for (x = 0; x <
width; x++) {
417 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
419 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
421 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
427 for (x = 0; x <
width; x++) {
428 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
429 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
430 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
434 for (x = 0; x <
width; x++) {
435 *dest++ =
av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
436 *dest++ =
av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
437 *dest++ =
av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
443 for (x = 0; x <
width; x++) {
450 for (x = 0; x <
width; x++) {
459 for (x = 0; x <
width; x++) {
460 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
461 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
462 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
466 for (x = 0; x <
width; x++) {
467 *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
468 *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
469 *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
473 for (i = 0; i < 3; i++)
474 src[i] += srcStride[i] >> 1;
479 int srcStride[],
int srcSliceY,
int srcSliceH,
480 uint8_t *dst[],
int dstStride[])
482 const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2] };
483 const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1] };
484 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
485 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
499 bits_per_sample <= 8) {
501 src_format->
name, dst_format->
name);
508 dst[0] + srcSliceY * dstStride[0], dstStride[0],
509 srcSliceH, 0, swap, bits_per_sample, c->
srcW);
514 dst[0] + srcSliceY * dstStride[0], dstStride[0],
515 srcSliceH, 0, swap, bits_per_sample, c->
srcW);
520 dst[0] + srcSliceY * dstStride[0], dstStride[0],
521 srcSliceH, 1, swap, bits_per_sample, c->
srcW);
526 dst[0] + srcSliceY * dstStride[0], dstStride[0],
527 srcSliceH, 1, swap, bits_per_sample, c->
srcW);
531 "unsupported planar RGB conversion %s -> %s\n",
532 src_format->
name, dst_format->
name);
539 uint8_t *dst,
int dstStride,
int srcSliceH,
543 for (h = 0; h < srcSliceH; h++) {
544 uint8_t *dest = dst + dstStride * h;
545 for (x = 0; x <
width; x++) {
551 for (i = 0; i < 3; i++)
552 src[i] += srcStride[i];
557 uint8_t *dst,
int dstStride,
int srcSliceH,
558 int alpha_first,
int width)
561 for (h = 0; h < srcSliceH; h++) {
562 uint8_t *dest = dst + dstStride * h;
565 for (x = 0; x <
width; x++) {
572 for (x = 0; x <
width; x++) {
580 for (i = 0; i < 3; i++)
581 src[i] += srcStride[i];
586 int srcStride[],
int srcSliceY,
int srcSliceH,
587 uint8_t *dst[],
int dstStride[])
590 const uint8_t *src102[] = { src[1], src[0], src[2] };
591 const uint8_t *src201[] = { src[2], src[0], src[1] };
592 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
593 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
605 dst[0] + srcSliceY * dstStride[0], dstStride[0],
611 dst[0] + srcSliceY * dstStride[0], dstStride[0],
619 dst[0] + srcSliceY * dstStride[0], dstStride[0],
620 srcSliceH, alpha_first, c->
srcW);
627 dst[0] + srcSliceY * dstStride[0], dstStride[0],
628 srcSliceH, alpha_first, c->
srcW);
633 "unsupported planar RGB conversion %s -> %s\n",
642 int srcStride[],
int srcSliceY,
int srcSliceH,
643 uint8_t *dst[],
int dstStride[])
645 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
646 dst[0], dstStride[0]);
647 copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->
srcW,
648 dst[1], dstStride[1]);
649 copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->
srcW,
650 dst[2], dstStride[2]);
652 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
658 uint8_t *dst[],
int dstStride[],
int srcSliceH,
659 int alpha_first,
int inc_size,
int width)
671 for (h = 0; h < srcSliceH; h++) {
672 for (x = 0; x <
width; x++) {
679 src += srcStride - width * inc_size;
680 dest[0] += dstStride[0];
681 dest[1] += dstStride[1];
682 dest[2] += dstStride[2];
687 int srcStride[],
int srcSliceY,
int srcSliceH,
688 uint8_t *dst[],
int dstStride[])
691 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
692 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
693 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
694 dst[0] + srcSliceY * dstStride[0],
695 dst[2] + srcSliceY * dstStride[2] };
696 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
697 dst[0] + srcSliceY * dstStride[0],
698 dst[1] + srcSliceY * dstStride[1] };
703 stride201, srcSliceH, alpha_first, 3, c->
srcW);
707 stride102, srcSliceH, alpha_first, 3, c->
srcW);
713 stride201, srcSliceH, alpha_first, 4, c->
srcW);
719 stride102, srcSliceH, alpha_first, 4, c->
srcW);
723 "unsupported planar RGB conversion %s -> %s\n",
731 #define isRGBA32(x) ( \
732 (x) == AV_PIX_FMT_ARGB \
733 || (x) == AV_PIX_FMT_RGBA \
734 || (x) == AV_PIX_FMT_BGRA \
735 || (x) == AV_PIX_FMT_ABGR \
738 #define isRGBA64(x) ( \
739 (x) == AV_PIX_FMT_RGBA64LE \
740 || (x) == AV_PIX_FMT_RGBA64BE \
741 || (x) == AV_PIX_FMT_BGRA64LE \
742 || (x) == AV_PIX_FMT_BGRA64BE \
745 #define isRGB48(x) ( \
746 (x) == AV_PIX_FMT_RGB48LE \
747 || (x) == AV_PIX_FMT_RGB48BE \
748 || (x) == AV_PIX_FMT_BGR48LE \
749 || (x) == AV_PIX_FMT_BGR48BE \
762 #define IS_NOT_NE(bpp, desc) \
763 (((bpp + 7) >> 3) == 2 && \
764 (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
766 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
786 else if (
CONV_IS(RGB48LE, BGR48BE)
795 else if (
CONV_IS(RGBA64LE, BGR48BE)
799 else if (
CONV_IS(RGBA64LE, RGB48LE)
803 else if (
CONV_IS(RGBA64LE, RGB48BE)
811 switch (srcId | (dstId << 16)) {
812 case 0x000F000C: conv =
rgb12to15;
break;
813 case 0x000F0010: conv =
rgb16to15;
break;
814 case 0x000F0018: conv =
rgb24to15;
break;
815 case 0x000F0020: conv =
rgb32to15;
break;
816 case 0x0010000F: conv =
rgb15to16;
break;
817 case 0x00100018: conv =
rgb24to16;
break;
818 case 0x00100020: conv =
rgb32to16;
break;
819 case 0x0018000F: conv =
rgb15to24;
break;
820 case 0x00180010: conv =
rgb16to24;
break;
821 case 0x00180020: conv =
rgb32to24;
break;
822 case 0x0020000F: conv =
rgb15to32;
break;
823 case 0x00200010: conv =
rgb16to32;
break;
824 case 0x00200018: conv =
rgb24to32;
break;
828 switch (srcId | (dstId << 16)) {
856 int srcSliceY,
int srcSliceH, uint8_t *dst[],
872 const uint8_t *srcPtr = src[0];
873 uint8_t *dstPtr = dst[0];
885 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
886 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
887 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
888 srcSliceH * srcStride[0]);
891 dstPtr += dstStride[0] * srcSliceY;
893 for (i = 0; i < srcSliceH; i++) {
895 for(j=0; j<c->
srcW; j++)
899 conv(srcPtr, dstPtr, c->
srcW * srcBpp);
901 for(j=0; j<c->
srcW; j++)
902 ((uint16_t*)dstPtr)[j] =
av_bswap16(((uint16_t*)dstPtr)[j]);
903 srcPtr += srcStride[0];
904 dstPtr += dstStride[0];
912 int srcStride[],
int srcSliceY,
int srcSliceH,
913 uint8_t *dst[],
int dstStride[])
917 dst[0] + srcSliceY * dstStride[0],
918 dst[1] + (srcSliceY >> 1) * dstStride[1],
919 dst[2] + (srcSliceY >> 1) * dstStride[2],
921 dstStride[0], dstStride[1], srcStride[0],
924 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
929 int srcStride[],
int srcSliceY,
int srcSliceH,
930 uint8_t *dst[],
int dstStride[])
932 copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->
srcW,
933 dst[0], dstStride[0]);
936 srcSliceH >> 2, srcStride[1], dstStride[1]);
938 srcSliceH >> 2, srcStride[2], dstStride[2]);
940 fillPlane(dst[3], dstStride[3], c->
srcW, srcSliceH, srcSliceY, 255);
946 int srcStride[],
int srcSliceY,
int srcSliceH,
947 uint8_t *dst[],
int dstStride[])
949 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
950 memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
953 const uint8_t *srcPtr = src[0];
954 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
958 while (length + c->
srcW <=
FFABS(dstStride[0]) &&
963 for (i = 0; i < srcSliceH; i++) {
964 memcpy(dstPtr, srcPtr, length);
965 srcPtr += srcStride[0];
966 dstPtr += dstStride[0];
972 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
973 uint16_t scale= dither_scale[dst_depth-1][src_depth-1];\
974 int shift= src_depth-dst_depth + dither_scale[src_depth-2][dst_depth-1];\
975 for (i = 0; i < height; i++) {\
976 const uint8_t *dither= dithers[src_depth-9][i&7];\
977 for (j = 0; j < length-7; j+=8){\
978 dst[j+0] = dbswap((bswap(src[j+0]) + dither[0])*scale>>shift);\
979 dst[j+1] = dbswap((bswap(src[j+1]) + dither[1])*scale>>shift);\
980 dst[j+2] = dbswap((bswap(src[j+2]) + dither[2])*scale>>shift);\
981 dst[j+3] = dbswap((bswap(src[j+3]) + dither[3])*scale>>shift);\
982 dst[j+4] = dbswap((bswap(src[j+4]) + dither[4])*scale>>shift);\
983 dst[j+5] = dbswap((bswap(src[j+5]) + dither[5])*scale>>shift);\
984 dst[j+6] = dbswap((bswap(src[j+6]) + dither[6])*scale>>shift);\
985 dst[j+7] = dbswap((bswap(src[j+7]) + dither[7])*scale>>shift);\
987 for (; j < length; j++)\
988 dst[j] = dbswap((bswap(src[j]) + dither[j&7])*scale>>shift);\
994 int srcStride[],
int srcSliceY,
int srcSliceH,
995 uint8_t *dst[],
int dstStride[])
1000 for (plane = 0; plane < 4; plane++) {
1004 const uint8_t *srcPtr = src[plane];
1005 uint8_t *dstPtr = dst[plane] + dstStride[plane] *
y;
1006 int shiftonly= plane==1 || plane==2 || (!c->
srcRange && plane==0);
1011 if (plane == 1 && !dst[2])
continue;
1012 if (!src[plane] || (plane == 1 && !src[2])) {
1014 fillPlane16(dst[plane], dstStride[plane], length, height, y,
1018 fillPlane(dst[plane], dstStride[plane], length, height, y,
1019 (plane == 3) ? 255 : 128);
1027 const uint16_t *srcPtr2 = (
const uint16_t *) srcPtr;
1028 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1030 if (dst_depth == 8) {
1032 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
1036 }
else if (src_depth == 8) {
1037 for (i = 0; i <
height; i++) {
1040 for (j = 0; j < length; j++)\
1041 w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
1043 for (j = 0; j < length; j++)\
1044 w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
1045 (srcPtr[j]>>(2*8-dst_depth)));\
1052 dstPtr2 += dstStride[plane]/2;
1053 srcPtr += srcStride[plane];
1055 }
else if (src_depth <= dst_depth) {
1056 int orig_length =
length;
1057 for (i = 0; i <
height; i++) {
1061 unsigned shift = dst_depth - src_depth;
1062 length = orig_length;
1064 #define FAST_COPY_UP(shift) \
1065 for (j = 0; j < length - 3; j += 4) { \
1066 uint64_t v = AV_RN64A(srcPtr2 + j); \
1067 AV_WN64A(dstPtr2 + j, v << shift); \
1071 #define FAST_COPY_UP(shift) \
1072 for (j = 0; j < length - 1; j += 2) { \
1073 uint32_t v = AV_RN32A(srcPtr2 + j); \
1074 AV_WN32A(dstPtr2 + j, v << shift); \
1084 #define COPY_UP(r,w) \
1086 for (j = 0; j < length; j++){ \
1087 unsigned int v= r(&srcPtr2[j]);\
1088 w(&dstPtr2[j], v<<(dst_depth-src_depth));\
1091 for (j = 0; j < length; j++){ \
1092 unsigned int v= r(&srcPtr2[j]);\
1093 w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
1094 (v>>(2*src_depth-dst_depth)));\
1110 dstPtr2 += dstStride[plane]/2;
1111 srcPtr2 += srcStride[plane]/2;
1116 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
1131 for (i = 0; i <
height; i++) {
1132 for (j = 0; j <
length; j++)
1133 ((uint16_t *) dstPtr)[j] =
av_bswap16(((
const uint16_t *) srcPtr)[j]);
1134 srcPtr += srcStride[plane];
1135 dstPtr += dstStride[plane];
1137 }
else if (dstStride[plane] == srcStride[plane] &&
1138 srcStride[plane] > 0 && srcStride[plane] == length) {
1139 memcpy(dst[plane] + dstStride[plane] * y, src[plane],
1140 height * dstStride[plane]);
1146 for (i = 0; i <
height; i++) {
1147 memcpy(dstPtr, srcPtr, length);
1148 srcPtr += srcStride[plane];
1149 dstPtr += dstStride[plane];
1158 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
1159 ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
1160 (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
1171 needsDither =
isAnyRGB(dstFormat) &&
1208 #define isByteRGB(f) ( \
1209 f == AV_PIX_FMT_RGB32 || \
1210 f == AV_PIX_FMT_RGB32_1 || \
1211 f == AV_PIX_FMT_RGB24 || \
1212 f == AV_PIX_FMT_BGR32 || \
1213 f == AV_PIX_FMT_BGR32_1 || \
1214 f == AV_PIX_FMT_BGR24)
1301 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_GRAY8A)
1303 if ( srcFormat == dstFormat ||
1329 int num_pixels,
const uint8_t *
palette)
1333 for (i = 0; i < num_pixels; i++)
1334 ((uint32_t *) dst)[i] = ((
const uint32_t *) palette)[src[i]];
1339 int num_pixels,
const uint8_t *
palette)
1343 for (i = 0; i < num_pixels; i++) {
1345 dst[0] = palette[src[i] * 4 + 0];
1346 dst[1] = palette[src[i] * 4 + 1];
1347 dst[2] = palette[src[i] * 4 + 2];