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;
126 int srcSliceY,
int srcSliceH,
int width,
127 uint8_t *dst,
int dstStride)
129 dst += dstStride * srcSliceY;
130 if (dstStride == srcStride && srcStride > 0) {
131 memcpy(dst,
src, srcSliceH * dstStride);
134 for (
i = 0;
i < srcSliceH;
i++) {
143 int srcStride[],
int srcSliceY,
144 int srcSliceH, uint8_t *dstParam[],
147 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
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;
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 *dstParam[],
188 uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY;
191 dstParam[0], dstStride[0]);
195 srcStride[1], srcStride[2], dstStride[1]);
198 srcStride[2], srcStride[1], dstStride[1]);
204 int srcStride[],
int srcSliceY,
205 int srcSliceH, uint8_t *dstParam[],
208 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY;
209 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY;
212 dstParam[0], dstStride[0]);
216 srcStride[1], dstStride[1], dstStride[2]);
219 srcStride[1], dstStride[2], dstStride[1]);
225 uint8_t *dst2,
int dstStride2,
226 const uint8_t *
src,
int srcStride,
230 const uint8_t *
src2 =
src + srcStride;
232 for (
int y = 0; y <
h; y += 2) {
233 for (
int x = 0; x <
w; x++) {
234 dst1[x] = (
src1[4 * x + 0] +
src1[4 * x + 2] +
235 src2[4 * x + 0] +
src2[4 * x + 2]) >> 2;
236 dst2[x] = (
src1[4 * x + 1] +
src1[4 * x + 3] +
237 src2[4 * x + 1] +
src2[4 * x + 3]) >> 2;
239 src1 += srcStride * 2;
240 src2 += srcStride * 2;
247 int srcStride[],
int srcSliceY,
int srcSliceH,
248 uint8_t *dstParam[],
int dstStride[])
250 uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
251 uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
254 dstParam[0], dstStride[0]);
258 src[1], srcStride[1],
c->srcW / 2, srcSliceH);
261 src[1], srcStride[1],
c->srcW / 2, srcSliceH);
267 int srcStride[],
int srcSliceY,
268 int srcSliceH, uint8_t *dstParam8[],
273 const uint16_t **
src = (
const uint16_t**)src8;
274 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
275 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
279 const int shift[3] = {
288 av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
289 dstStride[0] % 2 || dstStride[1] % 2));
291 for (y = 0; y < srcSliceH; y++) {
292 uint16_t *tdstY =
dstY;
293 const uint16_t *tsrc0 =
src[0];
294 for (x =
c->srcW; x > 0; x--) {
295 *tdstY++ = *tsrc0++ <<
shift[0];
297 src[0] += srcStride[0] / 2;
298 dstY += dstStride[0] / 2;
301 uint16_t *tdstUV = dstUV;
302 const uint16_t *tsrc1 =
src[1];
303 const uint16_t *tsrc2 =
src[2];
304 for (x =
c->srcW / 2; x > 0; x--) {
305 *tdstUV++ = *tsrc1++ <<
shift[1];
306 *tdstUV++ = *tsrc2++ <<
shift[2];
308 src[1] += srcStride[1] / 2;
309 src[2] += srcStride[2] / 2;
310 dstUV += dstStride[1] / 2;
317 #if AV_HAVE_BIGENDIAN
318 #define output_pixel(p, v) do { \
319 uint16_t *pp = (p); \
323 #define output_pixel(p, v) (*p) = (v)
327 int srcStride[],
int srcSliceY,
328 int srcSliceH, uint8_t *dstParam8[],
331 uint16_t *
dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
332 uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
335 av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
337 for (y = 0; y < srcSliceH; y++) {
338 uint16_t *tdstY =
dstY;
339 const uint8_t *tsrc0 =
src[0];
340 for (x =
c->srcW; x > 0; x--) {
344 src[0] += srcStride[0];
345 dstY += dstStride[0] / 2;
348 uint16_t *tdstUV = dstUV;
349 const uint8_t *tsrc1 =
src[1];
350 const uint8_t *tsrc2 =
src[2];
351 for (x =
c->srcW / 2; x > 0; x--) {
357 src[1] += srcStride[1];
358 src[2] += srcStride[2];
359 dstUV += dstStride[1] / 2;
369 int srcStride[],
int srcSliceY,
int srcSliceH,
370 uint8_t *dstParam[],
int dstStride[])
372 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
375 srcStride[1], dstStride[0]);
381 int srcStride[],
int srcSliceY,
int srcSliceH,
382 uint8_t *dstParam[],
int dstStride[])
384 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
387 srcStride[1], dstStride[0]);
393 int srcStride[],
int srcSliceY,
int srcSliceH,
394 uint8_t *dstParam[],
int dstStride[])
396 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
399 srcStride[1], dstStride[0]);
405 int srcStride[],
int srcSliceY,
int srcSliceH,
406 uint8_t *dstParam[],
int dstStride[])
408 uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
411 srcStride[1], dstStride[0]);
417 int srcStride[],
int srcSliceY,
int srcSliceH,
418 uint8_t *dstParam[],
int dstStride[])
420 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
421 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
422 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
425 dstStride[1], srcStride[0]);
428 fillPlane(dstParam[3], dstStride[3],
c->srcW, srcSliceH, srcSliceY, 255);
434 int srcStride[],
int srcSliceY,
int srcSliceH,
435 uint8_t *dstParam[],
int dstStride[])
437 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
438 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
439 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
442 dstStride[1], srcStride[0]);
448 int srcStride[],
int srcSliceY,
int srcSliceH,
449 uint8_t *dstParam[],
int dstStride[])
451 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
452 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
453 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
456 dstStride[1], srcStride[0]);
459 fillPlane(dstParam[3], dstStride[3],
c->srcW, srcSliceH, srcSliceY, 255);
465 int srcStride[],
int srcSliceY,
int srcSliceH,
466 uint8_t *dstParam[],
int dstStride[])
468 uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
469 uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
470 uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
473 dstStride[1], srcStride[0]);
479 const uint8_t *palette)
482 for (
i = 0;
i < num_pixels;
i++)
483 ((uint32_t *) dst)[
i] = ((
const uint32_t *) palette)[
src[
i << 1]] | (
src[(
i << 1) + 1] << 24);
487 const uint8_t *palette)
491 for (
i = 0;
i < num_pixels;
i++)
492 ((uint32_t *) dst)[
i] = ((
const uint32_t *) palette)[
src[
i << 1]] |
src[(
i << 1) + 1];
496 const uint8_t *palette)
500 for (
i = 0;
i < num_pixels;
i++) {
502 dst[0] = palette[
src[
i << 1] * 4 + 0];
503 dst[1] = palette[
src[
i << 1] * 4 + 1];
504 dst[2] = palette[
src[
i << 1] * 4 + 2];
510 int srcStride[],
int srcSliceY,
int srcSliceH,
511 uint8_t *dst[],
int dstStride[])
515 for (p = 0; p < 4; p++) {
516 int srcstr = srcStride[p] / 2;
517 int dststr = dstStride[p] / 2;
518 uint16_t *dstPtr = (uint16_t *) dst[p];
519 const uint16_t *srcPtr = (
const uint16_t *)
src[p];
521 if(!dstPtr || !srcPtr)
523 dstPtr += (srcSliceY >>
c->chrDstVSubSample) * dststr;
524 for (
i = 0;
i < (srcSliceH >>
c->chrDstVSubSample);
i++) {
525 for (j = 0; j < min_stride; j++) {
537 int srcStride[],
int srcSliceY,
int srcSliceH,
538 uint8_t *dst[],
int dstStride[])
542 for (p = 0; p < 4; p++) {
543 int srcstr = srcStride[p] / 4;
544 int dststr = dstStride[p] / 4;
545 uint32_t *dstPtr = (uint32_t *) dst[p];
546 const uint32_t *srcPtr = (
const uint32_t *)
src[p];
548 if(!dstPtr || !srcPtr)
550 dstPtr += (srcSliceY >>
c->chrDstVSubSample) * dststr;
551 for (
i = 0;
i < (srcSliceH >>
c->chrDstVSubSample);
i++) {
552 for (j = 0; j < min_stride; j++) {
565 int srcSliceY,
int srcSliceH, uint8_t *dst[],
570 void (*
conv)(
const uint8_t *
src, uint8_t *dst,
int num_pixels,
571 const uint8_t *palette) =
NULL;
573 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
574 const uint8_t *srcPtr =
src[0];
600 for (
i = 0;
i < srcSliceH;
i++) {
601 conv(srcPtr, dstPtr,
c->srcW, (uint8_t *)
c->pal_rgb);
602 srcPtr += srcStride[0];
603 dstPtr += dstStride[0];
611 uint16_t *dst[],
int dstStride[],
int srcSliceH,
612 int src_alpha,
int swap,
int shift,
int width)
615 int dst_alpha = dst[3] !=
NULL;
616 for (
h = 0;
h < srcSliceH;
h++) {
617 uint16_t *src_line = (uint16_t *)(
src + srcStride *
h);
620 if (src_alpha && dst_alpha) {
621 for (x = 0; x <
width; x++) {
627 }
else if (dst_alpha) {
628 for (x = 0; x <
width; x++) {
634 }
else if (src_alpha) {
635 for (x = 0; x <
width; x++) {
642 for (x = 0; x <
width; x++) {
650 if (src_alpha && dst_alpha) {
651 for (x = 0; x <
width; x++) {
657 }
else if (dst_alpha) {
658 for (x = 0; x <
width; x++) {
664 }
else if (src_alpha) {
665 for (x = 0; x <
width; x++) {
672 for (x = 0; x <
width; x++) {
680 if (src_alpha && dst_alpha) {
681 for (x = 0; x <
width; x++) {
687 }
else if (dst_alpha) {
688 for (x = 0; x <
width; x++) {
694 }
else if (src_alpha) {
695 for (x = 0; x <
width; x++) {
702 for (x = 0; x <
width; x++) {
710 if (src_alpha && dst_alpha) {
711 for (x = 0; x <
width; x++) {
712 dst[0][x] = *src_line++ >>
shift;
713 dst[1][x] = *src_line++ >>
shift;
714 dst[2][x] = *src_line++ >>
shift;
715 dst[3][x] = *src_line++ >>
shift;
717 }
else if (dst_alpha) {
718 for (x = 0; x <
width; x++) {
719 dst[0][x] = *src_line++ >>
shift;
720 dst[1][x] = *src_line++ >>
shift;
721 dst[2][x] = *src_line++ >>
shift;
724 }
else if (src_alpha) {
725 for (x = 0; x <
width; x++) {
726 dst[0][x] = *src_line++ >>
shift;
727 dst[1][x] = *src_line++ >>
shift;
728 dst[2][x] = *src_line++ >>
shift;
732 for (x = 0; x <
width; x++) {
733 dst[0][x] = *src_line++ >>
shift;
734 dst[1][x] = *src_line++ >>
shift;
735 dst[2][x] = *src_line++ >>
shift;
739 for (
i = 0;
i < 4;
i++)
740 dst[
i] += dstStride[
i] >> 1;
745 int srcStride[],
int srcSliceY,
int srcSliceH,
746 uint8_t *dst[],
int dstStride[])
748 uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
749 uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
750 int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
751 int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
769 src_format->
name, dst_format->
name);
774 dst2013[
i] += stride2013[
i] * srcSliceY / 2;
775 dst1023[
i] += stride1023[
i] * srcSliceY / 2;
778 switch (
c->srcFormat) {
784 dst2013, stride2013, srcSliceH,
alpha, swap,
792 dst1023, stride1023, srcSliceH,
alpha, swap,
797 "unsupported conversion to planar RGB %s -> %s\n",
798 src_format->
name, dst_format->
name);
805 uint8_t *dst,
int dstStride,
int srcSliceH,
809 int src_alpha =
src[3] !=
NULL;
810 int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
811 for (
h = 0;
h < srcSliceH;
h++) {
812 uint16_t *dest = (uint16_t *)(dst + dstStride *
h);
817 if (
alpha && !src_alpha) {
818 for (x = 0; x <
width; x++) {
820 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
822 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
824 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
827 }
else if (
alpha && src_alpha) {
828 for (x = 0; x <
width; x++) {
830 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
832 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
834 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
836 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
839 for (x = 0; x <
width; x++) {
841 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
843 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
845 *dest++ =
av_bswap16(component << scale_high | component >> scale_low);
850 if (
alpha && !src_alpha) {
851 for (x = 0; x <
width; x++) {
857 }
else if (
alpha && src_alpha) {
858 for (x = 0; x <
width; x++) {
865 for (x = 0; x <
width; x++) {
873 if (
alpha && !src_alpha) {
874 for (x = 0; x <
width; x++) {
880 }
else if (
alpha && src_alpha) {
881 for (x = 0; x <
width; x++) {
888 for (x = 0; x <
width; x++) {
896 if (
alpha && !src_alpha) {
897 for (x = 0; x <
width; x++) {
898 *dest++ =
src[0][x] << scale_high |
src[0][x] >> scale_low;
899 *dest++ =
src[1][x] << scale_high |
src[1][x] >> scale_low;
900 *dest++ =
src[2][x] << scale_high |
src[2][x] >> scale_low;
903 }
else if (
alpha && src_alpha) {
904 for (x = 0; x <
width; x++) {
905 *dest++ =
src[0][x] << scale_high |
src[0][x] >> scale_low;
906 *dest++ =
src[1][x] << scale_high |
src[1][x] >> scale_low;
907 *dest++ =
src[2][x] << scale_high |
src[2][x] >> scale_low;
908 *dest++ =
src[3][x] << scale_high |
src[3][x] >> scale_low;
911 for (x = 0; x <
width; x++) {
912 *dest++ =
src[0][x] << scale_high |
src[0][x] >> scale_low;
913 *dest++ =
src[1][x] << scale_high |
src[1][x] >> scale_low;
914 *dest++ =
src[2][x] << scale_high |
src[2][x] >> scale_low;
918 for (
i = 0;
i < 3 + src_alpha;
i++)
919 src[
i] += srcStride[
i] >> 1;
924 int srcStride[],
int srcSliceY,
int srcSliceH,
925 uint8_t *dst[],
int dstStride[])
927 const uint16_t *src102[] = { (uint16_t *)
src[1], (uint16_t *)
src[0], (uint16_t *)
src[2], (uint16_t *)
src[3] };
928 const uint16_t *src201[] = { (uint16_t *)
src[2], (uint16_t *)
src[0], (uint16_t *)
src[1], (uint16_t *)
src[3] };
929 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
930 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
933 int bits_per_sample = src_format->
comp[0].
depth;
944 bits_per_sample <= 8) {
946 src_format->
name, dst_format->
name);
949 switch (
c->dstFormat) {
953 dst[0] + srcSliceY * dstStride[0], dstStride[0],
954 srcSliceH, 0, swap, bits_per_sample,
c->srcW);
959 dst[0] + srcSliceY * dstStride[0], dstStride[0],
960 srcSliceH, 0, swap, bits_per_sample,
c->srcW);
965 dst[0] + srcSliceY * dstStride[0], dstStride[0],
966 srcSliceH, 1, swap, bits_per_sample,
c->srcW);
971 dst[0] + srcSliceY * dstStride[0], dstStride[0],
972 srcSliceH, 1, swap, bits_per_sample,
c->srcW);
976 "unsupported planar RGB conversion %s -> %s\n",
977 src_format->
name, dst_format->
name);
984 uint8_t *dst,
int dstStride,
int srcSliceH,
988 for (
h = 0;
h < srcSliceH;
h++) {
989 uint8_t *dest = dst + dstStride *
h;
990 for (x = 0; x <
width; x++) {
996 for (
i = 0;
i < 3;
i++)
997 src[
i] += srcStride[
i];
1002 uint8_t *dst,
int dstStride,
int srcSliceH,
1003 int alpha_first,
int width)
1006 for (
h = 0;
h < srcSliceH;
h++) {
1007 uint8_t *dest = dst + dstStride *
h;
1010 for (x = 0; x <
width; x++) {
1012 *dest++ =
src[0][x];
1013 *dest++ =
src[1][x];
1014 *dest++ =
src[2][x];
1017 for (x = 0; x <
width; x++) {
1018 *dest++ =
src[0][x];
1019 *dest++ =
src[1][x];
1020 *dest++ =
src[2][x];
1025 for (
i = 0;
i < 3;
i++)
1026 src[
i] += srcStride[
i];
1031 uint8_t *dst,
int dstStride,
int srcSliceH,
1032 int alpha_first,
int width)
1035 for (
h = 0;
h < srcSliceH;
h++) {
1036 uint8_t *dest = dst + dstStride *
h;
1039 for (x = 0; x <
width; x++) {
1040 *dest++ =
src[3][x];
1041 *dest++ =
src[0][x];
1042 *dest++ =
src[1][x];
1043 *dest++ =
src[2][x];
1046 for (x = 0; x <
width; x++) {
1047 *dest++ =
src[0][x];
1048 *dest++ =
src[1][x];
1049 *dest++ =
src[2][x];
1050 *dest++ =
src[3][x];
1054 for (
i = 0;
i < 4;
i++)
1055 src[
i] += srcStride[
i];
1060 int srcStride[],
int srcSliceY,
int srcSliceH,
1061 uint8_t *dst[],
int dstStride[])
1063 int alpha_first = 0;
1064 const uint8_t *src102[] = {
src[1],
src[0],
src[2],
src[3] };
1065 const uint8_t *src201[] = {
src[2],
src[0],
src[1],
src[3] };
1066 int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1067 int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1076 switch (
c->dstFormat) {
1079 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1080 srcSliceH,
c->srcW);
1085 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1086 srcSliceH,
c->srcW);
1093 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1094 srcSliceH, alpha_first,
c->srcW);
1101 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1102 srcSliceH, alpha_first,
c->srcW);
1107 "unsupported planar RGB conversion %s -> %s\n",
1116 int srcStride[],
int srcSliceY,
int srcSliceH,
1117 uint8_t *dst[],
int dstStride[])
1119 int alpha_first = 0;
1120 const uint8_t *src102[] = {
src[1],
src[0],
src[2] };
1121 const uint8_t *src201[] = {
src[2],
src[0],
src[1] };
1122 int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
1123 int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
1132 switch (
c->dstFormat) {
1135 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1136 srcSliceH,
c->srcW);
1141 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1142 srcSliceH,
c->srcW);
1149 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1150 srcSliceH, alpha_first,
c->srcW);
1157 dst[0] + srcSliceY * dstStride[0], dstStride[0],
1158 srcSliceH, alpha_first,
c->srcW);
1163 "unsupported planar RGB conversion %s -> %s\n",
1172 const uint8_t *
src[],
int srcStride[],
1173 int srcSliceY,
int srcSliceH,
1174 uint8_t *dst[],
int dstStride[])
1177 dst[0], dstStride[0]);
1179 dst[1], dstStride[1]);
1181 dst[2], dstStride[2]);
1183 fillPlane(dst[3], dstStride[3],
c->srcW, srcSliceH, srcSliceY, 255);
1189 uint8_t *dst[],
int dstStride[],
int srcSliceH,
1190 int alpha_first,
int inc_size,
int width)
1202 for (
h = 0;
h < srcSliceH;
h++) {
1203 for (x = 0; x <
width; x++) {
1204 dest[0][x] =
src[0];
1205 dest[1][x] =
src[1];
1206 dest[2][x] =
src[2];
1210 src += srcStride -
width * inc_size;
1211 dest[0] += dstStride[0];
1212 dest[1] += dstStride[1];
1213 dest[2] += dstStride[2];
1218 int srcStride[],
int srcSliceY,
int srcSliceH,
1219 uint8_t *dst[],
int dstStride[])
1221 int alpha_first = 0;
1222 int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1223 int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1224 uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1225 dst[0] + srcSliceY * dstStride[0],
1226 dst[2] + srcSliceY * dstStride[2] };
1227 uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1228 dst[0] + srcSliceY * dstStride[0],
1229 dst[1] + srcSliceY * dstStride[1] };
1231 switch (
c->srcFormat) {
1234 stride201, srcSliceH, alpha_first, 3,
c->srcW);
1238 stride102, srcSliceH, alpha_first, 3,
c->srcW);
1244 stride201, srcSliceH, alpha_first, 4,
c->srcW);
1250 stride102, srcSliceH, alpha_first, 4,
c->srcW);
1254 "unsupported planar RGB conversion %s -> %s\n",
1264 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1269 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1274 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1279 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1284 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1289 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1294 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1299 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1304 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1309 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1314 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1319 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1323 int srcSliceH, uint8_t* dst[],
int dstStride[])
1325 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1326 const uint8_t *srcPtr=
src[0];
1328 void (*
copy) (
const uint8_t *
src,
int src_stride, uint8_t *dst,
int dst_stride,
int width);
1329 void (*
interpolate)(
const uint8_t *
src,
int src_stride, uint8_t *dst,
int dst_stride,
int width);
1331 switch(
c->srcFormat) {
1332 #define CASE(pixfmt, prefix) \
1333 case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1334 interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1354 copy(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1355 srcPtr += 2 * srcStride[0];
1356 dstPtr += 2 * dstStride[0];
1358 for (
i = 2;
i < srcSliceH - 2;
i += 2) {
1359 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1360 srcPtr += 2 * srcStride[0];
1361 dstPtr += 2 * dstStride[0];
1364 if (
i + 1 == srcSliceH) {
1365 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0],
c->srcW);
1366 }
else if (
i < srcSliceH)
1367 copy(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1372 int srcSliceH, uint8_t* dst[],
int dstStride[])
1374 uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1375 const uint8_t *srcPtr=
src[0];
1377 void (*
copy) (
const uint8_t *
src,
int src_stride, uint8_t *dst,
int dst_stride,
int width);
1378 void (*
interpolate)(
const uint8_t *
src,
int src_stride, uint8_t *dst,
int dst_stride,
int width);
1380 switch(
c->srcFormat) {
1381 #define CASE(pixfmt, prefix) \
1382 case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
1383 interpolate = bayer_##prefix##_to_rgb48_interpolate; \
1403 copy(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1404 srcPtr += 2 * srcStride[0];
1405 dstPtr += 2 * dstStride[0];
1407 for (
i = 2;
i < srcSliceH - 2;
i += 2) {
1408 interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1409 srcPtr += 2 * srcStride[0];
1410 dstPtr += 2 * dstStride[0];
1413 if (
i + 1 == srcSliceH) {
1414 copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0],
c->srcW);
1415 }
else if (
i < srcSliceH)
1416 copy(srcPtr, srcStride[0], dstPtr, dstStride[0],
c->srcW);
1421 int srcSliceH, uint8_t* dst[],
int dstStride[])
1423 const uint8_t *srcPtr=
src[0];
1424 uint8_t *
dstY= dst[0] + srcSliceY * dstStride[0];
1425 uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1426 uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1431 switch(
c->srcFormat) {
1432 #define CASE(pixfmt, prefix) \
1433 case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1434 interpolate = bayer_##prefix##_to_yv12_interpolate; \
1454 copy(srcPtr, srcStride[0],
dstY, dstU, dstV, dstStride[0],
c->srcW,
c->input_rgb2yuv_table);
1455 srcPtr += 2 * srcStride[0];
1456 dstY += 2 * dstStride[0];
1457 dstU += dstStride[1];
1458 dstV += dstStride[1];
1460 for (
i = 2;
i < srcSliceH - 2;
i += 2) {
1461 interpolate(srcPtr, srcStride[0],
dstY, dstU, dstV, dstStride[0],
c->srcW,
c->input_rgb2yuv_table);
1462 srcPtr += 2 * srcStride[0];
1463 dstY += 2 * dstStride[0];
1464 dstU += dstStride[1];
1465 dstV += dstStride[1];
1468 if (
i + 1 == srcSliceH) {
1469 copy(srcPtr, -srcStride[0],
dstY, dstU, dstV, -dstStride[0],
c->srcW,
c->input_rgb2yuv_table);
1470 }
else if (
i < srcSliceH)
1471 copy(srcPtr, srcStride[0],
dstY, dstU, dstV, dstStride[0],
c->srcW,
c->input_rgb2yuv_table);
1475 #define isRGBA32(x) ( \
1476 (x) == AV_PIX_FMT_ARGB \
1477 || (x) == AV_PIX_FMT_RGBA \
1478 || (x) == AV_PIX_FMT_BGRA \
1479 || (x) == AV_PIX_FMT_ABGR \
1482 #define isRGBA64(x) ( \
1483 (x) == AV_PIX_FMT_RGBA64LE \
1484 || (x) == AV_PIX_FMT_RGBA64BE \
1485 || (x) == AV_PIX_FMT_BGRA64LE \
1486 || (x) == AV_PIX_FMT_BGRA64BE \
1489 #define isRGB48(x) ( \
1490 (x) == AV_PIX_FMT_RGB48LE \
1491 || (x) == AV_PIX_FMT_RGB48BE \
1492 || (x) == AV_PIX_FMT_BGR48LE \
1493 || (x) == AV_PIX_FMT_BGR48BE \
1497 typedef void (*
rgbConvFn) (
const uint8_t *, uint8_t *, int);
1502 const int srcId =
c->srcFormatBpp;
1503 const int dstId =
c->dstFormatBpp;
1506 #define IS_NOT_NE(bpp, desc) \
1507 (((bpp + 7) >> 3) == 2 && \
1508 (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1510 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1530 else if (
CONV_IS(RGB48LE, BGR48BE)
1535 if (
CONV_IS(RGB48LE, BGRA64LE)
1539 else if (
CONV_IS(RGB48LE, BGRA64BE)
1543 if (
CONV_IS(RGB48LE, RGBA64LE)
1547 else if (
CONV_IS(RGB48LE, RGBA64BE)
1552 if (
CONV_IS(RGBA64LE, BGR48LE)
1556 else if (
CONV_IS(RGBA64LE, BGR48BE)
1560 else if (
CONV_IS(RGBA64LE, RGB48LE)
1564 else if (
CONV_IS(RGBA64LE, RGB48BE)
1572 switch (srcId | (dstId << 16)) {
1589 switch (srcId | (dstId << 16)) {
1622 int srcSliceY,
int srcSliceH, uint8_t *dst[],
1630 const int srcBpp = (
c->srcFormatBpp + 7) >> 3;
1631 const int dstBpp = (
c->dstFormatBpp + 7) >> 3;
1638 const uint8_t *srcPtr =
src[0];
1639 uint8_t *dstPtr = dst[0];
1640 int src_bswap =
IS_NOT_NE(
c->srcFormatBpp, desc_src);
1641 int dst_bswap =
IS_NOT_NE(
c->dstFormatBpp, desc_dst);
1651 for (
i = 0;
i < srcSliceH;
i++)
1652 dstPtr[dstStride[0] * (srcSliceY +
i)] = 255;
1656 if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
1657 !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
1658 conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
1659 (srcSliceH - 1) * srcStride[0] +
c->srcW * srcBpp);
1662 dstPtr += dstStride[0] * srcSliceY;
1664 for (
i = 0;
i < srcSliceH;
i++) {
1666 for(j=0; j<
c->srcW; j++)
1667 ((uint16_t*)
c->formatConvBuffer)[j] =
av_bswap16(((uint16_t*)srcPtr)[j]);
1668 conv(
c->formatConvBuffer, dstPtr,
c->srcW * srcBpp);
1670 conv(srcPtr, dstPtr,
c->srcW * srcBpp);
1672 for(j=0; j<
c->srcW; j++)
1673 ((uint16_t*)dstPtr)[j] =
av_bswap16(((uint16_t*)dstPtr)[j]);
1674 srcPtr += srcStride[0];
1675 dstPtr += dstStride[0];
1683 int srcStride[],
int srcSliceY,
int srcSliceH,
1684 uint8_t *dst[],
int dstStride[])
1688 dst[0] + srcSliceY * dstStride[0],
1689 dst[1] + (srcSliceY >> 1) * dstStride[1],
1690 dst[2] + (srcSliceY >> 1) * dstStride[2],
1692 dstStride[0], dstStride[1], srcStride[0],
1693 c->input_rgb2yuv_table);
1695 fillPlane(dst[3], dstStride[3],
c->srcW, srcSliceH, srcSliceY, 255);
1700 int srcStride[],
int srcSliceY,
int srcSliceH,
1701 uint8_t *dst[],
int dstStride[])
1704 dst[0], dstStride[0]);
1706 planar2x(
src[1], dst[1] + dstStride[1] * (srcSliceY >> 1),
c->chrSrcW,
1707 srcSliceH >> 2, srcStride[1], dstStride[1]);
1708 planar2x(
src[2], dst[2] + dstStride[2] * (srcSliceY >> 1),
c->chrSrcW,
1709 srcSliceH >> 2, srcStride[2], dstStride[2]);
1711 fillPlane(dst[3], dstStride[3],
c->srcW, srcSliceH, srcSliceY, 255);
1716 int srcStride[],
int srcSliceY,
1717 int srcSliceH, uint8_t *dst[],
int dstStride[])
1720 ptrdiff_t dstStrideFloat = dstStride[0] >> 2;
1721 const uint8_t *srcPtr =
src[0];
1722 float *dstPtr = (
float *)(dst[0] + dstStride[0] * srcSliceY);
1724 for (y = 0; y < srcSliceH; ++y){
1725 for (x = 0; x <
c->srcW; ++x){
1726 dstPtr[x] =
c->uint2float_lut[srcPtr[x]];
1728 srcPtr += srcStride[0];
1729 dstPtr += dstStrideFloat;
1736 int srcStride[],
int srcSliceY,
1737 int srcSliceH, uint8_t* dst[],
int dstStride[])
1740 ptrdiff_t srcStrideFloat = srcStride[0] >> 2;
1741 const float *srcPtr = (
const float *)
src[0];
1742 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
1744 for (y = 0; y < srcSliceH; ++y){
1745 for (x = 0; x <
c->srcW; ++x){
1748 srcPtr += srcStrideFloat;
1749 dstPtr += dstStride[0];
1757 int srcStride[],
int srcSliceY,
int srcSliceH,
1758 uint8_t *dst[],
int dstStride[])
1760 if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
1761 memcpy(dst[0] + dstStride[0] * srcSliceY,
src[0], srcSliceH * dstStride[0]);
1764 const uint8_t *srcPtr =
src[0];
1765 uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
1769 while (length +
c->srcW <=
FFABS(dstStride[0]) &&
1770 length +
c->srcW <=
FFABS(srcStride[0]))
1774 for (
i = 0;
i < srcSliceH;
i++) {
1775 memcpy(dstPtr, srcPtr, length);
1776 srcPtr += srcStride[0];
1777 dstPtr += dstStride[0];
1783 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
1784 unsigned shift= src_depth-dst_depth, tmp;\
1785 if (c->dither == SWS_DITHER_NONE) {\
1786 for (i = 0; i < height; i++) {\
1787 for (j = 0; j < length-7; j+=8) {\
1788 dst[j+0] = dbswap(bswap(src[j+0])>>shift);\
1789 dst[j+1] = dbswap(bswap(src[j+1])>>shift);\
1790 dst[j+2] = dbswap(bswap(src[j+2])>>shift);\
1791 dst[j+3] = dbswap(bswap(src[j+3])>>shift);\
1792 dst[j+4] = dbswap(bswap(src[j+4])>>shift);\
1793 dst[j+5] = dbswap(bswap(src[j+5])>>shift);\
1794 dst[j+6] = dbswap(bswap(src[j+6])>>shift);\
1795 dst[j+7] = dbswap(bswap(src[j+7])>>shift);\
1797 for (; j < length; j++) {\
1798 dst[j] = dbswap(bswap(src[j])>>shift);\
1803 } else if (shiftonly) {\
1804 for (i = 0; i < height; i++) {\
1805 const uint8_t *dither= dithers[shift-1][i&7];\
1806 for (j = 0; j < length-7; j+=8) {\
1807 tmp = (bswap(src[j+0]) + dither[0])>>shift; dst[j+0] = dbswap(tmp - (tmp>>dst_depth));\
1808 tmp = (bswap(src[j+1]) + dither[1])>>shift; dst[j+1] = dbswap(tmp - (tmp>>dst_depth));\
1809 tmp = (bswap(src[j+2]) + dither[2])>>shift; dst[j+2] = dbswap(tmp - (tmp>>dst_depth));\
1810 tmp = (bswap(src[j+3]) + dither[3])>>shift; dst[j+3] = dbswap(tmp - (tmp>>dst_depth));\
1811 tmp = (bswap(src[j+4]) + dither[4])>>shift; dst[j+4] = dbswap(tmp - (tmp>>dst_depth));\
1812 tmp = (bswap(src[j+5]) + dither[5])>>shift; dst[j+5] = dbswap(tmp - (tmp>>dst_depth));\
1813 tmp = (bswap(src[j+6]) + dither[6])>>shift; dst[j+6] = dbswap(tmp - (tmp>>dst_depth));\
1814 tmp = (bswap(src[j+7]) + dither[7])>>shift; dst[j+7] = dbswap(tmp - (tmp>>dst_depth));\
1816 for (; j < length; j++) {\
1817 tmp = (bswap(src[j]) + dither[j&7])>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth));\
1823 for (i = 0; i < height; i++) {\
1824 const uint8_t *dither= dithers[shift-1][i&7];\
1825 for (j = 0; j < length-7; j+=8) {\
1826 tmp = bswap(src[j+0]); dst[j+0] = dbswap((tmp - (tmp>>dst_depth) + dither[0])>>shift);\
1827 tmp = bswap(src[j+1]); dst[j+1] = dbswap((tmp - (tmp>>dst_depth) + dither[1])>>shift);\
1828 tmp = bswap(src[j+2]); dst[j+2] = dbswap((tmp - (tmp>>dst_depth) + dither[2])>>shift);\
1829 tmp = bswap(src[j+3]); dst[j+3] = dbswap((tmp - (tmp>>dst_depth) + dither[3])>>shift);\
1830 tmp = bswap(src[j+4]); dst[j+4] = dbswap((tmp - (tmp>>dst_depth) + dither[4])>>shift);\
1831 tmp = bswap(src[j+5]); dst[j+5] = dbswap((tmp - (tmp>>dst_depth) + dither[5])>>shift);\
1832 tmp = bswap(src[j+6]); dst[j+6] = dbswap((tmp - (tmp>>dst_depth) + dither[6])>>shift);\
1833 tmp = bswap(src[j+7]); dst[j+7] = dbswap((tmp - (tmp>>dst_depth) + dither[7])>>shift);\
1835 for (; j < length; j++) {\
1836 tmp = bswap(src[j]); dst[j] = dbswap((tmp - (tmp>>dst_depth) + dither[j&7])>>shift);\
1844 int srcStride[],
int srcSliceY,
int srcSliceH,
1845 uint8_t *dst[],
int dstStride[])
1850 for (plane = 0; plane < 4 && dst[plane] !=
NULL; plane++) {
1851 int length = (plane == 0 || plane == 3) ?
c->srcW :
AV_CEIL_RSHIFT(
c->srcW,
c->chrDstHSubSample);
1852 int y = (plane == 0 || plane == 3) ? srcSliceY:
AV_CEIL_RSHIFT(srcSliceY,
c->chrDstVSubSample);
1853 int height = (plane == 0 || plane == 3) ? srcSliceH:
AV_CEIL_RSHIFT(srcSliceH,
c->chrDstVSubSample);
1854 const uint8_t *srcPtr =
src[plane];
1855 uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
1856 int shiftonly = plane == 1 || plane == 2 || (!
c->srcRange && plane == 0);
1859 if (plane == 1 && !dst[2])
continue;
1860 if (!
src[plane] || (plane == 1 && !
src[2])) {
1863 plane == 3, desc_dst->
comp[plane].
depth,
1864 isBE(
c->dstFormat));
1867 (plane == 3) ? 255 : 128);
1873 const int src_depth = desc_src->
comp[plane].
depth;
1874 const int dst_depth = desc_dst->
comp[plane].
depth;
1875 const uint16_t *srcPtr2 = (
const uint16_t *) srcPtr;
1876 uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1878 if (dst_depth == 8) {
1879 if(
isBE(
c->srcFormat) == HAVE_BIGENDIAN){
1880 DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
1884 }
else if (src_depth == 8) {
1888 for (j = 0; j < length; j++)\
1889 w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
1891 for (j = 0; j < length; j++)\
1892 w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
1893 (srcPtr[j]>>(2*8-dst_depth)));\
1895 if(
isBE(
c->dstFormat)){
1900 dstPtr2 += dstStride[plane]/2;
1901 srcPtr += srcStride[plane];
1903 }
else if (src_depth <= dst_depth) {
1906 if(
isBE(
c->srcFormat) == HAVE_BIGENDIAN &&
1907 isBE(
c->dstFormat) == HAVE_BIGENDIAN &&
1909 unsigned shift = dst_depth - src_depth;
1911 #define FAST_COPY_UP(shift) \
1912 for (; j < length - 3; j += 4) { \
1913 uint64_t v = AV_RN64A(srcPtr2 + j); \
1914 AV_WN64A(dstPtr2 + j, v << shift); \
1917 #define FAST_COPY_UP(shift) \
1918 for (; j < length - 1; j += 2) { \
1919 uint32_t v = AV_RN32A(srcPtr2 + j); \
1920 AV_WN32A(dstPtr2 + j, v << shift); \
1929 #define COPY_UP(r,w) \
1931 for (; j < length; j++){ \
1932 unsigned int v= r(&srcPtr2[j]);\
1933 w(&dstPtr2[j], v<<(dst_depth-src_depth));\
1936 for (; j < length; j++){ \
1937 unsigned int v= r(&srcPtr2[j]);\
1938 w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
1939 (v>>(2*src_depth-dst_depth)));\
1942 if(
isBE(
c->srcFormat)){
1943 if(
isBE(
c->dstFormat)){
1949 if(
isBE(
c->dstFormat)){
1955 dstPtr2 += dstStride[plane]/2;
1956 srcPtr2 += srcStride[plane]/2;
1959 if(
isBE(
c->srcFormat) == HAVE_BIGENDIAN){
1960 if(
isBE(
c->dstFormat) == HAVE_BIGENDIAN){
1961 DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
1966 if(
isBE(
c->dstFormat) == HAVE_BIGENDIAN){
1977 for (j = 0; j < length; j++)
1978 ((uint16_t *) dstPtr)[j] =
av_bswap16(((
const uint16_t *) srcPtr)[j]);
1979 srcPtr += srcStride[plane];
1980 dstPtr += dstStride[plane];
1985 for (j = 0; j < length; j++)
1986 ((uint32_t *) dstPtr)[j] =
av_bswap32(((
const uint32_t *) srcPtr)[j]);
1987 srcPtr += srcStride[plane];
1988 dstPtr += dstStride[plane];
1990 }
else if (dstStride[plane] == srcStride[plane] &&
1991 srcStride[plane] > 0 && srcStride[plane] == length) {
1992 memcpy(dst[plane] + dstStride[plane] * y,
src[plane],
1993 height * dstStride[plane]);
2000 memcpy(dstPtr, srcPtr, length);
2001 srcPtr += srcStride[plane];
2002 dstPtr += dstStride[plane];
2011 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
2012 ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
2013 (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
2020 const int flags =
c->flags;
2021 const int dstH =
c->dstH;
2022 const int dstW =
c->dstW;
2026 c->dstFormatBpp < 24 &&
2054 c->dst_slice_align = 2;
2074 c->dst_slice_align = 4;
2093 #define isByteRGB(f) ( \
2094 f == AV_PIX_FMT_RGB32 || \
2095 f == AV_PIX_FMT_RGB32_1 || \
2096 f == AV_PIX_FMT_RGB24 || \
2097 f == AV_PIX_FMT_BGR32 || \
2098 f == AV_PIX_FMT_BGR32_1 || \
2099 f == AV_PIX_FMT_BGR24)
2142 c->dst_slice_align = 2;
2255 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
2264 c->chrDstHSubSample ==
c->chrSrcHSubSample &&
2265 c->chrDstVSubSample ==
c->chrSrcVSubSample &&
2285 int num_pixels,
const uint8_t *palette)
2289 for (
i = 0;
i < num_pixels;
i++)
2290 ((uint32_t *) dst)[
i] = ((
const uint32_t *) palette)[
src[
i]];
2295 int num_pixels,
const uint8_t *palette)
2299 for (
i = 0;
i < num_pixels;
i++) {
2301 dst[0] = palette[
src[
i] * 4 + 0];
2302 dst[1] = palette[
src[
i] * 4 + 1];
2303 dst[2] = palette[
src[
i] * 4 + 2];