Mercurial > mplayer.hg
annotate postproc/rgb2rgb_template.c @ 6606:50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
author | michael |
---|---|
date | Sat, 29 Jun 2002 21:26:15 +0000 |
parents | 5ddfba86d5a4 |
children | da27a1bc1763 |
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 */ |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
10 |
6492 | 11 #include <stddef.h> |
12 #include <inttypes.h> /* for __WORDSIZE */ | |
13 | |
14 #ifndef __WORDSIZE | |
15 #warning You have misconfigured system and probably will lose performance! | |
16 #endif | |
17 | |
3132 | 18 #undef PREFETCH |
19 #undef MOVNTQ | |
20 #undef EMMS | |
21 #undef SFENCE | |
22 #undef MMREG_SIZE | |
23 #undef PREFETCHW | |
24 #undef PAVGB | |
2755 | 25 |
3132 | 26 #ifdef HAVE_SSE2 |
27 #define MMREG_SIZE 16 | |
28 #else | |
29 #define MMREG_SIZE 8 | |
2535 | 30 #endif |
2513 | 31 |
3132 | 32 #ifdef HAVE_3DNOW |
33 #define PREFETCH "prefetch" | |
34 #define PREFETCHW "prefetchw" | |
35 #define PAVGB "pavgusb" | |
36 #elif defined ( HAVE_MMX2 ) | |
37 #define PREFETCH "prefetchnta" | |
38 #define PREFETCHW "prefetcht0" | |
39 #define PAVGB "pavgb" | |
40 #else | |
41 #define PREFETCH "/nop" | |
42 #define PREFETCHW "/nop" | |
43 #endif | |
44 | |
45 #ifdef HAVE_3DNOW | |
46 /* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */ | |
47 #define EMMS "femms" | |
48 #else | |
49 #define EMMS "emms" | |
50 #endif | |
51 | |
52 #ifdef HAVE_MMX2 | |
53 #define MOVNTQ "movntq" | |
54 #define SFENCE "sfence" | |
55 #else | |
56 #define MOVNTQ "movq" | |
57 #define SFENCE "/nop" | |
58 #endif | |
59 | |
60 static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,unsigned src_size) | |
2504 | 61 { |
2508 | 62 uint8_t *dest = dst; |
2677 | 63 const uint8_t *s = src; |
64 const uint8_t *end; | |
2510 | 65 #ifdef HAVE_MMX |
6605 | 66 const uint8_t *mm_end; |
2510 | 67 #endif |
2504 | 68 end = s + src_size; |
2510 | 69 #ifdef HAVE_MMX |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
70 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); |
6605 | 71 mm_end = end - 23; |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
72 __asm __volatile("movq %0, %%mm7"::"m"(mask32):"memory"); |
2510 | 73 while(s < mm_end) |
74 { | |
2511 | 75 __asm __volatile( |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
76 PREFETCH" 32%1\n\t" |
2510 | 77 "movd %1, %%mm0\n\t" |
2738 | 78 "punpckldq 3%1, %%mm0\n\t" |
79 "movd 6%1, %%mm1\n\t" | |
80 "punpckldq 9%1, %%mm1\n\t" | |
81 "movd 12%1, %%mm2\n\t" | |
82 "punpckldq 15%1, %%mm2\n\t" | |
83 "movd 18%1, %%mm3\n\t" | |
84 "punpckldq 21%1, %%mm3\n\t" | |
2510 | 85 "pand %%mm7, %%mm0\n\t" |
2738 | 86 "pand %%mm7, %%mm1\n\t" |
2510 | 87 "pand %%mm7, %%mm2\n\t" |
2738 | 88 "pand %%mm7, %%mm3\n\t" |
2511 | 89 MOVNTQ" %%mm0, %0\n\t" |
2738 | 90 MOVNTQ" %%mm1, 8%0\n\t" |
91 MOVNTQ" %%mm2, 16%0\n\t" | |
92 MOVNTQ" %%mm3, 24%0" | |
2510 | 93 :"=m"(*dest) |
94 :"m"(*s) | |
95 :"memory"); | |
2738 | 96 dest += 32; |
97 s += 24; | |
2510 | 98 } |
2513 | 99 __asm __volatile(SFENCE:::"memory"); |
2511 | 100 __asm __volatile(EMMS:::"memory"); |
2510 | 101 #endif |
2504 | 102 while(s < end) |
103 { | |
2508 | 104 *dest++ = *s++; |
105 *dest++ = *s++; | |
106 *dest++ = *s++; | |
107 *dest++ = 0; | |
2504 | 108 } |
109 } | |
2505 | 110 |
3132 | 111 static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,unsigned src_size) |
2505 | 112 { |
113 uint8_t *dest = dst; | |
2677 | 114 const uint8_t *s = src; |
115 const uint8_t *end; | |
2517 | 116 #ifdef HAVE_MMX |
6605 | 117 const uint8_t *mm_end; |
2517 | 118 #endif |
2505 | 119 end = s + src_size; |
2517 | 120 #ifdef HAVE_MMX |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
121 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); |
6605 | 122 mm_end = end - 31; |
2517 | 123 while(s < mm_end) |
124 { | |
125 __asm __volatile( | |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
126 PREFETCH" 32%1\n\t" |
2517 | 127 "movq %1, %%mm0\n\t" |
128 "movq 8%1, %%mm1\n\t" | |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
129 "movq 16%1, %%mm4\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
130 "movq 24%1, %%mm5\n\t" |
2517 | 131 "movq %%mm0, %%mm2\n\t" |
132 "movq %%mm1, %%mm3\n\t" | |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
133 "movq %%mm4, %%mm6\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
134 "movq %%mm5, %%mm7\n\t" |
2517 | 135 "psrlq $8, %%mm2\n\t" |
136 "psrlq $8, %%mm3\n\t" | |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
137 "psrlq $8, %%mm6\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
138 "psrlq $8, %%mm7\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
139 "pand %2, %%mm0\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
140 "pand %2, %%mm1\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
141 "pand %2, %%mm4\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
142 "pand %2, %%mm5\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
143 "pand %3, %%mm2\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
144 "pand %3, %%mm3\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
145 "pand %3, %%mm6\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
146 "pand %3, %%mm7\n\t" |
2517 | 147 "por %%mm2, %%mm0\n\t" |
148 "por %%mm3, %%mm1\n\t" | |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
149 "por %%mm6, %%mm4\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
150 "por %%mm7, %%mm5\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
151 |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
152 "movq %%mm1, %%mm2\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
153 "movq %%mm4, %%mm3\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
154 "psllq $48, %%mm2\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
155 "psllq $32, %%mm3\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
156 "pand %4, %%mm2\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
157 "pand %5, %%mm3\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
158 "por %%mm2, %%mm0\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
159 "psrlq $16, %%mm1\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
160 "psrlq $32, %%mm4\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
161 "psllq $16, %%mm5\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
162 "por %%mm3, %%mm1\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
163 "pand %6, %%mm5\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
164 "por %%mm5, %%mm4\n\t" |
3132 | 165 |
2517 | 166 MOVNTQ" %%mm0, %0\n\t" |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
167 MOVNTQ" %%mm1, 8%0\n\t" |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
168 MOVNTQ" %%mm4, 16%0" |
2517 | 169 :"=m"(*dest) |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
170 :"m"(*s),"m"(mask24l), |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
171 "m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) |
2517 | 172 :"memory"); |
2746
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
173 dest += 24; |
dece635a28e3
Minor speedup of rgb32to24. (performance is not successful)
nick
parents:
2741
diff
changeset
|
174 s += 32; |
2517 | 175 } |
176 __asm __volatile(SFENCE:::"memory"); | |
177 __asm __volatile(EMMS:::"memory"); | |
178 #endif | |
2505 | 179 while(s < end) |
180 { | |
181 *dest++ = *s++; | |
182 *dest++ = *s++; | |
183 *dest++ = *s++; | |
184 s++; | |
185 } | |
186 } | |
2506 | 187 |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
188 /* |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
189 Original by Strepto/Astral |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
190 ported to gcc & bugfixed : A'rpi |
2564 | 191 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
|
192 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
|
193 */ |
3132 | 194 static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,unsigned src_size) |
2506 | 195 { |
6492 | 196 register const uint8_t* s=src; |
197 register uint8_t* d=dst; | |
198 register const uint8_t *end; | |
6605 | 199 const uint8_t *mm_end; |
6492 | 200 end = s + src_size; |
2506 | 201 #ifdef HAVE_MMX |
6492 | 202 __asm __volatile(PREFETCH" %0"::"m"(*s)); |
203 __asm __volatile("movq %0, %%mm4"::"m"(mask15s)); | |
6605 | 204 mm_end = end - 15; |
6492 | 205 while(s<mm_end) |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
206 { |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
207 __asm __volatile( |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
208 PREFETCH" 32%1\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
209 "movq %1, %%mm0\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
210 "movq 8%1, %%mm2\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
211 "movq %%mm0, %%mm1\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
212 "movq %%mm2, %%mm3\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
213 "pand %%mm4, %%mm0\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
214 "pand %%mm4, %%mm2\n\t" |
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
|
215 "paddw %%mm1, %%mm0\n\t" |
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
|
216 "paddw %%mm3, %%mm2\n\t" |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
217 MOVNTQ" %%mm0, %0\n\t" |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
218 MOVNTQ" %%mm2, 8%0" |
6492 | 219 :"=m"(*d) |
220 :"m"(*s) | |
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
|
221 ); |
6492 | 222 d+=16; |
223 s+=16; | |
2506 | 224 } |
2538
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
225 __asm __volatile(SFENCE:::"memory"); |
71320898b333
Finish mmx2, 3dnow optimiz. 15to16 should be tested. Better fix of can't compile
nick
parents:
2535
diff
changeset
|
226 __asm __volatile(EMMS:::"memory"); |
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
|
227 #endif |
6605 | 228 mm_end = end - 3; |
6492 | 229 while(s < mm_end) |
230 { | |
231 register unsigned x= *((uint32_t *)s); | |
232 *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0); | |
233 d+=4; | |
234 s+=4; | |
235 } | |
236 if(s < end) | |
237 { | |
238 register unsigned short x= *((uint16_t *)s); | |
239 *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0); | |
240 } | |
2506 | 241 } |
2694 | 242 |
6484
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
243 static inline void RENAME(bgr24torgb24)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
244 { |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
245 unsigned j,i,num_pixels=src_size/3; |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
246 for(i=0,j=0; j<num_pixels; i+=3,j+=3) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
247 { |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
248 dst[j+0] = src[i+2]; |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
249 dst[j+1] = src[i+1]; |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
250 dst[j+2] = src[i+0]; |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
251 } |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
252 } |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
253 |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
254 static inline void RENAME(rgb16to15)(const uint8_t *src,uint8_t *dst,unsigned src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
255 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
256 register const uint8_t* s=src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
257 register uint8_t* d=dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
258 register const uint8_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
259 uint8_t *mm_end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
260 end = s + src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
261 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
262 __asm __volatile(PREFETCH" %0"::"m"(*s)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
263 __asm __volatile("movq %0, %%mm7"::"m"(mask15rg)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
264 __asm __volatile("movq %0, %%mm6"::"m"(mask15b)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
265 mm_end = (uint8_t*)((((unsigned long)end)/16)*16); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
266 while(s<mm_end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
267 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
268 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
269 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
270 "movq %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
271 "movq 8%1, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
272 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
273 "movq %%mm2, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
274 "psrlq $1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
275 "psrlq $1, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
276 "pand %%mm7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
277 "pand %%mm7, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
278 "pand %%mm6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
279 "pand %%mm6, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
280 "por %%mm1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
281 "por %%mm3, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
282 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
283 MOVNTQ" %%mm2, 8%0" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
284 :"=m"(*d) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
285 :"m"(*s) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
286 ); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
287 d+=16; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
288 s+=16; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
289 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
290 __asm __volatile(SFENCE:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
291 __asm __volatile(EMMS:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
292 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
293 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
294 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
295 register uint32_t x= *((uint32_t *)s); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
296 *((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
297 s+=4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
298 d+=4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
299 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
300 if(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
301 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
302 register uint16_t x= *((uint16_t *)s); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
303 *((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
304 s+=2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
305 d+=2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
306 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
307 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
308 |
3132 | 309 static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2694 | 310 { |
6492 | 311 const uint8_t *s = src; |
312 const uint8_t *end; | |
2741 | 313 #ifdef HAVE_MMX |
6492 | 314 const uint8_t *mm_end; |
315 #endif | |
2741 | 316 uint16_t *d = (uint16_t *)dst; |
317 end = s + src_size; | |
6492 | 318 #ifdef HAVE_MMX |
2741 | 319 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
320 __asm __volatile( | |
321 "movq %0, %%mm7\n\t" | |
322 "movq %1, %%mm6\n\t" | |
323 ::"m"(red_16mask),"m"(green_16mask)); | |
6605 | 324 mm_end = end - 15; |
2741 | 325 while(s < mm_end) |
326 { | |
327 __asm __volatile( | |
328 PREFETCH" 32%1\n\t" | |
329 "movd %1, %%mm0\n\t" | |
330 "movd 4%1, %%mm3\n\t" | |
331 "punpckldq 8%1, %%mm0\n\t" | |
332 "punpckldq 12%1, %%mm3\n\t" | |
333 "movq %%mm0, %%mm1\n\t" | |
334 "movq %%mm0, %%mm2\n\t" | |
335 "movq %%mm3, %%mm4\n\t" | |
336 "movq %%mm3, %%mm5\n\t" | |
337 "psrlq $3, %%mm0\n\t" | |
338 "psrlq $3, %%mm3\n\t" | |
339 "pand %2, %%mm0\n\t" | |
340 "pand %2, %%mm3\n\t" | |
341 "psrlq $5, %%mm1\n\t" | |
342 "psrlq $5, %%mm4\n\t" | |
343 "pand %%mm6, %%mm1\n\t" | |
344 "pand %%mm6, %%mm4\n\t" | |
345 "psrlq $8, %%mm2\n\t" | |
346 "psrlq $8, %%mm5\n\t" | |
347 "pand %%mm7, %%mm2\n\t" | |
348 "pand %%mm7, %%mm5\n\t" | |
349 "por %%mm1, %%mm0\n\t" | |
350 "por %%mm4, %%mm3\n\t" | |
351 "por %%mm2, %%mm0\n\t" | |
352 "por %%mm5, %%mm3\n\t" | |
353 "psllq $16, %%mm3\n\t" | |
354 "por %%mm3, %%mm0\n\t" | |
355 MOVNTQ" %%mm0, %0\n\t" | |
356 :"=m"(*d):"m"(*s),"m"(blue_16mask):"memory"); | |
357 d += 4; | |
358 s += 16; | |
359 } | |
6492 | 360 __asm __volatile(SFENCE:::"memory"); |
361 __asm __volatile(EMMS:::"memory"); | |
362 #endif | |
2741 | 363 while(s < end) |
364 { | |
365 const int b= *s++; | |
366 const int g= *s++; | |
367 const int r= *s++; | |
368 *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); | |
6492 | 369 s++; |
2741 | 370 } |
2694 | 371 } |
372 | |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
373 static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
374 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
375 const uint8_t *s = src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
376 const uint8_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
377 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
378 const uint8_t *mm_end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
379 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
380 uint16_t *d = (uint16_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
381 end = s + src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
382 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
383 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
384 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
385 "movq %0, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
386 "movq %1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
387 ::"m"(red_16mask),"m"(green_16mask)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
388 mm_end = (uint8_t*)((((unsigned long)end)/16)*16); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
389 while(s < mm_end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
390 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
391 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
392 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
393 "movd %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
394 "movd 4%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
395 "punpckldq 8%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
396 "punpckldq 12%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
397 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
398 "movq %%mm0, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
399 "movq %%mm3, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
400 "movq %%mm3, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
401 "psllq $8, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
402 "psllq $8, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
403 "pand %%mm7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
404 "pand %%mm7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
405 "psrlq $5, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
406 "psrlq $5, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
407 "pand %%mm6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
408 "pand %%mm6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
409 "psrlq $19, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
410 "psrlq $19, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
411 "pand %2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
412 "pand %2, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
413 "por %%mm1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
414 "por %%mm4, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
415 "por %%mm2, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
416 "por %%mm5, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
417 "psllq $16, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
418 "por %%mm3, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
419 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
420 :"=m"(*d):"m"(*s),"m"(blue_16mask):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
421 d += 4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
422 s += 16; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
423 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
424 __asm __volatile(SFENCE:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
425 __asm __volatile(EMMS:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
426 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
427 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
428 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
429 const int r= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
430 const int g= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
431 const int b= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
432 *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
433 s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
434 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
435 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
436 |
3132 | 437 static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2694 | 438 { |
6492 | 439 const uint8_t *s = src; |
440 const uint8_t *end; | |
2741 | 441 #ifdef HAVE_MMX |
6492 | 442 const uint8_t *mm_end; |
443 #endif | |
2741 | 444 uint16_t *d = (uint16_t *)dst; |
445 end = s + src_size; | |
6492 | 446 #ifdef HAVE_MMX |
2741 | 447 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
448 __asm __volatile( | |
449 "movq %0, %%mm7\n\t" | |
450 "movq %1, %%mm6\n\t" | |
451 ::"m"(red_15mask),"m"(green_15mask)); | |
6605 | 452 mm_end = end - 15; |
2741 | 453 while(s < mm_end) |
454 { | |
455 __asm __volatile( | |
456 PREFETCH" 32%1\n\t" | |
457 "movd %1, %%mm0\n\t" | |
458 "movd 4%1, %%mm3\n\t" | |
459 "punpckldq 8%1, %%mm0\n\t" | |
460 "punpckldq 12%1, %%mm3\n\t" | |
461 "movq %%mm0, %%mm1\n\t" | |
462 "movq %%mm0, %%mm2\n\t" | |
463 "movq %%mm3, %%mm4\n\t" | |
464 "movq %%mm3, %%mm5\n\t" | |
465 "psrlq $3, %%mm0\n\t" | |
466 "psrlq $3, %%mm3\n\t" | |
467 "pand %2, %%mm0\n\t" | |
468 "pand %2, %%mm3\n\t" | |
469 "psrlq $6, %%mm1\n\t" | |
470 "psrlq $6, %%mm4\n\t" | |
471 "pand %%mm6, %%mm1\n\t" | |
472 "pand %%mm6, %%mm4\n\t" | |
473 "psrlq $9, %%mm2\n\t" | |
474 "psrlq $9, %%mm5\n\t" | |
475 "pand %%mm7, %%mm2\n\t" | |
476 "pand %%mm7, %%mm5\n\t" | |
477 "por %%mm1, %%mm0\n\t" | |
478 "por %%mm4, %%mm3\n\t" | |
479 "por %%mm2, %%mm0\n\t" | |
480 "por %%mm5, %%mm3\n\t" | |
481 "psllq $16, %%mm3\n\t" | |
482 "por %%mm3, %%mm0\n\t" | |
483 MOVNTQ" %%mm0, %0\n\t" | |
484 :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); | |
485 d += 4; | |
486 s += 16; | |
487 } | |
6492 | 488 __asm __volatile(SFENCE:::"memory"); |
489 __asm __volatile(EMMS:::"memory"); | |
490 #endif | |
2741 | 491 while(s < end) |
492 { | |
493 const int b= *s++; | |
494 const int g= *s++; | |
495 const int r= *s++; | |
6492 | 496 *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); |
6096 | 497 s++; |
2741 | 498 } |
2694 | 499 } |
500 | |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
501 static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
502 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
503 const uint8_t *s = src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
504 const uint8_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
505 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
506 const uint8_t *mm_end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
507 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
508 uint16_t *d = (uint16_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
509 end = s + src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
510 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
511 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
512 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
513 "movq %0, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
514 "movq %1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
515 ::"m"(red_15mask),"m"(green_15mask)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
516 mm_end = (uint8_t*)((((unsigned long)end)/16)*16); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
517 while(s < mm_end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
518 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
519 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
520 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
521 "movd %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
522 "movd 4%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
523 "punpckldq 8%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
524 "punpckldq 12%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
525 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
526 "movq %%mm0, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
527 "movq %%mm3, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
528 "movq %%mm3, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
529 "psllq $7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
530 "psllq $7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
531 "pand %%mm7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
532 "pand %%mm7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
533 "psrlq $6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
534 "psrlq $6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
535 "pand %%mm6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
536 "pand %%mm6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
537 "psrlq $19, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
538 "psrlq $19, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
539 "pand %2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
540 "pand %2, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
541 "por %%mm1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
542 "por %%mm4, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
543 "por %%mm2, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
544 "por %%mm5, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
545 "psllq $16, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
546 "por %%mm3, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
547 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
548 :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
549 d += 4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
550 s += 16; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
551 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
552 __asm __volatile(SFENCE:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
553 __asm __volatile(EMMS:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
554 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
555 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
556 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
557 const int r= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
558 const int g= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
559 const int b= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
560 *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
561 s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
562 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
563 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
564 |
3132 | 565 static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2718 | 566 { |
6492 | 567 const uint8_t *s = src; |
568 const uint8_t *end; | |
2740 | 569 #ifdef HAVE_MMX |
6492 | 570 const uint8_t *mm_end; |
571 #endif | |
2719
fafa73d6d80c
Fixed rgb32(24)to16 stuff, rgb32(24)to15 is still broken
nick
parents:
2718
diff
changeset
|
572 uint16_t *d = (uint16_t *)dst; |
2740 | 573 end = s + src_size; |
6492 | 574 #ifdef HAVE_MMX |
2738 | 575 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
576 __asm __volatile( | |
577 "movq %0, %%mm7\n\t" | |
578 "movq %1, %%mm6\n\t" | |
2741 | 579 ::"m"(red_16mask),"m"(green_16mask)); |
6605 | 580 mm_end = end - 11; |
2740 | 581 while(s < mm_end) |
2738 | 582 { |
583 __asm __volatile( | |
584 PREFETCH" 32%1\n\t" | |
585 "movd %1, %%mm0\n\t" | |
2740 | 586 "movd 3%1, %%mm3\n\t" |
587 "punpckldq 6%1, %%mm0\n\t" | |
2738 | 588 "punpckldq 9%1, %%mm3\n\t" |
589 "movq %%mm0, %%mm1\n\t" | |
590 "movq %%mm0, %%mm2\n\t" | |
591 "movq %%mm3, %%mm4\n\t" | |
592 "movq %%mm3, %%mm5\n\t" | |
593 "psrlq $3, %%mm0\n\t" | |
594 "psrlq $3, %%mm3\n\t" | |
2740 | 595 "pand %2, %%mm0\n\t" |
596 "pand %2, %%mm3\n\t" | |
597 "psrlq $5, %%mm1\n\t" | |
598 "psrlq $5, %%mm4\n\t" | |
599 "pand %%mm6, %%mm1\n\t" | |
600 "pand %%mm6, %%mm4\n\t" | |
601 "psrlq $8, %%mm2\n\t" | |
602 "psrlq $8, %%mm5\n\t" | |
603 "pand %%mm7, %%mm2\n\t" | |
604 "pand %%mm7, %%mm5\n\t" | |
2738 | 605 "por %%mm1, %%mm0\n\t" |
2740 | 606 "por %%mm4, %%mm3\n\t" |
2738 | 607 "por %%mm2, %%mm0\n\t" |
608 "por %%mm5, %%mm3\n\t" | |
2740 | 609 "psllq $16, %%mm3\n\t" |
610 "por %%mm3, %%mm0\n\t" | |
2738 | 611 MOVNTQ" %%mm0, %0\n\t" |
2741 | 612 :"=m"(*d):"m"(*s),"m"(blue_16mask):"memory"); |
2740 | 613 d += 4; |
614 s += 12; | |
2738 | 615 } |
6492 | 616 __asm __volatile(SFENCE:::"memory"); |
617 __asm __volatile(EMMS:::"memory"); | |
618 #endif | |
2740 | 619 while(s < end) |
620 { | |
621 const int b= *s++; | |
622 const int g= *s++; | |
623 const int r= *s++; | |
624 *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); | |
625 } | |
2718 | 626 } |
627 | |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
628 static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
629 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
630 const uint8_t *s = src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
631 const uint8_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
632 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
633 const uint8_t *mm_end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
634 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
635 uint16_t *d = (uint16_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
636 end = s + src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
637 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
638 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
639 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
640 "movq %0, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
641 "movq %1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
642 ::"m"(red_16mask),"m"(green_16mask)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
643 mm_end = (uint8_t*)((((unsigned long)end)/16)*16); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
644 while(s < mm_end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
645 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
646 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
647 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
648 "movd %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
649 "movd 3%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
650 "punpckldq 6%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
651 "punpckldq 9%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
652 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
653 "movq %%mm0, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
654 "movq %%mm3, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
655 "movq %%mm3, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
656 "psllq $8, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
657 "psllq $8, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
658 "pand %%mm7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
659 "pand %%mm7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
660 "psrlq $5, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
661 "psrlq $5, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
662 "pand %%mm6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
663 "pand %%mm6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
664 "psrlq $19, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
665 "psrlq $19, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
666 "pand %2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
667 "pand %2, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
668 "por %%mm1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
669 "por %%mm4, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
670 "por %%mm2, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
671 "por %%mm5, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
672 "psllq $16, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
673 "por %%mm3, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
674 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
675 :"=m"(*d):"m"(*s),"m"(blue_16mask):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
676 d += 4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
677 s += 12; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
678 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
679 __asm __volatile(SFENCE:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
680 __asm __volatile(EMMS:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
681 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
682 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
683 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
684 const int r= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
685 const int g= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
686 const int b= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
687 *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
688 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
689 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
690 |
3132 | 691 static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
2718 | 692 { |
6492 | 693 const uint8_t *s = src; |
694 const uint8_t *end; | |
2741 | 695 #ifdef HAVE_MMX |
6492 | 696 const uint8_t *mm_end; |
697 #endif | |
2741 | 698 uint16_t *d = (uint16_t *)dst; |
699 end = s + src_size; | |
6492 | 700 #ifdef HAVE_MMX |
2741 | 701 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
702 __asm __volatile( | |
703 "movq %0, %%mm7\n\t" | |
704 "movq %1, %%mm6\n\t" | |
705 ::"m"(red_15mask),"m"(green_15mask)); | |
6605 | 706 mm_end = end - 11; |
2741 | 707 while(s < mm_end) |
708 { | |
709 __asm __volatile( | |
710 PREFETCH" 32%1\n\t" | |
711 "movd %1, %%mm0\n\t" | |
712 "movd 3%1, %%mm3\n\t" | |
713 "punpckldq 6%1, %%mm0\n\t" | |
714 "punpckldq 9%1, %%mm3\n\t" | |
715 "movq %%mm0, %%mm1\n\t" | |
716 "movq %%mm0, %%mm2\n\t" | |
717 "movq %%mm3, %%mm4\n\t" | |
718 "movq %%mm3, %%mm5\n\t" | |
719 "psrlq $3, %%mm0\n\t" | |
720 "psrlq $3, %%mm3\n\t" | |
721 "pand %2, %%mm0\n\t" | |
722 "pand %2, %%mm3\n\t" | |
723 "psrlq $6, %%mm1\n\t" | |
724 "psrlq $6, %%mm4\n\t" | |
725 "pand %%mm6, %%mm1\n\t" | |
726 "pand %%mm6, %%mm4\n\t" | |
727 "psrlq $9, %%mm2\n\t" | |
728 "psrlq $9, %%mm5\n\t" | |
729 "pand %%mm7, %%mm2\n\t" | |
730 "pand %%mm7, %%mm5\n\t" | |
731 "por %%mm1, %%mm0\n\t" | |
732 "por %%mm4, %%mm3\n\t" | |
733 "por %%mm2, %%mm0\n\t" | |
734 "por %%mm5, %%mm3\n\t" | |
735 "psllq $16, %%mm3\n\t" | |
736 "por %%mm3, %%mm0\n\t" | |
737 MOVNTQ" %%mm0, %0\n\t" | |
738 :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); | |
739 d += 4; | |
740 s += 12; | |
741 } | |
6492 | 742 __asm __volatile(SFENCE:::"memory"); |
743 __asm __volatile(EMMS:::"memory"); | |
744 #endif | |
2741 | 745 while(s < end) |
746 { | |
747 const int b= *s++; | |
748 const int g= *s++; | |
749 const int r= *s++; | |
750 *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); | |
751 } | |
6492 | 752 } |
753 | |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
754 static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
755 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
756 const uint8_t *s = src; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
757 const uint8_t *end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
758 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
759 const uint8_t *mm_end; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
760 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
761 uint16_t *d = (uint16_t *)dst; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
762 end = s + src_size; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
763 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
764 __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
765 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
766 "movq %0, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
767 "movq %1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
768 ::"m"(red_15mask),"m"(green_15mask)); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
769 mm_end = (uint8_t*)((((unsigned long)end)/16)*16); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
770 while(s < mm_end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
771 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
772 __asm __volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
773 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
774 "movd %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
775 "movd 3%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
776 "punpckldq 6%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
777 "punpckldq 9%1, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
778 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
779 "movq %%mm0, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
780 "movq %%mm3, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
781 "movq %%mm3, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
782 "psllq $7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
783 "psllq $7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
784 "pand %%mm7, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
785 "pand %%mm7, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
786 "psrlq $6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
787 "psrlq $6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
788 "pand %%mm6, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
789 "pand %%mm6, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
790 "psrlq $19, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
791 "psrlq $19, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
792 "pand %2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
793 "pand %2, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
794 "por %%mm1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
795 "por %%mm4, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
796 "por %%mm2, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
797 "por %%mm5, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
798 "psllq $16, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
799 "por %%mm3, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
800 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
801 :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
802 d += 4; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
803 s += 12; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
804 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
805 __asm __volatile(SFENCE:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
806 __asm __volatile(EMMS:::"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
807 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
808 while(s < end) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
809 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
810 const int r= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
811 const int g= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
812 const int b= *s++; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
813 *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
814 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
815 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
816 |
6492 | 817 /* |
818 I use here less accurate approximation by simply | |
819 left-shifting the input | |
820 value and filling the low order bits with | |
821 zeroes. This method improves png's | |
822 compression but this scheme cannot reproduce white exactly, since it does not | |
823 generate an all-ones maximum value; the net effect is to darken the | |
824 image slightly. | |
825 | |
826 The better method should be "left bit replication": | |
827 | |
828 4 3 2 1 0 | |
829 --------- | |
830 1 1 0 1 1 | |
831 | |
832 7 6 5 4 3 2 1 0 | |
833 ---------------- | |
834 1 1 0 1 1 1 1 0 | |
835 |=======| |===| | |
836 | Leftmost Bits Repeated to Fill Open Bits | |
837 | | |
838 Original Bits | |
839 */ | |
840 static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, unsigned src_size) | |
841 { | |
842 const uint16_t *end; | |
843 #ifdef HAVE_MMX | |
844 const uint16_t *mm_end; | |
845 #endif | |
846 uint8_t *d = (uint8_t *)dst; | |
847 const uint16_t *s = (uint16_t *)src; | |
848 end = s + src_size/2; | |
849 #ifdef HAVE_MMX | |
850 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); | |
6605 | 851 mm_end = end - 7; |
6492 | 852 while(s < mm_end) |
853 { | |
854 __asm __volatile( | |
855 PREFETCH" 32%1\n\t" | |
856 "movq %1, %%mm0\n\t" | |
857 "movq %1, %%mm1\n\t" | |
858 "movq %1, %%mm2\n\t" | |
859 "pand %2, %%mm0\n\t" | |
860 "pand %3, %%mm1\n\t" | |
861 "pand %4, %%mm2\n\t" | |
862 "psllq $3, %%mm0\n\t" | |
863 "psrlq $2, %%mm1\n\t" | |
864 "psrlq $7, %%mm2\n\t" | |
865 "movq %%mm0, %%mm3\n\t" | |
866 "movq %%mm1, %%mm4\n\t" | |
867 "movq %%mm2, %%mm5\n\t" | |
868 "punpcklwd %5, %%mm0\n\t" | |
869 "punpcklwd %5, %%mm1\n\t" | |
870 "punpcklwd %5, %%mm2\n\t" | |
871 "punpckhwd %5, %%mm3\n\t" | |
872 "punpckhwd %5, %%mm4\n\t" | |
873 "punpckhwd %5, %%mm5\n\t" | |
874 "psllq $8, %%mm1\n\t" | |
875 "psllq $16, %%mm2\n\t" | |
876 "por %%mm1, %%mm0\n\t" | |
877 "por %%mm2, %%mm0\n\t" | |
878 "psllq $8, %%mm4\n\t" | |
879 "psllq $16, %%mm5\n\t" | |
880 "por %%mm4, %%mm3\n\t" | |
881 "por %%mm5, %%mm3\n\t" | |
882 | |
883 "movq %%mm0, %%mm6\n\t" | |
884 "movq %%mm3, %%mm7\n\t" | |
885 | |
886 "movq 8%1, %%mm0\n\t" | |
887 "movq 8%1, %%mm1\n\t" | |
888 "movq 8%1, %%mm2\n\t" | |
889 "pand %2, %%mm0\n\t" | |
890 "pand %3, %%mm1\n\t" | |
891 "pand %4, %%mm2\n\t" | |
892 "psllq $3, %%mm0\n\t" | |
893 "psrlq $2, %%mm1\n\t" | |
894 "psrlq $7, %%mm2\n\t" | |
895 "movq %%mm0, %%mm3\n\t" | |
896 "movq %%mm1, %%mm4\n\t" | |
897 "movq %%mm2, %%mm5\n\t" | |
898 "punpcklwd %5, %%mm0\n\t" | |
899 "punpcklwd %5, %%mm1\n\t" | |
900 "punpcklwd %5, %%mm2\n\t" | |
901 "punpckhwd %5, %%mm3\n\t" | |
902 "punpckhwd %5, %%mm4\n\t" | |
903 "punpckhwd %5, %%mm5\n\t" | |
904 "psllq $8, %%mm1\n\t" | |
905 "psllq $16, %%mm2\n\t" | |
906 "por %%mm1, %%mm0\n\t" | |
907 "por %%mm2, %%mm0\n\t" | |
908 "psllq $8, %%mm4\n\t" | |
909 "psllq $16, %%mm5\n\t" | |
910 "por %%mm4, %%mm3\n\t" | |
911 "por %%mm5, %%mm3\n\t" | |
912 | |
913 :"=m"(*d) | |
914 :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null) | |
915 :"memory"); | |
916 /* Borrowed 32 to 24 */ | |
917 __asm __volatile( | |
918 "movq %%mm0, %%mm4\n\t" | |
919 "movq %%mm3, %%mm5\n\t" | |
920 "movq %%mm6, %%mm0\n\t" | |
921 "movq %%mm7, %%mm1\n\t" | |
922 | |
923 "movq %%mm4, %%mm6\n\t" | |
924 "movq %%mm5, %%mm7\n\t" | |
925 "movq %%mm0, %%mm2\n\t" | |
926 "movq %%mm1, %%mm3\n\t" | |
927 | |
928 "psrlq $8, %%mm2\n\t" | |
929 "psrlq $8, %%mm3\n\t" | |
930 "psrlq $8, %%mm6\n\t" | |
931 "psrlq $8, %%mm7\n\t" | |
932 "pand %2, %%mm0\n\t" | |
933 "pand %2, %%mm1\n\t" | |
934 "pand %2, %%mm4\n\t" | |
935 "pand %2, %%mm5\n\t" | |
936 "pand %3, %%mm2\n\t" | |
937 "pand %3, %%mm3\n\t" | |
938 "pand %3, %%mm6\n\t" | |
939 "pand %3, %%mm7\n\t" | |
940 "por %%mm2, %%mm0\n\t" | |
941 "por %%mm3, %%mm1\n\t" | |
942 "por %%mm6, %%mm4\n\t" | |
943 "por %%mm7, %%mm5\n\t" | |
944 | |
945 "movq %%mm1, %%mm2\n\t" | |
946 "movq %%mm4, %%mm3\n\t" | |
947 "psllq $48, %%mm2\n\t" | |
948 "psllq $32, %%mm3\n\t" | |
949 "pand %4, %%mm2\n\t" | |
950 "pand %5, %%mm3\n\t" | |
951 "por %%mm2, %%mm0\n\t" | |
952 "psrlq $16, %%mm1\n\t" | |
953 "psrlq $32, %%mm4\n\t" | |
954 "psllq $16, %%mm5\n\t" | |
955 "por %%mm3, %%mm1\n\t" | |
956 "pand %6, %%mm5\n\t" | |
957 "por %%mm5, %%mm4\n\t" | |
958 | |
959 MOVNTQ" %%mm0, %0\n\t" | |
960 MOVNTQ" %%mm1, 8%0\n\t" | |
961 MOVNTQ" %%mm4, 16%0" | |
962 | |
963 :"=m"(*d) | |
964 :"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) | |
965 :"memory"); | |
966 d += 24; | |
967 s += 8; | |
968 } | |
2741 | 969 __asm __volatile(SFENCE:::"memory"); |
970 __asm __volatile(EMMS:::"memory"); | |
6492 | 971 #endif |
972 while(s < end) | |
973 { | |
974 register uint16_t bgr; | |
975 bgr = *s++; | |
976 *d++ = (bgr&0x1F)<<3; | |
977 *d++ = (bgr&0x3E0)>>2; | |
978 *d++ = (bgr&0x7C00)>>7; | |
979 } | |
980 } | |
981 | |
982 static inline void RENAME(rgb16to24)(const uint8_t *src, uint8_t *dst, unsigned src_size) | |
983 { | |
984 const uint16_t *end; | |
985 #ifdef HAVE_MMX | |
986 const uint16_t *mm_end; | |
987 #endif | |
988 uint8_t *d = (uint8_t *)dst; | |
989 const uint16_t *s = (const uint16_t *)src; | |
990 end = s + src_size/2; | |
991 #ifdef HAVE_MMX | |
992 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); | |
6605 | 993 mm_end = end - 7; |
6492 | 994 while(s < mm_end) |
2718 | 995 { |
6492 | 996 __asm __volatile( |
997 PREFETCH" 32%1\n\t" | |
998 "movq %1, %%mm0\n\t" | |
999 "movq %1, %%mm1\n\t" | |
1000 "movq %1, %%mm2\n\t" | |
1001 "pand %2, %%mm0\n\t" | |
1002 "pand %3, %%mm1\n\t" | |
1003 "pand %4, %%mm2\n\t" | |
1004 "psllq $3, %%mm0\n\t" | |
1005 "psrlq $3, %%mm1\n\t" | |
1006 "psrlq $8, %%mm2\n\t" | |
1007 "movq %%mm0, %%mm3\n\t" | |
1008 "movq %%mm1, %%mm4\n\t" | |
1009 "movq %%mm2, %%mm5\n\t" | |
1010 "punpcklwd %5, %%mm0\n\t" | |
1011 "punpcklwd %5, %%mm1\n\t" | |
1012 "punpcklwd %5, %%mm2\n\t" | |
1013 "punpckhwd %5, %%mm3\n\t" | |
1014 "punpckhwd %5, %%mm4\n\t" | |
1015 "punpckhwd %5, %%mm5\n\t" | |
1016 "psllq $8, %%mm1\n\t" | |
1017 "psllq $16, %%mm2\n\t" | |
1018 "por %%mm1, %%mm0\n\t" | |
1019 "por %%mm2, %%mm0\n\t" | |
1020 "psllq $8, %%mm4\n\t" | |
1021 "psllq $16, %%mm5\n\t" | |
1022 "por %%mm4, %%mm3\n\t" | |
1023 "por %%mm5, %%mm3\n\t" | |
1024 | |
1025 "movq %%mm0, %%mm6\n\t" | |
1026 "movq %%mm3, %%mm7\n\t" | |
1027 | |
1028 "movq 8%1, %%mm0\n\t" | |
1029 "movq 8%1, %%mm1\n\t" | |
1030 "movq 8%1, %%mm2\n\t" | |
1031 "pand %2, %%mm0\n\t" | |
1032 "pand %3, %%mm1\n\t" | |
1033 "pand %4, %%mm2\n\t" | |
1034 "psllq $3, %%mm0\n\t" | |
1035 "psrlq $3, %%mm1\n\t" | |
1036 "psrlq $8, %%mm2\n\t" | |
1037 "movq %%mm0, %%mm3\n\t" | |
1038 "movq %%mm1, %%mm4\n\t" | |
1039 "movq %%mm2, %%mm5\n\t" | |
1040 "punpcklwd %5, %%mm0\n\t" | |
1041 "punpcklwd %5, %%mm1\n\t" | |
1042 "punpcklwd %5, %%mm2\n\t" | |
1043 "punpckhwd %5, %%mm3\n\t" | |
1044 "punpckhwd %5, %%mm4\n\t" | |
1045 "punpckhwd %5, %%mm5\n\t" | |
1046 "psllq $8, %%mm1\n\t" | |
1047 "psllq $16, %%mm2\n\t" | |
1048 "por %%mm1, %%mm0\n\t" | |
1049 "por %%mm2, %%mm0\n\t" | |
1050 "psllq $8, %%mm4\n\t" | |
1051 "psllq $16, %%mm5\n\t" | |
1052 "por %%mm4, %%mm3\n\t" | |
1053 "por %%mm5, %%mm3\n\t" | |
1054 :"=m"(*d) | |
1055 :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null) | |
1056 :"memory"); | |
1057 /* Borrowed 32 to 24 */ | |
1058 __asm __volatile( | |
1059 "movq %%mm0, %%mm4\n\t" | |
1060 "movq %%mm3, %%mm5\n\t" | |
1061 "movq %%mm6, %%mm0\n\t" | |
1062 "movq %%mm7, %%mm1\n\t" | |
1063 | |
1064 "movq %%mm4, %%mm6\n\t" | |
1065 "movq %%mm5, %%mm7\n\t" | |
1066 "movq %%mm0, %%mm2\n\t" | |
1067 "movq %%mm1, %%mm3\n\t" | |
1068 | |
1069 "psrlq $8, %%mm2\n\t" | |
1070 "psrlq $8, %%mm3\n\t" | |
1071 "psrlq $8, %%mm6\n\t" | |
1072 "psrlq $8, %%mm7\n\t" | |
1073 "pand %2, %%mm0\n\t" | |
1074 "pand %2, %%mm1\n\t" | |
1075 "pand %2, %%mm4\n\t" | |
1076 "pand %2, %%mm5\n\t" | |
1077 "pand %3, %%mm2\n\t" | |
1078 "pand %3, %%mm3\n\t" | |
1079 "pand %3, %%mm6\n\t" | |
1080 "pand %3, %%mm7\n\t" | |
1081 "por %%mm2, %%mm0\n\t" | |
1082 "por %%mm3, %%mm1\n\t" | |
1083 "por %%mm6, %%mm4\n\t" | |
1084 "por %%mm7, %%mm5\n\t" | |
1085 | |
1086 "movq %%mm1, %%mm2\n\t" | |
1087 "movq %%mm4, %%mm3\n\t" | |
1088 "psllq $48, %%mm2\n\t" | |
1089 "psllq $32, %%mm3\n\t" | |
1090 "pand %4, %%mm2\n\t" | |
1091 "pand %5, %%mm3\n\t" | |
1092 "por %%mm2, %%mm0\n\t" | |
1093 "psrlq $16, %%mm1\n\t" | |
1094 "psrlq $32, %%mm4\n\t" | |
1095 "psllq $16, %%mm5\n\t" | |
1096 "por %%mm3, %%mm1\n\t" | |
1097 "pand %6, %%mm5\n\t" | |
1098 "por %%mm5, %%mm4\n\t" | |
1099 | |
1100 MOVNTQ" %%mm0, %0\n\t" | |
1101 MOVNTQ" %%mm1, 8%0\n\t" | |
1102 MOVNTQ" %%mm4, 16%0" | |
1103 | |
1104 :"=m"(*d) | |
1105 :"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh) | |
1106 :"memory"); | |
1107 d += 24; | |
1108 s += 8; | |
1109 } | |
1110 __asm __volatile(SFENCE:::"memory"); | |
1111 __asm __volatile(EMMS:::"memory"); | |
1112 #endif | |
1113 while(s < end) | |
1114 { | |
1115 register uint16_t bgr; | |
1116 bgr = *s++; | |
1117 *d++ = (bgr&0x1F)<<3; | |
1118 *d++ = (bgr&0x7E0)>>3; | |
1119 *d++ = (bgr&0xF800)>>8; | |
1120 } | |
1121 } | |
2718 | 1122 |
6492 | 1123 static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, unsigned src_size) |
1124 { | |
1125 const uint16_t *end; | |
1126 #ifdef HAVE_MMX | |
1127 const uint16_t *mm_end; | |
1128 #endif | |
1129 uint8_t *d = (uint8_t *)dst; | |
1130 const uint16_t *s = (const uint16_t *)src; | |
1131 end = s + src_size/2; | |
1132 #ifdef HAVE_MMX | |
1133 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); | |
1134 __asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory"); | |
6605 | 1135 mm_end = end - 3; |
6492 | 1136 while(s < mm_end) |
1137 { | |
1138 __asm __volatile( | |
1139 PREFETCH" 32%1\n\t" | |
1140 "movq %1, %%mm0\n\t" | |
1141 "movq %1, %%mm1\n\t" | |
1142 "movq %1, %%mm2\n\t" | |
1143 "pand %2, %%mm0\n\t" | |
1144 "pand %3, %%mm1\n\t" | |
1145 "pand %4, %%mm2\n\t" | |
1146 "psllq $3, %%mm0\n\t" | |
1147 "psrlq $2, %%mm1\n\t" | |
1148 "psrlq $7, %%mm2\n\t" | |
1149 "movq %%mm0, %%mm3\n\t" | |
1150 "movq %%mm1, %%mm4\n\t" | |
1151 "movq %%mm2, %%mm5\n\t" | |
1152 "punpcklwd %%mm7, %%mm0\n\t" | |
1153 "punpcklwd %%mm7, %%mm1\n\t" | |
1154 "punpcklwd %%mm7, %%mm2\n\t" | |
1155 "punpckhwd %%mm7, %%mm3\n\t" | |
1156 "punpckhwd %%mm7, %%mm4\n\t" | |
1157 "punpckhwd %%mm7, %%mm5\n\t" | |
1158 "psllq $8, %%mm1\n\t" | |
1159 "psllq $16, %%mm2\n\t" | |
1160 "por %%mm1, %%mm0\n\t" | |
1161 "por %%mm2, %%mm0\n\t" | |
1162 "psllq $8, %%mm4\n\t" | |
1163 "psllq $16, %%mm5\n\t" | |
1164 "por %%mm4, %%mm3\n\t" | |
1165 "por %%mm5, %%mm3\n\t" | |
1166 MOVNTQ" %%mm0, %0\n\t" | |
1167 MOVNTQ" %%mm3, 8%0\n\t" | |
1168 :"=m"(*d) | |
1169 :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r) | |
1170 :"memory"); | |
1171 d += 16; | |
1172 s += 4; | |
1173 } | |
1174 __asm __volatile(SFENCE:::"memory"); | |
1175 __asm __volatile(EMMS:::"memory"); | |
1176 #endif | |
1177 while(s < end) | |
1178 { | |
1179 register uint16_t bgr; | |
1180 bgr = *s++; | |
1181 *d++ = (bgr&0x1F)<<3; | |
1182 *d++ = (bgr&0x3E0)>>2; | |
1183 *d++ = (bgr&0x7C00)>>7; | |
1184 *d++ = 0; | |
2718 | 1185 } |
6492 | 1186 } |
1187 | |
1188 static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, unsigned src_size) | |
1189 { | |
1190 const uint16_t *end; | |
1191 #ifdef HAVE_MMX | |
1192 const uint16_t *mm_end; | |
2741 | 1193 #endif |
6492 | 1194 uint8_t *d = (uint8_t *)dst; |
1195 const uint16_t *s = (uint16_t *)src; | |
1196 end = s + src_size/2; | |
1197 #ifdef HAVE_MMX | |
1198 __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); | |
1199 __asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory"); | |
6605 | 1200 mm_end = end - 3; |
6492 | 1201 while(s < mm_end) |
1202 { | |
1203 __asm __volatile( | |
1204 PREFETCH" 32%1\n\t" | |
1205 "movq %1, %%mm0\n\t" | |
1206 "movq %1, %%mm1\n\t" | |
1207 "movq %1, %%mm2\n\t" | |
1208 "pand %2, %%mm0\n\t" | |
1209 "pand %3, %%mm1\n\t" | |
1210 "pand %4, %%mm2\n\t" | |
1211 "psllq $3, %%mm0\n\t" | |
1212 "psrlq $3, %%mm1\n\t" | |
1213 "psrlq $8, %%mm2\n\t" | |
1214 "movq %%mm0, %%mm3\n\t" | |
1215 "movq %%mm1, %%mm4\n\t" | |
1216 "movq %%mm2, %%mm5\n\t" | |
1217 "punpcklwd %%mm7, %%mm0\n\t" | |
1218 "punpcklwd %%mm7, %%mm1\n\t" | |
1219 "punpcklwd %%mm7, %%mm2\n\t" | |
1220 "punpckhwd %%mm7, %%mm3\n\t" | |
1221 "punpckhwd %%mm7, %%mm4\n\t" | |
1222 "punpckhwd %%mm7, %%mm5\n\t" | |
1223 "psllq $8, %%mm1\n\t" | |
1224 "psllq $16, %%mm2\n\t" | |
1225 "por %%mm1, %%mm0\n\t" | |
1226 "por %%mm2, %%mm0\n\t" | |
1227 "psllq $8, %%mm4\n\t" | |
1228 "psllq $16, %%mm5\n\t" | |
1229 "por %%mm4, %%mm3\n\t" | |
1230 "por %%mm5, %%mm3\n\t" | |
1231 MOVNTQ" %%mm0, %0\n\t" | |
1232 MOVNTQ" %%mm3, 8%0\n\t" | |
1233 :"=m"(*d) | |
1234 :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r) | |
1235 :"memory"); | |
1236 d += 16; | |
1237 s += 4; | |
1238 } | |
1239 __asm __volatile(SFENCE:::"memory"); | |
1240 __asm __volatile(EMMS:::"memory"); | |
1241 #endif | |
1242 while(s < end) | |
1243 { | |
1244 register uint16_t bgr; | |
1245 bgr = *s++; | |
1246 *d++ = (bgr&0x1F)<<3; | |
1247 *d++ = (bgr&0x7E0)>>3; | |
1248 *d++ = (bgr&0xF800)>>8; | |
1249 *d++ = 0; | |
1250 } | |
2718 | 1251 } |
2694 | 1252 |
3132 | 1253 static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
2755 | 1254 { |
1255 #ifdef HAVE_MMX | |
6492 | 1256 /* TODO: unroll this loop */ |
2755 | 1257 asm volatile ( |
1258 "xorl %%eax, %%eax \n\t" | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1259 ".balign 16 \n\t" |
2755 | 1260 "1: \n\t" |
1261 PREFETCH" 32(%0, %%eax) \n\t" | |
1262 "movq (%0, %%eax), %%mm0 \n\t" | |
1263 "movq %%mm0, %%mm1 \n\t" | |
1264 "movq %%mm0, %%mm2 \n\t" | |
1265 "pslld $16, %%mm0 \n\t" | |
1266 "psrld $16, %%mm1 \n\t" | |
6492 | 1267 "pand "MANGLE(mask32r)", %%mm0 \n\t" |
1268 "pand "MANGLE(mask32g)", %%mm2 \n\t" | |
1269 "pand "MANGLE(mask32b)", %%mm1 \n\t" | |
2755 | 1270 "por %%mm0, %%mm2 \n\t" |
1271 "por %%mm1, %%mm2 \n\t" | |
1272 MOVNTQ" %%mm2, (%1, %%eax) \n\t" | |
6096 | 1273 "addl $8, %%eax \n\t" |
2755 | 1274 "cmpl %2, %%eax \n\t" |
1275 " jb 1b \n\t" | |
6605 | 1276 :: "r" (src), "r"(dst), "r" (src_size-7) |
2755 | 1277 : "%eax" |
1278 ); | |
2766 | 1279 |
1280 __asm __volatile(SFENCE:::"memory"); | |
1281 __asm __volatile(EMMS:::"memory"); | |
2755 | 1282 #else |
6492 | 1283 unsigned i; |
1284 unsigned num_pixels = src_size >> 2; | |
2755 | 1285 for(i=0; i<num_pixels; i++) |
1286 { | |
1287 dst[4*i + 0] = src[4*i + 2]; | |
1288 dst[4*i + 1] = src[4*i + 1]; | |
1289 dst[4*i + 2] = src[4*i + 0]; | |
1290 } | |
1291 #endif | |
1292 } | |
1293 | |
5582 | 1294 static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, unsigned int src_size) |
1295 { | |
6492 | 1296 unsigned i; |
5582 | 1297 #ifdef HAVE_MMX |
1298 int mmx_size= 23 - src_size; | |
1299 asm volatile ( | |
1300 "movq "MANGLE(mask24r)", %%mm5 \n\t" | |
1301 "movq "MANGLE(mask24g)", %%mm6 \n\t" | |
1302 "movq "MANGLE(mask24b)", %%mm7 \n\t" | |
1303 ".balign 16 \n\t" | |
1304 "1: \n\t" | |
1305 PREFETCH" 32(%1, %%eax) \n\t" | |
1306 "movq (%1, %%eax), %%mm0 \n\t" // BGR BGR BG | |
1307 "movq (%1, %%eax), %%mm1 \n\t" // BGR BGR BG | |
1308 "movq 2(%1, %%eax), %%mm2 \n\t" // R BGR BGR B | |
1309 "psllq $16, %%mm0 \n\t" // 00 BGR BGR | |
1310 "pand %%mm5, %%mm0 \n\t" | |
1311 "pand %%mm6, %%mm1 \n\t" | |
1312 "pand %%mm7, %%mm2 \n\t" | |
1313 "por %%mm0, %%mm1 \n\t" | |
1314 "por %%mm2, %%mm1 \n\t" | |
1315 "movq 6(%1, %%eax), %%mm0 \n\t" // BGR BGR BG | |
1316 MOVNTQ" %%mm1, (%2, %%eax) \n\t" // RGB RGB RG | |
1317 "movq 8(%1, %%eax), %%mm1 \n\t" // R BGR BGR B | |
1318 "movq 10(%1, %%eax), %%mm2 \n\t" // GR BGR BGR | |
1319 "pand %%mm7, %%mm0 \n\t" | |
1320 "pand %%mm5, %%mm1 \n\t" | |
1321 "pand %%mm6, %%mm2 \n\t" | |
1322 "por %%mm0, %%mm1 \n\t" | |
1323 "por %%mm2, %%mm1 \n\t" | |
1324 "movq 14(%1, %%eax), %%mm0 \n\t" // R BGR BGR B | |
1325 MOVNTQ" %%mm1, 8(%2, %%eax) \n\t" // B RGB RGB R | |
1326 "movq 16(%1, %%eax), %%mm1 \n\t" // GR BGR BGR | |
1327 "movq 18(%1, %%eax), %%mm2 \n\t" // BGR BGR BG | |
1328 "pand %%mm6, %%mm0 \n\t" | |
1329 "pand %%mm7, %%mm1 \n\t" | |
1330 "pand %%mm5, %%mm2 \n\t" | |
1331 "por %%mm0, %%mm1 \n\t" | |
1332 "por %%mm2, %%mm1 \n\t" | |
1333 MOVNTQ" %%mm1, 16(%2, %%eax) \n\t" | |
1334 "addl $24, %%eax \n\t" | |
1335 " js 1b \n\t" | |
1336 : "+a" (mmx_size) | |
1337 : "r" (src-mmx_size), "r"(dst-mmx_size) | |
1338 ); | |
1339 | |
1340 __asm __volatile(SFENCE:::"memory"); | |
1341 __asm __volatile(EMMS:::"memory"); | |
1342 | |
6096 | 1343 if(mmx_size==23) return; //finihsed, was multiple of 8 |
6492 | 1344 |
5582 | 1345 src+= src_size; |
1346 dst+= src_size; | |
6492 | 1347 src_size= 23-mmx_size; |
5582 | 1348 src-= src_size; |
1349 dst-= src_size; | |
1350 #endif | |
1351 for(i=0; i<src_size; i+=3) | |
1352 { | |
6492 | 1353 register uint8_t x; |
5582 | 1354 x = src[i + 2]; |
1355 dst[i + 1] = src[i + 1]; | |
1356 dst[i + 2] = src[i + 0]; | |
1357 dst[i + 0] = x; | |
1358 } | |
1359 } | |
1360 | |
5588 | 1361 static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
2725 | 1362 unsigned int width, unsigned int height, |
5588 | 1363 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride, int vertLumPerChroma) |
2701 | 1364 { |
6492 | 1365 unsigned y; |
1366 const unsigned chromWidth= width>>1; | |
2723 | 1367 for(y=0; y<height; y++) |
1368 { | |
2702 | 1369 #ifdef HAVE_MMX |
2723 | 1370 //FIXME handle 2 lines a once (fewer prefetch, reuse some chrom, but very likely limited by mem anyway) |
1371 asm volatile( | |
1372 "xorl %%eax, %%eax \n\t" | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1373 ".balign 16 \n\t" |
2723 | 1374 "1: \n\t" |
1375 PREFETCH" 32(%1, %%eax, 2) \n\t" | |
1376 PREFETCH" 32(%2, %%eax) \n\t" | |
1377 PREFETCH" 32(%3, %%eax) \n\t" | |
1378 "movq (%2, %%eax), %%mm0 \n\t" // U(0) | |
1379 "movq %%mm0, %%mm2 \n\t" // U(0) | |
1380 "movq (%3, %%eax), %%mm1 \n\t" // V(0) | |
1381 "punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0) | |
1382 "punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8) | |
1383 | |
1384 "movq (%1, %%eax,2), %%mm3 \n\t" // Y(0) | |
1385 "movq 8(%1, %%eax,2), %%mm5 \n\t" // Y(8) | |
1386 "movq %%mm3, %%mm4 \n\t" // Y(0) | |
1387 "movq %%mm5, %%mm6 \n\t" // Y(8) | |
1388 "punpcklbw %%mm0, %%mm3 \n\t" // YUYV YUYV(0) | |
1389 "punpckhbw %%mm0, %%mm4 \n\t" // YUYV YUYV(4) | |
1390 "punpcklbw %%mm2, %%mm5 \n\t" // YUYV YUYV(8) | |
1391 "punpckhbw %%mm2, %%mm6 \n\t" // YUYV YUYV(12) | |
2702 | 1392 |
2723 | 1393 MOVNTQ" %%mm3, (%0, %%eax, 4) \n\t" |
1394 MOVNTQ" %%mm4, 8(%0, %%eax, 4) \n\t" | |
1395 MOVNTQ" %%mm5, 16(%0, %%eax, 4) \n\t" | |
1396 MOVNTQ" %%mm6, 24(%0, %%eax, 4) \n\t" | |
2702 | 1397 |
2723 | 1398 "addl $8, %%eax \n\t" |
1399 "cmpl %4, %%eax \n\t" | |
1400 " jb 1b \n\t" | |
1401 ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "r" (chromWidth) | |
1402 : "%eax" | |
1403 ); | |
2702 | 1404 #else |
6492 | 1405 #if __WORDSIZE >= 64 |
2723 | 1406 int i; |
6492 | 1407 uint64_t *ldst = (uint64_t *) dst; |
1408 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; | |
1409 for(i = 0; i < chromWidth; i += 2){ | |
1410 uint64_t k, l; | |
1411 k = yc[0] + (uc[0] << 8) + | |
1412 (yc[1] << 16) + (vc[0] << 24); | |
1413 l = yc[2] + (uc[1] << 8) + | |
1414 (yc[3] << 16) + (vc[1] << 24); | |
1415 *ldst++ = k + (l << 32); | |
1416 yc += 4; | |
1417 uc += 2; | |
1418 vc += 2; | |
2723 | 1419 } |
6492 | 1420 |
1421 #else | |
1422 int i, *idst = (int32_t *) dst; | |
1423 const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc; | |
1424 for(i = 0; i < chromWidth; i++){ | |
1425 *idst++ = yc[0] + (uc[0] << 8) + | |
1426 (yc[1] << 16) + (vc[0] << 24); | |
1427 yc += 2; | |
1428 uc++; | |
1429 vc++; | |
1430 } | |
1431 #endif | |
2723 | 1432 #endif |
5588 | 1433 if((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) |
2723 | 1434 { |
1435 usrc += chromStride; | |
1436 vsrc += chromStride; | |
1437 } | |
1438 ysrc += lumStride; | |
1439 dst += dstStride; | |
2701 | 1440 } |
2723 | 1441 #ifdef HAVE_MMX |
1442 asm( EMMS" \n\t" | |
1443 SFENCE" \n\t" | |
1444 :::"memory"); | |
2702 | 1445 #endif |
2701 | 1446 } |
1447 | |
2724 | 1448 /** |
1449 * | |
1450 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | |
1451 * problem for anyone then tell me, and ill fix it) | |
1452 */ | |
5588 | 1453 static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, |
1454 unsigned int width, unsigned int height, | |
1455 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
1456 { | |
1457 //FIXME interpolate chroma | |
1458 RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2); | |
1459 } | |
1460 | |
1461 /** | |
1462 * | |
1463 * width should be a multiple of 16 | |
1464 */ | |
1465 static inline void RENAME(yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, | |
1466 unsigned int width, unsigned int height, | |
1467 unsigned int lumStride, unsigned int chromStride, unsigned int dstStride) | |
1468 { | |
1469 RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1); | |
1470 } | |
1471 | |
1472 /** | |
1473 * | |
1474 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | |
1475 * problem for anyone then tell me, and ill fix it) | |
1476 */ | |
3132 | 1477 static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
2725 | 1478 unsigned int width, unsigned int height, |
1479 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
2701 | 1480 { |
6492 | 1481 unsigned y; |
1482 const unsigned chromWidth= width>>1; | |
2724 | 1483 for(y=0; y<height; y+=2) |
1484 { | |
2704 | 1485 #ifdef HAVE_MMX |
2724 | 1486 asm volatile( |
1487 "xorl %%eax, %%eax \n\t" | |
1488 "pcmpeqw %%mm7, %%mm7 \n\t" | |
1489 "psrlw $8, %%mm7 \n\t" // FF,00,FF,00... | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1490 ".balign 16 \n\t" |
2724 | 1491 "1: \n\t" |
1492 PREFETCH" 64(%0, %%eax, 4) \n\t" | |
1493 "movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0) | |
1494 "movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4) | |
1495 "movq %%mm0, %%mm2 \n\t" // YUYV YUYV(0) | |
1496 "movq %%mm1, %%mm3 \n\t" // YUYV YUYV(4) | |
1497 "psrlw $8, %%mm0 \n\t" // U0V0 U0V0(0) | |
1498 "psrlw $8, %%mm1 \n\t" // U0V0 U0V0(4) | |
1499 "pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(0) | |
1500 "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(4) | |
1501 "packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0) | |
1502 "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0) | |
1503 | |
1504 MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t" | |
2704 | 1505 |
2724 | 1506 "movq 16(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(8) |
1507 "movq 24(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(12) | |
1508 "movq %%mm1, %%mm3 \n\t" // YUYV YUYV(8) | |
1509 "movq %%mm2, %%mm4 \n\t" // YUYV YUYV(12) | |
1510 "psrlw $8, %%mm1 \n\t" // U0V0 U0V0(8) | |
1511 "psrlw $8, %%mm2 \n\t" // U0V0 U0V0(12) | |
1512 "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(8) | |
1513 "pand %%mm7, %%mm4 \n\t" // Y0Y0 Y0Y0(12) | |
1514 "packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8) | |
1515 "packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8) | |
2704 | 1516 |
2724 | 1517 MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t" |
1518 | |
1519 "movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0) | |
1520 "movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8) | |
1521 "psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0) | |
1522 "psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8) | |
1523 "pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0) | |
1524 "pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8) | |
1525 "packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0) | |
1526 "packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0) | |
2704 | 1527 |
2724 | 1528 MOVNTQ" %%mm0, (%3, %%eax) \n\t" |
1529 MOVNTQ" %%mm2, (%2, %%eax) \n\t" | |
1530 | |
1531 "addl $8, %%eax \n\t" | |
1532 "cmpl %4, %%eax \n\t" | |
1533 " jb 1b \n\t" | |
2725 | 1534 ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth) |
1535 : "memory", "%eax" | |
1536 ); | |
2704 | 1537 |
2806 | 1538 ydst += lumStride; |
1539 src += srcStride; | |
1540 | |
2725 | 1541 asm volatile( |
1542 "xorl %%eax, %%eax \n\t" | |
2800
7847d6b7ad3d
.balign or we¡ll align by 64kb on some architectures
michael
parents:
2799
diff
changeset
|
1543 ".balign 16 \n\t" |
2724 | 1544 "1: \n\t" |
1545 PREFETCH" 64(%0, %%eax, 4) \n\t" | |
1546 "movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0) | |
1547 "movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4) | |
1548 "movq 16(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(8) | |
1549 "movq 24(%0, %%eax, 4), %%mm3 \n\t" // YUYV YUYV(12) | |
1550 "pand %%mm7, %%mm0 \n\t" // Y0Y0 Y0Y0(0) | |
1551 "pand %%mm7, %%mm1 \n\t" // Y0Y0 Y0Y0(4) | |
1552 "pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(8) | |
1553 "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(12) | |
1554 "packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0) | |
1555 "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8) | |
2704 | 1556 |
2724 | 1557 MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t" |
1558 MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t" | |
1559 | |
1560 "addl $8, %%eax \n\t" | |
2725 | 1561 "cmpl %4, %%eax \n\t" |
2724 | 1562 " jb 1b \n\t" |
2704 | 1563 |
2806 | 1564 ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth) |
2724 | 1565 : "memory", "%eax" |
1566 ); | |
2704 | 1567 #else |
6492 | 1568 unsigned i; |
2724 | 1569 for(i=0; i<chromWidth; i++) |
1570 { | |
1571 ydst[2*i+0] = src[4*i+0]; | |
1572 udst[i] = src[4*i+1]; | |
1573 ydst[2*i+1] = src[4*i+2]; | |
1574 vdst[i] = src[4*i+3]; | |
1575 } | |
1576 ydst += lumStride; | |
1577 src += srcStride; | |
1578 | |
1579 for(i=0; i<chromWidth; i++) | |
1580 { | |
1581 ydst[2*i+0] = src[4*i+0]; | |
1582 ydst[2*i+1] = src[4*i+2]; | |
1583 } | |
1584 #endif | |
1585 udst += chromStride; | |
1586 vdst += chromStride; | |
1587 ydst += lumStride; | |
1588 src += srcStride; | |
2701 | 1589 } |
2724 | 1590 #ifdef HAVE_MMX |
2847 | 1591 asm volatile( EMMS" \n\t" |
1592 SFENCE" \n\t" | |
1593 :::"memory"); | |
2704 | 1594 #endif |
2723 | 1595 } |
2801 | 1596 |
6484
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1597 static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1598 uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1599 unsigned int width, unsigned int height, unsigned int lumStride, unsigned int chromStride) |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1600 { |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1601 /* Y Plane */ |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1602 memcpy(ydst, ysrc, width*height); |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1603 |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1604 /* XXX: implement upscaling for U,V */ |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1605 } |
c5cf988c6d6f
pre-yvu9toyv12 converter, only grayscale Y-plane coping :)
alex
parents:
6096
diff
changeset
|
1606 |
6582
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1607 static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride) |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1608 { |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1609 int x,y; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1610 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1611 // first line |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1612 for(x=0; x<srcWidth; x++){ |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1613 dst[2*x+0]= |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1614 dst[2*x+1]= src[x]; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1615 } |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1616 dst+= dstStride; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1617 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1618 for(y=1; y<srcHeight; y++){ |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1619 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1620 const int mmxSize= srcWidth; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1621 asm volatile( |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1622 "movl %4, %%eax \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1623 "1: \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1624 "movq (%0, %%eax), %%mm0 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1625 "movq (%1, %%eax), %%mm1 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1626 "movq 1(%0, %%eax), %%mm2 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1627 "movq 1(%1, %%eax), %%mm3 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1628 "movq %%mm0, %%mm4 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1629 "movq %%mm1, %%mm5 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1630 PAVGB" %%mm3, %%mm0 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1631 PAVGB" %%mm3, %%mm0 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1632 PAVGB" %%mm4, %%mm3 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1633 PAVGB" %%mm4, %%mm3 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1634 PAVGB" %%mm2, %%mm1 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1635 PAVGB" %%mm2, %%mm1 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1636 PAVGB" %%mm5, %%mm2 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1637 PAVGB" %%mm5, %%mm2 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1638 "movq %%mm3, %%mm4 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1639 "movq %%mm2, %%mm5 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1640 "punpcklbw %%mm1, %%mm3 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1641 "punpckhbw %%mm1, %%mm4 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1642 "punpcklbw %%mm0, %%mm2 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1643 "punpckhbw %%mm0, %%mm5 \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1644 #if 1 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1645 MOVNTQ" %%mm3, (%2, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1646 MOVNTQ" %%mm4, 8(%2, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1647 MOVNTQ" %%mm2, (%3, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1648 MOVNTQ" %%mm5, 8(%3, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1649 #else |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1650 "movq %%mm3, (%2, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1651 "movq %%mm4, 8(%2, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1652 "movq %%mm2, (%3, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1653 "movq %%mm5, 8(%3, %%eax, 2) \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1654 #endif |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1655 "addl $8, %%eax \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1656 " js 1b \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1657 :: "r" (src + mmxSize-1), "r" (src + srcStride + mmxSize-1), |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1658 "r" (dst + mmxSize*2), "r" (dst + dstStride + mmxSize*2), |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1659 "g" (-mmxSize) |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1660 : "%eax" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1661 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1662 ); |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1663 dst[0]= |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1664 dst[dstStride]= src[0]; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1665 #else |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1666 dst[0]= |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1667 dst[dstStride]= src[0]; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1668 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1669 for(x=0; x<srcWidth-1; x++){ |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1670 dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1671 dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1672 dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1673 dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1674 } |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1675 #endif |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1676 dst[srcWidth*2 -1]= |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1677 dst[srcWidth*2 -1 + dstStride]= src[srcWidth-1]; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1678 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1679 dst+=dstStride*2; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1680 src+=srcStride; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1681 } |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1682 src-=srcStride; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1683 |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1684 // last line |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1685 for(x=0; x<srcWidth; x++){ |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1686 dst[2*x+0]= |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1687 dst[2*x+1]= src[x]; |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1688 } |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1689 #ifdef HAVE_MMX |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1690 asm volatile( EMMS" \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1691 SFENCE" \n\t" |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1692 :::"memory"); |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1693 #endif |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1694 } |
f98313dcd428
yvu9 -> yv12 unscaled converter with linear chroma scaling
michael
parents:
6492
diff
changeset
|
1695 |
2801 | 1696 /** |
1697 * | |
1698 * height should be a multiple of 2 and width should be a multiple of 16 (if this is a | |
1699 * problem for anyone then tell me, and ill fix it) | |
3132 | 1700 * chrominance data is only taken from every secound line others are ignored FIXME write HQ version |
2801 | 1701 */ |
3132 | 1702 static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, |
2801 | 1703 unsigned int width, unsigned int height, |
1704 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
1705 { | |
6492 | 1706 unsigned y; |
1707 const unsigned chromWidth= width>>1; | |
2801 | 1708 for(y=0; y<height; y+=2) |
1709 { | |
2847 | 1710 #ifdef HAVE_MMX |
1711 asm volatile( | |
1712 "xorl %%eax, %%eax \n\t" | |
1713 "pcmpeqw %%mm7, %%mm7 \n\t" | |
1714 "psrlw $8, %%mm7 \n\t" // FF,00,FF,00... | |
1715 ".balign 16 \n\t" | |
1716 "1: \n\t" | |
1717 PREFETCH" 64(%0, %%eax, 4) \n\t" | |
1718 "movq (%0, %%eax, 4), %%mm0 \n\t" // UYVY UYVY(0) | |
1719 "movq 8(%0, %%eax, 4), %%mm1 \n\t" // UYVY UYVY(4) | |
1720 "movq %%mm0, %%mm2 \n\t" // UYVY UYVY(0) | |
1721 "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(4) | |
1722 "pand %%mm7, %%mm0 \n\t" // U0V0 U0V0(0) | |
1723 "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(4) | |
1724 "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(0) | |
1725 "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(4) | |
1726 "packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0) | |
1727 "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0) | |
1728 | |
1729 MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t" | |
1730 | |
1731 "movq 16(%0, %%eax, 4), %%mm1 \n\t" // UYVY UYVY(8) | |
1732 "movq 24(%0, %%eax, 4), %%mm2 \n\t" // UYVY UYVY(12) | |
1733 "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(8) | |
1734 "movq %%mm2, %%mm4 \n\t" // UYVY UYVY(12) | |
1735 "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(8) | |
1736 "pand %%mm7, %%mm2 \n\t" // U0V0 U0V0(12) | |
1737 "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(8) | |
1738 "psrlw $8, %%mm4 \n\t" // Y0Y0 Y0Y0(12) | |
1739 "packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8) | |
1740 "packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8) | |
1741 | |
1742 MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t" | |
1743 | |
1744 "movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0) | |
1745 "movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8) | |
1746 "psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0) | |
1747 "psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8) | |
1748 "pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0) | |
1749 "pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8) | |
1750 "packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0) | |
1751 "packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0) | |
1752 | |
1753 MOVNTQ" %%mm0, (%3, %%eax) \n\t" | |
1754 MOVNTQ" %%mm2, (%2, %%eax) \n\t" | |
1755 | |
1756 "addl $8, %%eax \n\t" | |
1757 "cmpl %4, %%eax \n\t" | |
1758 " jb 1b \n\t" | |
1759 ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth) | |
1760 : "memory", "%eax" | |
1761 ); | |
1762 | |
1763 ydst += lumStride; | |
1764 src += srcStride; | |
1765 | |
1766 asm volatile( | |
1767 "xorl %%eax, %%eax \n\t" | |
1768 ".balign 16 \n\t" | |
1769 "1: \n\t" | |
1770 PREFETCH" 64(%0, %%eax, 4) \n\t" | |
1771 "movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0) | |
1772 "movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4) | |
1773 "movq 16(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(8) | |
1774 "movq 24(%0, %%eax, 4), %%mm3 \n\t" // YUYV YUYV(12) | |
1775 "psrlw $8, %%mm0 \n\t" // Y0Y0 Y0Y0(0) | |
1776 "psrlw $8, %%mm1 \n\t" // Y0Y0 Y0Y0(4) | |
1777 "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(8) | |
1778 "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(12) | |
1779 "packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0) | |
1780 "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8) | |
1781 | |
1782 MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t" | |
1783 MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t" | |
1784 | |
1785 "addl $8, %%eax \n\t" | |
1786 "cmpl %4, %%eax \n\t" | |
1787 " jb 1b \n\t" | |
1788 | |
1789 ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "r" (chromWidth) | |
1790 : "memory", "%eax" | |
1791 ); | |
1792 #else | |
6492 | 1793 unsigned i; |
2801 | 1794 for(i=0; i<chromWidth; i++) |
1795 { | |
1796 udst[i] = src[4*i+0]; | |
1797 ydst[2*i+0] = src[4*i+1]; | |
1798 vdst[i] = src[4*i+2]; | |
1799 ydst[2*i+1] = src[4*i+3]; | |
1800 } | |
1801 ydst += lumStride; | |
1802 src += srcStride; | |
1803 | |
1804 for(i=0; i<chromWidth; i++) | |
1805 { | |
1806 ydst[2*i+0] = src[4*i+1]; | |
1807 ydst[2*i+1] = src[4*i+3]; | |
1808 } | |
2847 | 1809 #endif |
2801 | 1810 udst += chromStride; |
1811 vdst += chromStride; | |
1812 ydst += lumStride; | |
1813 src += srcStride; | |
1814 } | |
2847 | 1815 #ifdef HAVE_MMX |
1816 asm volatile( EMMS" \n\t" | |
1817 SFENCE" \n\t" | |
1818 :::"memory"); | |
1819 #endif | |
2801 | 1820 } |
1821 | |
3132 | 1822 /** |
1823 * | |
1824 * height should be a multiple of 2 and width should be a multiple of 2 (if this is a | |
1825 * problem for anyone then tell me, and ill fix it) | |
4622 | 1826 * chrominance data is only taken from every secound line others are ignored in the C version FIXME write HQ version |
3132 | 1827 */ |
1828 static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, | |
1829 unsigned int width, unsigned int height, | |
1830 unsigned int lumStride, unsigned int chromStride, unsigned int srcStride) | |
1831 { | |
6492 | 1832 unsigned y; |
1833 const unsigned chromWidth= width>>1; | |
4622 | 1834 #ifdef HAVE_MMX |
1835 for(y=0; y<height-2; y+=2) | |
1836 { | |
6492 | 1837 unsigned i; |
4622 | 1838 for(i=0; i<2; i++) |
1839 { | |
1840 asm volatile( | |
1841 "movl %2, %%eax \n\t" | |
4923 | 1842 "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" |
1843 "movq "MANGLE(w1111)", %%mm5 \n\t" | |
4622 | 1844 "pxor %%mm7, %%mm7 \n\t" |
1845 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1846 ".balign 16 \n\t" | |
1847 "1: \n\t" | |
1848 PREFETCH" 64(%0, %%ebx) \n\t" | |
1849 "movd (%0, %%ebx), %%mm0 \n\t" | |
1850 "movd 3(%0, %%ebx), %%mm1 \n\t" | |
1851 "punpcklbw %%mm7, %%mm0 \n\t" | |
1852 "punpcklbw %%mm7, %%mm1 \n\t" | |
1853 "movd 6(%0, %%ebx), %%mm2 \n\t" | |
1854 "movd 9(%0, %%ebx), %%mm3 \n\t" | |
1855 "punpcklbw %%mm7, %%mm2 \n\t" | |
1856 "punpcklbw %%mm7, %%mm3 \n\t" | |
1857 "pmaddwd %%mm6, %%mm0 \n\t" | |
1858 "pmaddwd %%mm6, %%mm1 \n\t" | |
1859 "pmaddwd %%mm6, %%mm2 \n\t" | |
1860 "pmaddwd %%mm6, %%mm3 \n\t" | |
1861 #ifndef FAST_BGR2YV12 | |
1862 "psrad $8, %%mm0 \n\t" | |
1863 "psrad $8, %%mm1 \n\t" | |
1864 "psrad $8, %%mm2 \n\t" | |
1865 "psrad $8, %%mm3 \n\t" | |
1866 #endif | |
1867 "packssdw %%mm1, %%mm0 \n\t" | |
1868 "packssdw %%mm3, %%mm2 \n\t" | |
1869 "pmaddwd %%mm5, %%mm0 \n\t" | |
1870 "pmaddwd %%mm5, %%mm2 \n\t" | |
1871 "packssdw %%mm2, %%mm0 \n\t" | |
1872 "psraw $7, %%mm0 \n\t" | |
1873 | |
1874 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
1875 "movd 15(%0, %%ebx), %%mm1 \n\t" | |
1876 "punpcklbw %%mm7, %%mm4 \n\t" | |
1877 "punpcklbw %%mm7, %%mm1 \n\t" | |
1878 "movd 18(%0, %%ebx), %%mm2 \n\t" | |
1879 "movd 21(%0, %%ebx), %%mm3 \n\t" | |
1880 "punpcklbw %%mm7, %%mm2 \n\t" | |
1881 "punpcklbw %%mm7, %%mm3 \n\t" | |
1882 "pmaddwd %%mm6, %%mm4 \n\t" | |
1883 "pmaddwd %%mm6, %%mm1 \n\t" | |
1884 "pmaddwd %%mm6, %%mm2 \n\t" | |
1885 "pmaddwd %%mm6, %%mm3 \n\t" | |
1886 #ifndef FAST_BGR2YV12 | |
1887 "psrad $8, %%mm4 \n\t" | |
1888 "psrad $8, %%mm1 \n\t" | |
1889 "psrad $8, %%mm2 \n\t" | |
1890 "psrad $8, %%mm3 \n\t" | |
1891 #endif | |
1892 "packssdw %%mm1, %%mm4 \n\t" | |
1893 "packssdw %%mm3, %%mm2 \n\t" | |
1894 "pmaddwd %%mm5, %%mm4 \n\t" | |
1895 "pmaddwd %%mm5, %%mm2 \n\t" | |
1896 "addl $24, %%ebx \n\t" | |
1897 "packssdw %%mm2, %%mm4 \n\t" | |
1898 "psraw $7, %%mm4 \n\t" | |
1899 | |
1900 "packuswb %%mm4, %%mm0 \n\t" | |
4923 | 1901 "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" |
4622 | 1902 |
1903 MOVNTQ" %%mm0, (%1, %%eax) \n\t" | |
1904 "addl $8, %%eax \n\t" | |
1905 " js 1b \n\t" | |
1906 : : "r" (src+width*3), "r" (ydst+width), "g" (-width) | |
1907 : "%eax", "%ebx" | |
1908 ); | |
1909 ydst += lumStride; | |
1910 src += srcStride; | |
1911 } | |
1912 src -= srcStride*2; | |
1913 asm volatile( | |
1914 "movl %4, %%eax \n\t" | |
4923 | 1915 "movq "MANGLE(w1111)", %%mm5 \n\t" |
1916 "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" | |
4622 | 1917 "pxor %%mm7, %%mm7 \n\t" |
1918 "leal (%%eax, %%eax, 2), %%ebx \n\t" | |
1919 "addl %%ebx, %%ebx \n\t" | |
1920 ".balign 16 \n\t" | |
1921 "1: \n\t" | |
1922 PREFETCH" 64(%0, %%ebx) \n\t" | |
1923 PREFETCH" 64(%1, %%ebx) \n\t" | |
1924 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1925 "movq (%0, %%ebx), %%mm0 \n\t" | |
1926 "movq (%1, %%ebx), %%mm1 \n\t" | |
1927 "movq 6(%0, %%ebx), %%mm2 \n\t" | |
1928 "movq 6(%1, %%ebx), %%mm3 \n\t" | |
1929 PAVGB" %%mm1, %%mm0 \n\t" | |
1930 PAVGB" %%mm3, %%mm2 \n\t" | |
1931 "movq %%mm0, %%mm1 \n\t" | |
1932 "movq %%mm2, %%mm3 \n\t" | |
1933 "psrlq $24, %%mm0 \n\t" | |
1934 "psrlq $24, %%mm2 \n\t" | |
1935 PAVGB" %%mm1, %%mm0 \n\t" | |
1936 PAVGB" %%mm3, %%mm2 \n\t" | |
1937 "punpcklbw %%mm7, %%mm0 \n\t" | |
1938 "punpcklbw %%mm7, %%mm2 \n\t" | |
1939 #else | |
1940 "movd (%0, %%ebx), %%mm0 \n\t" | |
1941 "movd (%1, %%ebx), %%mm1 \n\t" | |
1942 "movd 3(%0, %%ebx), %%mm2 \n\t" | |
1943 "movd 3(%1, %%ebx), %%mm3 \n\t" | |
1944 "punpcklbw %%mm7, %%mm0 \n\t" | |
1945 "punpcklbw %%mm7, %%mm1 \n\t" | |
1946 "punpcklbw %%mm7, %%mm2 \n\t" | |
1947 "punpcklbw %%mm7, %%mm3 \n\t" | |
1948 "paddw %%mm1, %%mm0 \n\t" | |
1949 "paddw %%mm3, %%mm2 \n\t" | |
1950 "paddw %%mm2, %%mm0 \n\t" | |
1951 "movd 6(%0, %%ebx), %%mm4 \n\t" | |
1952 "movd 6(%1, %%ebx), %%mm1 \n\t" | |
1953 "movd 9(%0, %%ebx), %%mm2 \n\t" | |
1954 "movd 9(%1, %%ebx), %%mm3 \n\t" | |
1955 "punpcklbw %%mm7, %%mm4 \n\t" | |
1956 "punpcklbw %%mm7, %%mm1 \n\t" | |
1957 "punpcklbw %%mm7, %%mm2 \n\t" | |
1958 "punpcklbw %%mm7, %%mm3 \n\t" | |
1959 "paddw %%mm1, %%mm4 \n\t" | |
1960 "paddw %%mm3, %%mm2 \n\t" | |
1961 "paddw %%mm4, %%mm2 \n\t" | |
1962 "psrlw $2, %%mm0 \n\t" | |
1963 "psrlw $2, %%mm2 \n\t" | |
1964 #endif | |
4923 | 1965 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
1966 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4622 | 1967 |
1968 "pmaddwd %%mm0, %%mm1 \n\t" | |
1969 "pmaddwd %%mm2, %%mm3 \n\t" | |
1970 "pmaddwd %%mm6, %%mm0 \n\t" | |
1971 "pmaddwd %%mm6, %%mm2 \n\t" | |
1972 #ifndef FAST_BGR2YV12 | |
1973 "psrad $8, %%mm0 \n\t" | |
1974 "psrad $8, %%mm1 \n\t" | |
1975 "psrad $8, %%mm2 \n\t" | |
1976 "psrad $8, %%mm3 \n\t" | |
1977 #endif | |
1978 "packssdw %%mm2, %%mm0 \n\t" | |
1979 "packssdw %%mm3, %%mm1 \n\t" | |
1980 "pmaddwd %%mm5, %%mm0 \n\t" | |
1981 "pmaddwd %%mm5, %%mm1 \n\t" | |
1982 "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 | |
1983 "psraw $7, %%mm0 \n\t" | |
1984 | |
1985 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) | |
1986 "movq 12(%0, %%ebx), %%mm4 \n\t" | |
1987 "movq 12(%1, %%ebx), %%mm1 \n\t" | |
1988 "movq 18(%0, %%ebx), %%mm2 \n\t" | |
1989 "movq 18(%1, %%ebx), %%mm3 \n\t" | |
1990 PAVGB" %%mm1, %%mm4 \n\t" | |
1991 PAVGB" %%mm3, %%mm2 \n\t" | |
1992 "movq %%mm4, %%mm1 \n\t" | |
1993 "movq %%mm2, %%mm3 \n\t" | |
1994 "psrlq $24, %%mm4 \n\t" | |
1995 "psrlq $24, %%mm2 \n\t" | |
1996 PAVGB" %%mm1, %%mm4 \n\t" | |
1997 PAVGB" %%mm3, %%mm2 \n\t" | |
1998 "punpcklbw %%mm7, %%mm4 \n\t" | |
1999 "punpcklbw %%mm7, %%mm2 \n\t" | |
2000 #else | |
2001 "movd 12(%0, %%ebx), %%mm4 \n\t" | |
2002 "movd 12(%1, %%ebx), %%mm1 \n\t" | |
2003 "movd 15(%0, %%ebx), %%mm2 \n\t" | |
2004 "movd 15(%1, %%ebx), %%mm3 \n\t" | |
2005 "punpcklbw %%mm7, %%mm4 \n\t" | |
2006 "punpcklbw %%mm7, %%mm1 \n\t" | |
2007 "punpcklbw %%mm7, %%mm2 \n\t" | |
2008 "punpcklbw %%mm7, %%mm3 \n\t" | |
2009 "paddw %%mm1, %%mm4 \n\t" | |
2010 "paddw %%mm3, %%mm2 \n\t" | |
2011 "paddw %%mm2, %%mm4 \n\t" | |
2012 "movd 18(%0, %%ebx), %%mm5 \n\t" | |
2013 "movd 18(%1, %%ebx), %%mm1 \n\t" | |
2014 "movd 21(%0, %%ebx), %%mm2 \n\t" | |
2015 "movd 21(%1, %%ebx), %%mm3 \n\t" | |
2016 "punpcklbw %%mm7, %%mm5 \n\t" | |
2017 "punpcklbw %%mm7, %%mm1 \n\t" | |
2018 "punpcklbw %%mm7, %%mm2 \n\t" | |
2019 "punpcklbw %%mm7, %%mm3 \n\t" | |
2020 "paddw %%mm1, %%mm5 \n\t" | |
2021 "paddw %%mm3, %%mm2 \n\t" | |
2022 "paddw %%mm5, %%mm2 \n\t" | |
4923 | 2023 "movq "MANGLE(w1111)", %%mm5 \n\t" |
4622 | 2024 "psrlw $2, %%mm4 \n\t" |
2025 "psrlw $2, %%mm2 \n\t" | |
2026 #endif | |
4923 | 2027 "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" |
2028 "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" | |
4622 | 2029 |
2030 "pmaddwd %%mm4, %%mm1 \n\t" | |
2031 "pmaddwd %%mm2, %%mm3 \n\t" | |
2032 "pmaddwd %%mm6, %%mm4 \n\t" | |
2033 "pmaddwd %%mm6, %%mm2 \n\t" | |
2034 #ifndef FAST_BGR2YV12 | |
2035 "psrad $8, %%mm4 \n\t" | |
2036 "psrad $8, %%mm1 \n\t" | |
2037 "psrad $8, %%mm2 \n\t" | |
2038 "psrad $8, %%mm3 \n\t" | |
2039 #endif | |
2040 "packssdw %%mm2, %%mm4 \n\t" | |
2041 "packssdw %%mm3, %%mm1 \n\t" | |
2042 "pmaddwd %%mm5, %%mm4 \n\t" | |
2043 "pmaddwd %%mm5, %%mm1 \n\t" | |
2044 "addl $24, %%ebx \n\t" | |
2045 "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 | |
2046 "psraw $7, %%mm4 \n\t" | |
2047 | |
2048 "movq %%mm0, %%mm1 \n\t" | |
2049 "punpckldq %%mm4, %%mm0 \n\t" | |
2050 "punpckhdq %%mm4, %%mm1 \n\t" | |
2051 "packsswb %%mm1, %%mm0 \n\t" | |
4923 | 2052 "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" |
4622 | 2053 |
2054 "movd %%mm0, (%2, %%eax) \n\t" | |
2055 "punpckhdq %%mm0, %%mm0 \n\t" | |
2056 "movd %%mm0, (%3, %%eax) \n\t" | |
2057 "addl $4, %%eax \n\t" | |
2058 " js 1b \n\t" | |
2059 : : "r" (src+width*6), "r" (src+srcStride+width*6), "r" (udst+width), "r" (vdst+width), "g" (-width) | |
2060 : "%eax", "%ebx" | |
2061 ); | |
2062 | |
2063 udst += chromStride; | |
2064 vdst += chromStride; | |
2065 src += srcStride*2; | |
2066 } | |
2067 | |
2068 asm volatile( EMMS" \n\t" | |
2069 SFENCE" \n\t" | |
2070 :::"memory"); | |
2071 #else | |
2072 y=0; | |
2073 #endif | |
2074 for(; y<height; y+=2) | |
3132 | 2075 { |
6492 | 2076 unsigned i; |
3132 | 2077 for(i=0; i<chromWidth; i++) |
2078 { | |
2079 unsigned int b= src[6*i+0]; | |
2080 unsigned int g= src[6*i+1]; | |
2081 unsigned int r= src[6*i+2]; | |
2801 | 2082 |
3633 | 2083 unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
2084 unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; | |
2085 unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; | |
3132 | 2086 |
2087 udst[i] = U; | |
2088 vdst[i] = V; | |
2089 ydst[2*i] = Y; | |
2090 | |
2091 b= src[6*i+3]; | |
2092 g= src[6*i+4]; | |
2093 r= src[6*i+5]; | |
2094 | |
3633 | 2095 Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
3132 | 2096 ydst[2*i+1] = Y; |
2097 } | |
2098 ydst += lumStride; | |
2099 src += srcStride; | |
2100 | |
2101 for(i=0; i<chromWidth; i++) | |
2102 { | |
2103 unsigned int b= src[6*i+0]; | |
2104 unsigned int g= src[6*i+1]; | |
2105 unsigned int r= src[6*i+2]; | |
2106 | |
3633 | 2107 unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
3132 | 2108 |
2109 ydst[2*i] = Y; | |
2110 | |
2111 b= src[6*i+3]; | |
2112 g= src[6*i+4]; | |
2113 r= src[6*i+5]; | |
2114 | |
3633 | 2115 Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; |
3132 | 2116 ydst[2*i+1] = Y; |
2117 } | |
2118 udst += chromStride; | |
2119 vdst += chromStride; | |
2120 ydst += lumStride; | |
2121 src += srcStride; | |
2122 } | |
2123 } | |
5337 | 2124 |
2125 void RENAME(interleaveBytes)(uint8_t *src1, uint8_t *src2, uint8_t *dest, | |
6492 | 2126 unsigned width, unsigned height, unsigned src1Stride, |
2127 unsigned src2Stride, unsigned dstStride){ | |
2128 unsigned h; | |
5337 | 2129 |
2130 for(h=0; h < height; h++) | |
2131 { | |
6492 | 2132 unsigned w; |
5337 | 2133 |
2134 #ifdef HAVE_MMX | |
2135 #ifdef HAVE_SSE2 | |
2136 asm( | |
2137 "xorl %%eax, %%eax \n\t" | |
2138 "1: \n\t" | |
2139 PREFETCH" 64(%1, %%eax) \n\t" | |
2140 PREFETCH" 64(%2, %%eax) \n\t" | |
2141 "movdqa (%1, %%eax), %%xmm0 \n\t" | |
2142 "movdqa (%1, %%eax), %%xmm1 \n\t" | |
2143 "movdqa (%2, %%eax), %%xmm2 \n\t" | |
2144 "punpcklbw %%xmm2, %%xmm0 \n\t" | |
2145 "punpckhbw %%xmm2, %%xmm1 \n\t" | |
2146 "movntdq %%xmm0, (%0, %%eax, 2) \n\t" | |
2147 "movntdq %%xmm1, 16(%0, %%eax, 2)\n\t" | |
2148 "addl $16, %%eax \n\t" | |
2149 "cmpl %3, %%eax \n\t" | |
2150 " jb 1b \n\t" | |
2151 ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15) | |
2152 : "memory", "%eax" | |
2153 ); | |
2154 #else | |
2155 asm( | |
2156 "xorl %%eax, %%eax \n\t" | |
2157 "1: \n\t" | |
2158 PREFETCH" 64(%1, %%eax) \n\t" | |
2159 PREFETCH" 64(%2, %%eax) \n\t" | |
2160 "movq (%1, %%eax), %%mm0 \n\t" | |
2161 "movq 8(%1, %%eax), %%mm2 \n\t" | |
2162 "movq %%mm0, %%mm1 \n\t" | |
2163 "movq %%mm2, %%mm3 \n\t" | |
2164 "movq (%2, %%eax), %%mm4 \n\t" | |
2165 "movq 8(%2, %%eax), %%mm5 \n\t" | |
2166 "punpcklbw %%mm4, %%mm0 \n\t" | |
2167 "punpckhbw %%mm4, %%mm1 \n\t" | |
2168 "punpcklbw %%mm5, %%mm2 \n\t" | |
2169 "punpckhbw %%mm5, %%mm3 \n\t" | |
2170 MOVNTQ" %%mm0, (%0, %%eax, 2) \n\t" | |
2171 MOVNTQ" %%mm1, 8(%0, %%eax, 2) \n\t" | |
2172 MOVNTQ" %%mm2, 16(%0, %%eax, 2) \n\t" | |
2173 MOVNTQ" %%mm3, 24(%0, %%eax, 2) \n\t" | |
2174 "addl $16, %%eax \n\t" | |
2175 "cmpl %3, %%eax \n\t" | |
2176 " jb 1b \n\t" | |
2177 ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15) | |
2178 : "memory", "%eax" | |
2179 ); | |
2180 #endif | |
2181 for(w= (width&(~15)); w < width; w++) | |
2182 { | |
2183 dest[2*w+0] = src1[w]; | |
2184 dest[2*w+1] = src2[w]; | |
2185 } | |
2186 #else | |
2187 for(w=0; w < width; w++) | |
2188 { | |
2189 dest[2*w+0] = src1[w]; | |
2190 dest[2*w+1] = src2[w]; | |
2191 } | |
2192 #endif | |
2193 dest += dstStride; | |
2194 src1 += src1Stride; | |
2195 src2 += src2Stride; | |
2196 } | |
2197 #ifdef HAVE_MMX | |
2198 asm( | |
2199 EMMS" \n\t" | |
2200 SFENCE" \n\t" | |
2201 ::: "memory" | |
2202 ); | |
2203 #endif | |
2204 } | |
6606
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2205 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2206 static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2207 uint8_t *dst1, uint8_t *dst2, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2208 unsigned width, unsigned height, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2209 unsigned srcStride1, unsigned srcStride2, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2210 unsigned dstStride1, unsigned dstStride2) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2211 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2212 unsigned y,x,w,h; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2213 w=width/2; h=height/2; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2214 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2215 asm volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2216 PREFETCH" %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2217 PREFETCH" %1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2218 ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2219 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2220 for(y=0;y<h;y++){ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2221 const uint8_t* s1=src1+srcStride1*(y>>1); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2222 uint8_t* d=dst1+dstStride1*y; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2223 x=0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2224 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2225 if(w > 32) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2226 for(;x<w;x+=32) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2227 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2228 asm volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2229 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2230 "movq %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2231 "movq 8%1, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2232 "movq 16%1, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2233 "movq 24%1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2234 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2235 "movq %%mm2, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2236 "movq %%mm4, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2237 "movq %%mm6, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2238 "punpcklbw %%mm0, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2239 "punpckhbw %%mm1, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2240 "punpcklbw %%mm2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2241 "punpckhbw %%mm3, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2242 "punpcklbw %%mm4, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2243 "punpckhbw %%mm5, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2244 "punpcklbw %%mm6, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2245 "punpckhbw %%mm7, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2246 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2247 MOVNTQ" %%mm1, 8%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2248 MOVNTQ" %%mm2, 16%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2249 MOVNTQ" %%mm3, 24%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2250 MOVNTQ" %%mm4, 32%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2251 MOVNTQ" %%mm5, 40%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2252 MOVNTQ" %%mm6, 48%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2253 MOVNTQ" %%mm7, 56%0" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2254 :"=m"(d[2*x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2255 :"m"(s1[x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2256 :"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2257 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2258 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2259 for(;x<w;x++) d[2*x]=d[2*x+1]=s1[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2260 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2261 for(y=0;y<h;y++){ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2262 const uint8_t* s2=src2+srcStride2*(y>>1); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2263 uint8_t* d=dst2+dstStride2*y; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2264 x=0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2265 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2266 if(w > 32) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2267 for(;x<w;x+=32) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2268 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2269 asm volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2270 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2271 "movq %1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2272 "movq 8%1, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2273 "movq 16%1, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2274 "movq 24%1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2275 "movq %%mm0, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2276 "movq %%mm2, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2277 "movq %%mm4, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2278 "movq %%mm6, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2279 "punpcklbw %%mm0, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2280 "punpckhbw %%mm1, %%mm1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2281 "punpcklbw %%mm2, %%mm2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2282 "punpckhbw %%mm3, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2283 "punpcklbw %%mm4, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2284 "punpckhbw %%mm5, %%mm5\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2285 "punpcklbw %%mm6, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2286 "punpckhbw %%mm7, %%mm7\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2287 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2288 MOVNTQ" %%mm1, 8%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2289 MOVNTQ" %%mm2, 16%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2290 MOVNTQ" %%mm3, 24%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2291 MOVNTQ" %%mm4, 32%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2292 MOVNTQ" %%mm5, 40%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2293 MOVNTQ" %%mm6, 48%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2294 MOVNTQ" %%mm7, 56%0" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2295 :"=m"(d[2*x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2296 :"m"(s2[x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2297 :"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2298 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2299 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2300 for(;x<w;x++) d[2*x]=d[2*x+1]=s2[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2301 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2302 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2303 asm( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2304 EMMS" \n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2305 SFENCE" \n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2306 ::: "memory" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2307 ); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2308 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2309 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2310 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2311 static inline void RENAME(yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2312 uint8_t *dst, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2313 unsigned width, unsigned height, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2314 unsigned srcStride1, unsigned srcStride2, |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2315 unsigned srcStride3, unsigned dstStride) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2316 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2317 unsigned y,x,x2,w,h; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2318 w=width/2; h=height; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2319 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2320 asm volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2321 PREFETCH" %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2322 PREFETCH" %1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2323 PREFETCH" %2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2324 ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)),"m"(*(src3+srcStride3)):"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2325 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2326 for(y=0;y<h;y++){ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2327 const uint8_t* yp=src1+srcStride1*y; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2328 const uint8_t* up=src2+srcStride2*(y>>2); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2329 const uint8_t* vp=src3+srcStride3*(y>>2); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2330 uint8_t* d=dst+dstStride*y; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2331 x2=0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2332 x=0; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2333 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2334 for(;x<w;x+=8,x2+=32) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2335 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2336 asm volatile( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2337 PREFETCH" 32%1\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2338 PREFETCH" 32%2\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2339 PREFETCH" 32%3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2340 "movq %1, %%mm0\n\t" /* Y0Y1Y2Y3Y4Y5Y6Y7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2341 "movq %2, %%mm1\n\t" /* U0U1U2U3U4U5U6U7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2342 "movq %3, %%mm2\n\t" /* V0V1V2V3V4V5V6V7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2343 "movq %%mm0, %%mm3\n\t" /* Y0Y1Y2Y3Y4Y5Y6Y7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2344 "movq %%mm1, %%mm4\n\t" /* U0U1U2U3U4U5U6U7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2345 "movq %%mm2, %%mm5\n\t" /* V0V1V2V3V4V5V6V7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2346 "punpcklbw %%mm1, %%mm1\n\t" /* U0U0 U1U1 U2U2 U3U3 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2347 "punpcklbw %%mm2, %%mm2\n\t" /* V0V0 V1V1 V2V2 V3V3 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2348 "punpckhbw %%mm4, %%mm4\n\t" /* U4U4 U5U5 U6U6 U7U7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2349 "punpckhbw %%mm5, %%mm5\n\t" /* V4V4 V5V5 V6V6 V7V7 */ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2350 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2351 "movq %%mm1, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2352 "punpcklbw %%mm2, %%mm1\n\t" /* U0V0 U0V0 U1V1 U1V1*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2353 "punpcklbw %%mm1, %%mm0\n\t" /* Y0U0 Y1V0 Y2U0 Y3V0*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2354 "punpckhbw %%mm1, %%mm3\n\t" /* Y4U1 Y5V1 Y6U1 Y7V1*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2355 MOVNTQ" %%mm0, %0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2356 MOVNTQ" %%mm3, 8%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2357 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2358 "punpckhbw %%mm2, %%mm6\n\t" /* U2V2 U2V2 U3V3 U3V3*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2359 "movq 8%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2360 "movq %%mm0, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2361 "punpcklbw %%mm6, %%mm0\n\t" /* Y U2 Y V2 Y U2 Y V2*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2362 "punpckhbw %%mm6, %%mm3\n\t" /* Y U3 Y V3 Y U3 Y V3*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2363 MOVNTQ" %%mm0, 16%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2364 MOVNTQ" %%mm3, 24%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2365 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2366 "movq %%mm4, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2367 "movq 16%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2368 "movq %%mm0, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2369 "punpcklbw %%mm5, %%mm4\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2370 "punpcklbw %%mm4, %%mm0\n\t" /* Y U4 Y V4 Y U4 Y V4*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2371 "punpckhbw %%mm4, %%mm3\n\t" /* Y U5 Y V5 Y U5 Y V5*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2372 MOVNTQ" %%mm0, 32%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2373 MOVNTQ" %%mm3, 40%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2374 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2375 "punpckhbw %%mm5, %%mm6\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2376 "movq 24%1, %%mm0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2377 "movq %%mm0, %%mm3\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2378 "punpcklbw %%mm6, %%mm0\n\t" /* Y U6 Y V6 Y U6 Y V6*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2379 "punpckhbw %%mm6, %%mm3\n\t" /* Y U7 Y V7 Y U7 Y V7*/ |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2380 MOVNTQ" %%mm0, 48%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2381 MOVNTQ" %%mm3, 56%0\n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2382 |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2383 :"=m"(d[8*x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2384 :"m"(yp[x2]),"m"(up[x]),"m"(vp[x]) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2385 :"memory"); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2386 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2387 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2388 for(;x<w;x++,x2+=4) |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2389 { |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2390 d[8*x+0]=yp[x2]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2391 d[8*x+1]=up[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2392 d[8*x+2]=yp[x2+1]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2393 d[8*x+3]=vp[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2394 d[8*x+4]=yp[x2+2]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2395 d[8*x+5]=up[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2396 d[8*x+6]=yp[x2+3]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2397 d[8*x+7]=vp[x]; |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2398 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2399 } |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2400 #ifdef HAVE_MMX |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2401 asm( |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2402 EMMS" \n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2403 SFENCE" \n\t" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2404 ::: "memory" |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2405 ); |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2406 #endif |
50b5d8367318
merging changes from mplayerxp (rgb2rgb*.{c,h} only)
michael
parents:
6605
diff
changeset
|
2407 } |