Mercurial > mplayer.hg
annotate liba52/resample.c @ 3577:6bf4dbfb941c
mmx opt
author | michael |
---|---|
date | Tue, 18 Dec 2001 02:48:14 +0000 |
parents | c282fd9e8534 |
children | 79759c05911e |
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: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
314 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
315 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
316 s16[6*i+1] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
317 s16[6*i+2] = s16[6*i+3] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
318 s16[6*i+4] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
319 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
320 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
321 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
322 case A52_2F2R | A52_LFE: |
3577 | 323 #ifdef HAVE_MMX |
324 asm volatile( | |
325 "movl $-1024, %%esi \n\t" | |
326 "movq magicF2W, %%mm7 \n\t" | |
327 // "pxor %%mm6, %%mm6 \n\t" | |
328 "1: \n\t" | |
329 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
330 "movq 2048(%1, %%esi), %%mm1 \n\t" | |
331 "movq 3072(%1, %%esi), %%mm2 \n\t" | |
332 "movq 4096(%1, %%esi), %%mm3 \n\t" | |
333 "movq (%1, %%esi), %%mm5 \n\t" | |
334 "psubd %%mm7, %%mm0 \n\t" | |
335 "psubd %%mm7, %%mm1 \n\t" | |
336 "psubd %%mm7, %%mm2 \n\t" | |
337 "psubd %%mm7, %%mm3 \n\t" | |
338 "psubd %%mm7, %%mm5 \n\t" | |
339 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
340 | |
341 "packssdw %%mm2, %%mm0 \n\t" // CcAa | |
342 "packssdw %%mm3, %%mm1 \n\t" // DdBb | |
343 "packssdw %%mm5, %%mm5 \n\t" // FfFf | |
344 "movq %%mm0, %%mm2 \n\t" // CcAa | |
345 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
346 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc | |
347 "pxor %%mm4, %%mm4 \n\t" // 0000 | |
348 "punpcklwd %%mm5, %%mm4 \n\t" // F0f0 | |
349 "movq %%mm0, %%mm1 \n\t" // BAba | |
350 "movq %%mm4, %%mm3 \n\t" // F0f0 | |
351 "punpckldq %%mm2, %%mm0 \n\t" // dcba | |
352 "punpckhdq %%mm1, %%mm1 \n\t" // BABA | |
353 "punpckldq %%mm1, %%mm4 \n\t" // BAf0 | |
354 "punpckhdq %%mm3, %%mm2 \n\t" // F0DC | |
355 | |
356 "movq %%mm0, (%0, %%edi) \n\t" | |
357 "movq %%mm4, 8(%0, %%edi) \n\t" | |
358 "movq %%mm2, 16(%0, %%edi) \n\t" | |
359 "addl $8, %%esi \n\t" | |
360 " jnz 1b \n\t" | |
361 "emms \n\t" | |
362 :: "r" (s16+1536), "r" (f+256) | |
363 :"%esi", "%edi", "memory" | |
364 ); | |
365 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
366 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
367 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
368 s16[6*i+1] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
369 s16[6*i+2] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
370 s16[6*i+3] = convert (f[i+1024]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
371 s16[6*i+4] = 0; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
372 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
373 } |
3577 | 374 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
375 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
376 case A52_3F2R | A52_LFE: |
3575 | 377 #ifdef HAVE_MMX |
378 asm volatile( | |
379 "movl $-1024, %%esi \n\t" | |
380 "movq magicF2W, %%mm7 \n\t" | |
381 // "pxor %%mm6, %%mm6 \n\t" | |
382 "1: \n\t" | |
383 "movq 1024(%1, %%esi), %%mm0 \n\t" | |
384 "movq 3072(%1, %%esi), %%mm1 \n\t" | |
385 "movq 4096(%1, %%esi), %%mm2 \n\t" | |
386 "movq 5120(%1, %%esi), %%mm3 \n\t" | |
387 "movq 2048(%1, %%esi), %%mm4 \n\t" | |
388 "movq (%1, %%esi), %%mm5 \n\t" | |
389 "psubd %%mm7, %%mm0 \n\t" | |
390 "psubd %%mm7, %%mm1 \n\t" | |
391 "psubd %%mm7, %%mm2 \n\t" | |
392 "psubd %%mm7, %%mm3 \n\t" | |
393 "psubd %%mm7, %%mm4 \n\t" | |
394 "psubd %%mm7, %%mm5 \n\t" | |
395 "leal (%%esi, %%esi, 2), %%edi \n\t" | |
396 | |
397 "packssdw %%mm2, %%mm0 \n\t" // CcAa | |
398 "packssdw %%mm3, %%mm1 \n\t" // DdBb | |
399 "packssdw %%mm4, %%mm4 \n\t" // EeEe | |
400 "packssdw %%mm5, %%mm5 \n\t" // FfFf | |
401 "movq %%mm0, %%mm2 \n\t" // CcAa | |
402 "punpcklwd %%mm1, %%mm0 \n\t" // BAba | |
403 "punpckhwd %%mm1, %%mm2 \n\t" // DCdc | |
404 "punpcklwd %%mm5, %%mm4 \n\t" // FEfe | |
405 "movq %%mm0, %%mm1 \n\t" // BAba | |
406 "movq %%mm4, %%mm3 \n\t" // FEfe | |
407 "punpckldq %%mm2, %%mm0 \n\t" // dcba | |
408 "punpckhdq %%mm1, %%mm1 \n\t" // BABA | |
409 "punpckldq %%mm1, %%mm4 \n\t" // BAfe | |
410 "punpckhdq %%mm3, %%mm2 \n\t" // FEDC | |
411 | |
412 "movq %%mm0, (%0, %%edi) \n\t" | |
413 "movq %%mm4, 8(%0, %%edi) \n\t" | |
414 "movq %%mm2, 16(%0, %%edi) \n\t" | |
415 "addl $8, %%esi \n\t" | |
416 " jnz 1b \n\t" | |
417 "emms \n\t" | |
418 :: "r" (s16+1536), "r" (f+256) | |
419 :"%esi", "%edi", "memory" | |
420 ); | |
421 #else | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
422 for (i = 0; i < 256; i++) { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
423 s16[6*i] = convert (f[i+256]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
424 s16[6*i+1] = convert (f[i+768]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
425 s16[6*i+2] = convert (f[i+1024]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
426 s16[6*i+3] = convert (f[i+1280]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
427 s16[6*i+4] = convert (f[i+512]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
428 s16[6*i+5] = convert (f[i]); |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
429 } |
3575 | 430 #endif |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
431 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
432 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
433 return chans*256; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
434 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
435 |