Mercurial > mplayer.hg
annotate postproc/rgb2rgb.c @ 5999:792d58595767
fix -fs and 'f'
author | pontscho |
---|---|
date | Mon, 06 May 2002 16:56:41 +0000 |
parents | f0fa3373f616 |
children | c5cf988c6d6f |
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 | |
2718 | 217 void rgb32to16(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2694 | 218 { |
3132 | 219 #ifdef CAN_COMPILE_X86_ASM |
220 // ordered per speed fasterst first | |
221 if(gCpuCaps.hasMMX2) | |
222 rgb32to16_MMX2(src, dst, src_size); | |
223 else if(gCpuCaps.has3DNow) | |
224 rgb32to16_3DNow(src, dst, src_size); | |
225 else if(gCpuCaps.hasMMX) | |
226 rgb32to16_MMX(src, dst, src_size); | |
227 else | |
228 rgb32to16_C(src, dst, src_size); | |
2741 | 229 #else |
3132 | 230 rgb32to16_C(src, dst, src_size); |
2741 | 231 #endif |
2694 | 232 } |
233 | |
2718 | 234 void rgb32to15(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 rgb32to15_MMX2(src, dst, src_size); | |
240 else if(gCpuCaps.has3DNow) | |
241 rgb32to15_3DNow(src, dst, src_size); | |
242 else if(gCpuCaps.hasMMX) | |
243 rgb32to15_MMX(src, dst, src_size); | |
244 else | |
245 rgb32to15_C(src, dst, src_size); | |
2741 | 246 #else |
3132 | 247 rgb32to15_C(src, dst, src_size); |
2741 | 248 #endif |
2694 | 249 } |
250 | |
2718 | 251 void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size) |
252 { | |
3132 | 253 #ifdef CAN_COMPILE_X86_ASM |
254 // ordered per speed fasterst first | |
255 if(gCpuCaps.hasMMX2) | |
256 rgb24to16_MMX2(src, dst, src_size); | |
257 else if(gCpuCaps.has3DNow) | |
258 rgb24to16_3DNow(src, dst, src_size); | |
259 else if(gCpuCaps.hasMMX) | |
260 rgb24to16_MMX(src, dst, src_size); | |
261 else | |
262 rgb24to16_C(src, dst, src_size); | |
2740 | 263 #else |
3132 | 264 rgb24to16_C(src, dst, src_size); |
2740 | 265 #endif |
2718 | 266 } |
267 | |
268 void rgb24to15(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 rgb24to15_MMX2(src, dst, src_size); | |
274 else if(gCpuCaps.has3DNow) | |
275 rgb24to15_3DNow(src, dst, src_size); | |
276 else if(gCpuCaps.hasMMX) | |
277 rgb24to15_MMX(src, dst, src_size); | |
278 else | |
279 rgb24to15_C(src, dst, src_size); | |
2741 | 280 #else |
3132 | 281 rgb24to15_C(src, dst, src_size); |
2741 | 282 #endif |
2718 | 283 } |
2694 | 284 |
285 /** | |
286 * Palette is assumed to contain bgr16, see rgb32to16 to convert the palette | |
287 */ | |
2718 | 288 void palette8torgb16(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 289 { |
2718 | 290 unsigned i; |
2702 | 291 for(i=0; i<num_pixels; i++) |
2694 | 292 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
293 } | |
294 | |
295 /** | |
296 * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette | |
297 */ | |
2718 | 298 void palette8torgb15(const uint8_t *src, uint8_t *dst, unsigned num_pixels, const uint8_t *palette) |
2694 | 299 { |
2718 | 300 unsigned i; |
2702 | 301 for(i=0; i<num_pixels; i++) |
2694 | 302 ((uint16_t *)dst)[i] = ((uint16_t *)palette)[ src[i] ]; |
2697 | 303 } |
2755 | 304 |
305 void rgb32tobgr32(const uint8_t *src, uint8_t *dst, unsigned int src_size) | |
306 { | |
3132 | 307 #ifdef CAN_COMPILE_X86_ASM |
308 // ordered per speed fasterst first | |
309 if(gCpuCaps.hasMMX2) | |
310 rgb32tobgr32_MMX2(src, dst, src_size); | |
311 else if(gCpuCaps.has3DNow) | |
312 rgb32tobgr32_3DNow(src, dst, src_size); | |
313 else if(gCpuCaps.hasMMX) | |
314 rgb32tobgr32_MMX(src, dst, src_size); | |
315 else | |
316 rgb32tobgr32_C(src, dst, src_size); | |
2755 | 317 #else |
3132 | 318 rgb32tobgr32_C(src, dst, src_size); |
2755 | 319 #endif |
320 } | |
321 | |
5582 | 322 void rgb24tobgr24(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
323 { | |
324 #ifdef CAN_COMPILE_X86_ASM | |
325 // ordered per speed fasterst first | |
326 if(gCpuCaps.hasMMX2) | |
327 rgb24tobgr24_MMX2(src, dst, src_size); | |
328 else if(gCpuCaps.has3DNow) | |
329 rgb24tobgr24_3DNow(src, dst, src_size); | |
330 else if(gCpuCaps.hasMMX) | |
331 rgb24tobgr24_MMX(src, dst, src_size); | |
332 else | |
333 rgb24tobgr24_C(src, dst, src_size); | |
334 #else | |
335 rgb24tobgr24_C(src, dst, src_size); | |
336 #endif | |
337 } | |
338 | |
2702 | 339 /** |
340 * | |
2724 | 341 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a |
342 * problem for anyone then tell me, and ill fix it) | |
2702 | 343 */ |
2723 | 344 void yv12toyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
2725 | 345 unsigned int width, unsigned int height, |
346 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
2701 | 347 { |
3132 | 348 #ifdef CAN_COMPILE_X86_ASM |
349 // ordered per speed fasterst first | |
350 if(gCpuCaps.hasMMX2) | |
351 yv12toyuy2_MMX2(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
352 else if(gCpuCaps.has3DNow) | |
353 yv12toyuy2_3DNow(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
354 else if(gCpuCaps.hasMMX) | |
355 yv12toyuy2_MMX(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
356 else | |
357 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
2702 | 358 #else |
3132 | 359 yv12toyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); |
2702 | 360 #endif |
2701 | 361 } |
362 | |
2724 | 363 /** |
364 * | |
5588 | 365 * width should be a multiple of 16 |
366 */ | |
367 void yuv422ptoyuy2(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |
368 unsigned int width, unsigned int height, | |
369 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
370 { | |
371 #ifdef CAN_COMPILE_X86_ASM | |
372 // ordered per speed fasterst first | |
373 if(gCpuCaps.hasMMX2) | |
374 yuv422ptoyuy2_MMX2(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
375 else if(gCpuCaps.has3DNow) | |
376 yuv422ptoyuy2_3DNow(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
377 else if(gCpuCaps.hasMMX) | |
378 yuv422ptoyuy2_MMX(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
379 else | |
380 yuv422ptoyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
381 #else | |
382 yuv422ptoyuy2_C(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride); | |
383 #endif | |
384 } | |
385 | |
386 /** | |
387 * | |
2724 | 388 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a |
389 * problem for anyone then tell me, and ill fix it) | |
390 */ | |
391 void yuy2toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
2725 | 392 unsigned int width, unsigned int height, |
393 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
2701 | 394 { |
3132 | 395 #ifdef CAN_COMPILE_X86_ASM |
396 // ordered per speed fasterst first | |
397 if(gCpuCaps.hasMMX2) | |
398 yuy2toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
399 else if(gCpuCaps.has3DNow) | |
400 yuy2toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
401 else if(gCpuCaps.hasMMX) | |
402 yuy2toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
403 else | |
404 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
2704 | 405 #else |
3132 | 406 yuy2toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); |
2704 | 407 #endif |
2723 | 408 } |
2801 | 409 |
410 /** | |
411 * | |
412 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | |
413 * problem for anyone then tell me, and ill fix it) | |
3132 | 414 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version |
2801 | 415 */ |
416 void uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
417 unsigned int width, unsigned int height, | |
418 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
419 { | |
3132 | 420 #ifdef CAN_COMPILE_X86_ASM |
421 // ordered per speed fasterst first | |
422 if(gCpuCaps.hasMMX2) | |
423 uyvytoyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
424 else if(gCpuCaps.has3DNow) | |
425 uyvytoyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
426 else if(gCpuCaps.hasMMX) | |
427 uyvytoyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
428 else | |
429 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
2847 | 430 #else |
3132 | 431 uyvytoyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); |
2847 | 432 #endif |
2801 | 433 } |
434 | |
3132 | 435 /** |
436 * | |
437 * height should be a multiple of 2 and width should be a multiple of 2 (if this is a | |
438 * problem for anyone then tell me, and ill fix it) | |
439 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version | |
440 */ | |
441 void rgb24toyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
442 unsigned int width, unsigned int height, | |
443 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
444 { | |
445 #ifdef CAN_COMPILE_X86_ASM | |
446 // ordered per speed fasterst first | |
447 if(gCpuCaps.hasMMX2) | |
448 rgb24toyv12_MMX2(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
449 else if(gCpuCaps.has3DNow) | |
450 rgb24toyv12_3DNow(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
451 else if(gCpuCaps.hasMMX) | |
452 rgb24toyv12_MMX(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
453 else | |
454 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
455 #else | |
456 rgb24toyv12_C(src, ydst, udst, vdst, width, height, lumStride, chromStride, srcStride); | |
457 #endif | |
458 } | |
5337 | 459 |
460 void interleaveBytes(uint8_t *src1, uint8_t *src2, uint8_t *dst, | |
461 int width, int height, int src1Stride, int src2Stride, int dstStride) | |
462 { | |
463 #ifdef CAN_COMPILE_X86_ASM | |
464 // ordered per speed fasterst first | |
465 if(gCpuCaps.hasMMX2) | |
466 interleaveBytes_MMX2(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
467 else if(gCpuCaps.has3DNow) | |
468 interleaveBytes_3DNow(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
469 else if(gCpuCaps.hasMMX) | |
470 interleaveBytes_MMX(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
471 else | |
472 interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
473 #else | |
474 interleaveBytes_C(src1, src2, dst, width, height, src1Stride, src2Stride, dstStride); | |
475 #endif | |
476 } |