]> git.sesse.net Git - vlc/blob - plugins/imdct/ac3_imdct_sse.c
50ff4d1c643fcc132df2582a84395c534963d95b
[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.4 2001/07/08 23:15:11 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  8(%%ebp), %%eax\n"     /* pmt */
107     "movl 12(%%ebp), %%ebx\n"     /* buf */
108     "movl 16(%%ebp), %%ecx\n"     /* data */
109     "movl 20(%%ebp), %%edx\n"     /* xcos_sin_sse */
110     "movl $64, -4(%%ebp)\n"
111     
112     ".align 16\n"
113 ".loop:\n"
114     "movl  (%%eax), %%esi\n"
115     "movl 4(%%eax), %%edi\n"
116     "movss (%%ecx, %%esi, 8), %%xmm1\n" /* 2j */
117     "movss (%%ecx, %%edi, 8), %%xmm3\n" /* 2(j+1) */
118
119     "shll $1, %%esi\n"
120     "shll $1, %%edi\n"
121
122     "movaps (%%edx, %%esi, 8), %%xmm0\n" /* -c_j | -s_j | -s_j | c_j */
123     "movaps (%%edx, %%edi, 8), %%xmm2\n" /* -c_j+1 | -s_j+1 | -s_j+1 | c_j+1 */
124
125     "negl %%esi\n"
126     "negl %%edi\n"
127
128     "movss 1020(%%ecx, %%esi, 4), %%xmm4\n" /* 255-2j */
129     "addl  $8, %%eax\n"
130     "movss 1020(%%ecx, %%edi, 4), %%xmm5\n" /* 255-2(j+1) */
131
132     "shufps  $0, %%xmm1, %%xmm4\n" /* 2j | 2j | 255-2j | 255-2j */
133     "shufps  $0, %%xmm3, %%xmm5\n" /* 2(j+1) | 2(j+1) | 255-2(j+1) | 255-2(j+1) */
134     "mulps   %%xmm4, %%xmm0\n"
135     "mulps   %%xmm5, %%xmm2\n"
136     "movhlps %%xmm0, %%xmm1\n"
137     "movhlps %%xmm2, %%xmm3\n"
138     "addl    $16, %%ebx\n"
139     "addps   %%xmm1, %%xmm0\n"
140     "addps   %%xmm3, %%xmm2\n"
141     "movlhps %%xmm2, %%xmm0\n"
142     
143     "movaps  %%xmm0, -16(%%ebx)\n"
144     "decl    -4(%%ebp)\n"
145     "jnz     .loop\n"
146
147     "popl %%esi\n"
148     "popl %%edi\n"
149     "popl %%edx\n"
150     "popl %%ecx\n"
151     "popl %%ebx\n"
152     "popl %%eax\n"
153
154     "addl $4, %%esp\n"
155     "popl %%ebp\n"
156     ::);
157 }
158
159 static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse)
160 {
161     __asm__ __volatile__ ( 
162     ".align 16\n"
163     "pushl %%ebx\n"
164     "movl  $32, %%ebx\n"               /* loop counter */
165
166     ".align 16\n"
167 ".loop1:\n"
168     "movaps (%%eax), %%xmm0\n"         /*  im1 | re1 | im0 | re0 */
169
170     "movaps (%%ecx), %%xmm2\n"         /* -c | -s | -s | c */
171     "movhlps %%xmm0, %%xmm1\n"         /* im1 | re1 */
172     "movaps 16(%%ecx), %%xmm3\n"       /* -c1 | -s1 | -s1 | c1 */
173
174     "shufps $0x50, %%xmm0, %%xmm0\n"   /* im0 | im0 | re0 | re0 */
175     "shufps $0x50, %%xmm1, %%xmm1\n"   /* im1 | im1 | re1 | re1 */
176
177     "movaps  16(%%eax), %%xmm4\n"      /* im3 | re3 | im2 | re2 */
178
179     "shufps  $0x27, %%xmm2, %%xmm2\n"  /* c | -s | -s | -c */
180     "movhlps %%xmm4, %%xmm5\n"         /* im3 | re3 */
181     "shufps  $0x27, %%xmm3, %%xmm3\n"  /* c1 | -s1 | -s1 | -c1 */
182
183     "movaps 32(%%ecx), %%xmm6\n"       /* -c2 | -s2 | -s2 | c2 */
184     "movaps 48(%%ecx), %%xmm7\n"       /* -c3 | -s3 | -s3 | c3 */
185
186     "shufps $0x50, %%xmm4, %%xmm4\n"   /* im2 | im2 | re2 | re2 */
187     "shufps $0x50, %%xmm5, %%xmm5\n"   /* im3 | im3 | re3 | re3 */
188
189     "mulps %%xmm2, %%xmm0\n"
190     "mulps %%xmm3, %%xmm1\n"
191
192     "shufps $0x27, %%xmm6, %%xmm6\n"   /* c2 | -s2 | -s2 | -c2 */
193     "shufps $0x27, %%xmm7, %%xmm7\n"   /* c3 | -s3 | -s3 | -c3 */
194
195     "movhlps %%xmm0, %%xmm2\n"
196     "movhlps %%xmm1, %%xmm3\n"
197
198     "mulps %%xmm6, %%xmm4\n"
199     "mulps %%xmm7, %%xmm5\n"
200
201     "addps %%xmm2, %%xmm0\n"
202     "addps %%xmm3, %%xmm1\n"
203
204     "movhlps %%xmm4, %%xmm6\n"
205     "movhlps %%xmm5, %%xmm7\n"
206
207     "addps %%xmm6, %%xmm4\n"
208     "addps %%xmm7, %%xmm5\n"
209
210     "movlhps %%xmm1, %%xmm0\n"
211     "movlhps %%xmm5, %%xmm4\n"
212
213     "movaps %%xmm0, (%%eax)\n"
214     "movaps %%xmm4, 16(%%eax)\n"
215     "addl $64, %%ecx\n"
216     "addl $32, %%eax\n"
217     "decl %%ebx\n"
218     "jnz .loop1\n"
219
220     "popl %%ebx\n"
221     : "=a" (buf)
222     : "a" (buf), "c" (xcos_sin_sse) );
223 }
224
225 static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt)
226 {
227     __asm__ __volatile__ (
228     ".align 16\n"
229     "pushl %%ebp\n"
230     "movl  %%esp, %%ebp\n"
231     
232     "pushl %%eax\n"
233     "pushl %%ebx\n"
234     "pushl %%ecx\n"
235     "pushl %%edx\n"
236     "pushl %%esi\n"
237     "pushl %%edi\n"
238
239     "movl 20(%%ebp), %%ebx\n"   /* delay */
240     "movl 16(%%ebp), %%edx\n"   /* window */
241
242     "movl 8(%%ebp), %%eax\n"    /* buf */
243     "movl $16, %%ecx\n"         /* loop count */
244     "leal 516(%%eax), %%esi\n"  /* buf[64].im */
245     "leal 504(%%eax), %%edi\n"  /* buf[63].re */
246     "movl  12(%%ebp), %%eax\n"  /* data */
247
248     ".align 16\n"
249 ".first_128_samples:\n"
250     "movss   (%%esi), %%xmm0\n"
251     "movss  8(%%esi), %%xmm2\n"
252     "movss   (%%edi), %%xmm1\n"
253     "movss -8(%%edi), %%xmm3\n"
254
255     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
256     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
257
258     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
259     "movaps (%%ebx), %%xmm5\n"      /* d3 | d2 | d1 | d0 */
260     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
261
262     "movss  16(%%esi), %%xmm6\n"    /* im2 */
263     "movss  24(%%esi), %%xmm7\n"    /* im3 */
264     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
265     "movss -16(%%edi), %%xmm2\n"    /* re2 */
266     "movss -24(%%edi), %%xmm3\n"    /* re3 */
267     "mulps     %%xmm4, %%xmm0\n"
268     "movlhps   %%xmm7, %%xmm6\n"    /* 0.0 | im3 | 0.0 | im2 */
269     "movlhps   %%xmm3, %%xmm2\n"    /* 0.0 | re3 | 0.0 | re2 */
270     "addps  %%xmm5, %%xmm0\n"
271     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
272     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
273     "movaps 16(%%ebx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
274     "subps  %%xmm2, %%xmm6\n"       /* -re3 | im3 | -re2 | im2 */
275     "addl   $32, %%edx\n"
276     "movaps %%xmm0, (%%eax)\n"
277     "addl   $32, %%ebx\n"
278     "mulps  %%xmm4, %%xmm6\n"
279     "addl   $32, %%esi\n"
280     "addl   $32, %%eax\n"
281     "addps  %%xmm5, %%xmm6\n"
282     "addl   $-32, %%edi\n"
283     "movaps %%xmm6, -16(%%eax)\n"
284     "decl   %%ecx\n"
285     "jnz .first_128_samples\n"
286
287     "movl 8(%%ebp), %%esi\n"    /* buf[0].re */
288     "leal 1020(%%esi), %%edi\n" /* buf[127].im */
289     "movl $16, %%ecx\n"         /* loop count */
290     
291     ".align 16\n"
292 ".second_128_samples:\n"
293     "movss   (%%esi), %%xmm0\n" /* buf[i].re */
294     "movss  8(%%esi), %%xmm2\n" /* re1 */
295     "movss   (%%edi), %%xmm1\n" /* buf[127-i].im */
296     "movss -8(%%edi), %%xmm3\n" /* im1 */
297
298     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
299     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im1 */
300
301     "movups (%%edx), %%xmm4\n"  /* w3 | w2 | w1 | w0 */
302     "movaps (%%ebx), %%xmm5\n"  /* d3 | d2 | d1 | d0 */
303
304     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
305     "movss  16(%%esi), %%xmm6\n"    /* re2 */
306     "movss  24(%%esi), %%xmm7\n"    /* re3 */
307     "movss -16(%%edi), %%xmm2\n"    /* im2 */
308     "movss -24(%%edi), %%xmm3\n"    /* im3 */
309     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
310     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
311     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
312     "mulps   %%xmm4, %%xmm0\n"
313     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
314     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
315     "addl   $32, %%esi\n"
316     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
317     "addps  %%xmm5, %%xmm0\n"
318     "mulps  %%xmm4, %%xmm6\n"
319     "addl   $-32, %%edi\n"
320     "movaps 16(%%ebx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
321     "movaps %%xmm0, (%%eax)\n"
322     "addps  %%xmm5, %%xmm6\n"
323     "addl   $32, %%edx\n"
324     "addl   $32, %%eax\n"
325     "addl   $32, %%ebx\n"
326     "movaps %%xmm6, -16(%%eax)\n"
327     "decl   %%ecx\n"
328     "jnz .second_128_samples\n"
329
330     "movl   8(%%ebp), %%eax\n"
331     "leal 512(%%eax), %%esi\n"  /* buf[64].re */
332     "leal 508(%%eax), %%edi\n"  /* buf[63].im */
333     "movl $16, %%ecx\n"         /* loop count */
334     "movl  20(%%ebp), %%eax\n"  /* delay */
335
336     ".align 16\n"
337 ".first_128_delay:\n"
338     "movss   (%%esi), %%xmm0\n"
339     "movss  8(%%esi), %%xmm2\n"
340     "movss   (%%edi), %%xmm1\n"
341     "movss -8(%%edi), %%xmm3\n"
342
343     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
344     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im0 */
345
346     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
347     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
348     "movss  16(%%esi), %%xmm6\n"    /* re2 */
349     "movss  24(%%esi), %%xmm7\n"    /* re3 */
350     "movss -16(%%edi), %%xmm2\n"    /* im2 */
351     "movss -24(%%edi), %%xmm3\n"    /* im3 */
352     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
353     "addl    $-32, %%edx\n"
354     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
355     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
356     "mulps   %%xmm4, %%xmm0\n"
357     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
358     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
359     "movaps %%xmm0, (%%eax)\n"
360     "addl   $32, %%esi\n"
361     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
362     "addl   $-32, %%edi\n"
363     "mulps  %%xmm5, %%xmm6\n"
364     "addl   $32, %%eax\n"
365     "movaps %%xmm6, -16(%%eax)\n"
366     "decl   %%ecx\n"
367     "jnz .first_128_delay\n"
368
369     "movl    8(%%ebp), %%ebx\n"
370     "leal    4(%%ebx), %%esi\n" /* buf[0].im */
371     "leal 1016(%%ebx), %%edi\n" /* buf[127].re */
372     "movl $16, %%ecx\n"         /* loop count */
373     
374     ".align 16\n"
375 ".second_128_delay:\n"
376     "movss   (%%esi), %%xmm0\n"
377     "movss  8(%%esi), %%xmm2\n"
378     "movss   (%%edi), %%xmm1\n"
379     "movss -8(%%edi), %%xmm3\n"
380
381     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
382     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
383
384     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
385     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
386     "movss  16(%%esi), %%xmm6\n"    /* im2 */
387     "movss  24(%%esi), %%xmm7\n"    /* im3 */
388     "movss -16(%%edi), %%xmm2\n"    /* re2 */
389     "movss -24(%%edi), %%xmm3\n"    /* re3 */
390     "subps   %%xmm0, %%xmm1\n"      /* re1 | -im1 | re0 | -im0 */
391     "addl    $-32, %%edx\n"
392     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
393     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
394     "mulps   %%xmm4, %%xmm1\n"
395     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
396     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
397     "movaps %%xmm1, (%%eax)\n"
398     "addl   $32, %%esi\n"
399     "subps  %%xmm6, %%xmm2\n"       /* re | -im3 | re | -im2 */
400     "addl   $-32, %%edi\n"
401     "mulps  %%xmm5, %%xmm2\n"
402     "addl   $32, %%eax\n"
403     "movaps %%xmm2, -16(%%eax)\n"
404     "decl   %%ecx\n"
405     "jnz .second_128_delay\n"
406
407     "popl %%edi\n"
408     "popl %%esi\n"
409     "popl %%edx\n"
410     "popl %%ecx\n"
411     "popl %%ebx\n"
412     "popl %%eax\n"
413     
414     "leave\n"
415     ::);
416 }
417
418 static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, float *window_prt, float *delay_prt)
419 {
420     __asm__ __volatile__ (
421     ".align 16\n"
422     "pushl %%ebp\n"
423     "movl  %%esp, %%ebp\n"
424     
425     "pushl %%eax\n"
426     "pushl %%ebx\n"
427     "pushl %%ecx\n"
428     "pushl %%edx\n"
429     "pushl %%esi\n"
430     "pushl %%edi\n"
431
432     /* movl 20(%%ebp), %%ebx delay */
433     "movl 16(%%ebp), %%edx\n"   /* window */
434
435     "movl   8(%%ebp), %%eax\n"  /* buf */
436     "movl $16, %%ecx\n"         /* loop count */
437     "leal 516(%%eax), %%esi\n"  /* buf[64].im */
438     "leal 504(%%eax), %%edi\n"  /* buf[63].re */
439     "movl  12(%%ebp), %%eax\n"  /* data */
440     
441     ".align 16\n"
442 ".first_128_sample:\n"
443     "movss   (%%esi), %%xmm0\n"
444     "movss  8(%%esi), %%xmm2\n"
445     "movss   (%%edi), %%xmm1\n"
446     "movss -8(%%edi), %%xmm3\n"
447
448     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
449     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
450
451     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
452     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
453
454     "movss  16(%%esi), %%xmm6\n"    /* im2 */
455     "movss  24(%%esi), %%xmm7\n"    /* im3 */
456     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
457     "movss -16(%%edi), %%xmm2\n"    /* re2 */
458     "movss -24(%%edi), %%xmm3\n"    /* re3 */
459     "mulps   %%xmm4, %%xmm0\n"
460     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
461     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
462     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
463     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
464     "subps  %%xmm2, %%xmm6\n"       /* -re3 | im3 | -re2 | im2 */
465     "addl   $32, %%edx\n"
466     "movaps %%xmm0, (%%eax)\n"
467     "mulps  %%xmm4, %%xmm6\n"
468     "addl   $32, %%esi\n"
469     "addl   $32, %%eax\n"
470     "addl   $-32, %%edi\n"
471     "movaps %%xmm6, -16(%%eax)\n"
472     "decl   %%ecx\n"
473     "jnz .first_128_sample\n"
474
475     "movl    8(%%ebp), %%esi\n"     /* buf[0].re */
476     "leal 1020(%%esi), %%edi\n"     /* buf[127].im */
477     "movl $16, %%ecx\n"             /* loop count */
478     
479     ".align 16\n"
480 ".second_128_sample:\n"
481     "movss   (%%esi), %%xmm0\n"     /* buf[i].re */
482     "movss  8(%%esi), %%xmm2\n"     /* re1 */
483     "movss   (%%edi), %%xmm1\n"     /* buf[127-i].im */
484     "movss -8(%%edi), %%xmm3\n"     /* im1 */
485
486     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
487     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im1 */
488     
489     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
490
491     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
492     "movss  16(%%esi), %%xmm6\n"    /* re2 */
493     "movss  24(%%esi), %%xmm7\n"    /* re3 */
494     "movss -16(%%edi), %%xmm2\n"    /* im2 */
495     "movss -24(%%edi), %%xmm3\n"    /* im3 */
496     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
497     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
498     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
499     "mulps   %%xmm4, %%xmm0\n"
500     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
501     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
502     "addl   $32, %%esi\n"
503     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
504     "mulps  %%xmm4, %%xmm6\n"
505     "addl   $-32, %%edi\n"
506     "movaps %%xmm0, (%%eax)\n"
507     "addl   $32, %%edx\n"
508     "addl   $32, %%eax\n"
509     "movaps %%xmm6, -16(%%eax)\n"
510     "decl   %%ecx\n"
511     "jnz .second_128_sample\n"
512
513     "movl   8(%%ebp), %%eax\n"
514     "leal 512(%%eax), %%esi\n"  /* buf[64].re */
515     "leal 508(%%eax), %%edi\n"  /* buf[63].im */
516     "movl $16, %%ecx\n"         /* loop count */
517     "movl  20(%%ebp), %%eax\n"  /* delay */
518     
519     ".align 16\n"
520 ".first_128_delays:\n"
521     "movss   (%%esi), %%xmm0\n"
522     "movss  8(%%esi), %%xmm2\n"
523     "movss   (%%edi), %%xmm1\n"
524     "movss -8(%%edi), %%xmm3\n"
525
526     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
527     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im0 */
528
529     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
530     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
531     "movss  16(%%esi), %%xmm6\n"    /* re2 */
532     "movss  24(%%esi), %%xmm7\n"    /* re3 */
533     "movss -16(%%edi), %%xmm2\n"    /* im2 */
534     "movss -24(%%edi), %%xmm3\n"    /* im3 */
535     "subps %%xmm1, %%xmm0\n"        /* -im1 | re1 | -im0 | re0 */
536     "addl  $-32, %%edx\n"
537     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
538     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
539     "mulps   %%xmm4, %%xmm0\n"
540     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
541     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
542     "movaps %%xmm0, (%%eax)\n"
543     "addl   $32, %%esi\n"
544     "subps  %%xmm2, %%xmm6\n"       /* -im3 | re3 | -im2 | re2 */
545     "addl   $-32, %%edi\n"
546     "mulps  %%xmm5, %%xmm6\n"
547     "addl   $32, %%eax\n"
548     "movaps %%xmm6, -16(%%eax)\n"
549     "decl   %%ecx\n"
550     "jnz .first_128_delays\n"
551
552     "movl    8(%%ebp), %%ebx\n"
553     "leal    4(%%ebx), %%esi\n" /* buf[0].im */
554     "leal 1016(%%ebx), %%edi\n" /* buf[127].re */
555     "movl $16, %%ecx\n"         /* loop count */
556     
557     ".align 16\n"
558 ".second_128_delays:\n"
559     "movss   (%%esi), %%xmm0\n"
560     "movss  8(%%esi), %%xmm2\n"
561     "movss   (%%edi), %%xmm1\n"
562     "movss -8(%%edi), %%xmm3\n"
563
564     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | im1 | 0.0 | im0 */
565     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | re1 | 0.0 | re0 */
566
567     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
568     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
569     "movss  16(%%esi), %%xmm6\n"    /* im2 */
570     "movss  24(%%esi), %%xmm7\n"    /* im3 */
571     "movss -16(%%edi), %%xmm2\n"    /* re2 */
572     "movss -24(%%edi), %%xmm3\n"    /* re3 */
573     "subps   %%xmm0, %%xmm1\n"      /* re1 | -im1 | re0 | -im0 */
574     "addl    $-32, %%edx\n"
575     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
576     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
577     "mulps   %%xmm4, %%xmm1\n"
578     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
579     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
580     "movaps %%xmm1, (%%eax)\n"
581     "addl   $32, %%esi\n"
582     "subps  %%xmm6, %%xmm2\n"       /* re | -im3 | re | -im2 */
583     "addl   $-32, %%edi\n"
584     "mulps  %%xmm5, %%xmm2\n"
585     "addl   $32, %%eax\n"
586     "movaps %%xmm2, -16(%%eax)\n"
587     "decl   %%ecx\n"
588     "jnz .second_128_delays\n"
589
590     "popl %%edi\n"
591     "popl %%esi\n"
592     "popl %%edx\n"
593     "popl %%ecx\n"
594     "popl %%ebx\n"
595     "popl %%eax\n"
596     
597     "leave\n"
598     ::);
599 }