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