2 * FFT/MDCT transform with 3DNow! optimizations
3 * Copyright (c) 2006 Zuxy MENG Jie.
4 * Based on fft_sse.c copyright (c) 2002 Fabrice Bellard.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "../dsputil.h"
27 static const int p1m1[2] __attribute__((aligned(8))) =
30 static const int m1p1[2] __attribute__((aligned(8))) =
33 void ff_fft_calc_3dn(FFTContext *s, FFTComplex *z)
38 register FFTComplex *p, *q;
39 FFTComplex *cptr, *cptr1;
43 /* FEMMS not a must here but recommended by AMD */
47 __m64 *r, a0, a1, b0, b1, tmp, c;
57 /* do the pass 0 butterfly */
58 a0 = _m_pfadd(r[0], r[1]);
59 a1 = _m_pfsub(r[0], r[1]);
61 /* do the pass 0 butterfly */
62 b0 = _m_pfadd(r[2], r[3]);
63 b1 = _m_pfsub(r[2], r[3]);
65 /* multiply third by -i */
66 tmp = _m_punpckhdq(b1, b1);
67 b1 = _m_punpckldq(b1, b1);
68 b1 = _m_punpckldq(tmp, b1);
71 /* do the pass 1 butterfly */
72 r[0] = _m_pfadd(a0, b0);
73 r[1] = _m_pfadd(a1, b1);
74 r[2] = _m_pfsub(a0, b0);
75 r[3] = _m_pfsub(a1, b1);
94 __m64 a0, a1, b0, b1, c0, c1, t10, t11, t20, t21;
102 c0 = *(__m64 *)&cptr[0];
103 c1 = *(__m64 *)&cptr[1];
105 t10 = _m_pfmul(c0, _m_punpckldq(b0, b0));
106 t11 = _m_pfmul(c1, _m_punpckldq(b1, b1));
107 c0 = *(__m64 *)&cptr[2];
108 c1 = *(__m64 *)&cptr[3];
110 t20 = _m_pfmul(c0, _m_punpckhdq(b0, b0));
111 t21 = _m_pfmul(c1, _m_punpckhdq(b1, b1));
112 b0 = _m_pfadd(t10, t20);
113 b1 = _m_pfadd(t11, t21);
116 *(__m64 *)&p[0] = _m_pfadd(a0, b0);
117 *(__m64 *)&p[1] = _m_pfadd(a1, b1);
118 *(__m64 *)&q[0] = _m_pfsub(a0, b0);
119 *(__m64 *)&q[1] = _m_pfsub(a1, b1);
130 nblocks = nblocks >> 1;
131 nloops = nloops << 1;
132 } while (nblocks != 0);