4497
|
1 /*
|
|
2 3DNOW and 3DNOWEX optimized IMDCT
|
|
3 Licence: GPL v2
|
|
4 Copyrights: Nick Kurshev
|
|
5 */
|
|
6
|
|
7 #undef FFT_4_3DNOW
|
|
8 #undef FFT_8_3DNOW
|
|
9 #undef FFT_ASMB_3DNOW
|
|
10 #undef FFT_ASMB16_3DNOW
|
|
11 #undef FFT_128P_3DNOW
|
|
12
|
|
13 #ifdef HAVE_3DNOWEX
|
|
14 #define FFT_4_3DNOW fft_4_3dnowex
|
|
15 #define FFT_8_3DNOW fft_8_3dnowex
|
|
16 #define FFT_ASMB_3DNOW fft_asmb_3dnowex
|
|
17 #define FFT_ASMB16_3DNOW fft_asmb16_3dnowex
|
|
18 #define FFT_128P_3DNOW fft_128p_3dnowex
|
|
19 #else
|
|
20 #define FFT_4_3DNOW fft_4_3dnow
|
|
21 #define FFT_8_3DNOW fft_8_3dnow
|
|
22 #define FFT_ASMB_3DNOW fft_asmb_3dnow
|
|
23 #define FFT_ASMB16_3DNOW fft_asmb16_3dnow
|
|
24 #define FFT_128P_3DNOW fft_128p_3dnow
|
|
25 #endif
|
|
26
|
|
27 static void FFT_4_3DNOW(complex_t *x)
|
|
28 {
|
|
29 /* delta_p = 1 here */
|
|
30 /* x[k] = sum_{i=0..3} x[i] * w^{i*k}, w=e^{-2*pi/4}
|
|
31 */
|
|
32 __asm__ __volatile__(
|
|
33 "movq 24(%1), %%mm3\n\t"
|
|
34 "movq 8(%1), %%mm1\n\t"
|
|
35 "pxor %2, %%mm3\n\t" /* mm3.re | -mm3.im */
|
|
36 "pxor %3, %%mm1\n\t" /* -mm1.re | mm1.im */
|
|
37 "pfadd %%mm1, %%mm3\n\t" /* vi.im = x[3].re - x[1].re; */
|
|
38 "movq %%mm3, %%mm4\n\t" /* vi.re =-x[3].im + x[1].im; mm4 = vi */
|
|
39 #ifdef HAVE_3DNOWEX
|
|
40 "pswapd %%mm4, %%mm4\n\t"
|
|
41 #else
|
|
42 "movq %%mm4, %%mm5\n\t"
|
|
43 "psrlq $32, %%mm4\n\t"
|
|
44 "punpckldq %%mm5, %%mm4\n\t"
|
|
45 #endif
|
|
46 "movq (%1), %%mm5\n\t" /* yb.re = x[0].re - x[2].re; */
|
|
47 "movq (%1), %%mm6\n\t" /* yt.re = x[0].re + x[2].re; */
|
|
48 "movq 24(%1), %%mm7\n\t" /* u.re = x[3].re + x[1].re; */
|
|
49 "pfsub 16(%1), %%mm5\n\t" /* yb.im = x[0].im - x[2].im; mm5 = yb */
|
|
50 "pfadd 16(%1), %%mm6\n\t" /* yt.im = x[0].im + x[2].im; mm6 = yt */
|
|
51 "pfadd 8(%1), %%mm7\n\t" /* u.im = x[3].im + x[1].im; mm7 = u */
|
|
52
|
|
53 "movq %%mm6, %%mm0\n\t" /* x[0].re = yt.re + u.re; */
|
|
54 "movq %%mm5, %%mm1\n\t" /* x[1].re = yb.re + vi.re; */
|
|
55 "pfadd %%mm7, %%mm0\n\t" /*x[0].im = yt.im + u.im; */
|
|
56 "pfadd %%mm4, %%mm1\n\t" /* x[1].im = yb.im + vi.im; */
|
|
57 "movq %%mm0, (%0)\n\t"
|
|
58 "movq %%mm1, 8(%0)\n\t"
|
|
59
|
|
60 "pfsub %%mm7, %%mm6\n\t" /* x[2].re = yt.re - u.re; */
|
|
61 "pfsub %%mm4, %%mm5\n\t" /* x[3].re = yb.re - vi.re; */
|
|
62 "movq %%mm6, 16(%0)\n\t" /* x[2].im = yt.im - u.im; */
|
|
63 "movq %%mm5, 24(%0)" /* x[3].im = yb.im - vi.im; */
|
|
64 :"=r"(x)
|
|
65 :"0"(x),
|
|
66 "m"(x_plus_minus_3dnow),
|
|
67 "m"(x_minus_plus_3dnow)
|
|
68 :"memory");
|
|
69 }
|
|
70
|
|
71 static void FFT_8_3DNOW(complex_t *x)
|
|
72 {
|
|
73 /* delta_p = diag{1, sqrt(i)} here */
|
|
74 /* x[k] = sum_{i=0..7} x[i] * w^{i*k}, w=e^{-2*pi/8}
|
|
75 */
|
|
76 complex_t wT1, wB1, wB2;
|
|
77
|
|
78 __asm__ __volatile__(
|
|
79 "movq 8(%2), %%mm0\n\t"
|
|
80 "movq 24(%2), %%mm1\n\t"
|
|
81 "movq %%mm0, %0\n\t" /* wT1 = x[1]; */
|
|
82 "movq %%mm1, %1\n\t" /* wB1 = x[3]; */
|
|
83 :"=m"(wT1), "=m"(wB1)
|
|
84 :"r"(x)
|
|
85 :"memory");
|
|
86
|
|
87 __asm__ __volatile__(
|
|
88 "movq 16(%0), %%mm2\n\t"
|
|
89 "movq 32(%0), %%mm3\n\t"
|
|
90 "movq %%mm2, 8(%0)\n\t" /* x[1] = x[2]; */
|
|
91 "movq 48(%0), %%mm4\n\t"
|
|
92 "movq %%mm3, 16(%0)\n\t" /* x[2] = x[4]; */
|
|
93 "movq %%mm4, 24(%0)\n\t" /* x[3] = x[6]; */
|
|
94 :"=r"(x)
|
|
95 :"0"(x)
|
|
96 :"memory");
|
|
97
|
|
98 fft_4_3dnow(&x[0]);
|
|
99
|
|
100 /* x[0] x[4] x[2] x[6] */
|
|
101
|
|
102 __asm__ __volatile__(
|
|
103 "movq 40(%1), %%mm0\n\t"
|
|
104 "movq %%mm0, %%mm3\n\t"
|
|
105 "movq 56(%1), %%mm1\n\t"
|
|
106 "pfadd %%mm1, %%mm0\n\t"
|
|
107 "pfsub %%mm1, %%mm3\n\t"
|
|
108 "movq (%2), %%mm2\n\t"
|
|
109 "pfadd %%mm2, %%mm0\n\t"
|
|
110 "pfadd %%mm2, %%mm3\n\t"
|
|
111 "movq (%3), %%mm1\n\t"
|
|
112 "pfadd %%mm1, %%mm0\n\t"
|
|
113 "pfsub %%mm1, %%mm3\n\t"
|
|
114 "movq (%1), %%mm1\n\t"
|
|
115 "movq 16(%1), %%mm4\n\t"
|
|
116 "movq %%mm1, %%mm2\n\t"
|
|
117 #ifdef HAVE_3DNOWEX
|
|
118 "pswapd %%mm3, %%mm3\n\t"
|
|
119 #else
|
|
120 "movq %%mm3, %%mm6\n\t"
|
|
121 "psrlq $32, %%mm3\n\t"
|
|
122 "punpckldq %%mm6, %%mm3\n\t"
|
|
123 #endif
|
|
124 "pfadd %%mm0, %%mm1\n\t"
|
|
125 "movq %%mm4, %%mm5\n\t"
|
|
126 "pfsub %%mm0, %%mm2\n\t"
|
|
127 "pfadd %%mm3, %%mm4\n\t"
|
|
128 "movq %%mm1, (%0)\n\t"
|
|
129 "pfsub %%mm3, %%mm5\n\t"
|
|
130 "movq %%mm2, 32(%0)\n\t"
|
|
131 "movd %%mm4, 16(%0)\n\t"
|
|
132 "movd %%mm5, 48(%0)\n\t"
|
|
133 "psrlq $32, %%mm4\n\t"
|
|
134 "psrlq $32, %%mm5\n\t"
|
|
135 "movd %%mm4, 52(%0)\n\t"
|
|
136 "movd %%mm5, 20(%0)"
|
|
137 :"=r"(x)
|
|
138 :"0"(x), "r"(&wT1), "r"(&wB1)
|
|
139 :"memory");
|
|
140
|
|
141 /* x[1] x[5] */
|
|
142 __asm__ __volatile__ (
|
|
143 "movq %6, %%mm6\n\t"
|
|
144 "movq %5, %%mm7\n\t"
|
|
145 "movq %1, %%mm0\n\t"
|
|
146 "movq %2, %%mm1\n\t"
|
|
147 "movq 56(%3), %%mm3\n\t"
|
|
148 "pfsub 40(%3), %%mm0\n\t"
|
|
149 #ifdef HAVE_3DNOWEX
|
|
150 "pswapd %%mm1, %%mm1\n\t"
|
|
151 #else
|
|
152 "movq %%mm1, %%mm2\n\t"
|
|
153 "psrlq $32, %%mm1\n\t"
|
|
154 "punpckldq %%mm2,%%mm1\n\t"
|
|
155 #endif
|
|
156 "pxor %%mm7, %%mm1\n\t"
|
|
157 "pfadd %%mm1, %%mm0\n\t"
|
|
158 #ifdef HAVE_3DNOWEX
|
|
159 "pswapd %%mm3, %%mm3\n\t"
|
|
160 #else
|
|
161 "movq %%mm3, %%mm2\n\t"
|
|
162 "psrlq $32, %%mm3\n\t"
|
|
163 "punpckldq %%mm2,%%mm3\n\t"
|
|
164 #endif
|
|
165 "pxor %%mm6, %%mm3\n\t"
|
|
166 "pfadd %%mm3, %%mm0\n\t"
|
|
167 "movq %%mm0, %%mm1\n\t"
|
|
168 "pxor %%mm6, %%mm1\n\t"
|
|
169 "pfacc %%mm1, %%mm0\n\t"
|
|
170 "pfmul %4, %%mm0\n\t"
|
|
171
|
|
172 "movq 40(%3), %%mm5\n\t"
|
|
173 #ifdef HAVE_3DNOWEX
|
|
174 "pswapd %%mm5, %%mm5\n\t"
|
|
175 #else
|
|
176 "movq %%mm5, %%mm1\n\t"
|
|
177 "psrlq $32, %%mm5\n\t"
|
|
178 "punpckldq %%mm1,%%mm5\n\t"
|
|
179 #endif
|
|
180 "movq %%mm5, %0\n\t"
|
|
181
|
|
182 "movq 8(%3), %%mm1\n\t"
|
|
183 "movq %%mm1, %%mm2\n\t"
|
|
184 "pfsub %%mm0, %%mm1\n\t"
|
|
185 "pfadd %%mm0, %%mm2\n\t"
|
|
186 "movq %%mm1, 40(%3)\n\t"
|
|
187 "movq %%mm2, 8(%3)\n\t"
|
|
188 :"=m"(wB2)
|
|
189 :"m"(wT1), "m"(wB1), "r"(x), "m"(HSQRT2_3DNOW),
|
|
190 "m"(x_plus_minus_3dnow), "m"(x_minus_plus_3dnow)
|
|
191 :"memory");
|
|
192
|
|
193
|
|
194 /* x[3] x[7] */
|
|
195 __asm__ __volatile__(
|
|
196 "movq %1, %%mm0\n\t"
|
|
197 #ifdef HAVE_3DNOWEX
|
|
198 "pswapd %3, %%mm1\n\t"
|
|
199 #else
|
|
200 "movq %3, %%mm1\n\t"
|
|
201 "psrlq $32, %%mm1\n\t"
|
|
202 "punpckldq %3, %%mm1\n\t"
|
|
203 #endif
|
|
204 "pxor %%mm6, %%mm1\n\t"
|
|
205 "pfadd %%mm1, %%mm0\n\t"
|
|
206 "movq %2, %%mm2\n\t"
|
|
207 "movq 56(%4), %%mm3\n\t"
|
|
208 "pxor %%mm7, %%mm3\n\t"
|
|
209 "pfadd %%mm3, %%mm2\n\t"
|
|
210 #ifdef HAVE_3DNOWEX
|
|
211 "pswapd %%mm2, %%mm2\n\t"
|
|
212 #else
|
|
213 "movq %%mm2, %%mm5\n\t"
|
|
214 "psrlq $32, %%mm2\n\t"
|
|
215 "punpckldq %%mm5,%%mm2\n\t"
|
|
216 #endif
|
|
217 "movq 24(%4), %%mm3\n\t"
|
|
218 "pfsub %%mm2, %%mm0\n\t"
|
|
219 "movq %%mm3, %%mm4\n\t"
|
|
220 "movq %%mm0, %%mm1\n\t"
|
|
221 "pxor %%mm6, %%mm0\n\t"
|
|
222 "pfacc %%mm1, %%mm0\n\t"
|
|
223 "pfmul %5, %%mm0\n\t"
|
|
224 "movq %%mm0, %%mm1\n\t"
|
|
225 "pxor %%mm6, %%mm1\n\t"
|
|
226 "pxor %%mm7, %%mm0\n\t"
|
|
227 "pfadd %%mm1, %%mm3\n\t"
|
|
228 "pfadd %%mm0, %%mm4\n\t"
|
|
229 "movq %%mm4, 24(%0)\n\t"
|
|
230 "movq %%mm3, 56(%0)\n\t"
|
|
231 :"=r"(x)
|
|
232 :"m"(wT1), "m"(wB2), "m"(wB1), "0"(x), "m"(HSQRT2_3DNOW)
|
|
233 :"memory");
|
|
234 }
|
|
235
|
|
236 static void FFT_ASMB_3DNOW(int k, complex_t *x, complex_t *wTB,
|
|
237 const complex_t *d, const complex_t *d_3)
|
|
238 {
|
|
239 register complex_t *x2k, *x3k, *x4k, *wB;
|
|
240
|
|
241 TRANS_FILL_MM6_MM7_3DNOW();
|
|
242 x2k = x + 2 * k;
|
|
243 x3k = x2k + 2 * k;
|
|
244 x4k = x3k + 2 * k;
|
|
245 wB = wTB + 2 * k;
|
|
246
|
|
247 TRANSZERO_3DNOW(x[0],x2k[0],x3k[0],x4k[0]);
|
|
248 TRANS_3DNOW(x[1],x2k[1],x3k[1],x4k[1],wTB[1],wB[1],d[1],d_3[1]);
|
|
249
|
|
250 --k;
|
|
251 for(;;) {
|
|
252 TRANS_3DNOW(x[2],x2k[2],x3k[2],x4k[2],wTB[2],wB[2],d[2],d_3[2]);
|
|
253 TRANS_3DNOW(x[3],x2k[3],x3k[3],x4k[3],wTB[3],wB[3],d[3],d_3[3]);
|
|
254 if (!--k) break;
|
|
255 x += 2;
|
|
256 x2k += 2;
|
|
257 x3k += 2;
|
|
258 x4k += 2;
|
|
259 d += 2;
|
|
260 d_3 += 2;
|
|
261 wTB += 2;
|
|
262 wB += 2;
|
|
263 }
|
|
264
|
|
265 }
|
|
266
|
|
267 void FFT_ASMB16_3DNOW(complex_t *x, complex_t *wTB)
|
|
268 {
|
|
269 int k = 2;
|
|
270
|
|
271 TRANS_FILL_MM6_MM7_3DNOW();
|
|
272 /* transform x[0], x[8], x[4], x[12] */
|
|
273 TRANSZERO_3DNOW(x[0],x[4],x[8],x[12]);
|
|
274
|
|
275 /* transform x[1], x[9], x[5], x[13] */
|
|
276 TRANS_3DNOW(x[1],x[5],x[9],x[13],wTB[1],wTB[5],delta16[1],delta16_3[1]);
|
|
277
|
|
278 /* transform x[2], x[10], x[6], x[14] */
|
|
279 TRANSHALF_16_3DNOW(x[2],x[6],x[10],x[14]);
|
|
280
|
|
281 /* transform x[3], x[11], x[7], x[15] */
|
|
282 TRANS_3DNOW(x[3],x[7],x[11],x[15],wTB[3],wTB[7],delta16[3],delta16_3[3]);
|
|
283
|
|
284 }
|
|
285
|
|
286 static void FFT_128P_3DNOW(complex_t *a)
|
|
287 {
|
|
288 FFT_8_3DNOW(&a[0]); FFT_4_3DNOW(&a[8]); FFT_4_3DNOW(&a[12]);
|
|
289 FFT_ASMB16_3DNOW(&a[0], &a[8]);
|
|
290
|
|
291 FFT_8_3DNOW(&a[16]), FFT_8_3DNOW(&a[24]);
|
|
292 FFT_ASMB_3DNOW(4, &a[0], &a[16],&delta32[0], &delta32_3[0]);
|
|
293
|
|
294 FFT_8_3DNOW(&a[32]); FFT_4_3DNOW(&a[40]); FFT_4_3DNOW(&a[44]);
|
|
295 FFT_ASMB16_3DNOW(&a[32], &a[40]);
|
|
296
|
|
297 FFT_8_3DNOW(&a[48]); FFT_4_3DNOW(&a[56]); FFT_4_3DNOW(&a[60]);
|
|
298 FFT_ASMB16_3DNOW(&a[48], &a[56]);
|
|
299
|
|
300 FFT_ASMB_3DNOW(8, &a[0], &a[32],&delta64[0], &delta64_3[0]);
|
|
301
|
|
302 FFT_8_3DNOW(&a[64]); FFT_4_3DNOW(&a[72]); FFT_4_3DNOW(&a[76]);
|
|
303 /* FFT_16(&a[64]); */
|
|
304 FFT_ASMB16_3DNOW(&a[64], &a[72]);
|
|
305
|
|
306 FFT_8_3DNOW(&a[80]); FFT_8_3DNOW(&a[88]);
|
|
307
|
|
308 /* FFT_32(&a[64]); */
|
|
309 FFT_ASMB_3DNOW(4, &a[64], &a[80],&delta32[0], &delta32_3[0]);
|
|
310
|
|
311 FFT_8_3DNOW(&a[96]); FFT_4_3DNOW(&a[104]), FFT_4_3DNOW(&a[108]);
|
|
312 /* FFT_16(&a[96]); */
|
|
313 FFT_ASMB16_3DNOW(&a[96], &a[104]);
|
|
314
|
|
315 FFT_8_3DNOW(&a[112]), FFT_8_3DNOW(&a[120]);
|
|
316 /* FFT_32(&a[96]); */
|
|
317 FFT_ASMB_3DNOW(4, &a[96], &a[112], &delta32[0], &delta32_3[0]);
|
|
318
|
|
319 /* FFT_128(&a[0]); */
|
|
320 FFT_ASMB_3DNOW(16, &a[0], &a[64], &delta128[0], &delta128_3[0]);
|
|
321 }
|
|
322
|
|
323 static void
|
|
324 #ifdef HAVE_3DNOWEX
|
|
325 imdct_do_512_3dnowex
|
|
326 #else
|
|
327 imdct_do_512_3dnow
|
|
328 #endif
|
|
329 (sample_t data[],sample_t delay[], sample_t bias)
|
|
330 {
|
|
331 int i,k;
|
|
332 int p,q;
|
|
333 int m;
|
|
334 int two_m;
|
|
335 int two_m_plus_one;
|
|
336
|
|
337 sample_t tmp_a_i;
|
|
338 sample_t tmp_a_r;
|
|
339 sample_t tmp_b_i;
|
|
340 sample_t tmp_b_r;
|
|
341
|
|
342 sample_t *data_ptr;
|
|
343 sample_t *delay_ptr;
|
|
344 sample_t *window_ptr;
|
|
345
|
|
346 /* 512 IMDCT with source and dest data in 'data' */
|
|
347
|
|
348 /* Pre IFFT complex multiply plus IFFT cmplx conjugate & reordering*/
|
|
349 #if 1
|
|
350 __asm__ __volatile__ (
|
|
351 "movq %0, %%mm7\n\t"
|
|
352 ::"m"(x_plus_minus_3dnow)
|
|
353 :"memory");
|
|
354 for( i=0; i < 128; i++) {
|
|
355 int j = pm128[i];
|
|
356 __asm__ __volatile__ (
|
|
357 "movd %1, %%mm0\n\t"
|
|
358 "movd %3, %%mm1\n\t"
|
|
359 "punpckldq %2, %%mm0\n\t" /* mm0 = data[256-2*j-1] | data[2*j]*/
|
|
360 "punpckldq %4, %%mm1\n\t" /* mm1 = xcos[j] | xsin[j] */
|
|
361 "movq %%mm0, %%mm2\n\t"
|
|
362 "pfmul %%mm1, %%mm0\n\t"
|
|
363 #ifdef HAVE_3DNOWEX
|
|
364 "pswapd %%mm1, %%mm1\n\t"
|
|
365 #else
|
|
366 "movq %%mm1, %%mm5\n\t"
|
|
367 "psrlq $32, %%mm1\n\t"
|
|
368 "punpckldq %%mm5, %%mm1\n\t"
|
|
369 #endif
|
|
370 "pfmul %%mm1, %%mm2\n\t"
|
|
371 #ifdef HAVE_3DNOWEX
|
|
372 "pfpnacc %%mm2, %%mm0\n\t"
|
|
373 #else
|
|
374 "pxor %%mm7, %%mm0\n\t"
|
|
375 "pfacc %%mm2, %%mm0\n\t"
|
|
376 #endif
|
|
377 "pxor %%mm7, %%mm0\n\t"
|
|
378 "movq %%mm0, %0"
|
|
379 :"=m"(buf[i])
|
|
380 :"m"(data[256-2*j-1]), "m"(data[2*j]), "m"(xcos1[j]), "m"(xsin1[j])
|
|
381 :"memory"
|
|
382 );
|
|
383 /* buf[i].re = (data[256-2*j-1] * xcos1[j] - data[2*j] * xsin1[j]);
|
|
384 buf[i].im = (data[256-2*j-1] * xsin1[j] + data[2*j] * xcos1[j])*(-1.0);*/
|
|
385 }
|
|
386 #else
|
|
387 __asm__ __volatile__ ("femms":::"memory");
|
|
388 for( i=0; i < 128; i++) {
|
|
389 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */
|
|
390 int j= pm128[i];
|
|
391 buf[i].real = (data[256-2*j-1] * xcos1[j]) - (data[2*j] * xsin1[j]);
|
|
392 buf[i].imag = -1.0 * ((data[2*j] * xcos1[j]) + (data[256-2*j-1] * xsin1[j]));
|
|
393 }
|
|
394 #endif
|
|
395
|
|
396 /* FFT Merge */
|
|
397 /* unoptimized variant
|
|
398 for (m=1; m < 7; m++) {
|
|
399 if(m)
|
|
400 two_m = (1 << m);
|
|
401 else
|
|
402 two_m = 1;
|
|
403
|
|
404 two_m_plus_one = (1 << (m+1));
|
|
405
|
|
406 for(i = 0; i < 128; i += two_m_plus_one) {
|
|
407 for(k = 0; k < two_m; k++) {
|
|
408 p = k + i;
|
|
409 q = p + two_m;
|
|
410 tmp_a_r = buf[p].real;
|
|
411 tmp_a_i = buf[p].imag;
|
|
412 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
|
|
413 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
|
|
414 buf[p].real = tmp_a_r + tmp_b_r;
|
|
415 buf[p].imag = tmp_a_i + tmp_b_i;
|
|
416 buf[q].real = tmp_a_r - tmp_b_r;
|
|
417 buf[q].imag = tmp_a_i - tmp_b_i;
|
|
418 }
|
|
419 }
|
|
420 }
|
|
421 */
|
|
422
|
|
423 FFT_128P_3DNOW (&buf[0]);
|
|
424 // asm volatile ("femms \n\t":::"memory");
|
|
425
|
|
426 /* Post IFFT complex multiply plus IFFT complex conjugate*/
|
|
427 #if 1
|
|
428 __asm__ __volatile__ (
|
|
429 "movq %0, %%mm7\n\t"
|
|
430 "movq %1, %%mm6\n\t"
|
|
431 ::"m"(x_plus_minus_3dnow),
|
|
432 "m"(x_minus_plus_3dnow)
|
|
433 :"eax","memory");
|
|
434 for (i=0; i < 128; i++) {
|
|
435 __asm__ __volatile__ (
|
|
436 "movq %1, %%mm0\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
|
|
437 "movq %%mm0, %%mm1\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
|
|
438 #ifndef HAVE_3DNOWEX
|
|
439 "movq %%mm1, %%mm2\n\t"
|
|
440 "psrlq $32, %%mm1\n\t"
|
|
441 "punpckldq %%mm2, %%mm1\n\t"
|
|
442 #else
|
|
443 "pswapd %%mm1, %%mm1\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
|
|
444 #endif
|
|
445 "movd %3, %%mm3\n\t" /* ac3_xsin[i] */
|
|
446 "punpckldq %2, %%mm3\n\t" /* ac3_xsin[i] | ac3_xcos[i] */
|
|
447 "pfmul %%mm3, %%mm0\n\t"
|
|
448 "pfmul %%mm3, %%mm1\n\t"
|
|
449 #ifndef HAVE_3DNOWEX
|
|
450 "pxor %%mm7, %%mm0\n\t"
|
|
451 "pfacc %%mm1, %%mm0\n\t"
|
|
452 "movd %%mm0, 4%0\n\t"
|
|
453 "psrlq $32, %%mm0\n\t"
|
|
454 "movd %%mm0, %0\n\t"
|
|
455 #else
|
|
456 "pfpnacc %%mm1, %%mm0\n\t" /* mm0 = mm0[0] - mm0[1] | mm1[0] + mm1[1] */
|
|
457 "pswapd %%mm0, %%mm0\n\t"
|
|
458 "movq %%mm0, %0"
|
|
459 #endif
|
|
460 :"=m"(buf[i])
|
|
461 :"m"(buf[i]),"m"(xcos1[i]),"m"(xsin1[i])
|
|
462 :"memory");
|
|
463 /* ac3_buf[i].re =(tmp_a_r * ac3_xcos1[i]) + (tmp_a_i * ac3_xsin1[i]);
|
|
464 ac3_buf[i].im =(tmp_a_r * ac3_xsin1[i]) - (tmp_a_i * ac3_xcos1[i]);*/
|
|
465 }
|
|
466 #else
|
|
467 __asm__ __volatile__ ("femms":::"memory");
|
|
468 for( i=0; i < 128; i++) {
|
|
469 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
|
|
470 tmp_a_r = buf[i].real;
|
|
471 tmp_a_i = -1.0 * buf[i].imag;
|
|
472 buf[i].real =(tmp_a_r * xcos1[i]) - (tmp_a_i * xsin1[i]);
|
|
473 buf[i].imag =(tmp_a_r * xsin1[i]) + (tmp_a_i * xcos1[i]);
|
|
474 }
|
|
475 #endif
|
|
476
|
|
477 data_ptr = data;
|
|
478 delay_ptr = delay;
|
|
479 window_ptr = imdct_window;
|
|
480
|
|
481 /* Window and convert to real valued signal */
|
|
482 #if 1
|
|
483 asm volatile (
|
|
484 "movd (%0), %%mm3 \n\t"
|
|
485 "punpckldq %%mm3, %%mm3 \n\t"
|
|
486 :: "r" (&bias)
|
|
487 );
|
|
488 for (i=0; i< 64; i++) {
|
|
489 /* merge two loops in one to enable working of 2 decoders */
|
|
490 __asm__ __volatile__ (
|
|
491 "movd 516(%1), %%mm0\n\t"
|
|
492 "movd (%1), %%mm1\n\t" /**data_ptr++=-buf[64+i].im**window_ptr+++*delay_ptr++;*/
|
|
493 "punpckldq (%2), %%mm0\n\t"/*data_ptr[128]=-buf[i].re*window_ptr[128]+delay_ptr[128];*/
|
|
494 "punpckldq 516(%2), %%mm1\n\t"
|
|
495 "pfmul (%3), %%mm0\n\t"/**data_ptr++=buf[64-i-1].re**window_ptr+++*delay_ptr++;*/
|
|
496 "pfmul 512(%3), %%mm1\n\t"
|
|
497 "pxor %%mm6, %%mm0\n\t"/*data_ptr[128]=buf[128-i-1].im*window_ptr[128]+delay_ptr[128];*/
|
|
498 "pxor %%mm6, %%mm1\n\t"
|
|
499 "pfadd (%4), %%mm0\n\t"
|
|
500 "pfadd 512(%4), %%mm1\n\t"
|
|
501 "pfadd %%mm3, %%mm0\n\t"
|
|
502 "pfadd %%mm3, %%mm1\n\t"
|
|
503 "movq %%mm0, (%0)\n\t"
|
|
504 "movq %%mm1, 512(%0)"
|
|
505 :"=r"(data_ptr)
|
|
506 :"r"(&buf[i].real), "r"(&buf[64-i-1].real), "r"(window_ptr), "r"(delay_ptr), "0"(data_ptr)
|
|
507 :"memory");
|
|
508 data_ptr += 2;
|
|
509 window_ptr += 2;
|
|
510 delay_ptr += 2;
|
|
511 }
|
|
512 window_ptr += 128;
|
|
513 #else
|
|
514 __asm__ __volatile__ ("femms":::"memory");
|
|
515 for(i=0; i< 64; i++) {
|
|
516 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias;
|
|
517 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
|
|
518 }
|
|
519
|
|
520 for(i=0; i< 64; i++) {
|
|
521 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias;
|
|
522 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
|
|
523 }
|
|
524 #endif
|
|
525
|
|
526 /* The trailing edge of the window goes into the delay line */
|
|
527 delay_ptr = delay;
|
|
528 #if 1
|
|
529 for(i=0; i< 64; i++) {
|
|
530 /* merge two loops in one to enable working of 2 decoders */
|
|
531 window_ptr -=2;
|
|
532 __asm__ __volatile__(
|
|
533 "movd 508(%1), %%mm0\n\t"
|
|
534 "movd (%1), %%mm1\n\t"
|
|
535 "punpckldq (%2), %%mm0\n\t"
|
|
536 "punpckldq 508(%2), %%mm1\n\t"
|
|
537 #ifdef HAVE_3DNOWEX
|
|
538 "pswapd (%3), %%mm3\n\t"
|
|
539 "pswapd -512(%3), %%mm4\n\t"
|
|
540 #else
|
|
541 "movq (%3), %%mm3\n\t"/**delay_ptr++=-buf[64+i].re**--window_ptr;*/
|
|
542 "movq -512(%3), %%mm4\n\t"
|
|
543 "psrlq $32, %%mm3\n\t"/*delay_ptr[128]=buf[i].im**window_ptr[-512];*/
|
|
544 "psrlq $32, %%mm4\n\t"/**delay_ptr++=buf[64-i-1].im**--window_ptr;*/
|
|
545 "punpckldq (%3), %%mm3\n\t"/*delay_ptr[128]=-buf[128-i-1].re**window_ptr[-512];*/
|
|
546 "punpckldq -512(%3), %%mm4\n\t"
|
|
547 #endif
|
|
548 "pfmul %%mm3, %%mm0\n\t"
|
|
549 "pfmul %%mm4, %%mm1\n\t"
|
|
550 "pxor %%mm6, %%mm0\n\t"
|
|
551 "pxor %%mm7, %%mm1\n\t"
|
|
552 "movq %%mm0, (%0)\n\t"
|
|
553 "movq %%mm1, 512(%0)"
|
|
554 :"=r"(delay_ptr)
|
|
555 :"r"(&buf[i].imag), "r"(&buf[64-i-1].imag), "r"(window_ptr), "0"(delay_ptr)
|
|
556 :"memory");
|
|
557 delay_ptr += 2;
|
|
558 }
|
|
559 __asm__ __volatile__ ("femms":::"memory");
|
|
560 #else
|
|
561 __asm__ __volatile__ ("femms":::"memory");
|
|
562 for(i=0; i< 64; i++) {
|
|
563 *delay_ptr++ = -buf[64+i].real * *--window_ptr;
|
|
564 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr;
|
|
565 }
|
|
566
|
|
567 for(i=0; i<64; i++) {
|
|
568 *delay_ptr++ = buf[i].imag * *--window_ptr;
|
|
569 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr;
|
|
570 }
|
|
571 #endif
|
|
572 }
|