2 * FFT/MDCT transform with SSE optimizations
3 * Copyright (c) 2002 Fabrice Bellard.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "../dsputil.h"
21 static const int p1p1p1m1[4] __attribute__((aligned(16))) =
24 static const int p1p1m1p1[4] __attribute__((aligned(16))) =
27 static const int p1p1m1m1[4] __attribute__((aligned(16))) =
28 { 0, 0, 1 << 31, 1 << 31 };
31 static void print_v4sf(const char *str, __m128 a)
33 float *p = (float *)&a;
34 printf("%s: %f %f %f %f\n",
35 str, p[0], p[1], p[2], p[3]);
39 /* XXX: handle reverse case */
40 void ff_fft_calc_sse(FFTContext *s, FFTComplex *z)
48 "movaps %0, %%xmm4 \n\t"
49 "movaps %1, %%xmm5 \n\t"
51 "m"(*(s->inverse ? p1p1m1p1 : p1p1p1m1))
58 /* do the pass 0 butterfly */
59 "movaps (%0,%1), %%xmm0 \n\t"
60 "movaps %%xmm0, %%xmm1 \n\t"
61 "shufps $0x4E, %%xmm0, %%xmm0 \n\t"
62 "xorps %%xmm4, %%xmm1 \n\t"
63 "addps %%xmm1, %%xmm0 \n\t"
64 "movaps 16(%0,%1), %%xmm2 \n\t"
65 "movaps %%xmm2, %%xmm3 \n\t"
66 "shufps $0x4E, %%xmm2, %%xmm2 \n\t"
67 "xorps %%xmm4, %%xmm3 \n\t"
68 "addps %%xmm3, %%xmm2 \n\t"
69 /* multiply third by -i */
70 /* by toggling the sign bit */
71 "shufps $0xB4, %%xmm2, %%xmm2 \n\t"
72 "xorps %%xmm5, %%xmm2 \n\t"
73 /* do the pass 1 butterfly */
74 "movaps %%xmm0, %%xmm1 \n\t"
75 "addps %%xmm2, %%xmm0 \n\t"
76 "subps %%xmm2, %%xmm1 \n\t"
77 "movaps %%xmm0, (%0,%1) \n\t"
78 "movaps %%xmm1, 16(%0,%1) \n\t"
85 nblocks = 1 << (ln-3);
96 "movaps (%2,%0), %%xmm1 \n\t"
97 "movaps (%1,%0), %%xmm0 \n\t"
98 "movaps %%xmm1, %%xmm2 \n\t"
99 "shufps $0xA0, %%xmm1, %%xmm1 \n\t"
100 "shufps $0xF5, %%xmm2, %%xmm2 \n\t"
101 "mulps (%3,%0,2), %%xmm1 \n\t" // cre*re cim*re
102 "mulps 16(%3,%0,2), %%xmm2 \n\t" // -cim*im cre*im
103 "addps %%xmm2, %%xmm1 \n\t"
104 "movaps %%xmm0, %%xmm3 \n\t"
105 "addps %%xmm1, %%xmm0 \n\t"
106 "subps %%xmm1, %%xmm3 \n\t"
107 "movaps %%xmm0, (%1,%0) \n\t"
108 "movaps %%xmm3, (%2,%0) \n\t"
111 :"r"(p), "r"(p + nloops), "r"(cptr)
118 } while (nblocks != 0);