Mercurial > mplayer.hg
annotate liba52/resample_mmx.c @ 3599:2141db140d84
nop_steraming fixed
author | arpi |
---|---|
date | Wed, 19 Dec 2001 01:59:25 +0000 |
parents | 79759c05911e |
children | e22ff7ebdc05 |
rev | line source |
---|---|
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
1 // this code come from a52dec/libao/audio_out_oss.c |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
2 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
3 // FIXME FIXME FIXME |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
4 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
5 // a52_resample_init should find the requested converter (from type flags -> |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
6 // given number of channels) and set up some function pointers... |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
7 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
8 // a52_resample() should do the conversion. |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
9 |
3569 | 10 // MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL) |
11 | |
12 /* optimization TODO / NOTES | |
13 movntq is slightly faster (0.5% with the current test.c benchmark) | |
14 (but thats just test.c so that needs to be testd in reallity) | |
15 and it would mean (C / MMX2 / MMX / 3DNOW) versions | |
16 */ | |
17 | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
18 #include <inttypes.h> |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
19 #include "a52.h" |
3567 | 20 #include "../config.h" |
21 | |
22 #ifdef HAVE_MMX | |
3574 | 23 static uint64_t __attribute__((aligned(8))) magicF2W= 0x43c0000043c00000LL; |
24 static uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000LL; | |
25 static uint64_t __attribute__((aligned(8))) wm0101= 0x0000FFFF0000FFFFLL; | |
26 static uint64_t __attribute__((aligned(8))) wm1100= 0xFFFFFFFF00000000LL; | |
3567 | 27 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
28 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
29 static inline int16_t convert (int32_t i) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
30 { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
31 if (i > 0x43c07fff) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
32 return 32767; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
33 else if (i < 0x43bf8000) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
34 return -32768; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
35 else |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
36 return i - 0x43c00000; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
37 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
38 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
39 static int chans=2; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
40 static int flags=0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
41 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
42 void a52_resample_init(int _flags,int _chans){ |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
43 chans=_chans; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
44 flags=_flags; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
45 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
46 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
47 int a52_resample(float * _f, int16_t * s16) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
48 { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
49 int i; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
50 int32_t * f = (int32_t *) _f; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
51 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
52 switch (flags) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
53 case A52_MONO: |
3574 | 54 #ifdef HAVE_MMX |
55 asm volatile( | |
56 "movl $-512, %%esi \n\t" | |
57 "movq magicF2W, %%mm7 \n\t" | |
58 "movq wm1100, %%mm3 \n\t" | |
59 "movq wm0101, %%mm4 \n\t" | |
60 "movq wm1010, %%mm5 \n\t" | |
61 "pxor %%mm6, %%mm6 \n\t" | |
62 "1: \n\t" | |
63 "movq (%1, %%esi, 2), %%mm0 \n\t" | |
64 "movq 8(%1, %%esi, 2), %%mm1 \n\t" | |
65 "leal (%%esi, %%esi, 4), %%edi \n\t" | |
66 "psubd %%mm7, %%mm0 \n\t" | |
67 "psubd %%mm7, %%mm1 \n\t" | |
68 "packssdw %%mm1, %%mm0 \n\t" | |
69 "movq %%mm0, %%mm1 \n\t" | |
70 "pand %%mm4, %%mm0 \n\t" | |
71 "pand %%mm5, %%mm1 \n\t" | |
72 "movq %%mm6, (%0, %%edi) \n\t" // 0 0 0 0 | |
73 "movd %%mm0, 8(%0, %%edi) \n\t" // A 0 | |
74 "pand %%mm3, %%mm0 \n\t" | |
75 "movd %%mm6, 12(%0, %%edi) \n\t" // 0 0 | |
76 "movd %%mm1, 16(%0, %%edi) \n\t" // 0 B | |
77 "pand %%mm3, %%mm1 \n\t" | |
78 "movd %%mm6, 20(%0, %%edi) \n\t" // 0 0 | |
79 "movq %%mm0, 24(%0, %%edi) \n\t" // 0 0 C 0 | |
80 "movq %%mm1, 32(%0, %%edi) \n\t" // 0 0 0 B | |
81 "addl $8, %%esi \n\t" | |
82 " jnz 1b \n\t" | |
83 "emms \n\t" | |
84 :: "r" (s16+1280), "r" (f+256) | |
85 :"%esi", "%edi", "memory" | |
86 ); | |
87 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
88 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
89 s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
90 s16[5*i+4] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
91 } |
3574 | 92 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
93 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
94 case A52_CHANNEL: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
95 case A52_STEREO: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
96 case A52_DOLBY: |
3567 | 97 /* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it |
98 #ifdef HAVE_SSE | |
99 asm volatile( | |
100 "movl $-1024, %%esi \n\t" | |
101 "1: \n\t" | |
102 "cvtps2pi (%1, %%esi), %%mm0 \n\t" | |
103 "cvtps2pi 1024(%1, %%esi), %%mm2\n\t" | |
104 "movq %%mm0, %%mm1 \n\t" | |
105 "punpcklwd %%mm2, %%mm0 \n\t" | |
106 "punpckhwd %%mm2, %%mm1 \n\t" | |
107 "movq %%mm0, (%0, %%esi) \n\t" | |
108 "movq %%mm1, 8(%0, %%esi) \n\t" | |
109 "addl $16, %%esi \n\t" | |
110 " jnz 1b \n\t" | |
111 "emms \n\t" | |
112 :: "r" (s16+512), "r" (f+256) | |
113 :"%esi", "memory" | |
114 );*/ | |
115 #ifdef HAVE_MMX | |
116 asm volatile( | |
117 "movl $-1024, %%esi \n\t" | |
118 "movq magicF2W, %%mm7 \n\t" | |
119 "1: \n\t" | |
120 "movq (%1, %%esi), %%mm0 \n\t" | |
121 "movq 8(%1, %%esi), %%mm1 \n\t" | |
122 "movq 1024(%1, %%esi), %%mm2 \n\t" | |
123 "movq 1032(%1, %%esi), %%mm3 \n\t" | |
124 "psubd %%mm7, %%mm0 \n\t" | |
125 "psubd %%mm7, %%mm1 \n\t" | |
126 "psubd %%mm7, %%mm2 \n\t" | |
127 "psubd %%mm7, %%mm3 \n\t" | |
128 "packssdw %%mm1, %%mm0 \n\t" | |
129 "packssdw %%mm3, %%mm2 \n\t" | |
130 "movq %%mm0, %%mm1 \n\t" | |
131 "punpcklwd %%mm2, %%mm0 \n\t" | |
132 "punpckhwd %%mm2, %%mm1 \n\t" | |
133 "movq %%mm0, (%0, %%esi) \n\t" | |
134 "movq %%mm1, 8(%0, %%esi) \n\t" | |
135 "addl $16, %%esi \n\t" | |
136 " jnz 1b \n\t" | |
137 "emms \n\t" | |
138 :: "r" (s16+512), "r" (f+256) | |
139 :"%esi", "memory" | |
140 ); | |
141 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
142 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
143 s16[2*i] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
144 s16[2*i+1] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
145 } |
3567 | 146 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
147 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
148 case A52_3F: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
149 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
150 s16[5*i] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
151 s16[5*i+1] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
152 s16[5*i+2] = s16[5*i+3] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
153 s16[5*i+4] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
154 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
155 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
156 case A52_2F2R: |
3569 | 157 #ifdef HAVE_MMX |
158 asm volatile( | |
159 "movl $-1024, %%esi \n\t" | |
160 "movq magicF2W, %%mm7 \n\t" | |
161 "1: \n\t" | |
162 "movq (%1, %%esi), %%mm0 \n\t" | |
163 "movq 8(%1, %%esi), %%mm1 \n\t" | |
164 "movq 1024(%1, %%esi), %%mm2 \n\t" | |
165 "movq 1032(%1, %%esi), %%mm3 \n\t" | |
166 "psubd %%mm7, %%mm0 \n\t" | |
167 "psubd %%mm7, %%mm1 \n\t" | |
168 "psubd %%mm7, %%mm2 \n\t" | |
169 "psubd %%mm7, %%mm3 \n\t" | |
170 "packssdw %%mm1, %%mm0 \n\t" | |
171 "packssdw %%mm3, %%mm2 \n\t" | |
172 "movq 2048(%1, %%esi), %%mm3 \n\t" | |
173 "movq 2056(%1, %%esi), %%mm4 \n\t" | |
174 "movq 3072(%1, %%esi), %%mm5 \n\t" | |
175 "movq 3080(%1, %%esi), %%mm6 \n\t" | |
176 "psubd %%mm7, %%mm3 \n\t" | |
177 "psubd %%mm7, %%mm4 \n\t" | |
178 "psubd %%mm7, %%mm5 \n\t" | |
179 "psubd %%mm7, %%mm6 \n\t" | |
180 "packssdw %%mm4, %%mm3 \n\t" | |
181 "packssdw %%mm6, %%mm5 \n\t" | |
182 "movq %%mm0, %%mm1 \n\t" | |
183 "movq %%mm3, %%mm4 \n\t" | |
184 "punpcklwd %%mm2, %%mm0 \n\t" | |
185 "punpckhwd %%mm2, %%mm1 \n\t" | |
186 "punpcklwd %%mm5, %%mm3 \n\t" | |
187 "punpckhwd %%mm5, %%mm4 \n\t" | |
188 "movq %%mm0, %%mm2 \n\t" | |
189 "movq %%mm1, %%mm5 \n\t" | |
190 "punpckldq %%mm3, %%mm0 \n\t" | |
191 "punpckhdq %%mm3, %%mm2 \n\t" | |
192 "punpckldq %%mm4, %%mm1 \n\t" | |
193 "punpckhdq %%mm4, %%mm5 \n\t" | |
194 "movq %%mm0, (%0, %%esi,2) \n\t" | |
195 "movq %%mm2, 8(%0, %%esi,2) \n\t" | |
196 "movq %%mm1, 16(%0, %%esi,2) \n\t" | |
197 "movq %%mm5, 24(%0, %%esi,2) \n\t" | |
198 "addl $16, %%esi \n\t" | |
199 " jnz 1b \n\t" | |
200 "emms \n\t" | |
201 :: "r" (s16+1024), "r" (f+256) | |
202 :"%esi", "memory" | |
203 ); | |
204 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
205 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
206 s16[4*i] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
207 s16[4*i+1] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
208 s16[4*i+2] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
209 s16[4*i+3] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
210 } |
3569 | 211 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
212 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
213 case A52_3F2R: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
214 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
215 s16[5*i] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
216 s16[5*i+1] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
217 s16[5*i+2] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
218 s16[5*i+3] = convert (f[i+1024]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
219 s16[5*i+4] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
220 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
221 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
222 case A52_MONO | A52_LFE: |
3569 | 223 #ifdef HAVE_MMX |
224 asm volatile( | |
225 "movl $-1024, %%esi \n\t" | |
226 "movq magicF2W, %%mm7 \n\t" | |
227 "pxor %%mm6, %%mm6 \n\t" | |
228 "1: \n\t" | |
229 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
230 "movq 1032(%1, %%esi), %%mm1 \n\t" | |
231 "movq (%1, %%esi), %%mm2 \n\t" | |
232 "movq 8(%1, %%esi), %%mm3 \n\t" | |
233 "psubd %%mm7, %%mm0 \n\t" | |
234 "psubd %%mm7, %%mm1 \n\t" | |
235 "psubd %%mm7, %%mm2 \n\t" | |
236 "psubd %%mm7, %%mm3 \n\t" | |
237 "packssdw %%mm1, %%mm0 \n\t" | |
238 "packssdw %%mm3, %%mm2 \n\t" | |
239 "movq %%mm0, %%mm1 \n\t" | |
240 "punpcklwd %%mm2, %%mm0 \n\t" | |
241 "punpckhwd %%mm2, %%mm1 \n\t" | |
242 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
243 "movq %%mm6, (%0, %%edi) \n\t" | |
244 "movd %%mm0, 8(%0, %%edi) \n\t" | |
245 "punpckhdq %%mm0, %%mm0 \n\t" | |
246 "movq %%mm6, 12(%0, %%edi) \n\t" | |
247 "movd %%mm0, 20(%0, %%edi) \n\t" | |
248 "movq %%mm6, 24(%0, %%edi) \n\t" | |
249 "movd %%mm1, 32(%0, %%edi) \n\t" | |
250 "punpckhdq %%mm1, %%mm1 \n\t" | |
251 "movq %%mm6, 36(%0, %%edi) \n\t" | |
252 "movd %%mm1, 44(%0, %%edi) \n\t" | |
253 "addl $16, %%esi \n\t" | |
254 " jnz 1b \n\t" | |
255 "emms \n\t" | |
256 :: "r" (s16+1536), "r" (f+256) | |
257 :"%esi", "%edi", "memory" | |
258 ); | |
259 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
260 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
261 s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
262 s16[6*i+4] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
263 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
264 } |
3569 | 265 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
266 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
267 case A52_CHANNEL | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
268 case A52_STEREO | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
269 case A52_DOLBY | A52_LFE: |
3576 | 270 #ifdef HAVE_MMX |
271 asm volatile( | |
272 "movl $-1024, %%esi \n\t" | |
273 "movq magicF2W, %%mm7 \n\t" | |
274 "pxor %%mm6, %%mm6 \n\t" | |
275 "1: \n\t" | |
276 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
277 "movq 2048(%1, %%esi), %%mm1 \n\t" | |
278 "movq (%1, %%esi), %%mm5 \n\t" | |
279 "psubd %%mm7, %%mm0 \n\t" | |
280 "psubd %%mm7, %%mm1 \n\t" | |
281 "psubd %%mm7, %%mm5 \n\t" | |
282 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
283 | |
284 "pxor %%mm4, %%mm4 \n\t" | |
285 "packssdw %%mm5, %%mm0 \n\t" // FfAa | |
286 "packssdw %%mm4, %%mm1 \n\t" // 00Bb | |
287 "punpckhwd %%mm0, %%mm4 \n\t" // F0f0 | |
288 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
289 "movq %%mm0, %%mm1 \n\t" // BAba | |
290 "punpckldq %%mm4, %%mm3 \n\t" // f0XX | |
291 "punpckldq %%mm6, %%mm0 \n\t" // 00ba | |
292 "punpckhdq %%mm1, %%mm3 \n\t" // BAf0 | |
293 | |
294 "movq %%mm0, (%0, %%edi) \n\t" // 00ba | |
295 "punpckhdq %%mm4, %%mm0 \n\t" // F000 | |
296 "movq %%mm3, 8(%0, %%edi) \n\t" // BAf0 | |
297 "movq %%mm0, 16(%0, %%edi) \n\t" // F000 | |
298 "addl $8, %%esi \n\t" | |
299 " jnz 1b \n\t" | |
300 "emms \n\t" | |
301 :: "r" (s16+1536), "r" (f+256) | |
302 :"%esi", "%edi", "memory" | |
303 ); | |
304 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
305 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
306 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
307 s16[6*i+1] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
308 s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
309 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
310 } |
3576 | 311 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
312 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
313 case A52_3F | A52_LFE: |
3578 | 314 #ifdef HAVE_MMX |
315 asm volatile( | |
316 "movl $-1024, %%esi \n\t" | |
317 "movq magicF2W, %%mm7 \n\t" | |
318 "pxor %%mm6, %%mm6 \n\t" | |
319 "1: \n\t" | |
320 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
321 "movq 3072(%1, %%esi), %%mm1 \n\t" | |
322 "movq 2048(%1, %%esi), %%mm4 \n\t" | |
323 "movq (%1, %%esi), %%mm5 \n\t" | |
324 "psubd %%mm7, %%mm0 \n\t" | |
325 "psubd %%mm7, %%mm1 \n\t" | |
326 "psubd %%mm7, %%mm4 \n\t" | |
327 "psubd %%mm7, %%mm5 \n\t" | |
328 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
329 | |
330 "packssdw %%mm4, %%mm0 \n\t" // EeAa | |
331 "packssdw %%mm5, %%mm1 \n\t" // FfBb | |
332 "movq %%mm0, %%mm2 \n\t" // EeAa | |
333 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
334 "punpckhwd %%mm1, %%mm2 \n\t" // FEfe | |
335 "movq %%mm0, %%mm1 \n\t" // BAba | |
336 "punpckldq %%mm6, %%mm0 \n\t" // 00ba | |
337 "punpckhdq %%mm1, %%mm1 \n\t" // BABA | |
338 | |
339 "movq %%mm0, (%0, %%edi) \n\t" | |
340 "punpckhdq %%mm2, %%mm0 \n\t" // FE00 | |
341 "punpckldq %%mm1, %%mm2 \n\t" // BAfe | |
342 "movq %%mm2, 8(%0, %%edi) \n\t" | |
343 "movq %%mm0, 16(%0, %%edi) \n\t" | |
344 "addl $8, %%esi \n\t" | |
345 " jnz 1b \n\t" | |
346 "emms \n\t" | |
347 :: "r" (s16+1536), "r" (f+256) | |
348 :"%esi", "%edi", "memory" | |
349 ); | |
350 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
351 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
352 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
353 s16[6*i+1] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
354 s16[6*i+2] = s16[6*i+3] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
355 s16[6*i+4] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
356 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
357 } |
3578 | 358 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
359 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
360 case A52_2F2R | A52_LFE: |
3577 | 361 #ifdef HAVE_MMX |
362 asm volatile( | |
363 "movl $-1024, %%esi \n\t" | |
364 "movq magicF2W, %%mm7 \n\t" | |
365 // "pxor %%mm6, %%mm6 \n\t" | |
366 "1: \n\t" | |
367 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
368 "movq 2048(%1, %%esi), %%mm1 \n\t" | |
369 "movq 3072(%1, %%esi), %%mm2 \n\t" | |
370 "movq 4096(%1, %%esi), %%mm3 \n\t" | |
371 "movq (%1, %%esi), %%mm5 \n\t" | |
372 "psubd %%mm7, %%mm0 \n\t" | |
373 "psubd %%mm7, %%mm1 \n\t" | |
374 "psubd %%mm7, %%mm2 \n\t" | |
375 "psubd %%mm7, %%mm3 \n\t" | |
376 "psubd %%mm7, %%mm5 \n\t" | |
377 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
378 | |
379 "packssdw %%mm2, %%mm0 \n\t" // CcAa | |
380 "packssdw %%mm3, %%mm1 \n\t" // DdBb | |
381 "packssdw %%mm5, %%mm5 \n\t" // FfFf | |
382 "movq %%mm0, %%mm2 \n\t" // CcAa | |
383 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
384 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc | |
385 "pxor %%mm4, %%mm4 \n\t" // 0000 | |
386 "punpcklwd %%mm5, %%mm4 \n\t" // F0f0 | |
387 "movq %%mm0, %%mm1 \n\t" // BAba | |
388 "movq %%mm4, %%mm3 \n\t" // F0f0 | |
389 "punpckldq %%mm2, %%mm0 \n\t" // dcba | |
390 "punpckhdq %%mm1, %%mm1 \n\t" // BABA | |
391 "punpckldq %%mm1, %%mm4 \n\t" // BAf0 | |
392 "punpckhdq %%mm3, %%mm2 \n\t" // F0DC | |
393 | |
394 "movq %%mm0, (%0, %%edi) \n\t" | |
395 "movq %%mm4, 8(%0, %%edi) \n\t" | |
396 "movq %%mm2, 16(%0, %%edi) \n\t" | |
397 "addl $8, %%esi \n\t" | |
398 " jnz 1b \n\t" | |
399 "emms \n\t" | |
400 :: "r" (s16+1536), "r" (f+256) | |
401 :"%esi", "%edi", "memory" | |
402 ); | |
403 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
404 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
405 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
406 s16[6*i+1] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
407 s16[6*i+2] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
408 s16[6*i+3] = convert (f[i+1024]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
409 s16[6*i+4] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
410 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
411 } |
3577 | 412 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
413 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
414 case A52_3F2R | A52_LFE: |
3575 | 415 #ifdef HAVE_MMX |
416 asm volatile( | |
417 "movl $-1024, %%esi \n\t" | |
418 "movq magicF2W, %%mm7 \n\t" | |
419 // "pxor %%mm6, %%mm6 \n\t" | |
420 "1: \n\t" | |
421 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
422 "movq 3072(%1, %%esi), %%mm1 \n\t" | |
423 "movq 4096(%1, %%esi), %%mm2 \n\t" | |
424 "movq 5120(%1, %%esi), %%mm3 \n\t" | |
425 "movq 2048(%1, %%esi), %%mm4 \n\t" | |
426 "movq (%1, %%esi), %%mm5 \n\t" | |
427 "psubd %%mm7, %%mm0 \n\t" | |
428 "psubd %%mm7, %%mm1 \n\t" | |
429 "psubd %%mm7, %%mm2 \n\t" | |
430 "psubd %%mm7, %%mm3 \n\t" | |
431 "psubd %%mm7, %%mm4 \n\t" | |
432 "psubd %%mm7, %%mm5 \n\t" | |
433 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
434 | |
435 "packssdw %%mm2, %%mm0 \n\t" // CcAa | |
436 "packssdw %%mm3, %%mm1 \n\t" // DdBb | |
437 "packssdw %%mm4, %%mm4 \n\t" // EeEe | |
438 "packssdw %%mm5, %%mm5 \n\t" // FfFf | |
439 "movq %%mm0, %%mm2 \n\t" // CcAa | |
440 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
441 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc | |
442 "punpcklwd %%mm5, %%mm4 \n\t" // FEfe | |
443 "movq %%mm0, %%mm1 \n\t" // BAba | |
444 "movq %%mm4, %%mm3 \n\t" // FEfe | |
445 "punpckldq %%mm2, %%mm0 \n\t" // dcba | |
446 "punpckhdq %%mm1, %%mm1 \n\t" // BABA | |
447 "punpckldq %%mm1, %%mm4 \n\t" // BAfe | |
448 "punpckhdq %%mm3, %%mm2 \n\t" // FEDC | |
449 | |
450 "movq %%mm0, (%0, %%edi) \n\t" | |
451 "movq %%mm4, 8(%0, %%edi) \n\t" | |
452 "movq %%mm2, 16(%0, %%edi) \n\t" | |
453 "addl $8, %%esi \n\t" | |
454 " jnz 1b \n\t" | |
455 "emms \n\t" | |
456 :: "r" (s16+1536), "r" (f+256) | |
457 :"%esi", "%edi", "memory" | |
458 ); | |
459 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
460 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
461 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
462 s16[6*i+1] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
463 s16[6*i+2] = convert (f[i+1024]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
464 s16[6*i+3] = convert (f[i+1280]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
465 s16[6*i+4] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
466 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
467 } |
3575 | 468 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
469 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
470 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
471 return chans*256; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
472 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
473 |