2 * software RGB to RGB converter
3 * pluralize by software PAL8 to RGB converter
4 * software YUV to YUV converter
5 * software YUV to RGB converter
6 * Written by Nick Kurshev.
7 * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
8 * lot of big-endian byte order fixes by Alex Beregszaszi
10 * This file is part of Libav.
12 * Libav is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * Libav is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with Libav; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 static inline void rgb24tobgr32_c(const uint8_t *src
, uint8_t *dst
,
33 const uint8_t *s
= src
;
34 const uint8_t *end
= s
+ src_size
;
38 /* RGB24 (= R, G, B) -> RGB32 (= A, B, G, R) */
53 static inline void rgb32tobgr24_c(const uint8_t *src
, uint8_t *dst
,
57 const uint8_t *s
= src
;
58 const uint8_t *end
= s
+ src_size
;
62 /* RGB32 (= A, B, G, R) -> RGB24 (= R, G, B) */
78 * original by Strepto/Astral
79 * ported to gcc & bugfixed: A'rpi
80 * MMXEXT, 3DNOW optimization by Nick Kurshev
81 * 32-bit C version, and and&add trick by Michael Niedermayer
83 static inline void rgb15to16_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
85 register uint8_t *d
= dst
;
86 register const uint8_t *s
= src
;
87 register const uint8_t *end
= s
+ src_size
;
88 const uint8_t *mm_end
= end
- 3;
91 register unsigned x
= *((const uint32_t *)s
);
92 *((uint32_t *)d
) = (x
& 0x7FFF7FFF) + (x
& 0x7FE07FE0);
97 register unsigned short x
= *((const uint16_t *)s
);
98 *((uint16_t *)d
) = (x
& 0x7FFF) + (x
& 0x7FE0);
102 static inline void rgb16to15_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
104 register uint8_t *d
= dst
;
105 register const uint8_t *s
= src
;
106 register const uint8_t *end
= s
+ src_size
;
107 const uint8_t *mm_end
= end
- 3;
110 register uint32_t x
= *((const uint32_t *)s
);
111 *((uint32_t *)d
) = ((x
>> 1) & 0x7FE07FE0) | (x
& 0x001F001F);
116 register uint16_t x
= *((const uint16_t *)s
);
117 *((uint16_t *)d
) = ((x
>> 1) & 0x7FE0) | (x
& 0x001F);
121 static inline void rgb32to16_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
123 uint16_t *d
= (uint16_t *)dst
;
124 const uint8_t *s
= src
;
125 const uint8_t *end
= s
+ src_size
;
128 register int rgb
= *(const uint32_t *)s
;
130 *d
++ = ((rgb
& 0xFF) >> 3) +
131 ((rgb
& 0xFC00) >> 5) +
132 ((rgb
& 0xF80000) >> 8);
136 static inline void rgb32tobgr16_c(const uint8_t *src
, uint8_t *dst
,
139 uint16_t *d
= (uint16_t *)dst
;
140 const uint8_t *s
= src
;
141 const uint8_t *end
= s
+ src_size
;
144 register int rgb
= *(const uint32_t *)s
;
146 *d
++ = ((rgb
& 0xF8) << 8) +
147 ((rgb
& 0xFC00) >> 5) +
148 ((rgb
& 0xF80000) >> 19);
152 static inline void rgb32to15_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
154 uint16_t *d
= (uint16_t *)dst
;
155 const uint8_t *s
= src
;
156 const uint8_t *end
= s
+ src_size
;
159 register int rgb
= *(const uint32_t *)s
;
161 *d
++ = ((rgb
& 0xFF) >> 3) +
162 ((rgb
& 0xF800) >> 6) +
163 ((rgb
& 0xF80000) >> 9);
167 static inline void rgb32tobgr15_c(const uint8_t *src
, uint8_t *dst
,
170 uint16_t *d
= (uint16_t *)dst
;
171 const uint8_t *s
= src
;
172 const uint8_t *end
= s
+ src_size
;
175 register int rgb
= *(const uint32_t *)s
;
177 *d
++ = ((rgb
& 0xF8) << 7) +
178 ((rgb
& 0xF800) >> 6) +
179 ((rgb
& 0xF80000) >> 19);
183 static inline void rgb24tobgr16_c(const uint8_t *src
, uint8_t *dst
,
186 uint16_t *d
= (uint16_t *)dst
;
187 const uint8_t *s
= src
;
188 const uint8_t *end
= s
+ src_size
;
194 *d
++ = (b
>> 3) | ((g
& 0xFC) << 3) | ((r
& 0xF8) << 8);
198 static inline void rgb24to16_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
200 uint16_t *d
= (uint16_t *)dst
;
201 const uint8_t *s
= src
;
202 const uint8_t *end
= s
+ src_size
;
208 *d
++ = (b
>> 3) | ((g
& 0xFC) << 3) | ((r
& 0xF8) << 8);
212 static inline void rgb24tobgr15_c(const uint8_t *src
, uint8_t *dst
,
215 uint16_t *d
= (uint16_t *)dst
;
216 const uint8_t *s
= src
;
217 const uint8_t *end
= s
+ src_size
;
223 *d
++ = (b
>> 3) | ((g
& 0xF8) << 2) | ((r
& 0xF8) << 7);
227 static inline void rgb24to15_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
229 uint16_t *d
= (uint16_t *)dst
;
230 const uint8_t *s
= src
;
231 const uint8_t *end
= s
+ src_size
;
237 *d
++ = (b
>> 3) | ((g
& 0xF8) << 2) | ((r
& 0xF8) << 7);
242 * I use less accurate approximation here by simply left-shifting the input
243 * value and filling the low order bits with zeroes. This method improves PNG
244 * compression but this scheme cannot reproduce white exactly, since it does
245 * not generate an all-ones maximum value; the net effect is to darken the
248 * The better method should be "left bit replication":
258 * | leftmost bits repeated to fill open bits
262 static inline void rgb15tobgr24_c(const uint8_t *src
, uint8_t *dst
,
266 const uint16_t *s
= (const uint16_t *)src
;
267 const uint16_t *end
= s
+ src_size
/ 2;
270 register uint16_t bgr
= *s
++;
271 *d
++ = (bgr
& 0x1F) << 3;
272 *d
++ = (bgr
& 0x3E0) >> 2;
273 *d
++ = (bgr
& 0x7C00) >> 7;
277 static inline void rgb16tobgr24_c(const uint8_t *src
, uint8_t *dst
,
280 uint8_t *d
= (uint8_t *)dst
;
281 const uint16_t *s
= (const uint16_t *)src
;
282 const uint16_t *end
= s
+ src_size
/ 2;
285 register uint16_t bgr
= *s
++;
286 *d
++ = (bgr
& 0x1F) << 3;
287 *d
++ = (bgr
& 0x7E0) >> 3;
288 *d
++ = (bgr
& 0xF800) >> 8;
292 static inline void rgb15to32_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
295 const uint16_t *s
= (const uint16_t *)src
;
296 const uint16_t *end
= s
+ src_size
/ 2;
299 register uint16_t bgr
= *s
++;
302 *d
++ = (bgr
& 0x7C00) >> 7;
303 *d
++ = (bgr
& 0x3E0) >> 2;
304 *d
++ = (bgr
& 0x1F) << 3;
306 *d
++ = (bgr
& 0x1F) << 3;
307 *d
++ = (bgr
& 0x3E0) >> 2;
308 *d
++ = (bgr
& 0x7C00) >> 7;
314 static inline void rgb16to32_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
317 const uint16_t *s
= (const uint16_t *)src
;
318 const uint16_t *end
= s
+ src_size
/ 2;
321 register uint16_t bgr
= *s
++;
324 *d
++ = (bgr
& 0xF800) >> 8;
325 *d
++ = (bgr
& 0x7E0) >> 3;
326 *d
++ = (bgr
& 0x1F) << 3;
328 *d
++ = (bgr
& 0x1F) << 3;
329 *d
++ = (bgr
& 0x7E0) >> 3;
330 *d
++ = (bgr
& 0xF800) >> 8;
336 static inline void shuffle_bytes_2103_c(const uint8_t *src
, uint8_t *dst
,
339 int idx
= 15 - src_size
;
340 const uint8_t *s
= src
- idx
;
341 uint8_t *d
= dst
- idx
;
343 for (; idx
< 15; idx
+= 4) {
344 register int v
= *(const uint32_t *)&s
[idx
], g
= v
& 0xff00ff00;
346 *(uint32_t *)&d
[idx
] = (v
>> 16) + g
+ (v
<< 16);
350 static inline void rgb24tobgr24_c(const uint8_t *src
, uint8_t *dst
, int src_size
)
354 for (i
= 0; i
< src_size
; i
+= 3) {
355 register uint8_t x
= src
[i
+ 2];
356 dst
[i
+ 1] = src
[i
+ 1];
357 dst
[i
+ 2] = src
[i
+ 0];
362 static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc
, const uint8_t *usrc
,
363 const uint8_t *vsrc
, uint8_t *dst
,
364 int width
, int height
,
365 int lumStride
, int chromStride
,
366 int dstStride
, int vertLumPerChroma
)
369 const int chromWidth
= width
>> 1;
371 for (y
= 0; y
< height
; y
++) {
373 uint64_t *ldst
= (uint64_t *)dst
;
374 const uint8_t *yc
= ysrc
, *uc
= usrc
, *vc
= vsrc
;
375 for (i
= 0; i
< chromWidth
; i
+= 2) {
376 uint64_t k
= yc
[0] + (uc
[0] << 8) +
377 (yc
[1] << 16) + (vc
[0] << 24);
378 uint64_t l
= yc
[2] + (uc
[1] << 8) +
379 (yc
[3] << 16) + (vc
[1] << 24);
380 *ldst
++ = k
+ (l
<< 32);
387 int *idst
= (int32_t *)dst
;
388 const uint8_t *yc
= ysrc
, *uc
= usrc
, *vc
= vsrc
;
390 for (i
= 0; i
< chromWidth
; i
++) {
392 *idst
++ = (yc
[0] << 24) + (uc
[0] << 16) +
393 (yc
[1] << 8) + (vc
[0] << 0);
395 *idst
++ = yc
[0] + (uc
[0] << 8) +
396 (yc
[1] << 16) + (vc
[0] << 24);
403 if ((y
& (vertLumPerChroma
- 1)) == vertLumPerChroma
- 1) {
413 * Height should be a multiple of 2 and width should be a multiple of 16.
414 * (If this is a problem for anyone then tell me, and I will fix it.)
416 static inline void yv12toyuy2_c(const uint8_t *ysrc
, const uint8_t *usrc
,
417 const uint8_t *vsrc
, uint8_t *dst
,
418 int width
, int height
, int lumStride
,
419 int chromStride
, int dstStride
)
421 //FIXME interpolate chroma
422 yuvPlanartoyuy2_c(ysrc
, usrc
, vsrc
, dst
, width
, height
, lumStride
,
423 chromStride
, dstStride
, 2);
426 static inline void yuvPlanartouyvy_c(const uint8_t *ysrc
, const uint8_t *usrc
,
427 const uint8_t *vsrc
, uint8_t *dst
,
428 int width
, int height
,
429 int lumStride
, int chromStride
,
430 int dstStride
, int vertLumPerChroma
)
433 const int chromWidth
= width
>> 1;
435 for (y
= 0; y
< height
; y
++) {
437 uint64_t *ldst
= (uint64_t *)dst
;
438 const uint8_t *yc
= ysrc
, *uc
= usrc
, *vc
= vsrc
;
439 for (i
= 0; i
< chromWidth
; i
+= 2) {
440 uint64_t k
= uc
[0] + (yc
[0] << 8) +
441 (vc
[0] << 16) + (yc
[1] << 24);
442 uint64_t l
= uc
[1] + (yc
[2] << 8) +
443 (vc
[1] << 16) + (yc
[3] << 24);
444 *ldst
++ = k
+ (l
<< 32);
451 int *idst
= (int32_t *)dst
;
452 const uint8_t *yc
= ysrc
, *uc
= usrc
, *vc
= vsrc
;
454 for (i
= 0; i
< chromWidth
; i
++) {
456 *idst
++ = (uc
[0] << 24) + (yc
[0] << 16) +
457 (vc
[0] << 8) + (yc
[1] << 0);
459 *idst
++ = uc
[0] + (yc
[0] << 8) +
460 (vc
[0] << 16) + (yc
[1] << 24);
467 if ((y
& (vertLumPerChroma
- 1)) == vertLumPerChroma
- 1) {
477 * Height should be a multiple of 2 and width should be a multiple of 16
478 * (If this is a problem for anyone then tell me, and I will fix it.)
480 static inline void yv12touyvy_c(const uint8_t *ysrc
, const uint8_t *usrc
,
481 const uint8_t *vsrc
, uint8_t *dst
,
482 int width
, int height
, int lumStride
,
483 int chromStride
, int dstStride
)
485 //FIXME interpolate chroma
486 yuvPlanartouyvy_c(ysrc
, usrc
, vsrc
, dst
, width
, height
, lumStride
,
487 chromStride
, dstStride
, 2);
491 * Width should be a multiple of 16.
493 static inline void yuv422ptouyvy_c(const uint8_t *ysrc
, const uint8_t *usrc
,
494 const uint8_t *vsrc
, uint8_t *dst
,
495 int width
, int height
, int lumStride
,
496 int chromStride
, int dstStride
)
498 yuvPlanartouyvy_c(ysrc
, usrc
, vsrc
, dst
, width
, height
, lumStride
,
499 chromStride
, dstStride
, 1);
503 * Width should be a multiple of 16.
505 static inline void yuv422ptoyuy2_c(const uint8_t *ysrc
, const uint8_t *usrc
,
506 const uint8_t *vsrc
, uint8_t *dst
,
507 int width
, int height
, int lumStride
,
508 int chromStride
, int dstStride
)
510 yuvPlanartoyuy2_c(ysrc
, usrc
, vsrc
, dst
, width
, height
, lumStride
,
511 chromStride
, dstStride
, 1);
515 * Height should be a multiple of 2 and width should be a multiple of 16.
516 * (If this is a problem for anyone then tell me, and I will fix it.)
518 static inline void yuy2toyv12_c(const uint8_t *src
, uint8_t *ydst
,
519 uint8_t *udst
, uint8_t *vdst
,
520 int width
, int height
, int lumStride
,
521 int chromStride
, int srcStride
)
524 const int chromWidth
= width
>> 1;
526 for (y
= 0; y
< height
; y
+= 2) {
528 for (i
= 0; i
< chromWidth
; i
++) {
529 ydst
[2 * i
+ 0] = src
[4 * i
+ 0];
530 udst
[i
] = src
[4 * i
+ 1];
531 ydst
[2 * i
+ 1] = src
[4 * i
+ 2];
532 vdst
[i
] = src
[4 * i
+ 3];
537 for (i
= 0; i
< chromWidth
; i
++) {
538 ydst
[2 * i
+ 0] = src
[4 * i
+ 0];
539 ydst
[2 * i
+ 1] = src
[4 * i
+ 2];
548 static inline void planar2x_c(const uint8_t *src
, uint8_t *dst
, int srcWidth
,
549 int srcHeight
, int srcStride
, int dstStride
)
556 for (x
= 0; x
< srcWidth
- 1; x
++) {
557 dst
[2 * x
+ 1] = (3 * src
[x
] + src
[x
+ 1]) >> 2;
558 dst
[2 * x
+ 2] = (src
[x
] + 3 * src
[x
+ 1]) >> 2;
560 dst
[2 * srcWidth
- 1] = src
[srcWidth
- 1];
564 for (y
= 1; y
< srcHeight
; y
++) {
565 const int mmxSize
= 1;
567 dst
[0] = (src
[0] * 3 + src
[srcStride
]) >> 2;
568 dst
[dstStride
] = (src
[0] + 3 * src
[srcStride
]) >> 2;
570 for (x
= mmxSize
- 1; x
< srcWidth
- 1; x
++) {
571 dst
[2 * x
+ 1] = (src
[x
+ 0] * 3 + src
[x
+ srcStride
+ 1]) >> 2;
572 dst
[2 * x
+ dstStride
+ 2] = (src
[x
+ 0] + 3 * src
[x
+ srcStride
+ 1]) >> 2;
573 dst
[2 * x
+ dstStride
+ 1] = (src
[x
+ 1] + 3 * src
[x
+ srcStride
]) >> 2;
574 dst
[2 * x
+ 2] = (src
[x
+ 1] * 3 + src
[x
+ srcStride
]) >> 2;
576 dst
[srcWidth
* 2 - 1] = (src
[srcWidth
- 1] * 3 + src
[srcWidth
- 1 + srcStride
]) >> 2;
577 dst
[srcWidth
* 2 - 1 + dstStride
] = (src
[srcWidth
- 1] + 3 * src
[srcWidth
- 1 + srcStride
]) >> 2;
579 dst
+= dstStride
* 2;
586 for (x
= 0; x
< srcWidth
- 1; x
++) {
587 dst
[2 * x
+ 1] = (src
[x
] * 3 + src
[x
+ 1]) >> 2;
588 dst
[2 * x
+ 2] = (src
[x
] + 3 * src
[x
+ 1]) >> 2;
590 dst
[2 * srcWidth
- 1] = src
[srcWidth
- 1];
594 * Height should be a multiple of 2 and width should be a multiple of 16.
595 * (If this is a problem for anyone then tell me, and I will fix it.)
596 * Chrominance data is only taken from every second line, others are ignored.
597 * FIXME: Write HQ version.
599 static inline void uyvytoyv12_c(const uint8_t *src
, uint8_t *ydst
,
600 uint8_t *udst
, uint8_t *vdst
,
601 int width
, int height
, int lumStride
,
602 int chromStride
, int srcStride
)
605 const int chromWidth
= width
>> 1;
607 for (y
= 0; y
< height
; y
+= 2) {
609 for (i
= 0; i
< chromWidth
; i
++) {
610 udst
[i
] = src
[4 * i
+ 0];
611 ydst
[2 * i
+ 0] = src
[4 * i
+ 1];
612 vdst
[i
] = src
[4 * i
+ 2];
613 ydst
[2 * i
+ 1] = src
[4 * i
+ 3];
618 for (i
= 0; i
< chromWidth
; i
++) {
619 ydst
[2 * i
+ 0] = src
[4 * i
+ 1];
620 ydst
[2 * i
+ 1] = src
[4 * i
+ 3];
630 * Height should be a multiple of 2 and width should be a multiple of 2.
631 * (If this is a problem for anyone then tell me, and I will fix it.)
632 * Chrominance data is only taken from every second line,
633 * others are ignored in the C version.
634 * FIXME: Write HQ version.
636 void rgb24toyv12_c(const uint8_t *src
, uint8_t *ydst
, uint8_t *udst
,
637 uint8_t *vdst
, int width
, int height
, int lumStride
,
638 int chromStride
, int srcStride
)
641 const int chromWidth
= width
>> 1;
643 for (y
= 0; y
< height
; y
+= 2) {
645 for (i
= 0; i
< chromWidth
; i
++) {
646 unsigned int b
= src
[6 * i
+ 0];
647 unsigned int g
= src
[6 * i
+ 1];
648 unsigned int r
= src
[6 * i
+ 2];
650 unsigned int Y
= ((RY
* r
+ GY
* g
+ BY
* b
) >> RGB2YUV_SHIFT
) + 16;
651 unsigned int V
= ((RV
* r
+ GV
* g
+ BV
* b
) >> RGB2YUV_SHIFT
) + 128;
652 unsigned int U
= ((RU
* r
+ GU
* g
+ BU
* b
) >> RGB2YUV_SHIFT
) + 128;
662 Y
= ((RY
* r
+ GY
* g
+ BY
* b
) >> RGB2YUV_SHIFT
) + 16;
668 for (i
= 0; i
< chromWidth
; i
++) {
669 unsigned int b
= src
[6 * i
+ 0];
670 unsigned int g
= src
[6 * i
+ 1];
671 unsigned int r
= src
[6 * i
+ 2];
673 unsigned int Y
= ((RY
* r
+ GY
* g
+ BY
* b
) >> RGB2YUV_SHIFT
) + 16;
681 Y
= ((RY
* r
+ GY
* g
+ BY
* b
) >> RGB2YUV_SHIFT
) + 16;
691 static void interleaveBytes_c(const uint8_t *src1
, const uint8_t *src2
,
692 uint8_t *dest
, int width
, int height
,
693 int src1Stride
, int src2Stride
, int dstStride
)
697 for (h
= 0; h
< height
; h
++) {
699 for (w
= 0; w
< width
; w
++) {
700 dest
[2 * w
+ 0] = src1
[w
];
701 dest
[2 * w
+ 1] = src2
[w
];
709 static inline void vu9_to_vu12_c(const uint8_t *src1
, const uint8_t *src2
,
710 uint8_t *dst1
, uint8_t *dst2
,
711 int width
, int height
,
712 int srcStride1
, int srcStride2
,
713 int dstStride1
, int dstStride2
)
719 for (y
= 0; y
< h
; y
++) {
720 const uint8_t *s1
= src1
+ srcStride1
* (y
>> 1);
721 uint8_t *d
= dst1
+ dstStride1
* y
;
722 for (x
= 0; x
< w
; x
++)
723 d
[2 * x
] = d
[2 * x
+ 1] = s1
[x
];
725 for (y
= 0; y
< h
; y
++) {
726 const uint8_t *s2
= src2
+ srcStride2
* (y
>> 1);
727 uint8_t *d
= dst2
+ dstStride2
* y
;
728 for (x
= 0; x
< w
; x
++)
729 d
[2 * x
] = d
[2 * x
+ 1] = s2
[x
];
733 static inline void yvu9_to_yuy2_c(const uint8_t *src1
, const uint8_t *src2
,
734 const uint8_t *src3
, uint8_t *dst
,
735 int width
, int height
,
736 int srcStride1
, int srcStride2
,
737 int srcStride3
, int dstStride
)
743 for (y
= 0; y
< h
; y
++) {
744 const uint8_t *yp
= src1
+ srcStride1
* y
;
745 const uint8_t *up
= src2
+ srcStride2
* (y
>> 2);
746 const uint8_t *vp
= src3
+ srcStride3
* (y
>> 2);
747 uint8_t *d
= dst
+ dstStride
* y
;
748 for (x
= 0; x
< w
; x
++) {
749 const int x2
= x
<< 2;
750 d
[8 * x
+ 0] = yp
[x2
];
751 d
[8 * x
+ 1] = up
[x
];
752 d
[8 * x
+ 2] = yp
[x2
+ 1];
753 d
[8 * x
+ 3] = vp
[x
];
754 d
[8 * x
+ 4] = yp
[x2
+ 2];
755 d
[8 * x
+ 5] = up
[x
];
756 d
[8 * x
+ 6] = yp
[x2
+ 3];
757 d
[8 * x
+ 7] = vp
[x
];
762 static void extract_even_c(const uint8_t *src
, uint8_t *dst
, int count
)
768 dst
[count
] = src
[2 * count
];
773 static void extract_even2_c(const uint8_t *src
, uint8_t *dst0
, uint8_t *dst1
,
781 dst0
[count
] = src
[4 * count
+ 0];
782 dst1
[count
] = src
[4 * count
+ 2];
787 static void extract_even2avg_c(const uint8_t *src0
, const uint8_t *src1
,
788 uint8_t *dst0
, uint8_t *dst1
, int count
)
796 dst0
[count
] = (src0
[4 * count
+ 0] + src1
[4 * count
+ 0]) >> 1;
797 dst1
[count
] = (src0
[4 * count
+ 2] + src1
[4 * count
+ 2]) >> 1;
802 static void extract_odd2_c(const uint8_t *src
, uint8_t *dst0
, uint8_t *dst1
,
811 dst0
[count
] = src
[4 * count
+ 0];
812 dst1
[count
] = src
[4 * count
+ 2];
817 static void extract_odd2avg_c(const uint8_t *src0
, const uint8_t *src1
,
818 uint8_t *dst0
, uint8_t *dst1
, int count
)
828 dst0
[count
] = (src0
[4 * count
+ 0] + src1
[4 * count
+ 0]) >> 1;
829 dst1
[count
] = (src0
[4 * count
+ 2] + src1
[4 * count
+ 2]) >> 1;
834 static void yuyvtoyuv420_c(uint8_t *ydst
, uint8_t *udst
, uint8_t *vdst
,
835 const uint8_t *src
, int width
, int height
,
836 int lumStride
, int chromStride
, int srcStride
)
839 const int chromWidth
= -((-width
) >> 1);
841 for (y
= 0; y
< height
; y
++) {
842 extract_even_c(src
, ydst
, width
);
844 extract_odd2avg_c(src
- srcStride
, src
, udst
, vdst
, chromWidth
);
854 static void yuyvtoyuv422_c(uint8_t *ydst
, uint8_t *udst
, uint8_t *vdst
,
855 const uint8_t *src
, int width
, int height
,
856 int lumStride
, int chromStride
, int srcStride
)
859 const int chromWidth
= -((-width
) >> 1);
861 for (y
= 0; y
< height
; y
++) {
862 extract_even_c(src
, ydst
, width
);
863 extract_odd2_c(src
, udst
, vdst
, chromWidth
);
872 static void uyvytoyuv420_c(uint8_t *ydst
, uint8_t *udst
, uint8_t *vdst
,
873 const uint8_t *src
, int width
, int height
,
874 int lumStride
, int chromStride
, int srcStride
)
877 const int chromWidth
= -((-width
) >> 1);
879 for (y
= 0; y
< height
; y
++) {
880 extract_even_c(src
+ 1, ydst
, width
);
882 extract_even2avg_c(src
- srcStride
, src
, udst
, vdst
, chromWidth
);
892 static void uyvytoyuv422_c(uint8_t *ydst
, uint8_t *udst
, uint8_t *vdst
,
893 const uint8_t *src
, int width
, int height
,
894 int lumStride
, int chromStride
, int srcStride
)
897 const int chromWidth
= -((-width
) >> 1);
899 for (y
= 0; y
< height
; y
++) {
900 extract_even_c(src
+ 1, ydst
, width
);
901 extract_even2_c(src
, udst
, vdst
, chromWidth
);
910 static inline void rgb2rgb_init_c(void)
912 rgb15to16
= rgb15to16_c
;
913 rgb15tobgr24
= rgb15tobgr24_c
;
914 rgb15to32
= rgb15to32_c
;
915 rgb16tobgr24
= rgb16tobgr24_c
;
916 rgb16to32
= rgb16to32_c
;
917 rgb16to15
= rgb16to15_c
;
918 rgb24tobgr16
= rgb24tobgr16_c
;
919 rgb24tobgr15
= rgb24tobgr15_c
;
920 rgb24tobgr32
= rgb24tobgr32_c
;
921 rgb32to16
= rgb32to16_c
;
922 rgb32to15
= rgb32to15_c
;
923 rgb32tobgr24
= rgb32tobgr24_c
;
924 rgb24to15
= rgb24to15_c
;
925 rgb24to16
= rgb24to16_c
;
926 rgb24tobgr24
= rgb24tobgr24_c
;
927 shuffle_bytes_2103
= shuffle_bytes_2103_c
;
928 rgb32tobgr16
= rgb32tobgr16_c
;
929 rgb32tobgr15
= rgb32tobgr15_c
;
930 yv12toyuy2
= yv12toyuy2_c
;
931 yv12touyvy
= yv12touyvy_c
;
932 yuv422ptoyuy2
= yuv422ptoyuy2_c
;
933 yuv422ptouyvy
= yuv422ptouyvy_c
;
934 yuy2toyv12
= yuy2toyv12_c
;
935 planar2x
= planar2x_c
;
936 rgb24toyv12
= rgb24toyv12_c
;
937 interleaveBytes
= interleaveBytes_c
;
938 vu9_to_vu12
= vu9_to_vu12_c
;
939 yvu9_to_yuy2
= yvu9_to_yuy2_c
;
941 uyvytoyuv420
= uyvytoyuv420_c
;
942 uyvytoyuv422
= uyvytoyuv422_c
;
943 yuyvtoyuv420
= yuyvtoyuv420_c
;
944 yuyvtoyuv422
= yuyvtoyuv422_c
;