Mercurial > mplayer.hg
annotate postproc/rgb2rgb.c @ 6484:c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
author | alex |
---|---|
date | Fri, 21 Jun 2002 17:37:00 +0000 |
parents | f0fa3373f616 |
children | e7635c03910f |
rev | line source |
---|---|
2694 | 1 /* |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
2 * |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
3 * rgb2rgb.c, Software RGB to RGB convertor |
2732 | 4 * pluralize by Software PAL8 to RGB convertor |
5 * Software YUV to YUV convertor | |
6 * Software YUV to RGB convertor | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
7 * Written by Nick Kurshev. |
3132 | 8 * palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL) |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
9 */ |
2504 | 10 #include <inttypes.h> |
11 #include "../config.h" | |
12 #include "rgb2rgb.h" | |
3132 | 13 #include "../cpudetect.h" |
4923 | 14 #include "../mangle.h" |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
15 |
3132 | 16 #ifdef ARCH_X86 |
17 #define CAN_COMPILE_X86_ASM | |
18 #endif | |
19 | |
4622 | 20 #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit |
21 | |
3132 | 22 #ifdef CAN_COMPILE_X86_ASM |
2755 | 23 static const uint64_t mask32b __attribute__((aligned(8))) = 0x000000FF000000FFULL; |
24 static const uint64_t mask32g __attribute__((aligned(8))) = 0x0000FF000000FF00ULL; | |
25 static const uint64_t mask32r __attribute__((aligned(8))) = 0x00FF000000FF0000ULL; | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
26 static const uint64_t mask32 __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL; |
5582 | 27 static const uint64_t mask24b __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL; |
28 static const uint64_t mask24g __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL; | |
29 static const uint64_t mask24r __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL; | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
30 static const uint64_t mask24l __attribute__((aligned(8))) = 0x0000000000FFFFFFULL; |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
31 static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL; |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
32 static const uint64_t mask24hh __attribute__((aligned(8))) = 0xffff000000000000ULL; |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
33 static const uint64_t mask24hhh __attribute__((aligned(8))) = 0xffffffff00000000ULL; |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
34 static const uint64_t mask24hhhh __attribute__((aligned(8))) = 0xffffffffffff0000ULL; |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
35 static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */ |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
36 static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */ |
2698
22652c028692
faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents:
2697
diff
changeset
|
37 static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL; |
2741 | 38 static const uint64_t red_16mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL; |
39 static const uint64_t green_16mask __attribute__((aligned(8)))= 0x000007e0000007e0ULL; | |
40 static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; | |
41 static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c000000f800ULL; | |
42 static const uint64_t green_15mask __attribute__((aligned(8)))= 0x000003e0000007e0ULL; | |
43 static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; | |
4622 | 44 |
45 #ifdef FAST_BGR2YV12 | |
46 static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000000210041000DULL; | |
47 static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL; | |
48 static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL; | |
49 #else | |
50 static const uint64_t bgr2YCoeff __attribute__((aligned(8))) = 0x000020E540830C8BULL; | |
51 static const uint64_t bgr2UCoeff __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL; | |
52 static const uint64_t bgr2VCoeff __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL; | |
53 #endif | |
54 static const uint64_t bgr2YOffset __attribute__((aligned(8))) = 0x1010101010101010ULL; | |
55 static const uint64_t bgr2UVOffset __attribute__((aligned(8)))= 0x8080808080808080ULL; | |
56 static const uint64_t w1111 __attribute__((aligned(8))) = 0x0001000100010001ULL; | |
57 | |
2755 | 58 #if 0 |
59 static volatile uint64_t __attribute__((aligned(8))) b5Dither; | |
60 static volatile uint64_t __attribute__((aligned(8))) g5Dither; | |
61 static volatile uint64_t __attribute__((aligned(8))) g6Dither; | |
62 static volatile uint64_t __attribute__((aligned(8))) r5Dither; | |
63 | |
64 static uint64_t __attribute__((aligned(8))) dither4[2]={ | |
65 0x0103010301030103LL, | |
66 0x0200020002000200LL,}; | |
67 | |
68 static uint64_t __attribute__((aligned(8))) dither8[2]={ | |
69 0x0602060206020602LL, | |
70 0x0004000400040004LL,}; | |
71 #endif | |
2535 | 72 #endif |
2513 | 73 |
3132 | 74 #define RGB2YUV_SHIFT 8 |
75 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5)) | |
76 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5)) | |
77 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |
78 #define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5)) | |
79 #define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5)) | |
80 #define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5)) | |
81 #define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5)) | |
82 #define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5)) | |
83 #define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5)) | |
84 | |
85 //Note: we have C, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one | |
86 //Plain C versions | |
87 #undef HAVE_MMX | |
88 #undef HAVE_MMX2 | |
89 #undef HAVE_3DNOW | |
90 #undef ARCH_X86 | |
5338 | 91 #undef HAVE_SSE2 |
3132 | 92 #define RENAME(a) a ## _C |
93 #include "rgb2rgb_template.c" | |
94 | |
95 #ifdef CAN_COMPILE_X86_ASM | |
96 | |
97 //MMX versions | |
98 #undef RENAME | |
99 #define HAVE_MMX | |
100 #undef HAVE_MMX2 | |
101 #undef HAVE_3DNOW | |
5338 | 102 #undef HAVE_SSE2 |
3132 | 103 #define ARCH_X86 |
104 #define RENAME(a) a ## _MMX | |
105 #include "rgb2rgb_template.c" | |
106 | |
107 //MMX2 versions | |
108 #undef RENAME | |
109 #define HAVE_MMX | |
110 #define HAVE_MMX2 | |
111 #undef HAVE_3DNOW | |
5338 | 112 #undef HAVE_SSE2 |
3132 | 113 #define ARCH_X86 |
114 #define RENAME(a) a ## _MMX2 | |
115 #include "rgb2rgb_template.c" | |
116 | |
117 //3DNOW versions | |
118 #undef RENAME | |
119 #define HAVE_MMX | |
120 #undef HAVE_MMX2 | |
121 #define HAVE_3DNOW | |
5338 | 122 #undef HAVE_SSE2 |
3132 | 123 #define ARCH_X86 |
124 #define RENAME(a) a ## _3DNow | |
125 #include "rgb2rgb_template.c" | |
126 | |
127 #endif //CAN_COMPILE_X86_ASM | |
128 | |
2718 | 129 void rgb24to32(const uint8_t *src,uint8_t *dst,unsigned src_size) |
2504 | 130 { |
3132 | 131 #ifdef CAN_COMPILE_X86_ASM |
132 // ordered per speed fasterst first | |
133 if(gCpuCaps.hasMMX2) | |
134 rgb24to32_MMX2(src, dst, src_size); | |
135 else if(gCpuCaps.has3DNow) | |
136 rgb24to32_3DNow(src, dst, src_size); | |
137 else if(gCpuCaps.hasMMX) | |
138 rgb24to32_MMX(src, dst, src_size); | |
139 else | |
140 rgb24to32_C(src, dst, src_size); | |
141 #else | |
142 rgb24to32_C(src, dst, src_size); | |
2510 | 143 #endif |
2504 | 144 } |
2505 | 145 |
2718 | 146 void rgb32to24(const uint8_t *src,uint8_t *dst,unsigned src_size) |
2505 | 147 { |
3132 | 148 #ifdef CAN_COMPILE_X86_ASM |
149 // ordered per speed fasterst first | |
150 if(gCpuCaps.hasMMX2) | |
151 rgb32to24_MMX2(src, dst, src_size); | |
152 else if(gCpuCaps.has3DNow) | |
153 rgb32to24_3DNow(src, dst, src_size); | |
154 else if(gCpuCaps.hasMMX) | |
155 rgb32to24_MMX(src, dst, src_size); | |
156 else | |
157 rgb32to24_C(src, dst, src_size); | |
158 #else | |
159 rgb32to24_C(src, dst, src_size); | |
2517 | 160 #endif |
2505 | 161 } |
2506 | 162 |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
163 /* |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
164 Original by Strepto/Astral |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
165 ported to gcc & bugfixed : A'rpi |
2564 | 166 MMX2, 3DNOW optimization by Nick Kurshev |
2698
22652c028692
faster 15to16 bit rgb (the mmx routine is limited by memory speed so there is no difference ): but the c routine is faster
michael
parents:
2697
diff
changeset
|
167 32bit c version, and and&add trick by Michael Niedermayer |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
168 */ |
2718 | 169 void rgb15to16(const uint8_t *src,uint8_t *dst,unsigned src_size) |
2506 | 170 { |
3132 | 171 #ifdef CAN_COMPILE_X86_ASM |
172 // ordered per speed fasterst first | |
173 if(gCpuCaps.hasMMX2) | |
174 rgb15to16_MMX2(src, dst, src_size); | |
175 else if(gCpuCaps.has3DNow) | |
176 rgb15to16_3DNow(src, dst, src_size); | |
177 else if(gCpuCaps.hasMMX) | |
178 rgb15to16_MMX(src, dst, src_size); | |
179 else | |
180 rgb15to16_C(src, dst, src_size); | |
2506 | 181 #else |
3132 | 182 rgb15to16_C(src, dst, src_size); |
2506 | 183 #endif |
184 } | |
2694 | 185 |
186 /** | |
187 * Pallete is assumed to contain bgr32 | |
188 */ | |
2718 | 189 void palette8torgb32(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 190 { |
2718 | 191 unsigned i; |
2702 | 192 for(i=0; i<num_pixels; i++) |
2718 | 193 ((unsigned *)dst)[i] = ((unsigned *)palette)[ src[i] ]; |
2694 | 194 } |
195 | |
2697 | 196 /** |
197 * Pallete is assumed to contain bgr32 | |
198 */ | |
2718 | 199 void palette8torgb24(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2697 | 200 { |
2718 | 201 unsigned i; |
2697 | 202 /* |
203 writes 1 byte o much and might cause alignment issues on some architectures? | |
2702 | 204 for(i=0; i<num_pixels; i++) |
2718 | 205 ((unsigned *)(&dst[i*3])) = ((unsigned *)palette)[ src[i] ]; |
2697 | 206 */ |
2702 | 207 for(i=0; i<num_pixels; i++) |
2697 | 208 { |
209 //FIXME slow? | |
210 dst[0]= palette[ src[i]*4+0 ]; | |
211 dst[1]= palette[ src[i]*4+1 ]; | |
212 dst[2]= palette[ src[i]*4+2 ]; | |
213 dst+= 3; | |
214 } | |
215 } | |
216 | |
6484
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
217 void bgr24torgb24(const uint8_t *src, uint8_t *dst, unsigned src_size) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
218 { |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
219 #ifdef CAN_COMPILE_X86_ASM |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
220 // ordered per speed fasterst first |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
221 if(gCpuCaps.hasMMX2) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
222 bgr24torgb24_MMX2(src, dst, src_size); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
223 else if(gCpuCaps.has3DNow) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
224 bgr24torgb24_3DNow(src, dst, src_size); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
225 else if(gCpuCaps.hasMMX) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
226 bgr24torgb24_MMX(src, dst, src_size); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
227 else |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
228 bgr24torgb24_C(src, dst, src_size); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
229 #else |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
230 bgr24torgb24_C(src, dst, src_size); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
231 #endif |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
232 } |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
233 |
2718 | 234 void rgb32to16(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2694 | 235 { |
3132 | 236 #ifdef CAN_COMPILE_X86_ASM |
237 // ordered per speed fasterst first | |
238 if(gCpuCaps.hasMMX2) | |
239 rgb32to16_MMX2(src, dst, src_size); | |
240 else if(gCpuCaps.has3DNow) | |
241 rgb32to16_3DNow(src, dst, src_size); | |
242 else if(gCpuCaps.hasMMX) | |
243 rgb32to16_MMX(src, dst, src_size); | |
244 else | |
245 rgb32to16_C(src, dst, src_size); | |
2741 | 246 #else |
3132 | 247 rgb32to16_C(src, dst, src_size); |
2741 | 248 #endif |
2694 | 249 } |
250 | |
2718 | 251 void rgb32to15(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2694 | 252 { |
3132 | 253 #ifdef CAN_COMPILE_X86_ASM |
254 // ordered per speed fasterst first | |
255 if(gCpuCaps.hasMMX2) | |
256 rgb32to15_MMX2(src, dst, src_size); | |
257 else if(gCpuCaps.has3DNow) | |
258 rgb32to15_3DNow(src, dst, src_size); | |
259 else if(gCpuCaps.hasMMX) | |
260 rgb32to15_MMX(src, dst, src_size); | |
261 else | |
262 rgb32to15_C(src, dst, src_size); | |
2741 | 263 #else |
3132 | 264 rgb32to15_C(src, dst, src_size); |
2741 | 265 #endif |
2694 | 266 } |
267 | |
2718 | 268 void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size) |
269 { | |
3132 | 270 #ifdef CAN_COMPILE_X86_ASM |
271 // ordered per speed fasterst first | |
272 if(gCpuCaps.hasMMX2) | |
273 rgb24to16_MMX2(src, dst, src_size); | |
274 else if(gCpuCaps.has3DNow) | |
275 rgb24to16_3DNow(src, dst, src_size); | |
276 else if(gCpuCaps.hasMMX) | |
277 rgb24to16_MMX(src, dst, src_size); | |
278 else | |
279 rgb24to16_C(src, dst, src_size); | |
2740 | 280 #else |
3132 | 281 rgb24to16_C(src, dst, src_size); |
2740 | 282 #endif |
2718 | 283 } |
284 | |
285 void rgb24to15(const uint8_t *src, uint8_t *dst, unsigned src_size) | |
286 { | |
3132 | 287 #ifdef CAN_COMPILE_X86_ASM |
288 // ordered per speed fasterst first | |
289 if(gCpuCaps.hasMMX2) | |
290 rgb24to15_MMX2(src, dst, src_size); | |
291 else if(gCpuCaps.has3DNow) | |
292 rgb24to15_3DNow(src, dst, src_size); | |
293 else if(gCpuCaps.hasMMX) | |
294 rgb24to15_MMX(src, dst, src_size); | |
295 else | |
296 rgb24to15_C(src, dst, src_size); | |
2741 | 297 #else |
3132 | 298 rgb24to15_C(src, dst, src_size); |
2741 | 299 #endif |
2718 | 300 } |
2694 | 301 |
302 /** | |
303 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette | |
304 */ | |
2718 | 305 void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 306 { |
2718 | 307 unsigned i; |
2702 | 308 for(i=0; i<num_pixels; i++) |
2694 | 309 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
310 } | |
311 | |
312 /** | |
313 * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette | |
314 */ | |
2718 | 315 void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 316 { |
2718 | 317 unsigned i; |
2702 | 318 for(i=0; i<num_pixels; i++) |
2694 | 319 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
2697 | 320 } |
2755 | 321 |
322 void rgb32tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) | |
323 { | |
3132 | 324 #ifdef CAN_COMPILE_X86_ASM |
325 // ordered per speed fasterst first | |
326 if(gCpuCaps.hasMMX2) | |
327 rgb32tobgr32_MMX2(src, dst, src_size); | |
328 else if(gCpuCaps.has3DNow) | |
329 rgb32tobgr32_3DNow(src, dst, src_size); | |
330 else if(gCpuCaps.hasMMX) | |
331 rgb32tobgr32_MMX(src, dst, src_size); | |
332 else | |
333 rgb32tobgr32_C(src, dst, src_size); | |
2755 | 334 #else |
3132 | 335 rgb32tobgr32_C(src, dst, src_size); |
2755 | 336 #endif |
337 } | |
338 | |
5582 | 339 void rgb24tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
340 { | |
341 #ifdef CAN_COMPILE_X86_ASM | |
342 // ordered per speed fasterst first | |
343 if(gCpuCaps.hasMMX2) | |
344 rgb24tobgr24_MMX2(src, dst, src_size); | |
345 else if(gCpuCaps.has3DNow) | |
346 rgb24tobgr24_3DNow(src, dst, src_size); | |
347 else if(gCpuCaps.hasMMX) | |
348 rgb24tobgr24_MMX(src, dst, src_size); | |
349 else | |
350 rgb24tobgr24_C(src, dst, src_size); | |
351 #else | |
352 rgb24tobgr24_C(src, dst, src_size); | |
353 #endif | |
354 } | |
355 | |
2702 | 356 /** |
357 * | |
2724 | 358 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a |
359 * problem for anyone then tell me, and ill fix it) | |
2702 | 360 */ |
2723 | 361 void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
2725 | 362 unsigned int width, unsigned int height, |
363 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
2701 | 364 { |
3132 | 365 #ifdef CAN_COMPILE_X86_ASM |
366 // ordered per speed fasterst first | |
367 if(gCpuCaps.hasMMX2) | |
368 yv12toyuy2_MMX2(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
369 else if(gCpuCaps.has3DNow) | |
370 yv12toyuy2_3DNow(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
371 else if(gCpuCaps.hasMMX) | |
372 yv12toyuy2_MMX(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
373 else | |
374 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
2702 | 375 #else |
3132 | 376 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); |
2702 | 377 #endif |
2701 | 378 } |
379 | |
2724 | 380 /** |
381 * | |
5588 | 382 * width should be a multiple of 16 |
383 */ | |
384 void yuv422ptoyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |
385 unsigned int width, unsigned int height, | |
386 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
387 { | |
388 #ifdef CAN_COMPILE_X86_ASM | |
389 // ordered per speed fasterst first | |
390 if(gCpuCaps.hasMMX2) | |
391 yuv422ptoyuy2_MMX2(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
392 else if(gCpuCaps.has3DNow) | |
393 yuv422ptoyuy2_3DNow(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
394 else if(gCpuCaps.hasMMX) | |
395 yuv422ptoyuy2_MMX(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
396 else | |
397 yuv422ptoyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
398 #else | |
399 yuv422ptoyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
400 #endif | |
401 } | |
402 | |
403 /** | |
404 * | |
2724 | 405 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a |
406 * problem for anyone then tell me, and ill fix it) | |
407 */ | |
408 void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
2725 | 409 unsigned int width, unsigned int height, |
410 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
2701 | 411 { |
3132 | 412 #ifdef CAN_COMPILE_X86_ASM |
413 // ordered per speed fasterst first | |
414 if(gCpuCaps.hasMMX2) | |
415 yuy2toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
416 else if(gCpuCaps.has3DNow) | |
417 yuy2toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
418 else if(gCpuCaps.hasMMX) | |
419 yuy2toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
420 else | |
421 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
2704 | 422 #else |
3132 | 423 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); |
2704 | 424 #endif |
2723 | 425 } |
2801 | 426 |
427 /** | |
428 * | |
429 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | |
430 * problem for anyone then tell me, and ill fix it) | |
3132 | 431 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version |
2801 | 432 */ |
433 void uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
434 unsigned int width, unsigned int height, | |
435 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
436 { | |
3132 | 437 #ifdef CAN_COMPILE_X86_ASM |
438 // ordered per speed fasterst first | |
439 if(gCpuCaps.hasMMX2) | |
440 uyvytoyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
441 else if(gCpuCaps.has3DNow) | |
442 uyvytoyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
443 else if(gCpuCaps.hasMMX) | |
444 uyvytoyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
445 else | |
446 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
2847 | 447 #else |
3132 | 448 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); |
2847 | 449 #endif |
2801 | 450 } |
451 | |
6484
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
452 void yvu9toyv12(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
453 uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
454 unsigned int width, unsigned int height, |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
455 unsigned int lumStride, unsigned int chromStride) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
456 { |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
457 #ifdef CAN_COMPILE_X86_ASM |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
458 // ordered per speed fasterst first |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
459 if(gCpuCaps.hasMMX2) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
460 yvu9toyv12_MMX2(ysrc, usrc, vsrc, ydst, udst, vdst, width, height, lumStride, chromStride); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
461 else if(gCpuCaps.has3DNow) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
462 yvu9toyv12_3DNow(ysrc, usrc, vsrc, ydst, udst, vdst, width, height, lumStride, chromStride); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
463 else if(gCpuCaps.hasMMX) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
464 yvu9toyv12_MMX(ysrc, usrc, vsrc, ydst, udst, vdst, width, height, lumStride, chromStride); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
465 else |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
466 yvu9toyv12_C(ysrc, usrc, vsrc, ydst, udst, vdst, width, height, lumStride, chromStride); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
467 #else |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
468 yvu9toyv12_C(ysrc, usrc, vsrc, ydst, udst, vdst, width, height, lumStride, chromStride); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
469 #endif |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
470 } |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
5588
diff
changeset
|
471 |
3132 | 472 /** |
473 * | |
474 * height should be a multiple of 2 and width should be a multiple of 2 (if this is a | |
475 * problem for anyone then tell me, and ill fix it) | |
476 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version | |
477 */ | |
478 void rgb24toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
479 unsigned int width, unsigned int height, | |
480 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
481 { | |
482 #ifdef CAN_COMPILE_X86_ASM | |
483 // ordered per speed fasterst first | |
484 if(gCpuCaps.hasMMX2) | |
485 rgb24toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
486 else if(gCpuCaps.has3DNow) | |
487 rgb24toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
488 else if(gCpuCaps.hasMMX) | |
489 rgb24toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
490 else | |
491 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
492 #else | |
493 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
494 #endif | |
495 } | |
5337 | 496 |
497 void interleaveBytes(uint8_t *src1, uint8_t *src2, uint8_t *dst, | |
498 int width, int height, int src1Stride, int src2Stride, int dstStride) | |
499 { | |
500 #ifdef CAN_COMPILE_X86_ASM | |
501 // ordered per speed fasterst first | |
502 if(gCpuCaps.hasMMX2) | |
503 interleaveBytes_MMX2(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
504 else if(gCpuCaps.has3DNow) | |
505 interleaveBytes_3DNow(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
506 else if(gCpuCaps.hasMMX) | |
507 interleaveBytes_MMX(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
508 else | |
509 interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
510 #else | |
511 interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
512 #endif | |
513 } |