]> git.sesse.net Git - vlc/blob - plugins/imdct/ac3_imdct_sse.c
* AC3 IMDCT and downmix functions are now in plugins, --imdct and
[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.1 2001/05/15 16:19:42 sam 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
44 static const float window[] = {
45     0.00014, 0.00024, 0.00037, 0.00051, 0.00067, 0.00086, 0.00107, 0.00130,
46     0.00157, 0.00187, 0.00220, 0.00256, 0.00297, 0.00341, 0.00390, 0.00443,
47     0.00501, 0.00564, 0.00632, 0.00706, 0.00785, 0.00871, 0.00962, 0.01061,
48     0.01166, 0.01279, 0.01399, 0.01526, 0.01662, 0.01806, 0.01959, 0.02121,
49     0.02292, 0.02472, 0.02662, 0.02863, 0.03073, 0.03294, 0.03527, 0.03770,
50     0.04025, 0.04292, 0.04571, 0.04862, 0.05165, 0.05481, 0.05810, 0.06153,
51     0.06508, 0.06878, 0.07261, 0.07658, 0.08069, 0.08495, 0.08935, 0.09389,
52     0.09859, 0.10343, 0.10842, 0.11356, 0.11885, 0.12429, 0.12988, 0.13563,
53     0.14152, 0.14757, 0.15376, 0.16011, 0.16661, 0.17325, 0.18005, 0.18699,
54     0.19407, 0.20130, 0.20867, 0.21618, 0.22382, 0.23161, 0.23952, 0.24757,
55     0.25574, 0.26404, 0.27246, 0.28100, 0.28965, 0.29841, 0.30729, 0.31626,
56     0.32533, 0.33450, 0.34376, 0.35311, 0.36253, 0.37204, 0.38161, 0.39126,
57     0.40096, 0.41072, 0.42054, 0.43040, 0.44030, 0.45023, 0.46020, 0.47019,
58     0.48020, 0.49022, 0.50025, 0.51028, 0.52031, 0.53033, 0.54033, 0.55031,
59     0.56026, 0.57019, 0.58007, 0.58991, 0.59970, 0.60944, 0.61912, 0.62873,
60     0.63827, 0.64774, 0.65713, 0.66643, 0.67564, 0.68476, 0.69377, 0.70269,
61     0.71150, 0.72019, 0.72877, 0.73723, 0.74557, 0.75378, 0.76186, 0.76981,
62     0.77762, 0.78530, 0.79283, 0.80022, 0.80747, 0.81457, 0.82151, 0.82831,
63     0.83496, 0.84145, 0.84779, 0.85398, 0.86001, 0.86588, 0.87160, 0.87716,
64     0.88257, 0.88782, 0.89291, 0.89785, 0.90264, 0.90728, 0.91176, 0.91610,
65     0.92028, 0.92432, 0.92822, 0.93197, 0.93558, 0.93906, 0.94240, 0.94560,
66     0.94867, 0.95162, 0.95444, 0.95713, 0.95971, 0.96217, 0.96451, 0.96674,
67     0.96887, 0.97089, 0.97281, 0.97463, 0.97635, 0.97799, 0.97953, 0.98099,
68     0.98236, 0.98366, 0.98488, 0.98602, 0.98710, 0.98811, 0.98905, 0.98994,
69     0.99076, 0.99153, 0.99225, 0.99291, 0.99353, 0.99411, 0.99464, 0.99513,
70     0.99558, 0.99600, 0.99639, 0.99674, 0.99706, 0.99736, 0.99763, 0.99788,
71     0.99811, 0.99831, 0.99850, 0.99867, 0.99882, 0.99895, 0.99908, 0.99919,
72     0.99929, 0.99938, 0.99946, 0.99953, 0.99959, 0.99965, 0.99969, 0.99974,
73     0.99978, 0.99981, 0.99984, 0.99986, 0.99988, 0.99990, 0.99992, 0.99993,
74     0.99994, 0.99995, 0.99996, 0.99997, 0.99998, 0.99998, 0.99998, 0.99999,
75     0.99999, 0.99999, 0.99999, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
76     1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000
77 };
78
79 static const int pm128[128] =
80 {
81     0, 16, 32, 48, 64, 80,  96, 112,  8, 40, 72, 104, 24, 56,  88, 120,
82     4, 20, 36, 52, 68, 84, 100, 116, 12, 28, 44,  60, 76, 92, 108, 124,
83     2, 18, 34, 50, 66, 82,  98, 114, 10, 42, 74, 106, 26, 58,  90, 122,
84     6, 22, 38, 54, 70, 86, 102, 118, 14, 46, 78, 110, 30, 62,  94, 126,
85     1, 17, 33, 49, 65, 81,  97, 113,  9, 41, 73, 105, 25, 57,  89, 121,
86     5, 21, 37, 53, 69, 85, 101, 117, 13, 29, 45,  61, 77, 93, 109, 125,
87     3, 19, 35, 51, 67, 83,  99, 115, 11, 43, 75, 107, 27, 59,  91, 123,
88     7, 23, 39, 55, 71, 87, 103, 119, 15, 31, 47,  63, 79, 95, 111, 127
89 }; 
90
91 void _M( fft_64p )  ( complex_t *x );
92 void _M( fft_128p ) ( complex_t *a );
93
94 static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse);
95 static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse);
96 static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, const float *window_prt, float *delay_prt);
97 static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, const float *window_prt, float *delay_prt);
98
99
100 void _M( imdct_init ) (imdct_t * p_imdct)
101 {
102     int i;
103     float scale = 181.019;
104
105     for (i=0; i < 128; i++)
106     {
107         float xcos_i = cos(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
108         float xsin_i = sin(2.0f * M_PI * (8*i+1)/(8*N)) * scale;
109         p_imdct->xcos_sin_sse[i * 4]     = xcos_i;
110         p_imdct->xcos_sin_sse[i * 4 + 1] = -xsin_i;
111         p_imdct->xcos_sin_sse[i * 4 + 2] = -xsin_i;
112         p_imdct->xcos_sin_sse[i * 4 + 3] = -xcos_i;
113     }
114 }
115
116 void _M( imdct_do_512 ) (imdct_t * p_imdct, float data[], float delay[])
117 {
118     imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);
119     _M( fft_128p ) ( p_imdct->buf );
120     imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
121     imdct512_window_delay_sse (p_imdct->buf, data, window, delay);
122 }
123
124
125 void _M( imdct_do_512_nol ) (imdct_t * p_imdct, float data[], float delay[])
126 {
127     imdct512_pre_ifft_twiddle_sse (pm128, p_imdct->buf, data, p_imdct->xcos_sin_sse);  
128     _M( fft_128p ) ( p_imdct->buf );
129     imdct512_post_ifft_twiddle_sse (p_imdct->buf, p_imdct->xcos_sin_sse);
130     imdct512_window_delay_nol_sse (p_imdct->buf, data, window, delay);
131 }
132
133 static void imdct512_pre_ifft_twiddle_sse (const int *pmt, complex_t *buf, float *data, float *xcos_sin_sse)
134 {
135     __asm__ __volatile__ (    
136     "pushl %%ebp\n"
137     "movl  %%esp, %%ebp\n"
138     "addl  $-4, %%esp\n" /* local variable, loop counter */
139     
140     "pushl %%eax\n"
141     "pushl %%ebx\n"
142     "pushl %%ecx\n"
143     "pushl %%edx\n"
144     "pushl %%edi\n"
145     "pushl %%esi\n"
146
147     "movl  8(%%ebp), %%eax\n"     /* pmt */
148     "movl 12(%%ebp), %%ebx\n"    /* buf */
149     "movl 16(%%ebp), %%ecx\n"    /* data */
150     "movl 20(%%ebp), %%edx\n"     /* xcos_sin_sse */
151     "movl $64, -4(%%ebp)\n"
152     
153 ".loop:\n"
154     "movl  (%%eax), %%esi\n"
155     "movl 4(%%eax), %%edi\n"
156     "movss (%%ecx, %%esi, 8), %%xmm1\n" /* 2j */
157     "movss (%%ecx, %%edi, 8), %%xmm3\n" /* 2(j+1) */
158
159     "shll $1, %%esi\n"
160     "shll $1, %%edi\n"
161
162     "movups (%%edx, %%esi, 8), %%xmm0\n" /* -c_j | -s_j | -s_j | c_j */
163     "movups (%%edx, %%edi, 8), %%xmm2\n" /* -c_j+1 | -s_j+1 | -s_j+1 | c_j+1 */
164
165     "negl %%esi\n"
166     "negl %%edi\n"
167
168     "movss 1020(%%ecx, %%esi, 4), %%xmm4\n" /* 255-2j */
169     "addl $8, %%eax\n"
170     "movss 1020(%%ecx, %%edi, 4), %%xmm5\n" /* 255-2(j+1) */
171
172     "shufps $0, %%xmm1, %%xmm4\n" /* 2j | 2j | 255-2j | 255-2j */
173     "shufps $0, %%xmm3, %%xmm5\n" /* 2(j+1) | 2(j+1) | 255-2(j+1) | 255-2(j+1) */
174     "mulps   %%xmm4, %%xmm0\n"
175     "mulps   %%xmm5, %%xmm2\n"
176     "movhlps %%xmm0, %%xmm1\n"
177     "movhlps %%xmm2, %%xmm3\n"
178     "addl    $16, %%ebx\n"
179     "addps   %%xmm1, %%xmm0\n"
180     "addps   %%xmm3, %%xmm2\n"
181     "movlhps %%xmm2, %%xmm0\n"
182     
183     "movups  %%xmm0, -16(%%ebx)\n"
184     "decl -4(%%ebp)\n"
185        "jnz .loop\n"
186
187     "popl %%esi\n"
188     "popl %%edi\n"
189     "popl %%edx\n"
190     "popl %%ecx\n"
191     "popl %%ebx\n"
192     "popl %%eax\n"
193
194     "addl $4, %%esp\n"
195     "popl %%ebp\n"
196     ::);
197 }
198
199 static void imdct512_post_ifft_twiddle_sse (complex_t *buf, float *xcos_sin_sse)
200 {
201     __asm__ __volatile__ ( 
202     "pushl %%ebx\n"
203     "movl $32, %%ebx\n"                 /* loop counter */
204
205 ".loop1:\n"
206     "movups    (%%eax), %%xmm0\n"          /*  im1 | re1 | im0 | re0 */
207
208     "movups  (%%ecx), %%xmm2\n"         /* -c | -s | -s | c */
209     "movhlps  %%xmm0, %%xmm1\n"         /* im1 | re1 */
210     "movups  16(%%ecx), %%xmm3\n"       /* -c1 | -s1 | -s1 | c1 */
211
212     "shufps $0x50, %%xmm0, %%xmm0\n"    /* im0 | im0 | re0 | re0 */
213     "shufps $0x50, %%xmm1, %%xmm1\n"    /* im1 | im1 | re1 | re1 */
214
215     "movups  16(%%eax), %%xmm4\n"       /* im3 | re3 | im2 | re2 */
216
217     "shufps $0x27, %%xmm2, %%xmm2\n"    /* c | -s | -s | -c */
218     "movhlps  %%xmm4, %%xmm5\n"         /* im3 | re3 */
219     "shufps $0x27, %%xmm3, %%xmm3\n"    /* c1 | -s1 | -s1 | -c1 */
220
221     "movups  32(%%ecx), %%xmm6\n"       /* -c2 | -s2 | -s2 | c2 */
222     "movups  48(%%ecx), %%xmm7\n"       /* -c3 | -s3 | -s3 | c3 */
223
224     "shufps $0x50, %%xmm4, %%xmm4\n"    /* im2 | im2 | re2 | re2 */
225     "shufps $0x50, %%xmm5, %%xmm5\n"    /* im3 | im3 | re3 | re3 */
226
227     "mulps %%xmm2, %%xmm0\n"
228     "mulps %%xmm3, %%xmm1\n"
229
230     "shufps $0x27, %%xmm6, %%xmm6\n"    /* c2 | -s2 | -s2 | -c2 */
231     "shufps $0x27, %%xmm7, %%xmm7\n"    /* c3 | -s3 | -s3 | -c3 */
232
233     "movhlps %%xmm0, %%xmm2\n"
234     "movhlps %%xmm1, %%xmm3\n"
235
236     "mulps %%xmm6, %%xmm4\n"
237     "mulps %%xmm7, %%xmm5\n"
238
239     "addps %%xmm2, %%xmm0\n"
240     "addps %%xmm3, %%xmm1\n"
241
242     "movhlps %%xmm4, %%xmm6\n"
243     "movhlps %%xmm5, %%xmm7\n"
244
245     "addps %%xmm6, %%xmm4\n"
246     "addps %%xmm7, %%xmm5\n"
247
248     "movlhps %%xmm1, %%xmm0\n"
249     "movlhps %%xmm5, %%xmm4\n"
250
251     "movups %%xmm0, (%%eax)\n"
252     "movups %%xmm4, 16(%%eax)\n"
253     "addl $64, %%ecx\n"
254     "addl $32, %%eax\n"
255     "decl %%ebx\n"
256     "jnz .loop1\n"
257
258     "popl %%ebx\n"
259     : "=a" (buf)
260     : "a" (buf), "c" (xcos_sin_sse) );
261 }
262
263 static void imdct512_window_delay_sse (complex_t *buf, float *data_ptr, const float *window_prt, float *delay_prt)
264 {
265     __asm__ __volatile__ (
266     "pushl %%ebp\n"
267     "movl  %%esp, %%ebp\n"
268     
269     "pushl %%eax\n"
270     "pushl %%ebx\n"
271     "pushl %%ecx\n"
272     "pushl %%edx\n"
273     "pushl %%esi\n"
274     "pushl %%edi\n"
275
276     "movl 20(%%ebp), %%ebx\n"   /* delay */
277     "movl 16(%%ebp), %%edx\n"   /* window */
278
279     "movl 8(%%ebp), %%eax\n"    /* buf */
280     "movl $16, %%ecx\n"         /* loop count */
281     "leal 516(%%eax), %%esi\n"  /* buf[64].im */
282     "leal 504(%%eax), %%edi\n"  /* buf[63].re */
283     "movl  12(%%ebp), %%eax\n"  /* data */
284
285 ".first_128_samples:\n"
286     "movss   (%%esi), %%xmm0\n"
287     "movss  8(%%esi), %%xmm2\n"
288     "movss   (%%edi), %%xmm1\n"
289     "movss -8(%%edi), %%xmm3\n"
290
291     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
292     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
293
294     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
295     "movups (%%ebx), %%xmm5\n"      /* d3 | d2 | d1 | d0 */
296     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
297
298     "movss  16(%%esi), %%xmm6\n"    /* im2 */
299     "movss  24(%%esi), %%xmm7\n"    /* im3 */
300     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
301     "movss -16(%%edi), %%xmm2\n"    /* re2 */
302     "movss -24(%%edi), %%xmm3\n"    /* re3 */
303     "mulps     %%xmm4, %%xmm0\n"
304     "movlhps   %%xmm7, %%xmm6\n"    /* 0.0 | im3 | 0.0 | im2 */
305     "movlhps   %%xmm3, %%xmm2\n"    /* 0.0 | re3 | 0.0 | re2 */
306     "addps %%xmm5, %%xmm0\n"
307     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
308     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
309     "movups 16(%%ebx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
310     "subps %%xmm2, %%xmm6\n"        /* -re3 | im3 | -re2 | im2 */
311     "addl $32, %%edx\n"
312     "movups %%xmm0, (%%eax)\n"
313     "addl $32, %%ebx\n"
314     "mulps %%xmm4, %%xmm6\n"
315     "addl $32, %%esi\n"
316     "addl $32, %%eax\n"
317     "addps %%xmm5, %%xmm6\n"
318     "addl $-32, %%edi\n"
319     "movups %%xmm6, -16(%%eax)\n"
320     "decl %%ecx\n"
321     "jnz .first_128_samples\n"
322
323     "movl 8(%%ebp), %%esi\n"    /* buf[0].re */
324     "leal 1020(%%esi), %%edi\n" /* buf[127].im */
325     "movl $16, %%ecx\n"         /* loop count */
326     
327 ".second_128_samples:\n"
328     "movss   (%%esi), %%xmm0\n" /* buf[i].re */
329     "movss  8(%%esi), %%xmm2\n" /* re1 */
330     "movss   (%%edi), %%xmm1\n" /* buf[127-i].im */
331     "movss -8(%%edi), %%xmm3\n" /* im1 */
332
333     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
334     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im1 */
335
336     "movups (%%edx), %%xmm4\n"  /* w3 | w2 | w1 | w0 */
337     "movups (%%ebx), %%xmm5\n"  /* d3 | d2 | d1 | d0 */
338
339     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
340     "movss  16(%%esi), %%xmm6\n"    /* re2 */
341     "movss  24(%%esi), %%xmm7\n"    /* re3 */
342     "movss -16(%%edi), %%xmm2\n"    /* im2 */
343     "movss -24(%%edi), %%xmm3\n"    /* im3 */
344     "subps   %%xmm1, %%xmm0\n"      /* -im1 | re1 | -im0 | re0 */
345     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
346     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
347     "mulps   %%xmm4, %%xmm0\n"
348     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
349     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
350     "addl $32, %%esi\n"
351     "subps %%xmm2, %%xmm6\n"        /* -im3 | re3 | -im2 | re2 */
352     "addps %%xmm5, %%xmm0\n"
353     "mulps %%xmm4, %%xmm6\n"
354     "addl $-32, %%edi\n"
355     "movups 16(%%ebx), %%xmm5\n"    /* d7 | d6 | d5 | d4 */
356     "movups %%xmm0, (%%eax)\n"
357     "addps %%xmm5, %%xmm6\n"
358     "addl $32, %%edx\n"
359     "addl $32, %%eax\n"
360     "addl $32, %%ebx\n"
361     "movups %%xmm6, -16(%%eax)\n"
362     "decl %%ecx\n"
363     "jnz .second_128_samples\n"
364
365     "movl   8(%%ebp), %%eax\n"
366     "leal 512(%%eax), %%esi\n"  /* buf[64].re */
367     "leal 508(%%eax), %%edi\n"  /* buf[63].im */
368     "movl $16, %%ecx\n"         /* loop count */
369     "movl  20(%%ebp), %%eax\n"  /* delay */
370
371 ".first_128_delay:\n"
372     "movss   (%%esi), %%xmm0\n"
373     "movss  8(%%esi), %%xmm2\n"
374     "movss   (%%edi), %%xmm1\n"
375     "movss -8(%%edi), %%xmm3\n"
376
377     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
378     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im0 */
379
380     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
381     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
382     "movss  16(%%esi), %%xmm6\n"    /* re2 */
383     "movss  24(%%esi), %%xmm7\n"    /* re3 */
384     "movss -16(%%edi), %%xmm2\n"    /* im2 */
385     "movss -24(%%edi), %%xmm3\n"    /* im3 */
386     "subps     %%xmm1, %%xmm0\n"    /* -im1 | re1 | -im0 | re0 */
387     "addl $-32, %%edx\n"
388     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
389     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
390     "mulps   %%xmm4, %%xmm0\n"
391     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
392     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
393     "movups %%xmm0, (%%eax)\n"
394     "addl $32, %%esi\n"
395     "subps %%xmm2, %%xmm6\n"        /* -im3 | re3 | -im2 | re2 */
396     "addl $-32, %%edi\n"
397     "mulps %%xmm5, %%xmm6\n"
398     "addl $32, %%eax\n"
399     "movups %%xmm6, -16(%%eax)\n"
400     "decl %%ecx\n"
401     "jnz .first_128_delay\n"
402
403     "movl    8(%%ebp), %%ebx\n"
404     "leal    4(%%ebx), %%esi\n" /* buf[0].im */
405     "leal 1016(%%ebx), %%edi\n" /* buf[127].re */
406     "movl $16, %%ecx\n"         /* loop count */
407     
408 ".second_128_delay:\n"
409     "movss   (%%esi), %%xmm0\n"
410     "movss  8(%%esi), %%xmm2\n"
411     "movss   (%%edi), %%xmm1\n"
412     "movss -8(%%edi), %%xmm3\n"
413
414     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
415     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
416
417     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
418     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
419     "movss  16(%%esi), %%xmm6\n"    /* im2 */
420     "movss  24(%%esi), %%xmm7\n"    /* im3 */
421     "movss -16(%%edi), %%xmm2\n"    /* re2 */
422     "movss -24(%%edi), %%xmm3\n"    /* re3 */
423     "subps %%xmm0, %%xmm1\n"        /* re1 | -im1 | re0 | -im0 */
424     "addl $-32, %%edx\n"
425     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
426     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
427     "mulps   %%xmm4, %%xmm1\n"
428     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
429     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
430     "movups %%xmm1, (%%eax)\n"
431     "addl $32, %%esi\n"
432     "subps %%xmm6, %%xmm2\n"        /* re | -im3 | re | -im2 */
433     "addl $-32, %%edi\n"
434     "mulps %%xmm5, %%xmm2\n"
435     "addl $32, %%eax\n"
436     "movups %%xmm2, -16(%%eax)\n"
437     "decl %%ecx\n"
438     "jnz .second_128_delay\n"
439
440     "popl %%edi\n"
441     "popl %%esi\n"
442     "popl %%edx\n"
443     "popl %%ecx\n"
444     "popl %%ebx\n"
445     "popl %%eax\n"
446     
447     "leave\n"
448     ::);
449 }
450
451 static void imdct512_window_delay_nol_sse (complex_t *buf, float *data_ptr, const float *window_prt, float *delay_prt)
452 {
453     __asm__ __volatile__ (
454     "pushl %%ebp\n"
455     "movl  %%esp, %%ebp\n"
456     
457     "pushl %%eax\n"
458     "pushl %%ebx\n"
459     "pushl %%ecx\n"
460     "pushl %%edx\n"
461     "pushl %%esi\n"
462     "pushl %%edi\n"
463
464     /* movl 20(%%ebp), %%ebx delay */
465     "movl 16(%%ebp), %%edx\n"   /* window */
466
467     "movl   8(%%ebp), %%eax\n"  /* buf */
468     "movl $16, %%ecx\n"         /* loop count */
469     "leal 516(%%eax), %%esi\n"  /* buf[64].im */
470     "leal 504(%%eax), %%edi\n"  /* buf[63].re */
471     "movl  12(%%ebp), %%eax\n"  /* data */
472     
473 ".first_128_sample:\n"
474     "movss   (%%esi), %%xmm0\n"
475     "movss  8(%%esi), %%xmm2\n"
476     "movss   (%%edi), %%xmm1\n"
477     "movss -8(%%edi), %%xmm3\n"
478
479     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | im1 | 0.0 | im0 */
480     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | re1 | 0.0 | re0 */
481
482     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
483     /* movups (%%ebx), %%xmm5 d3 | d2 | d1 | d0 */
484     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
485
486     "movss  16(%%esi), %%xmm6\n"    /* im2 */
487     "movss  24(%%esi), %%xmm7\n"    /* im3 */
488     "subps     %%xmm1, %%xmm0\n"    /* -re1 | im1 | -re0 | im0 */
489     "movss -16(%%edi), %%xmm2\n"    /* re2 */
490     "movss -24(%%edi), %%xmm3\n"    /* re3 */
491     "mulps %%xmm4, %%xmm0\n"
492     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
493     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
494     /* addps %%xmm5, %%xmm0 */
495     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
496     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
497     /* movups 16(%%ebx), %%xmm5  d7 | d6 | d5 | d4 */
498     "subps %%xmm2, %%xmm6\n"        /* -re3 | im3 | -re2 | im2 */
499     "addl $32, %%edx\n"
500     "movups %%xmm0, (%%eax)\n"
501     /* addl $32, %%ebx */
502     "mulps %%xmm4, %%xmm6\n"
503     "addl $32, %%esi\n"
504     "addl $32, %%eax\n"
505     /* addps %%xmm5, %%xmm6 */
506     "addl $-32, %%edi\n"
507     "movups %%xmm6, -16(%%eax)\n"
508     "decl %%ecx\n"
509     "jnz .first_128_sample\n"
510
511     "movl    8(%%ebp), %%esi\n"     /* buf[0].re */
512     "leal 1020(%%esi), %%edi\n"     /* buf[127].im */
513     "movl $16, %%ecx\n"             /* loop count */
514     
515 ".second_128_sample:\n"
516     "movss   (%%esi), %%xmm0\n"     /* buf[i].re */
517     "movss  8(%%esi), %%xmm2\n"     /* re1 */
518     "movss   (%%edi), %%xmm1\n"     /* buf[127-i].im */
519     "movss -8(%%edi), %%xmm3\n"     /* im1 */
520
521     "movlhps %%xmm2, %%xmm0\n"      /* 0.0 | re1 | 0.0 | re0 */
522     "movlhps %%xmm3, %%xmm1\n"      /* 0.0 | im1 | 0.0 | im1 */
523     
524     "movups (%%edx), %%xmm4\n"      /* w3 | w2 | w1 | w0 */
525     /* movups (%%ebx), %%xmm5 d3 | d2 | d1 | d0 */
526
527     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
528     "movss  16(%%esi), %%xmm6\n"    /* re2 */
529     "movss  24(%%esi), %%xmm7\n"    /* re3 */
530     "movss -16(%%edi), %%xmm2\n"    /* im2 */
531     "movss -24(%%edi), %%xmm3\n"    /* im3 */
532     "subps %%xmm1, %%xmm0\n"        /* -im1 | re1 | -im0 | re0 */
533     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
534     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
535     "mulps %%xmm4, %%xmm0\n"
536     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
537     "movups 16(%%edx), %%xmm4\n"    /* w7 | w6 | w5 | w4 */
538     "addl $32, %%esi\n"
539     "subps %%xmm2, %%xmm6\n"        /* -im3 | re3 | -im2 | re2 */
540     /* addps %%xmm5, %%xmm0 */
541     "mulps %%xmm4, %%xmm6\n"
542     "addl $-32, %%edi\n"
543     /* movups 16(%%ebx), %%xmm5  d7 | d6 | d5 | d4 */
544     "movups %%xmm0, (%%eax)\n"
545     /* addps %%xmm5, %%xmm6 */
546     "addl $32, %%edx\n"
547     "addl $32, %%eax\n"
548     /* addl $32, %%ebx */
549     "movups %%xmm6, -16(%%eax)\n"
550     "decl %%ecx\n"
551     "jnz .second_128_sample\n"
552
553     "movl   8(%%ebp), %%eax\n"
554     "leal 512(%%eax), %%esi\n"  /* buf[64].re */
555     "leal 508(%%eax), %%edi\n"  /* buf[63].im */
556     "movl $16, %%ecx\n"         /* loop count */
557     "movl  20(%%ebp), %%eax\n"  /* delay */
558     
559 ".first_128_delays:\n"
560     "movss   (%%esi), %%xmm0\n"
561     "movss  8(%%esi), %%xmm2\n"
562     "movss   (%%edi), %%xmm1\n"
563     "movss -8(%%edi), %%xmm3\n"
564
565     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | re1 | 0.0 | re0 */
566     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | im1 | 0.0 | im0 */
567
568     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
569     "shufps $0xb1, %%xmm1, %%xmm1\n"/* im1 | 0.0 | im0 | 0.0 */
570     "movss  16(%%esi), %%xmm6\n"    /* re2 */
571     "movss  24(%%esi), %%xmm7\n"    /* re3 */
572     "movss -16(%%edi), %%xmm2\n"    /* im2 */
573     "movss -24(%%edi), %%xmm3\n"    /* im3 */
574     "subps %%xmm1, %%xmm0\n"        /* -im1 | re1 | -im0 | re0 */
575     "addl $-32, %%edx\n"
576     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | re3 | 0.0 | re2 */
577     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | im3 | 0.0 | im2 */
578     "mulps %%xmm4, %%xmm0\n"
579     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
580     "shufps $0xb1, %%xmm2, %%xmm2\n"/* im3 | 0.0 | im2 | 0.0 */
581     "movups %%xmm0, (%%eax)\n"
582     "addl $32, %%esi\n"
583     "subps %%xmm2, %%xmm6\n"        /* -im3 | re3 | -im2 | re2 */
584     "addl $-32, %%edi\n"
585     "mulps %%xmm5, %%xmm6\n"
586     "addl $32, %%eax\n"
587     "movups %%xmm6, -16(%%eax)\n"
588     "decl %%ecx\n"
589     "jnz .first_128_delays\n"
590
591     "movl    8(%%ebp), %%ebx\n"
592     "leal    4(%%ebx), %%esi\n" /* buf[0].im */
593     "leal 1016(%%ebx), %%edi\n" /* buf[127].re */
594     "movl $16, %%ecx\n"         /* loop count */
595     
596 ".second_128_delays:\n"
597     "movss   (%%esi), %%xmm0\n"
598     "movss  8(%%esi), %%xmm2\n"
599     "movss   (%%edi), %%xmm1\n"
600     "movss -8(%%edi), %%xmm3\n"
601
602     "movlhps %%xmm2, %%xmm0\n"  /* 0.0 | im1 | 0.0 | im0 */
603     "movlhps %%xmm3, %%xmm1\n"  /* 0.0 | re1 | 0.0 | re0 */
604
605     "movups -16(%%edx), %%xmm4\n"   /* w3 | w2 | w1 | w0 */
606     "shufps $0xb1, %%xmm1, %%xmm1\n"/* re1 | 0.0 | re0 | 0.0 */
607     "movss  16(%%esi), %%xmm6\n"    /* im2 */
608     "movss  24(%%esi), %%xmm7\n"    /* im3 */
609     "movss -16(%%edi), %%xmm2\n"    /* re2 */
610     "movss -24(%%edi), %%xmm3\n"    /* re3 */
611     "subps %%xmm0, %%xmm1\n"        /* re1 | -im1 | re0 | -im0 */
612     "addl $-32, %%edx\n"
613     "movlhps %%xmm7, %%xmm6\n"      /* 0.0 | im3 | 0.0 | im2 */
614     "movlhps %%xmm3, %%xmm2\n"      /* 0.0 | re3 | 0.0 | re2 */
615     "mulps %%xmm4, %%xmm1\n"
616     "movups (%%edx), %%xmm5\n"      /* w7 | w6 | w5 | w4 */
617     "shufps $0xb1, %%xmm2, %%xmm2\n"/* re3 | 0.0 | re2 | 0.0 */
618     "movups %%xmm1, (%%eax)\n"
619     "addl $32, %%esi\n"
620     "subps %%xmm6, %%xmm2\n"        /* re | -im3 | re | -im2 */
621     "addl $-32, %%edi\n"
622     "mulps %%xmm5, %%xmm2\n"
623     "addl $32, %%eax\n"
624     "movups %%xmm2, -16(%%eax)\n"
625     "decl %%ecx\n"
626     "jnz .second_128_delays\n"
627
628     "popl %%edi\n"
629     "popl %%esi\n"
630     "popl %%edx\n"
631     "popl %%ecx\n"
632     "popl %%ebx\n"
633     "popl %%eax\n"
634     
635     "leave\n"
636     ::);
637 }