8e8e36b0f748289f378c3b353c23ea87a1b1a5db
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "../dsputil.h"
22 #include <xmmintrin.h>
24 static const float p1p1p1m1
[4] __attribute__((aligned(16))) =
25 { 1.0, 1.0, 1.0, -1.0 };
27 static const float p1p1m1m1
[4] __attribute__((aligned(16))) =
28 { 1.0, 1.0, -1.0, -1.0 };
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 fft_calc_sse(FFTContext
*s
, FFTComplex
*z
)
45 register FFTComplex
*p
, *q
;
46 FFTComplex
*cptr
, *cptr1
;
52 __m128
*r
, a
, b
, a1
, c1
, c2
;
55 c1
= *(__m128
*)p1p1m1m1
;
56 c2
= *(__m128
*)p1p1p1m1
;
60 b
= _mm_shuffle_ps(a
, a
, _MM_SHUFFLE(1, 0, 3, 2));
61 a
= _mm_mul_ps(a
, c1
);
62 /* do the pass 0 butterfly */
66 b
= _mm_shuffle_ps(a1
, a1
, _MM_SHUFFLE(1, 0, 3, 2));
67 a1
= _mm_mul_ps(a1
, c1
);
68 /* do the pass 0 butterfly */
69 b
= _mm_add_ps(a1
, b
);
71 /* multiply third by -i */
72 b
= _mm_shuffle_ps(b
, b
, _MM_SHUFFLE(2, 3, 1, 0));
73 b
= _mm_mul_ps(b
, c2
);
75 /* do the pass 1 butterfly */
76 r
[0] = _mm_add_ps(a
, b
);
77 r
[1] = _mm_sub_ps(a
, b
);
96 __m128 a
, b
, c
, t1
, t2
;
105 _mm_shuffle_ps(b
, b
, _MM_SHUFFLE(2, 2, 0, 0)));
106 c
= *(__m128
*)(cptr
+ 2);
109 _mm_shuffle_ps(b
, b
, _MM_SHUFFLE(3, 3, 1, 1)));
110 b
= _mm_add_ps(t1
, t2
);
113 *(__m128
*)p
= _mm_add_ps(a
, b
);
114 *(__m128
*)q
= _mm_sub_ps(a
, b
);
125 nblocks
= nblocks
>> 1;
126 nloops
= nloops
<< 1;
127 } while (nblocks
!= 0);