1 /*
2 * Copyright (C) 2001-2012 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <math.h>
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <string.h>
25
32 #include "config.h"
36
37 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
38
39 #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? b_r : r_b)
40 #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? r_b : b_r)
41
45 {
52
54 }
55 }
56
59 const uint16_t *
src1,
const uint16_t *src2,
61 {
70
73 }
74 }
75
78 const uint16_t *
src1,
const uint16_t *src2,
80 {
89
92 }
93 }
94
95 #define rgb64funcs(pattern, BE_LE, origin) \
96 static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
97 int width, uint32_t *rgb2yuv) \
98 { \
99 const uint16_t *src = (const uint16_t *) _src; \
100 uint16_t *dst = (uint16_t *) _dst; \
101 rgb64ToY_c_template(dst, src, width, origin, rgb2yuv); \
102 } \
103 \
104 static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
105 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
106 int width, uint32_t *rgb2yuv) \
107 { \
108 const uint16_t *src1 = (const uint16_t *) _src1, \
109 *src2 = (const uint16_t *) _src2; \
110 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
111 rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
112 } \
113 \
114 static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
115 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
116 int width, uint32_t *rgb2yuv) \
117 { \
118 const uint16_t *src1 = (const uint16_t *) _src1, \
119 *src2 = (const uint16_t *) _src2; \
120 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
121 rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
122 }
123
128
133 {
140
142 }
143 }
144
146 uint16_t *dstV,
147 const uint16_t *
src1,
148 const uint16_t *src2,
152 {
161
164 }
165 }
166
168 uint16_t *dstV,
169 const uint16_t *
src1,
170 const uint16_t *src2,
174 {
186
189 }
190 }
191
192 #undef r
193 #undef b
194 #undef input_pixel
195
196 #define rgb48funcs(pattern, BE_LE, origin) \
197 static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
198 const uint8_t *_src, \
199 const uint8_t *unused0, const uint8_t *unused1,\
200 int width, \
201 uint32_t *rgb2yuv) \
202 { \
203 const uint16_t *src = (const uint16_t *)_src; \
204 uint16_t *dst = (uint16_t *)_dst; \
205 rgb48ToY_c_template(dst, src, width, origin, rgb2yuv); \
206 } \
207 \
208 static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
209 uint8_t *_dstV, \
210 const uint8_t *unused0, \
211 const uint8_t *_src1, \
212 const uint8_t *_src2, \
213 int width, \
214 uint32_t *rgb2yuv) \
215 { \
216 const uint16_t *src1 = (const uint16_t *)_src1, \
217 *src2 = (const uint16_t *)_src2; \
218 uint16_t *dstU = (uint16_t *)_dstU, \
219 *dstV = (uint16_t *)_dstV; \
220 rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
221 } \
222 \
223 static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
224 uint8_t *_dstV, \
225 const uint8_t *unused0, \
226 const uint8_t *_src1, \
227 const uint8_t *_src2, \
228 int width, \
229 uint32_t *rgb2yuv) \
230 { \
231 const uint16_t *src1 = (const uint16_t *)_src1, \
232 *src2 = (const uint16_t *)_src2; \
233 uint16_t *dstU = (uint16_t *)_dstU, \
234 *dstV = (uint16_t *)_dstV; \
235 rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \
236 }
237
242
243 #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
244 origin == AV_PIX_FMT_BGRA || \
245 origin == AV_PIX_FMT_ARGB || \
246 origin == AV_PIX_FMT_ABGR) \
247 ? AV_RN32A(&src[(i) * 4]) \
248 : ((origin == AV_PIX_FMT_X2RGB10LE || \
249 origin == AV_PIX_FMT_X2BGR10LE) \
250 ? AV_RL32(&src[(i) * 4]) \
251 : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
252 : AV_RL16(&src[(i) * 2]))))
253
258 int shr, int shg,
259 int shb, int shp,
260 int maskr, int maskg,
261 int maskb, int rsh,
262 int gsh,
int bsh,
int S,
264 {
266 const unsigned rnd = (32<<((
S)-1)) + (1<<(
S-7));
268
271 int b = (px & maskb) >> shb;
272 int g = (px & maskg) >> shg;
273 int r = (px & maskr) >> shr;
274
275 dst[
i] = (ry *
r + gy *
g + by *
b +
rnd) >> ((
S)-6);
276 }
277 }
278
280 int16_t *dstV,
284 int shr, int shg,
285 int shb, int shp,
286 int maskr, int maskg,
287 int maskb, int rsh,
288 int gsh,
int bsh,
int S,
290 {
293 const unsigned rnd = (256
u<<((
S)-1)) + (1<<(
S-7));
295
298 int b = (px & maskb) >> shb;
299 int g = (px & maskg) >> shg;
300 int r = (px & maskr) >> shr;
301
302 dstU[
i] = (ru *
r + gu *
g + bu *
b +
rnd) >> ((
S)-6);
303 dstV[
i] = (rv *
r + gv *
g + bv *
b +
rnd) >> ((
S)-6);
304 }
305 }
306
308 int16_t *dstV,
312 int shr, int shg,
313 int shb, int shp,
314 int maskr, int maskg,
315 int maskb, int rsh,
316 int gsh,
int bsh,
int S,
318 {
321 maskgx = ~(maskr | maskb);
322 const unsigned rnd = (256
U<<(
S)) + (1<<(
S-6));
324
325 maskr |= maskr << 1;
326 maskb |= maskb << 1;
327 maskg |= maskg << 1;
331 int b,
r,
g = (px0 & maskgx) + (px1 & maskgx);
332 int rb = px0 + px1 -
g;
333
334 b = (rb & maskb) >> shb;
335 if (shp ||
339 } else {
340 g = (
g & maskg) >> shg;
341 }
342 r = (rb & maskr) >> shr;
343
344 dstU[
i] = (ru *
r + gu *
g + bu *
b + (unsigned)
rnd) >> ((
S)-6+1);
345 dstV[
i] = (rv *
r + gv *
g + bv *
b + (unsigned)
rnd) >> ((
S)-6+1);
346 }
347 }
348
349 #undef input_pixel
350
351 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
352 maskg, maskb, rsh, gsh, bsh, S) \
353 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
354 int width, uint32_t *tab) \
355 { \
356 rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
357 maskr, maskg, maskb, rsh, gsh, bsh, S, tab); \
358 } \
359 \
360 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
361 const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
362 int width, uint32_t *tab) \
363 { \
364 rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
365 shr, shg, shb, shp, \
366 maskr, maskg, maskb, rsh, gsh, bsh, S, tab);\
367 } \
368 \
369 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
370 const uint8_t *unused0, const uint8_t *src, \
371 const uint8_t *dummy, \
372 int width, uint32_t *tab) \
373 { \
374 rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
375 shr, shg, shb, shp, \
376 maskr, maskg, maskb, \
377 rsh, gsh, bsh, S, tab); \
378 }
379
380 rgb16_32_wrapper(
AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8,
RGB2YUV_SHIFT + 8)
381 rgb16_32_wrapper(
AV_PIX_FMT_BGR32_1,
bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8,
RGB2YUV_SHIFT + 8)
382 rgb16_32_wrapper(
AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8,
RGB2YUV_SHIFT + 8)
383 rgb16_32_wrapper(
AV_PIX_FMT_RGB32_1,
rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8,
RGB2YUV_SHIFT + 8)
384 rgb16_32_wrapper(
AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0,
RGB2YUV_SHIFT + 8)
385 rgb16_32_wrapper(
AV_PIX_FMT_BGR555LE,
bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0,
RGB2YUV_SHIFT + 7)
386 rgb16_32_wrapper(
AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0,
RGB2YUV_SHIFT + 4)
387 rgb16_32_wrapper(
AV_PIX_FMT_RGB565LE,
rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11,
RGB2YUV_SHIFT + 8)
388 rgb16_32_wrapper(
AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10,
RGB2YUV_SHIFT + 7)
389 rgb16_32_wrapper(
AV_PIX_FMT_RGB444LE,
rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8,
RGB2YUV_SHIFT + 4)
390 rgb16_32_wrapper(
AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0,
RGB2YUV_SHIFT + 8)
391 rgb16_32_wrapper(
AV_PIX_FMT_BGR555BE,
bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0,
RGB2YUV_SHIFT + 7)
392 rgb16_32_wrapper(
AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0,
RGB2YUV_SHIFT + 4)
393 rgb16_32_wrapper(
AV_PIX_FMT_RGB565BE,
rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11,
RGB2YUV_SHIFT + 8)
394 rgb16_32_wrapper(
AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10,
RGB2YUV_SHIFT + 7)
395 rgb16_32_wrapper(
AV_PIX_FMT_RGB444BE,
rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8,
RGB2YUV_SHIFT + 4)
396 rgb16_32_wrapper(
AV_PIX_FMT_X2RGB10LE, rgb30le, 16, 6, 0, 0, 0x3FF00000, 0xFFC00, 0x3FF, 0, 0, 4,
RGB2YUV_SHIFT + 6)
397 rgb16_32_wrapper(
AV_PIX_FMT_X2BGR10LE,
bgr30le, 0, 6, 16, 0, 0x3FF, 0xFFC00, 0x3FF00000, 4, 0, 0,
RGB2YUV_SHIFT + 6)
398
400 const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
402 {
403 uint16_t *dstU = (uint16_t *)_dstU;
404 uint16_t *dstV = (uint16_t *)_dstV;
407
410 unsigned int g = gsrc[2*
i] + gsrc[2*
i+1];
411 unsigned int b = bsrc[2*
i] + bsrc[2*
i+1];
412 unsigned int r = rsrc[2*
i] + rsrc[2*
i+1];
413
416 }
417 }
418
419 static void rgba64leToA_c(uint8_t *_dst,
const uint8_t *_src,
const uint8_t *unused1,
420 const uint8_t *unused2,
int width, uint32_t *unused)
421 {
422 int16_t *dst = (int16_t *)_dst;
423 const uint16_t *
src = (
const uint16_t *)_src;
427 }
428
429 static void rgba64beToA_c(uint8_t *_dst,
const uint8_t *_src,
const uint8_t *unused1,
430 const uint8_t *unused2,
int width, uint32_t *unused)
431 {
432 int16_t *dst = (int16_t *)_dst;
433 const uint16_t *
src = (
const uint16_t *)_src;
437 }
438
439 static void abgrToA_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *unused)
440 {
441 int16_t *dst = (int16_t *)_dst;
445 }
446 }
447
448 static void rgbaToA_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *unused)
449 {
450 int16_t *dst = (int16_t *)_dst;
454 }
455 }
456
457 static void palToA_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *pal)
458 {
459 int16_t *dst = (int16_t *)_dst;
463
464 dst[
i]= (pal[
d] >> 24)<<6 | pal[
d]>>26;
465 }
466 }
467
468 static void palToY_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *pal)
469 {
470 int16_t *dst = (int16_t *)_dst;
474
475 dst[
i] = (pal[
d] & 0xFF)<<6;
476 }
477 }
478
480 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
481 int width, uint32_t *pal)
482 {
483 uint16_t *dstU = (uint16_t *)_dstU;
484 int16_t *dstV = (int16_t *)_dstV;
488 int p = pal[
src1[
i]];
489
490 dstU[
i] = (uint8_t)(p>> 8)<<6;
491 dstV[
i] = (uint8_t)(p>>16)<<6;
492 }
493 }
494
495 static void monowhite2Y_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *unused)
496 {
497 int16_t *dst = (int16_t *)_dst;
502 for (j = 0; j < 8; j++)
503 dst[8*
i+j]= ((
d>>(7-j))&1) * 16383;
504 }
507 for (j = 0; j < (
width&7); j++)
508 dst[8*
i+j]= ((
d>>(7-j))&1) * 16383;
509 }
510 }
511
512 static void monoblack2Y_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width, uint32_t *unused)
513 {
514 int16_t *dst = (int16_t *)_dst;
519 for (j = 0; j < 8; j++)
520 dst[8*
i+j]= ((
d>>(7-j))&1) * 16383;
521 }
524 for (j = 0; j < (
width&7); j++)
525 dst[8*
i+j] = ((
d>>(7-j))&1) * 16383;
526 }
527 }
528
529 static void yuy2ToY_c(uint8_t *dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width,
530 uint32_t *unused)
531 {
535 }
536
537 static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0,
const uint8_t *
src1,
538 const uint8_t *src2,
int width, uint32_t *unused)
539 {
542 dstU[
i] =
src1[4 *
i + 1];
543 dstV[
i] =
src1[4 *
i + 3];
544 }
546 }
547
548 static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0,
const uint8_t *
src1,
549 const uint8_t *src2,
int width, uint32_t *unused)
550 {
553 dstV[
i] =
src1[4 *
i + 1];
554 dstU[
i] =
src1[4 *
i + 3];
555 }
557 }
558
559 static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0,
const uint8_t *
src,
560 const uint8_t *unused1,
int width, uint32_t *unused2)
561 {
566 }
567 }
568
569 static void y210le_Y_c(uint8_t *dst,
const uint8_t *
src,
const uint8_t *unused0,
570 const uint8_t *unused1,
int width, uint32_t *unused2)
571 {
575 }
576
577 static void bswap16Y_c(uint8_t *_dst,
const uint8_t *_src,
const uint8_t *unused1,
const uint8_t *unused2,
int width,
578 uint32_t *unused)
579 {
581 const uint16_t *
src = (
const uint16_t *)_src;
582 uint16_t *dst = (uint16_t *)_dst;
585 }
586
587 static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV,
const uint8_t *unused0,
const uint8_t *_src1,
588 const uint8_t *_src2,
int width, uint32_t *unused)
589 {
591 const uint16_t *
src1 = (
const uint16_t *)_src1,
592 *src2 = (const uint16_t *)_src2;
593 uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
597 }
598 }
599
601 uint32_t *unused)
602 {
606 }
607
609 uint32_t *unused)
610 {
614 }
615
617 uint32_t *unused)
618 {
622 }
623
625 uint32_t *unused)
626 {
630 }
631
633 uint32_t *unused2)
634 {
638 }
639
640
642 const uint8_t *unused1,
int width, uint32_t *unused2)
643 {
648 }
649 }
650
652 uint32_t *unused2)
653 {
657 }
658
659 /* This is almost identical to the previous, end exists only because
660 * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
661 static void uyvyToY_c(uint8_t *dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width,
662 uint32_t *unused)
663 {
666 dst[
i] =
src[2 *
i + 1];
667 }
668
669 static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV,
const uint8_t *unused0,
const uint8_t *
src1,
670 const uint8_t *src2,
int width, uint32_t *unused)
671 {
674 dstU[
i] =
src1[4 *
i + 0];
675 dstV[
i] =
src1[4 *
i + 2];
676 }
678 }
679
682 {
685 dst1[
i] =
src[2 *
i + 0];
686 dst2[
i] =
src[2 *
i + 1];
687 }
688 }
689
691 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
692 int width, uint32_t *unused)
693 {
695 }
696
698 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
699 int width, uint32_t *unused)
700 {
702 }
703
704 static void p010LEToY_c(uint8_t *dst,
const uint8_t *
src,
const uint8_t *unused1,
705 const uint8_t *unused2,
int width, uint32_t *unused)
706 {
710 }
711 }
712
713 static void p010BEToY_c(uint8_t *dst,
const uint8_t *
src,
const uint8_t *unused1,
714 const uint8_t *unused2,
int width, uint32_t *unused)
715 {
719 }
720 }
721
723 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
724 int width, uint32_t *unused)
725 {
730 }
731 }
732
734 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
735 int width, uint32_t *unused)
736 {
741 }
742 }
743
745 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
746 int width, uint32_t *unused)
747 {
752 }
753 }
754
756 const uint8_t *unused0,
const uint8_t *
src1,
const uint8_t *src2,
757 int width, uint32_t *unused)
758 {
763 }
764 }
765
766 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
767
768 static void bgr24ToY_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
770 {
771 int16_t *dst = (int16_t *)_dst;
775 int b =
src[
i * 3 + 0];
776 int g =
src[
i * 3 + 1];
777 int r =
src[
i * 3 + 2];
778
780 }
781 }
782
783 static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV,
const uint8_t *unused0,
const uint8_t *
src1,
785 {
786 int16_t *dstU = (int16_t *)_dstU;
787 int16_t *dstV = (int16_t *)_dstV;
795
798 }
800 }
801
804 {
805 int16_t *dstU = (int16_t *)_dstU;
806 int16_t *dstV = (int16_t *)_dstV;
814
817 }
819 }
820
821 static void rgb24ToY_c(uint8_t *_dst,
const uint8_t *
src,
const uint8_t *unused1,
const uint8_t *unused2,
int width,
823 {
824 int16_t *dst = (int16_t *)_dst;
828 int r =
src[
i * 3 + 0];
829 int g =
src[
i * 3 + 1];
830 int b =
src[
i * 3 + 2];
831
833 }
834 }
835
836 static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV,
const uint8_t *unused0,
const uint8_t *
src1,
838 {
839 int16_t *dstU = (int16_t *)_dstU;
840 int16_t *dstV = (int16_t *)_dstV;
849
852 }
853 }
854
857 {
858 int16_t *dstU = (int16_t *)_dstU;
859 int16_t *dstV = (int16_t *)_dstV;
868
871 }
872 }
873
875 {
876 uint16_t *dst = (uint16_t *)_dst;
883
885 }
886 }
887
889 {
890 uint16_t *dst = (uint16_t *)_dst;
893 dst[
i] =
src[3][
i] << 6;
894 }
895
897 {
898 uint16_t *dstU = (uint16_t *)_dstU;
899 uint16_t *dstV = (uint16_t *)_dstV;
907
910 }
911 }
912
913 #define rdpx(src) \
914 (is_be ? AV_RB16(src) : AV_RL16(src))
917 {
919 const uint16_t **
src = (
const uint16_t **)_src;
920 uint16_t *dst = (uint16_t *)_dst;
922 int shift = bpc < 16 ? bpc : 14;
927
929 }
930 }
931
934 {
936 const uint16_t **
src = (
const uint16_t **)_src;
937 uint16_t *dst = (uint16_t *)_dst;
938 int shift = bpc < 16 ? bpc : 14;
939
942 }
943 }
944
946 const uint8_t *_src[4],
int width,
948 {
950 const uint16_t **
src = (
const uint16_t **)_src;
951 uint16_t *dstU = (uint16_t *)_dstU;
952 uint16_t *dstV = (uint16_t *)_dstV;
955 int shift = bpc < 16 ? bpc : 14;
960
963 }
964 }
965 #undef rdpx
966
967 #define rdpx(src) (is_be ? av_int2float(AV_RB32(src)): av_int2float(AV_RL32(src)))
968
970 {
972 const float **
src = (
const float **)_src;
973 uint16_t *dst = (uint16_t *)_dst;
974
977 }
978 }
979
981 {
983 const float **
src = (
const float **)_src;
984 uint16_t *dstU = (uint16_t *)_dstU;
985 uint16_t *dstV = (uint16_t *)_dstV;
988
993
996 }
997 }
998
1000 {
1002 const float **
src = (
const float **)_src;
1003 uint16_t *dst = (uint16_t *)_dst;
1004
1006
1011
1013 }
1014 }
1015
1017 const uint8_t *unused2,
int width,
int is_be, uint32_t *unused)
1018 {
1020 const float *
src = (
const float *)_src;
1021 uint16_t *dst = (uint16_t *)_dst;
1022
1025 }
1026 }
1027
1028 #undef rdpx
1029
1030 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian) \
1031 static void planar_rgb##nbits##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1032 int w, int32_t *rgb2yuv) \
1033 { \
1034 planar_rgb16_to_y(dst, src, w, nbits, endian, rgb2yuv); \
1035 } \
1036 static void planar_rgb##nbits##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1037 const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1038 { \
1039 planar_rgb16_to_uv(dstU, dstV, src, w, nbits, endian, rgb2yuv); \
1040 } \
1041
1042 #define rgb9plus_planar_transparency_funcs(nbits) \
1043 static void planar_rgb##nbits##le_to_a(uint8_t *dst, const uint8_t *src[4], \
1044 int w, int32_t *rgb2yuv) \
1045 { \
1046 planar_rgb16_to_a(dst, src, w, nbits, 0, rgb2yuv); \
1047 } \
1048 static void planar_rgb##nbits##be_to_a(uint8_t *dst, const uint8_t *src[4], \
1049 int w, int32_t *rgb2yuv) \
1050 { \
1051 planar_rgb16_to_a(dst, src, w, nbits, 1, rgb2yuv); \
1052 }
1053
1054 #define rgb9plus_planar_funcs(nbits) \
1055 rgb9plus_planar_funcs_endian(nbits, le, 0) \
1056 rgb9plus_planar_funcs_endian(nbits, be, 1)
1057
1063
1067
1068 #define rgbf32_planar_funcs_endian(endian_name, endian) \
1069 static void planar_rgbf32##endian_name##_to_y(uint8_t *dst, const uint8_t *src[4], \
1070 int w, int32_t *rgb2yuv) \
1071 { \
1072 planar_rgbf32_to_y(dst, src, w, endian, rgb2yuv); \
1073 } \
1074 static void planar_rgbf32##endian_name##_to_uv(uint8_t *dstU, uint8_t *dstV, \
1075 const uint8_t *src[4], int w, int32_t *rgb2yuv) \
1076 { \
1077 planar_rgbf32_to_uv(dstU, dstV, src, w, endian, rgb2yuv); \
1078 } \
1079 static void planar_rgbf32##endian_name##_to_a(uint8_t *dst, const uint8_t *src[4], \
1080 int w, int32_t *rgb2yuv) \
1081 { \
1082 planar_rgbf32_to_a(dst, src, w, endian, rgb2yuv); \
1083 } \
1084 static void grayf32##endian_name##ToY16_c(uint8_t *dst, const uint8_t *src, \
1085 const uint8_t *unused1, const uint8_t *unused2, \
1086 int width, uint32_t *unused) \
1087 { \
1088 grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused); \
1089 }
1090
1093
1095 {
1097
1098 c->chrToYV12 =
NULL;
1099 switch (srcFormat) {
1102 break;
1105 break;
1108 break;
1112 break;
1116 break;
1123 break;
1125 c->readChrPlanar = planar_rgb9le_to_uv;
1126 break;
1129 c->readChrPlanar = planar_rgb10le_to_uv;
1130 break;
1133 c->readChrPlanar = planar_rgb12le_to_uv;
1134 break;
1136 c->readChrPlanar = planar_rgb14le_to_uv;
1137 break;
1140 c->readChrPlanar = planar_rgb16le_to_uv;
1141 break;
1144 c->readChrPlanar = planar_rgbf32le_to_uv;
1145 break;
1147 c->readChrPlanar = planar_rgb9be_to_uv;
1148 break;
1151 c->readChrPlanar = planar_rgb10be_to_uv;
1152 break;
1155 c->readChrPlanar = planar_rgb12be_to_uv;
1156 break;
1158 c->readChrPlanar = planar_rgb14be_to_uv;
1159 break;
1162 c->readChrPlanar = planar_rgb16be_to_uv;
1163 break;
1166 c->readChrPlanar = planar_rgbf32be_to_uv;
1167 break;
1171 break;
1172 #if HAVE_BIGENDIAN
1190
1203 break;
1204 #else
1222
1235 break;
1236 #endif
1239 break;
1244 break;
1249 break;
1254 break;
1259 break;
1262 break;
1263 }
1264 if (
c->chrSrcHSubSample) {
1265 switch (srcFormat) {
1267 c->chrToYV12 = rgb64BEToUV_half_c;
1268 break;
1270 c->chrToYV12 = rgb64LEToUV_half_c;
1271 break;
1273 c->chrToYV12 = bgr64BEToUV_half_c;
1274 break;
1276 c->chrToYV12 = bgr64LEToUV_half_c;
1277 break;
1279 c->chrToYV12 = rgb48BEToUV_half_c;
1280 break;
1282 c->chrToYV12 = rgb48LEToUV_half_c;
1283 break;
1285 c->chrToYV12 = bgr48BEToUV_half_c;
1286 break;
1288 c->chrToYV12 = bgr48LEToUV_half_c;
1289 break;
1291 c->chrToYV12 = bgr32ToUV_half_c;
1292 break;
1294 c->chrToYV12 = bgr321ToUV_half_c;
1295 break;
1298 break;
1300 c->chrToYV12 = bgr16leToUV_half_c;
1301 break;
1303 c->chrToYV12 = bgr16beToUV_half_c;
1304 break;
1306 c->chrToYV12 = bgr15leToUV_half_c;
1307 break;
1309 c->chrToYV12 = bgr15beToUV_half_c;
1310 break;
1314 break;
1316 c->chrToYV12 = bgr12leToUV_half_c;
1317 break;
1319 c->chrToYV12 = bgr12beToUV_half_c;
1320 break;
1322 c->chrToYV12 = rgb32ToUV_half_c;
1323 break;
1325 c->chrToYV12 = rgb321ToUV_half_c;
1326 break;
1329 break;
1331 c->chrToYV12 = rgb16leToUV_half_c;
1332 break;
1334 c->chrToYV12 = rgb16beToUV_half_c;
1335 break;
1337 c->chrToYV12 = rgb15leToUV_half_c;
1338 break;
1340 c->chrToYV12 = rgb15beToUV_half_c;
1341 break;
1343 c->chrToYV12 = rgb12leToUV_half_c;
1344 break;
1346 c->chrToYV12 = rgb12beToUV_half_c;
1347 break;
1349 c->chrToYV12 = rgb30leToUV_half_c;
1350 break;
1352 c->chrToYV12 = bgr30leToUV_half_c;
1353 break;
1354 }
1355 } else {
1356 switch (srcFormat) {
1358 c->chrToYV12 = rgb64BEToUV_c;
1359 break;
1361 c->chrToYV12 = rgb64LEToUV_c;
1362 break;
1364 c->chrToYV12 = bgr64BEToUV_c;
1365 break;
1367 c->chrToYV12 = bgr64LEToUV_c;
1368 break;
1370 c->chrToYV12 = rgb48BEToUV_c;
1371 break;
1373 c->chrToYV12 = rgb48LEToUV_c;
1374 break;
1376 c->chrToYV12 = bgr48BEToUV_c;
1377 break;
1379 c->chrToYV12 = bgr48LEToUV_c;
1380 break;
1382 c->chrToYV12 = bgr32ToUV_c;
1383 break;
1385 c->chrToYV12 = bgr321ToUV_c;
1386 break;
1389 break;
1391 c->chrToYV12 = bgr16leToUV_c;
1392 break;
1394 c->chrToYV12 = bgr16beToUV_c;
1395 break;
1397 c->chrToYV12 = bgr15leToUV_c;
1398 break;
1400 c->chrToYV12 = bgr15beToUV_c;
1401 break;
1403 c->chrToYV12 = bgr12leToUV_c;
1404 break;
1406 c->chrToYV12 = bgr12beToUV_c;
1407 break;
1409 c->chrToYV12 = rgb32ToUV_c;
1410 break;
1412 c->chrToYV12 = rgb321ToUV_c;
1413 break;
1416 break;
1418 c->chrToYV12 = rgb16leToUV_c;
1419 break;
1421 c->chrToYV12 = rgb16beToUV_c;
1422 break;
1424 c->chrToYV12 = rgb15leToUV_c;
1425 break;
1427 c->chrToYV12 = rgb15beToUV_c;
1428 break;
1430 c->chrToYV12 = rgb12leToUV_c;
1431 break;
1433 c->chrToYV12 = rgb12beToUV_c;
1434 break;
1436 c->chrToYV12 = rgb30leToUV_c;
1437 break;
1439 c->chrToYV12 = bgr30leToUV_c;
1440 break;
1441 }
1442 }
1443
1444 c->lumToYV12 =
NULL;
1445 c->alpToYV12 =
NULL;
1446 switch (srcFormat) {
1448 c->readLumPlanar = planar_rgb9le_to_y;
1449 break;
1451 c->readAlpPlanar = planar_rgb10le_to_a;
1453 c->readLumPlanar = planar_rgb10le_to_y;
1454 break;
1456 c->readAlpPlanar = planar_rgb12le_to_a;
1458 c->readLumPlanar = planar_rgb12le_to_y;
1459 break;
1461 c->readLumPlanar = planar_rgb14le_to_y;
1462 break;
1464 c->readAlpPlanar = planar_rgb16le_to_a;
1466 c->readLumPlanar = planar_rgb16le_to_y;
1467 break;
1469 c->readAlpPlanar = planar_rgbf32le_to_a;
1471 c->readLumPlanar = planar_rgbf32le_to_y;
1472 break;
1474 c->readLumPlanar = planar_rgb9be_to_y;
1475 break;
1477 c->readAlpPlanar = planar_rgb10be_to_a;
1479 c->readLumPlanar = planar_rgb10be_to_y;
1480 break;
1482 c->readAlpPlanar = planar_rgb12be_to_a;
1484 c->readLumPlanar = planar_rgb12be_to_y;
1485 break;
1487 c->readLumPlanar = planar_rgb14be_to_y;
1488 break;
1490 c->readAlpPlanar = planar_rgb16be_to_a;
1492 c->readLumPlanar = planar_rgb16be_to_y;
1493 break;
1495 c->readAlpPlanar = planar_rgbf32be_to_a;
1497 c->readLumPlanar = planar_rgbf32be_to_y;
1498 break;
1503 break;
1504 #if HAVE_BIGENDIAN
1522
1528
1533 break;
1547 break;
1548 #else
1566
1572
1577 break;
1591 break;
1592 #endif
1595 break;
1598 break;
1601 break;
1606 break;
1609 break;
1612 break;
1614 c->lumToYV12 = bgr16leToY_c;
1615 break;
1617 c->lumToYV12 = bgr16beToY_c;
1618 break;
1620 c->lumToYV12 = bgr15leToY_c;
1621 break;
1623 c->lumToYV12 = bgr15beToY_c;
1624 break;
1626 c->lumToYV12 = bgr12leToY_c;
1627 break;
1629 c->lumToYV12 = bgr12beToY_c;
1630 break;
1633 break;
1635 c->lumToYV12 = rgb16leToY_c;
1636 break;
1638 c->lumToYV12 = rgb16beToY_c;
1639 break;
1641 c->lumToYV12 = rgb15leToY_c;
1642 break;
1644 c->lumToYV12 = rgb15beToY_c;
1645 break;
1647 c->lumToYV12 = rgb12leToY_c;
1648 break;
1650 c->lumToYV12 = rgb12beToY_c;
1651 break;
1658 break;
1661 break;
1664 break;
1666 c->lumToYV12 = bgr32ToY_c;
1667 break;
1669 c->lumToYV12 = bgr321ToY_c;
1670 break;
1672 c->lumToYV12 = rgb32ToY_c;
1673 break;
1675 c->lumToYV12 = rgb321ToY_c;
1676 break;
1678 c->lumToYV12 = rgb48BEToY_c;
1679 break;
1681 c->lumToYV12 = rgb48LEToY_c;
1682 break;
1684 c->lumToYV12 = bgr48BEToY_c;
1685 break;
1687 c->lumToYV12 = bgr48LEToY_c;
1688 break;
1690 c->lumToYV12 = rgb64BEToY_c;
1691 break;
1693 c->lumToYV12 = rgb64LEToY_c;
1694 break;
1696 c->lumToYV12 = bgr64BEToY_c;
1697 break;
1699 c->lumToYV12 = bgr64LEToY_c;
1700 break;
1705 break;
1710 break;
1712 c->lumToYV12 = grayf32leToY16_c;
1713 break;
1715 c->lumToYV12 = grayf32beToY16_c;
1716 break;
1719 break;
1721 c->lumToYV12 = rgb30leToY_c;
1722 break;
1724 c->lumToYV12 = bgr30leToY_c;
1725 break;
1726 }
1729 if (HAVE_BIGENDIAN == !
isBE(srcFormat) && !
c->readAlpPlanar)
1731 }
1732 switch (srcFormat) {
1740 break;
1744 break;
1747 break;
1750 break;
1753 break;
1756 break;
1759 break;
1760 }
1761 }
1762 }