]> git.sesse.net Git - vlc/blob - plugins/imdct/ac3_imdct_sse.c
* Format asm functions for gcc
[vlc] / plugins / imdct / ac3_imdct_sse.c
1 /*****************************************************************************
2  * ac3_imdct_sse.c: accelerated SSE ac3 DCT
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: ac3_imdct_sse.c,v 1.5 2001/07/26 20:00:33 reno Exp $
6  *
7  * Authors: Renaud Dartus <reno@videolan.org>
8  *          Aaron Holtzman <aholtzma@engr.uvic.ca>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #define MODULE_NAME imdctsse
26 #include "modules_inner.h"
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include "defs.h"
32
33 #include <math.h>
34 #include <stdio.h>
35
36 #include "config.h"
37 #include "common.h"
38 #include "threads.h"
39 #include "mtime.h"
40
41 #include "ac3_imdct.h"
42 #include "ac3_imdct_common.h"
43 #include "ac3_retables.h"
44
45 #ifndef M_PI
46 #   define M_PI 3.14159265358979323846
47 #endif
48
49 void _M( fft_64p )  ( complex_t *x );
50 void _M( fft_128p ) ( complex_t *a );
51
52 static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse);
53 static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse);
54 static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);
55 static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt);
56
57
58 void _M( imdct_init ) (imdct_t * p_imdct)
59 {
60     int i;
61     float scale = 181.019;
62
63     for (i=0; i < 128; i++)
64     {
65         float xcos_i = cos(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
66         float xsin_i = sin(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
67         p_imdct->xcos_sin_sse[i * 4]     = xcos_i;
68         p_imdct->xcos_sin_sse[i * 4 + 1] = -xsin_i;
69         p_imdct->xcos_sin_sse[i * 4 + 2] = -xsin_i;
70         p_imdct->xcos_sin_sse[i * 4 + 3] = -xcos_i;
71     }
72 }
73
74 void _M( imdct_do_512 ) (imdct_t * p_imdct, float data[], float delay[])
75 {
76     imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);
77     _M( fft_128p ) ( p_imdct->buf );
78     imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
79     imdct512_window_delay_sse (p_imdct->buf, data, window, delay);
80 }
81
82
83 void _M( imdct_do_512_nol ) (imdct_t * p_imdct, float data[], float delay[])
84 {
85     imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);  
86     _M( fft_128p ) ( p_imdct->buf );
87     imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
88     imdct512_window_delay_nol_sse (p_imdct->buf, data, window, delay);
89 }
90
91 static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse)
92 {
93     __asm__ __volatile__ (    
94     ".align 16\n"
95     "pushl %%ebp\n"
96     "movl  %%esp, %%ebp\n"
97     "addl  $-4, %%esp\n" /* local variable, loop counter */
98     
99     "pushl %%eax\n"
100     "pushl %%ebx\n"
101     "pushl %%ecx\n"
102     "pushl %%edx\n"
103     "pushl %%edi\n"
104     "pushl %%esi\n"
105
106     "movl %%edi, %%ebx\n"   /* buf */
107     "movl $64, -4(%%ebp)\n"
108     
109     ".align 16\n"
110 ".loop:\n"
111     "movl  (%%eax), %%esi\n"
112     "movl 4(%%eax), %%edi\n"
113     "movss (%%ecx, %%esi, 8), %%xmm1\n" /* 2j */
114     "movss (%%ecx, %%edi, 8), %%xmm3\n" /* 2(j+1) */
115
116     "shll $1, %%esi\n"
117     "shll $1, %%edi\n"
118
119     "movaps (%%edx, %%esi, 8), %%xmm0\n" /* -c_j | -s_j | -s_j | c_j */
120     "movaps (%%edx, %%edi, 8), %%xmm2\n" /* -c_j+1 | -s_j+1 | -s_j+1 | c_j+1 */
121
122     "negl %%esi\n"
123     "negl %%edi\n"
124
125     "movss 1020(%%ecx, %%esi, 4), %%xmm4\n" /* 255-2j */
126     "addl  $8, %%eax\n"
127     "movss 1020(%%ecx, %%edi, 4), %%xmm5\n" /* 255-2(j+1) */
128
129     "shufps  $0, %%xmm1, %%xmm4\n" /* 2j | 2j | 255-2j | 255-2j */
130     "shufps  $0, %%xmm3, %%xmm5\n" /* 2(j+1) | 2(j+1) | 255-2(j+1) | 255-2(j+1) */
131     "mulps   %%xmm4, %%xmm0\n"
132     "mulps   %%xmm5, %%xmm2\n"
133     "movhlps %%xmm0, %%xmm1\n"
134     "movhlps %%xmm2, %%xmm3\n"
135     "addl    $16, %%ebx\n"
136     "addps   %%xmm1, %%xmm0\n"
137     "addps   %%xmm3, %%xmm2\n"
138     "movlhps %%xmm2, %%xmm0\n"
139     
140     "movaps  %%xmm0, -16(%%ebx)\n"
141     "decl    -4(%%ebp)\n"
142     "jnz     .loop\n"
143
144     "popl %%esi\n"
145     "popl %%edi\n"
146     "popl %%edx\n"
147     "popl %%ecx\n"
148     "popl %%ebx\n"
149     "popl %%eax\n"
150
151     "addl $4, %%esp\n"
152     "popl %%ebp\n"
153     : "=D" (buf)
154     : "a" (pmt), "c" (data), "d" (xcos_sin_sse), "D" (buf));
155     
156 }
157
158 static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse)
159 {
160     __asm__ __volatile__ ( 
161     ".align 16\n"
162     "pushl %%ebx\n"
163     "movl  $32, %%ebx\n"               /* loop counter */
164
165     ".align 16\n"
166 ".loop1:\n"
167     "movaps (%%eax), %%xmm0\n"         /*  im1 | re1 | im0 | re0 */
168
169     "movaps (%%ecx), %%xmm2\n"         /* -c | -s | -s | c */
170     "movhlps %%xmm0, %%xmm1\n"         /* im1 | re1 */
171     "movaps 16(%%ecx), %%xmm3\n"       /* -c1 | -s1 | -s1 | c1 */
172
173     "shufps $0x50, %%xmm0, %%xmm0\n"   /* im0 | im0 | re0 | re0 */
174     "shufps $0x50, %%xmm1, %%xmm1\n"   /* im1 | im1 | re1 | re1 */
175
176     "movaps  16(%%eax), %%xmm4\n"      /* im3 | re3 | im2 | re2 */
177
178     "shufps  $0x27, %%xmm2, %%xmm2\n"  /* c | -s | -s | -c */
179     "movhlps %%xmm4, %%xmm5\n"         /* im3 | re3 */
180     "shufps  $0x27, %%xmm3, %%xmm3\n"  /* c1 | -s1 | -s1 | -c1 */
181
182     "movaps 32(%%ecx), %%xmm6\n"       /* -c2 | -s2 | -s2 | c2 */
183     "movaps 48(%%ecx), %%xmm7\n"       /* -c3 | -s3 | -s3 | c3 */
184
185     "shufps $0x50, %%xmm4, %%xmm4\n"   /* im2 | im2 | re2 | re2 */
186     "shufps $0x50, %%xmm5, %%xmm5\n"   /* im3 | im3 | re3 | re3 */
187
188     "mulps %%xmm2, %%xmm0\n"
189     "mulps %%xmm3, %%xmm1\n"
190
191     "shufps $0x27, %%xmm6, %%xmm6\n"   /* c2 | -s2 | -s2 | -c2 */
192     "shufps $0x27, %%xmm7, %%xmm7\n"   /* c3 | -s3 | -s3 | -c3 */
193
194     "movhlps %%xmm0, %%xmm2\n"
195     "movhlps %%xmm1, %%xmm3\n"
196
197     "mulps %%xmm6, %%xmm4\n"
198     "mulps %%xmm7, %%xmm5\n"
199
200     "addps %%xmm2, %%xmm0\n"
201     "addps %%xmm3, %%xmm1\n"
202
203     "movhlps %%xmm4, %%xmm6\n"
204     "movhlps %%xmm5, %%xmm7\n"
205
206     "addps %%xmm6, %%xmm4\n"
207     "addps %%xmm7, %%xmm5\n"
208
209     "movlhps %%xmm1, %%xmm0\n"
210     "movlhps %%xmm5, %%xmm4\n"
211
212     "movaps %%xmm0, (%%eax)\n"
213     "movaps %%xmm4, 16(%%eax)\n"
214     "addl $64, %%ecx\n"
215     "addl $32, %%eax\n"
216     "decl %%ebx\n"
217     "jnz .loop1\n"
218
219     "popl %%ebx\n"
220     : "=a" (buf)
221     : "a" (buf), "c" (xcos_sin_sse) );
222 }
223
224 static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt)
225 {
226     __asm__ __volatile__ (
227     ".align 16\n"
228
229     "pushl %%eax\n"
230     "pushl %%ebx\n"
231     "pushl %%ecx\n"
232     "pushl %%edx\n"
233     "pushl %%edi\n"
234     "pushl %%esi\n"
235     "pushl %%ebp\n"
236
237     "movl %%esi, %%ebp\n"    /* buf */
238     "movl $16, %%ebx\n"         /* loop count */
239     "leal 516(%%ebp), %%esi\n"  /* buf[64].im */
240     "leal 504(%%ebp), %%edi\n"  /* buf[63].re */
241
242     ".align 16\n"
243 ".first_128_samples:\n"
244     "movss   (%%esi), %%xmm0\n"
245     "movss  8(%%esi), %%xmm2\n"
246     "movss   (%%edi), %%xmm1\n"
247     "movss -8(%%edi), %%xmm3\n"
248
249     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
250     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
251
252     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
253     "movaps (%%ecx), %%xmm5\n"      /* d3 | d2 | d1 | d0 */
254     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
255
256     "movss  16(%%esi), %%xmm6\n"    /* im2 */
257     "movss  24(%%esi), %%xmm7\n"    /* im3 */
258     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
259     "movss -16(%%edi), %%xmm2\n"    /* re2 */
260     "movss -24(%%edi), %%xmm3\n"    /* re3 */
261     "mulps     %%xmm4, %%xmm0\n"
262     "movlhps   %%xmm7, %%xmm6\n"    /* 0.0 | im3 | 0.0 | im2 */
263     "movlhps   %%xmm3, %%xmm2\n"    /* 0.0 | re3 | 0.0 | re2 */
264     "addps  %%xmm5, %%xmm0\n"
265     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
266     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
267     "movaps 16(%%ecx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
268     "subps  %%xmm2, %%xmm6\n"       /* -re3 | im3 | -re2 | im2 */
269     "addl   $32, %%edx\n"
270     "movaps %%xmm0, (%%eax)\n"
271     "addl   $32, %%ecx\n"
272     "mulps  %%xmm4, %%xmm6\n"
273     "addl   $32, %%esi\n"
274     "addl   $32, %%eax\n"
275     "addps  %%xmm5, %%xmm6\n"
276     "addl   $-32, %%edi\n"
277     "movaps %%xmm6, -16(%%eax)\n"
278     "decl   %%ebx\n"
279     "jnz .first_128_samples\n"
280
281     "movl %%ebp, %%esi\n"    /* buf[0].re */
282     "movl $16, %%ebx\n"         /* loop count */
283     "leal 1020(%%ebp), %%edi\n" /* buf[127].im */
284     
285     ".align 16\n"
286 ".second_128_samples:\n"
287     "movss   (%%esi), %%xmm0\n" /* buf[i].re */
288     "movss  8(%%esi), %%xmm2\n" /* re1 */
289     "movss   (%%edi), %%xmm1\n" /* buf[127-i].im */
290     "movss -8(%%edi), %%xmm3\n" /* im1 */
291
292     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
293     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im1 */
294
295     "movups (%%edx), %%xmm4\n"  /* w3 | w2 | w1 | w0 */
296     "movaps (%%ecx), %%xmm5\n"  /* d3 | d2 | d1 | d0 */
297
298     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
299     "movss  16(%%esi), %%xmm6\n"    /* re2 */
300     "movss  24(%%esi), %%xmm7\n"    /* re3 */
301     "movss -16(%%edi), %%xmm2\n"    /* im2 */
302     "movss -24(%%edi), %%xmm3\n"    /* im3 */
303     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
304     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
305     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
306     "mulps   %%xmm4, %%xmm0\n"
307     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
308     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
309     "addl   $32, %%esi\n"
310     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
311     "addps  %%xmm5, %%xmm0\n"
312     "mulps  %%xmm4, %%xmm6\n"
313     "addl   $-32, %%edi\n"
314     "movaps 16(%%ecx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
315     "movaps %%xmm0, (%%eax)\n"
316     "addps  %%xmm5, %%xmm6\n"
317     "addl   $32, %%edx\n"
318     "addl   $32, %%eax\n"
319     "addl   $32, %%ecx\n"
320     "movaps %%xmm6, -16(%%eax)\n"
321     "decl   %%ebx\n"
322     "jnz .second_128_samples\n"
323
324     "leal 512(%%ebp), %%esi\n"  /* buf[64].re */
325     "leal 508(%%ebp), %%edi\n"  /* buf[63].im */
326     "movl $16, %%ebx\n"         /* loop count */
327     "addl $-1024, %%ecx\n"  /* delay */
328
329     ".align 16\n"
330 ".first_128_delay:\n"
331     "movss   (%%esi), %%xmm0\n"
332     "movss  8(%%esi), %%xmm2\n"
333     "movss   (%%edi), %%xmm1\n"
334     "movss -8(%%edi), %%xmm3\n"
335
336     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
337     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im0 */
338
339     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
340     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
341     "movss  16(%%esi), %%xmm6\n"    /* re2 */
342     "movss  24(%%esi), %%xmm7\n"    /* re3 */
343     "movss -16(%%edi), %%xmm2\n"    /* im2 */
344     "movss -24(%%edi), %%xmm3\n"    /* im3 */
345     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
346     "addl    $-32, %%edx\n"
347     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
348     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
349     "mulps   %%xmm4, %%xmm0\n"
350     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
351     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
352     "movaps %%xmm0, (%%ecx)\n"
353     "addl   $32, %%esi\n"
354     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
355     "addl   $-32, %%edi\n"
356     "mulps  %%xmm5, %%xmm6\n"
357     "addl   $32, %%ecx\n"
358     "movaps %%xmm6, -16(%%ecx)\n"
359     "decl   %%ebx\n"
360     "jnz .first_128_delay\n"
361
362     "leal    4(%%ebp), %%esi\n" /* buf[0].im */
363     "leal 1016(%%ebp), %%edi\n" /* buf[127].re */
364     "movl $16, %%ebx\n"         /* loop count */
365     
366     ".align 16\n"
367 ".second_128_delay:\n"
368     "movss   (%%esi), %%xmm0\n"
369     "movss  8(%%esi), %%xmm2\n"
370     "movss   (%%edi), %%xmm1\n"
371     "movss -8(%%edi), %%xmm3\n"
372
373     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
374     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
375
376     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
377     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
378     "movss  16(%%esi), %%xmm6\n"    /* im2 */
379     "movss  24(%%esi), %%xmm7\n"    /* im3 */
380     "movss -16(%%edi), %%xmm2\n"    /* re2 */
381     "movss -24(%%edi), %%xmm3\n"    /* re3 */
382     "subps   %%xmm0, %%xmm1\n"      /* re1 | -im1 | re0 | -im0 */
383     "addl    $-32, %%edx\n"
384     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
385     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
386     "mulps   %%xmm4, %%xmm1\n"
387     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
388     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
389     "movaps %%xmm1, (%%ecx)\n"
390     "addl   $32, %%esi\n"
391     "subps  %%xmm6, %%xmm2\n"       /* re | -im3 | re | -im2 */
392     "addl   $-32, %%edi\n"
393     "mulps  %%xmm5, %%xmm2\n"
394     "addl   $32, %%ecx\n"
395     "movaps %%xmm2, -16(%%ecx)\n"
396     "decl   %%ebx\n"
397     "jnz .second_128_delay\n"
398
399     "popl %%ebp\n"
400     "popl %%esi\n"
401     "popl %%edi\n"
402     "popl %%edx\n"
403     "popl %%ecx\n"
404     "popl %%ebx\n"
405     "popl %%eax\n"
406     : "=S" (buf), "=a" (data_ptr), "=c" (delay_prt), "=d" (window_prt)
407     : "S" (buf), "a" (data_ptr), "c" (delay_prt), "d" (window_prt));
408     
409 }
410
411 static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt)
412 {
413     __asm__ __volatile__ (
414     ".align 16\n"
415     
416     "pushl %%eax\n"
417     "pushl %%ebx\n"
418     "pushl %%ecx\n"
419     "pushl %%edx\n"
420     "pushl %%edi\n"
421     "pushl %%esi\n"
422     "pushl %%ebp\n"
423
424     "movl %%esi, %%ebp\n"         /* buf */
425     "movl $16, %%ebx\n"         /* loop count */
426     "leal 516(%%ebp), %%esi\n"  /* buf[64].im */
427     "leal 504(%%ebp), %%edi\n"  /* buf[63].re */
428     
429     ".align 16\n"
430 ".first_128_sample:\n"
431     "movss   (%%esi), %%xmm0\n"
432     "movss  8(%%esi), %%xmm2\n"
433     "movss   (%%edi), %%xmm1\n"
434     "movss -8(%%edi), %%xmm3\n"
435
436     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
437     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
438
439     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
440     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
441
442     "movss  16(%%esi), %%xmm6\n"    /* im2 */
443     "movss  24(%%esi), %%xmm7\n"    /* im3 */
444     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
445     "movss -16(%%edi), %%xmm2\n"    /* re2 */
446     "movss -24(%%edi), %%xmm3\n"    /* re3 */
447     "mulps   %%xmm4, %%xmm0\n"
448     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
449     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
450     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
451     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
452     "subps  %%xmm2, %%xmm6\n"       /* -re3 | im3 | -re2 | im2 */
453     "addl   $32, %%edx\n"
454     "movaps %%xmm0, (%%eax)\n"
455     "mulps  %%xmm4, %%xmm6\n"
456     "addl   $32, %%esi\n"
457     "addl   $32, %%eax\n"
458     "addl   $-32, %%edi\n"
459     "movaps %%xmm6, -16(%%eax)\n"
460     "decl   %%ebx\n"
461     "jnz .first_128_sample\n"
462
463     "movl %%ebp, %%esi\n"     /* buf[0].re */
464     "movl $16, %%ebx\n"             /* loop count */
465     "leal 1020(%%ebp), %%edi\n"     /* buf[127].im */
466     
467     ".align 16\n"
468 ".second_128_sample:\n"
469     "movss   (%%esi), %%xmm0\n"     /* buf[i].re */
470     "movss  8(%%esi), %%xmm2\n"     /* re1 */
471     "movss   (%%edi), %%xmm1\n"     /* buf[127-i].im */
472     "movss -8(%%edi), %%xmm3\n"     /* im1 */
473
474     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
475     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im1 */
476     
477     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
478
479     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
480     "movss  16(%%esi), %%xmm6\n"    /* re2 */
481     "movss  24(%%esi), %%xmm7\n"    /* re3 */
482     "movss -16(%%edi), %%xmm2\n"    /* im2 */
483     "movss -24(%%edi), %%xmm3\n"    /* im3 */
484     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
485     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
486     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
487     "mulps   %%xmm4, %%xmm0\n"
488     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
489     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
490     "addl   $32, %%esi\n"
491     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
492     "mulps  %%xmm4, %%xmm6\n"
493     "addl   $-32, %%edi\n"
494     "movaps %%xmm0, (%%eax)\n"
495     "addl   $32, %%edx\n"
496     "addl   $32, %%eax\n"
497     "movaps %%xmm6, -16(%%eax)\n"
498     "decl   %%ebx\n"
499     "jnz .second_128_sample\n"
500
501     "leal 512(%%ebp), %%esi\n"  /* buf[64].re */
502     "leal 508(%%ebp), %%edi\n"  /* buf[63].im */
503     "movl $16, %%ebx\n"         /* loop count */
504     "addl  $-1024, %%ecx\n"  /* delay */
505     
506     ".align 16\n"
507 ".first_128_delays:\n"
508     "movss   (%%esi), %%xmm0\n"
509     "movss  8(%%esi), %%xmm2\n"
510     "movss   (%%edi), %%xmm1\n"
511     "movss -8(%%edi), %%xmm3\n"
512
513     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
514     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im0 */
515
516     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
517     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
518     "movss  16(%%esi), %%xmm6\n"    /* re2 */
519     "movss  24(%%esi), %%xmm7\n"    /* re3 */
520     "movss -16(%%edi), %%xmm2\n"    /* im2 */
521     "movss -24(%%edi), %%xmm3\n"    /* im3 */
522     "subps %%xmm1, %%xmm0\n"        /* -im1 | re1 | -im0 | re0 */
523     "addl  $-32, %%edx\n"
524     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
525     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
526     "mulps   %%xmm4, %%xmm0\n"
527     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
528     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
529     "movaps %%xmm0, (%%ecx)\n"
530     "addl   $32, %%esi\n"
531     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
532     "addl   $-32, %%edi\n"
533     "mulps  %%xmm5, %%xmm6\n"
534     "addl   $32, %%ecx\n"
535     "movaps %%xmm6, -16(%%ecx)\n"
536     "decl   %%ebx\n"
537     "jnz .first_128_delays\n"
538
539     "leal    4(%%ebp), %%esi\n" /* buf[0].im */
540     "leal 1016(%%ebp), %%edi\n" /* buf[127].re */
541     "movl $16, %%ebx\n"         /* loop count */
542     
543     ".align 16\n"
544 ".second_128_delays:\n"
545     "movss   (%%esi), %%xmm0\n"
546     "movss  8(%%esi), %%xmm2\n"
547     "movss   (%%edi), %%xmm1\n"
548     "movss -8(%%edi), %%xmm3\n"
549
550     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | im1 | 0.0 | im0 */
551     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | re1 | 0.0 | re0 */
552
553     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
554     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
555     "movss  16(%%esi), %%xmm6\n"    /* im2 */
556     "movss  24(%%esi), %%xmm7\n"    /* im3 */
557     "movss -16(%%edi), %%xmm2\n"    /* re2 */
558     "movss -24(%%edi), %%xmm3\n"    /* re3 */
559     "subps   %%xmm0, %%xmm1\n"      /* re1 | -im1 | re0 | -im0 */
560     "addl    $-32, %%edx\n"
561     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
562     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
563     "mulps   %%xmm4, %%xmm1\n"
564     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
565     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
566     "movaps %%xmm1, (%%ecx)\n"
567     "addl   $32, %%esi\n"
568     "subps  %%xmm6, %%xmm2\n"       /* re | -im3 | re | -im2 */
569     "addl   $-32, %%edi\n"
570     "mulps  %%xmm5, %%xmm2\n"
571     "addl   $32, %%ecx\n"
572     "movaps %%xmm2, -16(%%ecx)\n"
573     "decl   %%ebx\n"
574     "jnz .second_128_delays\n"
575
576     "popl %%ebp\n"
577     "popl %%esi\n"
578     "popl %%edi\n"
579     "popl %%edx\n"
580     "popl %%ecx\n"
581     "popl %%ebx\n"
582     "popl %%eax\n"
583     : "=S" (buf), "=a" (data_ptr), "=c" (delay_prt), "=d" (window_prt)
584     : "S" (buf), "a" (data_ptr), "c" (delay_prt), "d" (window_prt));
585
586 }