39 #define RGB2YUV_SHIFT 15
40 #define BY ((int)(0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
41 #define BV (-(int)(0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
42 #define BU ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
43 #define GY ((int)(0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
44 #define GV (-(int)(0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
45 #define GU (-(int)(0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
46 #define RY ((int)(0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
47 #define RV ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
48 #define RU (-(int)(0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
50 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
52 #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? b_r : r_b)
53 #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? r_b : b_r)
60 for (i = 0; i <
width; i++) {
71 const uint16_t *src1,
const uint16_t *src2,
76 for (i = 0; i <
width; i++) {
88 const uint16_t *src1,
const uint16_t *src2,
93 for (i = 0; i <
width; i++) {
103 #define rgb64funcs(pattern, BE_LE, origin) \
104 static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
105 int width, uint32_t *unused) \
107 const uint16_t *src = (const uint16_t *) _src; \
108 uint16_t *dst = (uint16_t *) _dst; \
109 rgb64ToY_c_template(dst, src, width, origin); \
112 static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
113 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
114 int width, uint32_t *unused) \
116 const uint16_t *src1 = (const uint16_t *) _src1, \
117 *src2 = (const uint16_t *) _src2; \
118 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
119 rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
122 static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
123 const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
124 int width, uint32_t *unused) \
126 const uint16_t *src1 = (const uint16_t *) _src1, \
127 *src2 = (const uint16_t *) _src2; \
128 uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
129 rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
136 const uint16_t *src,
int width,
140 for (i = 0; i <
width; i++) {
151 const uint16_t *src1,
152 const uint16_t *src2,
158 for (i = 0; i <
width; i++) {
170 const uint16_t *src1,
171 const uint16_t *src2,
177 for (i = 0; i <
width; i++) {
194 #define rgb48funcs(pattern, BE_LE, origin) \
195 static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
196 const uint8_t *_src, \
197 const uint8_t *unused0, const uint8_t *unused1,\
201 const uint16_t *src = (const uint16_t *)_src; \
202 uint16_t *dst = (uint16_t *)_dst; \
203 rgb48ToY_c_template(dst, src, width, origin); \
206 static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
208 const uint8_t *unused0, \
209 const uint8_t *_src1, \
210 const uint8_t *_src2, \
214 const uint16_t *src1 = (const uint16_t *)_src1, \
215 *src2 = (const uint16_t *)_src2; \
216 uint16_t *dstU = (uint16_t *)_dstU, \
217 *dstV = (uint16_t *)_dstV; \
218 rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
221 static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
223 const uint8_t *unused0, \
224 const uint8_t *_src1, \
225 const uint8_t *_src2, \
229 const uint16_t *src1 = (const uint16_t *)_src1, \
230 *src2 = (const uint16_t *)_src2; \
231 uint16_t *dstU = (uint16_t *)_dstU, \
232 *dstV = (uint16_t *)_dstV; \
233 rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
241 #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
242 origin == AV_PIX_FMT_BGRA || \
243 origin == AV_PIX_FMT_ARGB || \
244 origin == AV_PIX_FMT_ABGR) \
245 ? AV_RN32A(&src[(i) * 4]) \
246 : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
247 : AV_RL16(&src[(i) * 2])))
255 int maskr,
int maskg,
257 int gsh,
int bsh,
int S)
259 const int ry =
RY << rsh, gy =
GY << gsh, by =
BY << bsh;
260 const unsigned rnd = (32<<((
S)-1)) + (1<<(S-7));
263 for (i = 0; i <
width; i++) {
265 int b = (px & maskb) >> shb;
266 int g = (px & maskg) >> shg;
267 int r = (px & maskr) >> shr;
269 dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
280 int maskr,
int maskg,
282 int gsh,
int bsh,
int S)
284 const int ru =
RU << rsh, gu =
GU << gsh, bu =
BU << bsh,
285 rv =
RV << rsh, gv =
GV << gsh, bv =
BV << bsh;
286 const unsigned rnd = (256
u<<((
S)-1)) + (1<<(S-7));
289 for (i = 0; i <
width; i++) {
291 int b = (px & maskb) >> shb;
292 int g = (px & maskg) >> shg;
293 int r = (px & maskr) >> shr;
295 dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
296 dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
307 int maskr,
int maskg,
309 int gsh,
int bsh,
int S)
311 const int ru =
RU << rsh, gu =
GU << gsh, bu =
BU << bsh,
312 rv =
RV << rsh, gv =
GV << gsh, bv =
BV << bsh,
313 maskgx = ~(maskr | maskb);
314 const unsigned rnd = (256
U<<(
S)) + (1<<(S-6));
320 for (i = 0; i <
width; i++) {
323 int b,
r,
g = (px0 & maskgx) + (px1 & maskgx);
324 int rb = px0 + px1 -
g;
326 b = (rb & maskb) >> shb;
332 g = (g & maskg) >> shg;
334 r = (rb & maskr) >> shr;
336 dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((
S)-6+1);
337 dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((
S)-6+1);
343 #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
344 maskg, maskb, rsh, gsh, bsh, S) \
345 static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
346 int width, uint32_t *unused) \
348 rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
349 maskr, maskg, maskb, rsh, gsh, bsh, S); \
352 static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
353 const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
354 int width, uint32_t *unused) \
356 rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
357 shr, shg, shb, shp, \
358 maskr, maskg, maskb, rsh, gsh, bsh, S); \
361 static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
362 const uint8_t *unused0, const uint8_t *src, \
363 const uint8_t *dummy, \
364 int width, uint32_t *unused) \
366 rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
367 shr, shg, shb, shp, \
368 maskr, maskg, maskb, \
372 rgb16_32_wrapper(
AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8,
RGB2YUV_SHIFT + 8)
373 rgb16_32_wrapper(
AV_PIX_FMT_BGR32_1,
bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8,
RGB2YUV_SHIFT + 8)
374 rgb16_32_wrapper(
AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8,
RGB2YUV_SHIFT + 8)
375 rgb16_32_wrapper(
AV_PIX_FMT_RGB32_1,
rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8,
RGB2YUV_SHIFT + 8)
376 rgb16_32_wrapper(
AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0,
RGB2YUV_SHIFT + 8)
377 rgb16_32_wrapper(
AV_PIX_FMT_BGR555LE,
bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0,
RGB2YUV_SHIFT + 7)
378 rgb16_32_wrapper(
AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0,
RGB2YUV_SHIFT + 4)
379 rgb16_32_wrapper(
AV_PIX_FMT_RGB565LE,
rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11,
RGB2YUV_SHIFT + 8)
380 rgb16_32_wrapper(
AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10,
RGB2YUV_SHIFT + 7)
381 rgb16_32_wrapper(
AV_PIX_FMT_RGB444LE,
rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8,
RGB2YUV_SHIFT + 4)
382 rgb16_32_wrapper(
AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0,
RGB2YUV_SHIFT + 8)
383 rgb16_32_wrapper(
AV_PIX_FMT_BGR555BE,
bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0,
RGB2YUV_SHIFT + 7)
384 rgb16_32_wrapper(
AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0,
RGB2YUV_SHIFT + 4)
385 rgb16_32_wrapper(
AV_PIX_FMT_RGB565BE,
rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11,
RGB2YUV_SHIFT + 8)
386 rgb16_32_wrapper(
AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10,
RGB2YUV_SHIFT + 7)
387 rgb16_32_wrapper(
AV_PIX_FMT_RGB444BE,
rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8,
RGB2YUV_SHIFT + 4)
391 int width, uint32_t *unused)
393 uint16_t *dstU = (uint16_t *)_dstU;
394 uint16_t *dstV = (uint16_t *)_dstV;
396 for (i = 0; i <
width; i++) {
397 unsigned int g = gsrc[2*i] + gsrc[2*i+1];
398 unsigned int b = bsrc[2*i] + bsrc[2*i+1];
399 unsigned int r = rsrc[2*i] + rsrc[2*i+1];
409 int16_t *
dst = (int16_t *)_dst;
410 const uint16_t *src = (
const uint16_t *)_src;
412 for (i = 0; i <
width; i++)
413 dst[i] = src[4 * i + 3];
418 int16_t *
dst = (int16_t *)_dst;
420 for (i=0; i<
width; i++) {
427 int16_t *
dst = (int16_t *)_dst;
429 for (i=0; i<
width; i++) {
430 dst[i]= src[4*i+3]<<6;
436 int16_t *
dst = (int16_t *)_dst;
438 for (i=0; i<
width; i++) {
441 dst[i]= (pal[d] >> 24)<<6;
447 int16_t *
dst = (int16_t *)_dst;
449 for (i = 0; i <
width; i++) {
452 dst[i] = (pal[d] & 0xFF)<<6;
458 int width, uint32_t *pal)
460 uint16_t *dstU = (uint16_t *)_dstU;
461 int16_t *dstV = (int16_t *)_dstV;
464 for (i = 0; i <
width; i++) {
465 int p = pal[src1[i]];
474 int16_t *
dst = (int16_t *)_dst;
476 width = (width + 7) >> 3;
477 for (i = 0; i <
width; i++) {
479 for (j = 0; j < 8; j++)
480 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
484 for (j = 0; j < (width&7); j++)
485 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
491 int16_t *
dst = (int16_t *)_dst;
493 width = (width + 7) >> 3;
494 for (i = 0; i <
width; i++) {
496 for (j = 0; j < 8; j++)
497 dst[8*i+j]= ((d>>(7-j))&1) * 16383;
501 for (j = 0; j < (width&7); j++)
502 dst[8*i+j] = ((d>>(7-j))&1) * 16383;
510 for (i = 0; i <
width; i++)
518 for (i = 0; i <
width; i++) {
519 dstU[i] = src1[4 * i + 1];
520 dstV[i] = src1[4 * i + 3];
529 const uint16_t *src = (
const uint16_t *)_src;
530 uint16_t *
dst = (uint16_t *)_dst;
531 for (i = 0; i <
width; i++)
539 const uint16_t *src1 = (
const uint16_t *)_src1,
540 *src2 = (
const uint16_t *)_src2;
541 uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
542 for (i = 0; i <
width; i++) {
554 for (i = 0; i <
width; i++)
555 dst[i] = src[2 * i + 1];
562 for (i = 0; i <
width; i++) {
563 dstU[i] = src1[4 * i + 0];
564 dstV[i] = src1[4 * i + 2];
573 for (i = 0; i <
width; i++) {
574 dst1[i] = src[2 * i + 0];
575 dst2[i] = src[2 * i + 1];
581 int width, uint32_t *unused)
588 int width, uint32_t *unused)
593 #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
596 int width, uint32_t *unused)
598 int16_t *
dst = (int16_t *)_dst;
600 for (i = 0; i <
width; i++) {
601 int b = src[i * 3 + 0];
602 int g = src[i * 3 + 1];
603 int r = src[i * 3 + 2];
612 int16_t *dstU = (int16_t *)_dstU;
613 int16_t *dstV = (int16_t *)_dstV;
615 for (i = 0; i <
width; i++) {
616 int b = src1[3 * i + 0];
617 int g = src1[3 * i + 1];
618 int r = src1[3 * i + 2];
629 int16_t *dstU = (int16_t *)_dstU;
630 int16_t *dstV = (int16_t *)_dstV;
632 for (i = 0; i <
width; i++) {
633 int b = src1[6 * i + 0] + src1[6 * i + 3];
634 int g = src1[6 * i + 1] + src1[6 * i + 4];
635 int r = src1[6 * i + 2] + src1[6 * i + 5];
646 int16_t *
dst = (int16_t *)_dst;
648 for (i = 0; i <
width; i++) {
649 int r = src[i * 3 + 0];
650 int g = src[i * 3 + 1];
651 int b = src[i * 3 + 2];
660 int16_t *dstU = (int16_t *)_dstU;
661 int16_t *dstV = (int16_t *)_dstV;
664 for (i = 0; i <
width; i++) {
665 int r = src1[3 * i + 0];
666 int g = src1[3 * i + 1];
667 int b = src1[3 * i + 2];
677 int16_t *dstU = (int16_t *)_dstU;
678 int16_t *dstV = (int16_t *)_dstV;
681 for (i = 0; i <
width; i++) {
682 int r = src1[6 * i + 0] + src1[6 * i + 3];
683 int g = src1[6 * i + 1] + src1[6 * i + 4];
684 int b = src1[6 * i + 2] + src1[6 * i + 5];
693 uint16_t *
dst = (uint16_t *)_dst;
695 for (i = 0; i <
width; i++) {
706 uint16_t *dstU = (uint16_t *)_dstU;
707 uint16_t *dstV = (uint16_t *)_dstV;
709 for (i = 0; i <
width; i++) {
720 is_be ? AV_RB16(src) : AV_RL16(src)
722 int width,
int bpc,
int is_be)
725 const uint16_t **src = (
const uint16_t **)_src;
726 uint16_t *
dst = (uint16_t *)_dst;
727 for (i = 0; i <
width; i++) {
728 int g =
rdpx(src[0] + i);
729 int b =
rdpx(src[1] + i);
730 int r =
rdpx(src[2] + i);
791 const uint16_t **src = (
const uint16_t **)_src;
792 uint16_t *dstU = (uint16_t *)_dstU;
793 uint16_t *dstV = (uint16_t *)_dstV;
794 for (i = 0; i <
width; i++) {
795 int g =
rdpx(src[0] + i);
796 int b =
rdpx(src[1] + i);
797 int r =
rdpx(src[2] + i);
1060 switch (srcFormat) {
1138 switch (srcFormat) {
1332 if (HAVE_BIGENDIAN == !
isBE(srcFormat))
1335 switch (srcFormat) {