annotate liba52/imdct.c @ 3908:0cc94b1eec0f

runtime cpudetect in liba52 way
author michael
date Sun, 30 Dec 2001 21:38:53 +0000
parents 0410677eda4a
children 2dbd637ffe05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1 /*
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
2 * imdct.c
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
3 * Copyright (C) 2000-2001 Michel Lespinasse <walken@zoy.org>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
5 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
7 * See http://liba52.sourceforge.net/ for updates.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
8 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
9 * a52dec is free software; you can redistribute it and/or modify
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
12 * (at your option) any later version.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
13 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
14 * a52dec is distributed in the hope that it will be useful,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
17 * GNU General Public License for more details.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
18 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
22 *
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
23 * SSE optimizations from Michael Niedermayer (michaelni@gmx.at)
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
24 * 3DNOW optimizations from Nick Kurshev <nickols_k@mail.ru>
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
25 * michael did port them from libac3 (untested, perhaps totally broken)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
26 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
27
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
28 #include "config.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
29
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
30 #include <math.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
31 #include <stdio.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
32 #ifndef M_PI
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
33 #define M_PI 3.1415926535897932384626433832795029
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34 #endif
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35 #include <inttypes.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
37 #include "a52.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
38 #include "a52_internal.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
39 #include "mm_accel.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
40
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
41 #ifdef RUNTIME_CPUDETECT
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
42 #undef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
43 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
44
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
45 #define USE_AC3_C
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
46
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
47 void (* imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
48 void (* imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
49
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
50 typedef struct complex_s {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
51 sample_t real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
52 sample_t imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
53 } complex_t;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
54
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
55 static void fft_128p(complex_t *a);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
56 static void fft_128p_3dnow(complex_t *a);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
57
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
58 static const int pm128[128] __attribute__((aligned(16))) =
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
59 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
60 0, 16, 32, 48, 64, 80, 96, 112, 8, 40, 72, 104, 24, 56, 88, 120,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
61 4, 20, 36, 52, 68, 84, 100, 116, 12, 28, 44, 60, 76, 92, 108, 124,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
62 2, 18, 34, 50, 66, 82, 98, 114, 10, 42, 74, 106, 26, 58, 90, 122,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
63 6, 22, 38, 54, 70, 86, 102, 118, 14, 46, 78, 110, 30, 62, 94, 126,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
64 1, 17, 33, 49, 65, 81, 97, 113, 9, 41, 73, 105, 25, 57, 89, 121,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
65 5, 21, 37, 53, 69, 85, 101, 117, 13, 29, 45, 61, 77, 93, 109, 125,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
66 3, 19, 35, 51, 67, 83, 99, 115, 11, 43, 75, 107, 27, 59, 91, 123,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
67 7, 23, 39, 55, 71, 87, 103, 119, 15, 31, 47, 63, 79, 95, 111, 127
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
68 };
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
69
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
70 /* 128 point bit-reverse LUT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
71 static uint8_t bit_reverse_512[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
72 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
73 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
74 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
75 0x0c, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
76 0x02, 0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
77 0x0a, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
78 0x06, 0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
79 0x0e, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
80 0x01, 0x41, 0x21, 0x61, 0x11, 0x51, 0x31, 0x71,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
81 0x09, 0x49, 0x29, 0x69, 0x19, 0x59, 0x39, 0x79,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
82 0x05, 0x45, 0x25, 0x65, 0x15, 0x55, 0x35, 0x75,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
83 0x0d, 0x4d, 0x2d, 0x6d, 0x1d, 0x5d, 0x3d, 0x7d,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
84 0x03, 0x43, 0x23, 0x63, 0x13, 0x53, 0x33, 0x73,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
85 0x0b, 0x4b, 0x2b, 0x6b, 0x1b, 0x5b, 0x3b, 0x7b,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
86 0x07, 0x47, 0x27, 0x67, 0x17, 0x57, 0x37, 0x77,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
87 0x0f, 0x4f, 0x2f, 0x6f, 0x1f, 0x5f, 0x3f, 0x7f};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
88
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
89 static uint8_t bit_reverse_256[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
90 0x00, 0x20, 0x10, 0x30, 0x08, 0x28, 0x18, 0x38,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
91 0x04, 0x24, 0x14, 0x34, 0x0c, 0x2c, 0x1c, 0x3c,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 0x02, 0x22, 0x12, 0x32, 0x0a, 0x2a, 0x1a, 0x3a,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
93 0x06, 0x26, 0x16, 0x36, 0x0e, 0x2e, 0x1e, 0x3e,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94 0x01, 0x21, 0x11, 0x31, 0x09, 0x29, 0x19, 0x39,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
95 0x05, 0x25, 0x15, 0x35, 0x0d, 0x2d, 0x1d, 0x3d,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
96 0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
97 0x07, 0x27, 0x17, 0x37, 0x0f, 0x2f, 0x1f, 0x3f};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
98
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
99 #ifdef ARCH_X86
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
100 // NOTE: SSE needs 16byte alignment or it will segfault
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
101 //
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
102 static complex_t __attribute__((aligned(16))) buf[128];
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
103 static float __attribute__((aligned(16))) sseSinCos1c[256];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
104 static float __attribute__((aligned(16))) sseSinCos1d[256];
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
105 static float __attribute__((aligned(16))) ps111_1[4]={1,1,1,-1};
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
106 //static float __attribute__((aligned(16))) sseW0[4];
3483390a902b sse opt
michael
parents: 3529
diff changeset
107 static float __attribute__((aligned(16))) sseW1[8];
3483390a902b sse opt
michael
parents: 3529
diff changeset
108 static float __attribute__((aligned(16))) sseW2[16];
3483390a902b sse opt
michael
parents: 3529
diff changeset
109 static float __attribute__((aligned(16))) sseW3[32];
3483390a902b sse opt
michael
parents: 3529
diff changeset
110 static float __attribute__((aligned(16))) sseW4[64];
3483390a902b sse opt
michael
parents: 3529
diff changeset
111 static float __attribute__((aligned(16))) sseW5[128];
3483390a902b sse opt
michael
parents: 3529
diff changeset
112 static float __attribute__((aligned(16))) sseW6[256];
3483390a902b sse opt
michael
parents: 3529
diff changeset
113 static float __attribute__((aligned(16))) *sseW[7]=
3483390a902b sse opt
michael
parents: 3529
diff changeset
114 {NULL /*sseW0*/,sseW1,sseW2,sseW3,sseW4,sseW5,sseW6};
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
115 static float __attribute__((aligned(16))) sseWindow[512];
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
116 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117 static complex_t buf[128];
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
118 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
119
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
120 /* Twiddle factor LUT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
121 static complex_t w_1[1];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
122 static complex_t w_2[2];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
123 static complex_t w_4[4];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
124 static complex_t w_8[8];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
125 static complex_t w_16[16];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
126 static complex_t w_32[32];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
127 static complex_t w_64[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
128 static complex_t * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
129
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
130 /* Twiddle factors for IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
131 static sample_t xcos1[128];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
132 static sample_t xsin1[128];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
133 static sample_t xcos2[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
134 static sample_t xsin2[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
135
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
136 /* Windowing function for Modified DCT - Thank you acroread */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
137 sample_t imdct_window[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
138 0.00014, 0.00024, 0.00037, 0.00051, 0.00067, 0.00086, 0.00107, 0.00130,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
139 0.00157, 0.00187, 0.00220, 0.00256, 0.00297, 0.00341, 0.00390, 0.00443,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
140 0.00501, 0.00564, 0.00632, 0.00706, 0.00785, 0.00871, 0.00962, 0.01061,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
141 0.01166, 0.01279, 0.01399, 0.01526, 0.01662, 0.01806, 0.01959, 0.02121,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
142 0.02292, 0.02472, 0.02662, 0.02863, 0.03073, 0.03294, 0.03527, 0.03770,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
143 0.04025, 0.04292, 0.04571, 0.04862, 0.05165, 0.05481, 0.05810, 0.06153,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
144 0.06508, 0.06878, 0.07261, 0.07658, 0.08069, 0.08495, 0.08935, 0.09389,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
145 0.09859, 0.10343, 0.10842, 0.11356, 0.11885, 0.12429, 0.12988, 0.13563,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
146 0.14152, 0.14757, 0.15376, 0.16011, 0.16661, 0.17325, 0.18005, 0.18699,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
147 0.19407, 0.20130, 0.20867, 0.21618, 0.22382, 0.23161, 0.23952, 0.24757,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
148 0.25574, 0.26404, 0.27246, 0.28100, 0.28965, 0.29841, 0.30729, 0.31626,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
149 0.32533, 0.33450, 0.34376, 0.35311, 0.36253, 0.37204, 0.38161, 0.39126,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
150 0.40096, 0.41072, 0.42054, 0.43040, 0.44030, 0.45023, 0.46020, 0.47019,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
151 0.48020, 0.49022, 0.50025, 0.51028, 0.52031, 0.53033, 0.54033, 0.55031,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
152 0.56026, 0.57019, 0.58007, 0.58991, 0.59970, 0.60944, 0.61912, 0.62873,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153 0.63827, 0.64774, 0.65713, 0.66643, 0.67564, 0.68476, 0.69377, 0.70269,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
154 0.71150, 0.72019, 0.72877, 0.73723, 0.74557, 0.75378, 0.76186, 0.76981,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
155 0.77762, 0.78530, 0.79283, 0.80022, 0.80747, 0.81457, 0.82151, 0.82831,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
156 0.83496, 0.84145, 0.84779, 0.85398, 0.86001, 0.86588, 0.87160, 0.87716,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
157 0.88257, 0.88782, 0.89291, 0.89785, 0.90264, 0.90728, 0.91176, 0.91610,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
158 0.92028, 0.92432, 0.92822, 0.93197, 0.93558, 0.93906, 0.94240, 0.94560,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
159 0.94867, 0.95162, 0.95444, 0.95713, 0.95971, 0.96217, 0.96451, 0.96674,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
160 0.96887, 0.97089, 0.97281, 0.97463, 0.97635, 0.97799, 0.97953, 0.98099,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
161 0.98236, 0.98366, 0.98488, 0.98602, 0.98710, 0.98811, 0.98905, 0.98994,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
162 0.99076, 0.99153, 0.99225, 0.99291, 0.99353, 0.99411, 0.99464, 0.99513,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
163 0.99558, 0.99600, 0.99639, 0.99674, 0.99706, 0.99736, 0.99763, 0.99788,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
164 0.99811, 0.99831, 0.99850, 0.99867, 0.99882, 0.99895, 0.99908, 0.99919,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
165 0.99929, 0.99938, 0.99946, 0.99953, 0.99959, 0.99965, 0.99969, 0.99974,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
166 0.99978, 0.99981, 0.99984, 0.99986, 0.99988, 0.99990, 0.99992, 0.99993,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
167 0.99994, 0.99995, 0.99996, 0.99997, 0.99998, 0.99998, 0.99998, 0.99999,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168 0.99999, 0.99999, 0.99999, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
169 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000 };
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
171
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172 static inline void swap_cmplx(complex_t *a, complex_t *b)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
173 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
174 complex_t tmp;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
175
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
176 tmp = *a;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
177 *a = *b;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
178 *b = tmp;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
179 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
180
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
181
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
182
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
183 static inline complex_t cmplx_mult(complex_t a, complex_t b)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
184 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
185 complex_t ret;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
186
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
187 ret.real = a.real * b.real - a.imag * b.imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
188 ret.imag = a.real * b.imag + a.imag * b.real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
189
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
190 return ret;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
191 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
192
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
193 void
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
194 imdct_do_512(sample_t data[],sample_t delay[], sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
195 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
196 int i,k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
197 int p,q;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
198 int m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
199 int two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
200 int two_m_plus_one;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
201
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
202 sample_t tmp_a_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
203 sample_t tmp_a_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
204 sample_t tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
205 sample_t tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
206
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
207 sample_t *data_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
208 sample_t *delay_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
209 sample_t *window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
210
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
211 /* 512 IMDCT with source and dest data in 'data' */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
212
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
213 /* Pre IFFT complex multiply plus IFFT cmplx conjugate & reordering*/
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
214 for( i=0; i < 128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
215 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
216 #ifdef USE_AC3_C
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
217 int j= pm128[i];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
218 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
219 int j= bit_reverse_512[i];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
220 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
221 buf[i].real = (data[256-2*j-1] * xcos1[j]) - (data[2*j] * xsin1[j]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
222 buf[i].imag = -1.0 * ((data[2*j] * xcos1[j]) + (data[256-2*j-1] * xsin1[j]));
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
223 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
224
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
225 /* FFT Merge */
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
226 /* unoptimized variant
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
227 for (m=1; m < 7; m++) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
228 if(m)
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
229 two_m = (1 << m);
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
230 else
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
231 two_m = 1;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
232
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
233 two_m_plus_one = (1 << (m+1));
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
234
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
235 for(i = 0; i < 128; i += two_m_plus_one) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
236 for(k = 0; k < two_m; k++) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
237 p = k + i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
238 q = p + two_m;
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
239 tmp_a_r = buf[p].real;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
240 tmp_a_i = buf[p].imag;
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
241 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
242 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
243 buf[p].real = tmp_a_r + tmp_b_r;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
244 buf[p].imag = tmp_a_i + tmp_b_i;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
245 buf[q].real = tmp_a_r - tmp_b_r;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
246 buf[q].imag = tmp_a_i - tmp_b_i;
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
247 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
248 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
249 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
250 */
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
251 #ifdef USE_AC3_C
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
252 fft_128p (&buf[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
253 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
254
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
255 /* 1. iteration */
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
256 for(i = 0; i < 128; i += 2) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
257 tmp_a_r = buf[i].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
258 tmp_a_i = buf[i].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
259 tmp_b_r = buf[i+1].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
260 tmp_b_i = buf[i+1].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
261 buf[i].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
262 buf[i].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
263 buf[i+1].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
264 buf[i+1].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
265 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
266
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
267 /* 2. iteration */
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
268 // Note w[1]={{1,0}, {0,-1}}
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
269 for(i = 0; i < 128; i += 4) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
270 tmp_a_r = buf[i].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
271 tmp_a_i = buf[i].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
272 tmp_b_r = buf[i+2].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
273 tmp_b_i = buf[i+2].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
274 buf[i].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
275 buf[i].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
276 buf[i+2].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
277 buf[i+2].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
278 tmp_a_r = buf[i+1].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
279 tmp_a_i = buf[i+1].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
280 tmp_b_r = buf[i+3].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
281 tmp_b_i = buf[i+3].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
282 buf[i+1].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
283 buf[i+1].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
284 buf[i+3].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
285 buf[i+3].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
286 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
287
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
288 /* 3. iteration */
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
289 for(i = 0; i < 128; i += 8) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
290 tmp_a_r = buf[i].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
291 tmp_a_i = buf[i].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
292 tmp_b_r = buf[i+4].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
293 tmp_b_i = buf[i+4].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
294 buf[i].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
295 buf[i].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
296 buf[i+4].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
297 buf[i+4].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
298 tmp_a_r = buf[1+i].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
299 tmp_a_i = buf[1+i].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
300 tmp_b_r = (buf[i+5].real + buf[i+5].imag) * w[2][1].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
301 tmp_b_i = (buf[i+5].imag - buf[i+5].real) * w[2][1].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
302 buf[1+i].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
303 buf[1+i].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
304 buf[i+5].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
305 buf[i+5].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
306 tmp_a_r = buf[i+2].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
307 tmp_a_i = buf[i+2].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
308 tmp_b_r = buf[i+6].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
309 tmp_b_i = - buf[i+6].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
310 buf[i+2].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
311 buf[i+2].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
312 buf[i+6].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
313 buf[i+6].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
314 tmp_a_r = buf[i+3].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
315 tmp_a_i = buf[i+3].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
316 tmp_b_r = (buf[i+7].real - buf[i+7].imag) * w[2][3].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
317 tmp_b_i = (buf[i+7].imag + buf[i+7].real) * w[2][3].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
318 buf[i+3].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
319 buf[i+3].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
320 buf[i+7].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
321 buf[i+7].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
322 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
323
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
324 /* 4-7. iterations */
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
325 for (m=3; m < 7; m++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
326 two_m = (1 << m);
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
327
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
328 two_m_plus_one = two_m<<1;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
329
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
330 for(i = 0; i < 128; i += two_m_plus_one) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
331 for(k = 0; k < two_m; k++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
332 int p = k + i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
333 int q = p + two_m;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
334 tmp_a_r = buf[p].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
335 tmp_a_i = buf[p].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
336 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
337 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
338 buf[p].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
339 buf[p].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
340 buf[q].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
341 buf[q].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
342 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
343 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
344 }
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
345 #endif
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
346 /* Post IFFT complex multiply plus IFFT complex conjugate*/
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
347 for( i=0; i < 128; i++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
348 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
349 tmp_a_r = buf[i].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
350 tmp_a_i = -1.0 * buf[i].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
351 buf[i].real =(tmp_a_r * xcos1[i]) - (tmp_a_i * xsin1[i]);
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
352 buf[i].imag =(tmp_a_r * xsin1[i]) + (tmp_a_i * xcos1[i]);
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
353 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
354
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
355 data_ptr = data;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
356 delay_ptr = delay;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
357 window_ptr = imdct_window;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
358
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
359 /* Window and convert to real valued signal */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
360 for(i=0; i< 64; i++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
361 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
362 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
363 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
364
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
365 for(i=0; i< 64; i++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
366 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
367 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
368 }
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
369
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
370 /* The trailing edge of the window goes into the delay line */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
371 delay_ptr = delay;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
372
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
373 for(i=0; i< 64; i++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
374 *delay_ptr++ = -buf[64+i].real * *--window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
375 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
376 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
377
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
378 for(i=0; i<64; i++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
379 *delay_ptr++ = buf[i].imag * *--window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
380 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
381 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
382 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
383
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
384 #ifdef ARCH_X86
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
385 #include "srfftp_3dnow.h"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
386
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
387 const i_cmplx_t x_plus_minus_3dnow __attribute__ ((aligned (8))) = { 0x00000000UL, 0x80000000UL };
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
388 const i_cmplx_t x_minus_plus_3dnow __attribute__ ((aligned (8))) = { 0x80000000UL, 0x00000000UL };
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
389 const complex_t HSQRT2_3DNOW __attribute__ ((aligned (8))) = { 0.707106781188, 0.707106781188 };
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
390
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
391 void
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
392 imdct_do_512_3dnow(sample_t data[],sample_t delay[], sample_t bias)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
393 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
394 int i,k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
395 int p,q;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
396 int m;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
397 int two_m;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
398 int two_m_plus_one;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
399
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
400 sample_t tmp_a_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
401 sample_t tmp_a_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
402 sample_t tmp_b_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
403 sample_t tmp_b_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
404
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
405 sample_t *data_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
406 sample_t *delay_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
407 sample_t *window_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
408
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
409 /* 512 IMDCT with source and dest data in 'data' */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
410
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
411 /* Pre IFFT complex multiply plus IFFT cmplx conjugate & reordering*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
412 #if 1
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
413 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
414 "movq %0, %%mm7\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
415 ::"m"(x_plus_minus_3dnow)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
416 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
417 for( i=0; i < 128; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
418 int j = pm128[i];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
419 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
420 "movd %1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
421 "movd %3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
422 "punpckldq %2, %%mm0\n\t" /* mm0 = data[256-2*j-1] | data[2*j]*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
423 "punpckldq %4, %%mm1\n\t" /* mm1 = xcos[j] | xsin[j] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
424 "movq %%mm0, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
425 "pfmul %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
426 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
427 "pswapd %%mm1, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
428 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
429 "movq %%mm1, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
430 "psrlq $32, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
431 "punpckldq %%mm5, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
432 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
433 "pfmul %%mm1, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
434 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
435 "pfpnacc %%mm2, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
436 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
437 "pxor %%mm7, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
438 "pfacc %%mm2, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
439 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
440 "pxor %%mm7, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
441 "movq %%mm0, %0"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
442 :"=m"(buf[i])
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
443 :"m"(data[256-2*j-1]), "m"(data[2*j]), "m"(xcos1[j]), "m"(xsin1[j])
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
444 :"memory"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
445 );
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
446 /* buf[i].re = (data[256-2*j-1] * xcos1[j] - data[2*j] * xsin1[j]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
447 buf[i].im = (data[256-2*j-1] * xsin1[j] + data[2*j] * xcos1[j])*(-1.0);*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
448 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
449 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
450 __asm__ __volatile__ ("femms":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
451 for( i=0; i < 128; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
452 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
453 int j= pm128[i];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
454 buf[i].real = (data[256-2*j-1] * xcos1[j]) - (data[2*j] * xsin1[j]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
455 buf[i].imag = -1.0 * ((data[2*j] * xcos1[j]) + (data[256-2*j-1] * xsin1[j]));
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
456 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
457 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
458
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
459 /* FFT Merge */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
460 /* unoptimized variant
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
461 for (m=1; m < 7; m++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
462 if(m)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
463 two_m = (1 << m);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
464 else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
465 two_m = 1;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
466
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
467 two_m_plus_one = (1 << (m+1));
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
468
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
469 for(i = 0; i < 128; i += two_m_plus_one) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
470 for(k = 0; k < two_m; k++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
471 p = k + i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
472 q = p + two_m;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
473 tmp_a_r = buf[p].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
474 tmp_a_i = buf[p].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
475 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
476 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
477 buf[p].real = tmp_a_r + tmp_b_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
478 buf[p].imag = tmp_a_i + tmp_b_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
479 buf[q].real = tmp_a_r - tmp_b_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
480 buf[q].imag = tmp_a_i - tmp_b_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
481 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
482 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
483 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
484 */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
485
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
486 fft_128p_3dnow (&buf[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
487 // asm volatile ("femms \n\t":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
488
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
489 /* Post IFFT complex multiply plus IFFT complex conjugate*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
490 #if 1
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
491 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
492 "movq %0, %%mm7\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
493 "movq %1, %%mm6\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
494 ::"m"(x_plus_minus_3dnow),
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
495 "m"(x_minus_plus_3dnow)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
496 :"eax","memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
497 for (i=0; i < 128; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
498 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
499 "movq %1, %%mm0\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
500 "movq %%mm0, %%mm1\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
501 #ifndef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
502 "movq %%mm1, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
503 "psrlq $32, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
504 "punpckldq %%mm2, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
505 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
506 "pswapd %%mm1, %%mm1\n\t" /* ac3_buf[i].re | ac3_buf[i].im */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
507 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
508 "movd %3, %%mm3\n\t" /* ac3_xsin[i] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
509 "punpckldq %2, %%mm3\n\t" /* ac3_xsin[i] | ac3_xcos[i] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
510 "pfmul %%mm3, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
511 "pfmul %%mm3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
512 #ifndef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
513 "pxor %%mm7, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
514 "pfacc %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
515 "movd %%mm0, 4%0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
516 "psrlq $32, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
517 "movd %%mm0, %0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
518 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
519 "pfpnacc %%mm1, %%mm0\n\t" /* mm0 = mm0[0] - mm0[1] | mm1[0] + mm1[1] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
520 "pswapd %%mm0, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
521 "movq %%mm0, %0"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
522 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
523 :"=m"(buf[i])
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
524 :"m"(buf[i]),"m"(xcos1[i]),"m"(xsin1[i])
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
525 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
526 /* ac3_buf[i].re =(tmp_a_r * ac3_xcos1[i]) + (tmp_a_i * ac3_xsin1[i]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
527 ac3_buf[i].im =(tmp_a_r * ac3_xsin1[i]) - (tmp_a_i * ac3_xcos1[i]);*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
528 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
529 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
530 __asm__ __volatile__ ("femms":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
531 for( i=0; i < 128; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
532 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
533 tmp_a_r = buf[i].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
534 tmp_a_i = -1.0 * buf[i].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
535 buf[i].real =(tmp_a_r * xcos1[i]) - (tmp_a_i * xsin1[i]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
536 buf[i].imag =(tmp_a_r * xsin1[i]) + (tmp_a_i * xcos1[i]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
537 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
538 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
539
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
540 data_ptr = data;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
541 delay_ptr = delay;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
542 window_ptr = imdct_window;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
543
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
544 /* Window and convert to real valued signal */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
545 #if 1
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
546 asm volatile (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
547 "movd (%0), %%mm3 \n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
548 "punpckldq %%mm3, %%mm3 \n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
549 :: "r" (&bias)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
550 );
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
551 for (i=0; i< 64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
552 /* merge two loops in one to enable working of 2 decoders */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
553 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
554 "movd 516(%1), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
555 "movd (%1), %%mm1\n\t" /**data_ptr++=-buf[64+i].im**window_ptr+++*delay_ptr++;*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
556 "punpckldq (%2), %%mm0\n\t"/*data_ptr[128]=-buf[i].re*window_ptr[128]+delay_ptr[128];*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
557 "punpckldq 516(%2), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
558 "pfmul (%3), %%mm0\n\t"/**data_ptr++=buf[64-i-1].re**window_ptr+++*delay_ptr++;*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
559 "pfmul 512(%3), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
560 "pxor %%mm6, %%mm0\n\t"/*data_ptr[128]=buf[128-i-1].im*window_ptr[128]+delay_ptr[128];*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
561 "pxor %%mm6, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
562 "pfadd (%4), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
563 "pfadd 512(%4), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
564 "pfadd %%mm3, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
565 "pfadd %%mm3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
566 "movq %%mm0, (%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
567 "movq %%mm1, 512(%0)"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
568 :"=r"(data_ptr)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
569 :"r"(&buf[i].real), "r"(&buf[64-i-1].real), "r"(window_ptr), "r"(delay_ptr), "0"(data_ptr)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
570 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
571 data_ptr += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
572 window_ptr += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
573 delay_ptr += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
574 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
575 window_ptr += 128;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
576 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
577 __asm__ __volatile__ ("femms":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
578 for(i=0; i< 64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
579 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
580 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
581 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
582
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
583 for(i=0; i< 64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
584 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
585 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
586 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
587 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
588
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
589 /* The trailing edge of the window goes into the delay line */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
590 delay_ptr = delay;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
591 #if 1
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
592 for(i=0; i< 64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
593 /* merge two loops in one to enable working of 2 decoders */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
594 window_ptr -=2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
595 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
596 "movd 508(%1), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
597 "movd (%1), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
598 "punpckldq (%2), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
599 "punpckldq 508(%2), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
600 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
601 "pswapd (%3), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
602 "pswapd -512(%3), %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
603 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
604 "movq (%3), %%mm3\n\t"/**delay_ptr++=-buf[64+i].re**--window_ptr;*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
605 "movq -512(%3), %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
606 "psrlq $32, %%mm3\n\t"/*delay_ptr[128]=buf[i].im**window_ptr[-512];*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
607 "psrlq $32, %%mm4\n\t"/**delay_ptr++=buf[64-i-1].im**--window_ptr;*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
608 "punpckldq (%3), %%mm3\n\t"/*delay_ptr[128]=-buf[128-i-1].re**window_ptr[-512];*/
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
609 "punpckldq -512(%3), %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
610 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
611 "pfmul %%mm3, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
612 "pfmul %%mm4, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
613 "pxor %%mm6, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
614 "pxor %%mm7, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
615 "movq %%mm0, (%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
616 "movq %%mm1, 512(%0)"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
617 :"=r"(delay_ptr)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
618 :"r"(&buf[i].imag), "r"(&buf[64-i-1].imag), "r"(window_ptr), "0"(delay_ptr)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
619 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
620 delay_ptr += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
621 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
622 __asm__ __volatile__ ("femms":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
623 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
624 __asm__ __volatile__ ("femms":::"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
625 for(i=0; i< 64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
626 *delay_ptr++ = -buf[64+i].real * *--window_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
627 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
628 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
629
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
630 for(i=0; i<64; i++) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
631 *delay_ptr++ = buf[i].imag * *--window_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
632 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
633 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
634 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
635 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
636
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
637
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
638 void
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
639 imdct_do_512_sse(sample_t data[],sample_t delay[], sample_t bias)
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
640 {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
641 int i,k;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
642 int p,q;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
643 int m;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
644 int two_m;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
645 int two_m_plus_one;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
646
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
647 sample_t tmp_a_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
648 sample_t tmp_a_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
649 sample_t tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
650 sample_t tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
651
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
652 sample_t *data_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
653 sample_t *delay_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
654 sample_t *window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
655
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
656 /* 512 IMDCT with source and dest data in 'data' */
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
657 /* see the c version (dct_do_512()), its allmost identical, just in C */
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
658
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
659 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
660 /* Bit reversed shuffling */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
661 asm volatile(
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
662 "xorl %%esi, %%esi \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
663 "leal bit_reverse_512, %%eax \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
664 "movl $1008, %%edi \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
665 "pushl %%ebp \n\t" //use ebp without telling gcc
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
666 ".balign 16 \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
667 "1: \n\t"
3584
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
668 "movlps (%0, %%esi), %%xmm0 \n\t" // XXXI
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
669 "movhps 8(%0, %%edi), %%xmm0 \n\t" // RXXI
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
670 "movlps 8(%0, %%esi), %%xmm1 \n\t" // XXXi
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
671 "movhps (%0, %%edi), %%xmm1 \n\t" // rXXi
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
672 "shufps $0x33, %%xmm1, %%xmm0 \n\t" // irIR
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
673 "movaps sseSinCos1c(%%esi), %%xmm2 \n\t"
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
674 "mulps %%xmm0, %%xmm2 \n\t"
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
675 "shufps $0xB1, %%xmm0, %%xmm0 \n\t" // riRI
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
676 "mulps sseSinCos1d(%%esi), %%xmm0 \n\t"
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
677 "subps %%xmm0, %%xmm2 \n\t"
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
678 "movzbl (%%eax), %%edx \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
679 "movzbl 1(%%eax), %%ebp \n\t"
3584
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
680 "movlps %%xmm2, (%1, %%edx,8) \n\t"
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
681 "movhps %%xmm2, (%1, %%ebp,8) \n\t"
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
682 "addl $16, %%esi \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
683 "addl $2, %%eax \n\t" // avoid complex addressing for P4 crap
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
684 "subl $16, %%edi \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
685 " jnc 1b \n\t"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
686 "popl %%ebp \n\t"//no we didnt touch ebp *g*
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
687 :: "b" (data), "c" (buf)
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
688 : "%esi", "%edi", "%eax", "%edx"
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
689 );
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
690
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
691
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
692 /* FFT Merge */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
693 /* unoptimized variant
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
694 for (m=1; m < 7; m++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
695 if(m)
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
696 two_m = (1 << m);
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
697 else
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
698 two_m = 1;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
699
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
700 two_m_plus_one = (1 << (m+1));
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
701
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
702 for(i = 0; i < 128; i += two_m_plus_one) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
703 for(k = 0; k < two_m; k++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
704 p = k + i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
705 q = p + two_m;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
706 tmp_a_r = buf[p].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
707 tmp_a_i = buf[p].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
708 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
709 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
710 buf[p].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
711 buf[p].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
712 buf[q].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
713 buf[q].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
714 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
715 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
716 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
717 */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
718
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
719 /* 1. iteration */
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
720 // Note w[0][0]={1,0}
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
721 asm volatile(
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
722 "xorps %%xmm1, %%xmm1 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
723 "xorps %%xmm2, %%xmm2 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
724 "movl %0, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
725 ".balign 16 \n\t"
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
726 "1: \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
727 "movlps (%%esi), %%xmm0 \n\t" //buf[p]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
728 "movlps 8(%%esi), %%xmm1\n\t" //buf[q]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
729 "movhps (%%esi), %%xmm0 \n\t" //buf[p]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
730 "movhps 8(%%esi), %%xmm2\n\t" //buf[q]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
731 "addps %%xmm1, %%xmm0 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
732 "subps %%xmm2, %%xmm0 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
733 "movaps %%xmm0, (%%esi) \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
734 "addl $16, %%esi \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
735 "cmpl %1, %%esi \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
736 " jb 1b \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
737 :: "g" (buf), "r" (buf + 128)
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
738 : "%esi"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
739 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
740
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
741 /* 2. iteration */
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
742 // Note w[1]={{1,0}, {0,-1}}
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
743 asm volatile(
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
744 "movaps ps111_1, %%xmm7 \n\t" // 1,1,1,-1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
745 "movl %0, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
746 ".balign 16 \n\t"
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
747 "1: \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
748 "movaps 16(%%esi), %%xmm2 \n\t" //r2,i2,r3,i3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
749 "shufps $0xB4, %%xmm2, %%xmm2 \n\t" //r2,i2,i3,r3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
750 "mulps %%xmm7, %%xmm2 \n\t" //r2,i2,i3,-r3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
751 "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
752 "movaps (%%esi), %%xmm1 \n\t" //r0,i0,r1,i1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
753 "addps %%xmm2, %%xmm0 \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
754 "subps %%xmm2, %%xmm1 \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
755 "movaps %%xmm0, (%%esi) \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
756 "movaps %%xmm1, 16(%%esi) \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
757 "addl $32, %%esi \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
758 "cmpl %1, %%esi \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
759 " jb 1b \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
760 :: "g" (buf), "r" (buf + 128)
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
761 : "%esi"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
762 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
763
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
764 /* 3. iteration */
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
765 /*
3483390a902b sse opt
michael
parents: 3529
diff changeset
766 Note sseW2+0={1,1,sqrt(2),sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
767 Note sseW2+16={0,0,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
768 Note sseW2+32={0,0,-sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
769 Note sseW2+48={1,-1,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
770 */
3483390a902b sse opt
michael
parents: 3529
diff changeset
771 asm volatile(
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
772 "movaps 48+sseW2, %%xmm6 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
773 "movaps 16+sseW2, %%xmm7 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
774 "xorps %%xmm5, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
775 "xorps %%xmm2, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
776 "movl %0, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
777 ".balign 16 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
778 "1: \n\t"
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
779 "movaps 32(%%esi), %%xmm2 \n\t" //r4,i4,r5,i5
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
780 "movaps 48(%%esi), %%xmm3 \n\t" //r6,i6,r7,i7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
781 "movaps sseW2, %%xmm4 \n\t" //r4,i4,r5,i5
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
782 "movaps 32+sseW2, %%xmm5 \n\t" //r6,i6,r7,i7
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
783 "mulps %%xmm2, %%xmm4 \n\t"
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
784 "mulps %%xmm3, %%xmm5 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
785 "shufps $0xB1, %%xmm2, %%xmm2 \n\t" //i4,r4,i5,r5
3483390a902b sse opt
michael
parents: 3529
diff changeset
786 "shufps $0xB1, %%xmm3, %%xmm3 \n\t" //i6,r6,i7,r7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
787 "mulps %%xmm6, %%xmm3 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
788 "mulps %%xmm7, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
789 "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1
3483390a902b sse opt
michael
parents: 3529
diff changeset
790 "movaps 16(%%esi), %%xmm1 \n\t" //r2,i2,r3,i3
3483390a902b sse opt
michael
parents: 3529
diff changeset
791 "addps %%xmm4, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
792 "addps %%xmm5, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
793 "movaps %%xmm2, %%xmm4 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
794 "movaps %%xmm3, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
795 "addps %%xmm0, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
796 "addps %%xmm1, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
797 "subps %%xmm4, %%xmm0 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
798 "subps %%xmm5, %%xmm1 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
799 "movaps %%xmm2, (%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
800 "movaps %%xmm3, 16(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
801 "movaps %%xmm0, 32(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
802 "movaps %%xmm1, 48(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
803 "addl $64, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
804 "cmpl %1, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
805 " jb 1b \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
806 :: "g" (buf), "r" (buf + 128)
3483390a902b sse opt
michael
parents: 3529
diff changeset
807 : "%esi"
3483390a902b sse opt
michael
parents: 3529
diff changeset
808 );
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
809
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
810 /* 4-7. iterations */
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
811 for (m=3; m < 7; m++) {
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
812 two_m = (1 << m);
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
813 two_m_plus_one = two_m<<1;
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
814 asm volatile(
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
815 "movl %0, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
816 ".balign 16 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
817 "1: \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
818 "xorl %%edi, %%edi \n\t" // k
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
819 "leal (%%esi, %3), %%edx \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
820 "2: \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
821 "movaps (%%edx, %%edi), %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
822 "movaps (%4, %%edi, 2), %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
823 "mulps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
824 "shufps $0xB1, %%xmm1, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
825 "mulps 16(%4, %%edi, 2), %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
826 "movaps (%%esi, %%edi), %%xmm0 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
827 "addps %%xmm2, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
828 "movaps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
829 "addps %%xmm0, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
830 "subps %%xmm2, %%xmm0 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
831 "movaps %%xmm1, (%%esi, %%edi) \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
832 "movaps %%xmm0, (%%edx, %%edi) \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
833 "addl $16, %%edi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
834 "cmpl %3, %%edi \n\t" //FIXME (opt) count against 0
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
835 " jb 2b \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
836 "addl %2, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
837 "cmpl %1, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
838 " jb 1b \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
839 :: "g" (buf), "m" (buf+128), "m" (two_m_plus_one<<3), "r" (two_m<<3),
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
840 "r" (sseW[m])
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
841 : "%esi", "%edi", "%edx"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
842 );
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
843 }
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
844
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
845 /* Post IFFT complex multiply plus IFFT complex conjugate*/
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
846 asm volatile(
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
847 "movl $-1024, %%esi \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
848 ".balign 16 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
849 "1: \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
850 "movaps (%0, %%esi), %%xmm0 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
851 "movaps (%0, %%esi), %%xmm1 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
852 "shufps $0xB1, %%xmm0, %%xmm0 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
853 "mulps 1024+sseSinCos1c(%%esi), %%xmm1 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
854 "mulps 1024+sseSinCos1d(%%esi), %%xmm0 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
855 "addps %%xmm1, %%xmm0 \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
856 "movaps %%xmm0, (%0, %%esi) \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
857 "addl $16, %%esi \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
858 " jnz 1b \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
859 :: "r" (buf+128)
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
860 : "%esi"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
861 );
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
862
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
863
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
864 data_ptr = data;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
865 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
866 window_ptr = imdct_window;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
867
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
868 /* Window and convert to real valued signal */
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
869 asm volatile(
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
870 "xorl %%edi, %%edi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
871 "xorl %%esi, %%esi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
872 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
873 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
874 ".balign 16 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
875 "1: \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
876 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
877 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
878 "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
879 "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
880 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
881 "mulps sseWindow(%%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
882 "addps (%2, %%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
883 "addps %%xmm2, %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
884 "movaps %%xmm0, (%1, %%esi) \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
885 "addl $16, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
886 "subl $16, %%edi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
887 "cmpl $512, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
888 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
889 :: "r" (buf+64), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
890 : "%esi", "%edi"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
891 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
892 data_ptr+=128;
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
893 delay_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
894 // window_ptr+=128;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
895
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
896 asm volatile(
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
897 "movl $1024, %%edi \n\t" // 512
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
898 "xorl %%esi, %%esi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
899 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
900 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
901 ".balign 16 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
902 "1: \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
903 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
904 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
905 "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
906 "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
907 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
908 "mulps 512+sseWindow(%%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
909 "addps (%2, %%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
910 "addps %%xmm2, %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
911 "movaps %%xmm0, (%1, %%esi) \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
912 "addl $16, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
913 "subl $16, %%edi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
914 "cmpl $512, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
915 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
916 :: "r" (buf), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
917 : "%esi", "%edi"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
918 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
919 data_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
920 // window_ptr+=128;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
921
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
922 /* The trailing edge of the window goes into the delay line */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
923 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
924
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
925 asm volatile(
a501627fc6db sse opt
michael
parents: 3552
diff changeset
926 "xorl %%edi, %%edi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
927 "xorl %%esi, %%esi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
928 ".balign 16 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
929 "1: \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
930 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
931 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C
a501627fc6db sse opt
michael
parents: 3552
diff changeset
932 "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C
a501627fc6db sse opt
michael
parents: 3552
diff changeset
933 "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
934 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
935 "mulps 1024+sseWindow(%%esi), %%xmm0 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
936 "movaps %%xmm0, (%1, %%esi) \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
937 "addl $16, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
938 "subl $16, %%edi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
939 "cmpl $512, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
940 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
941 :: "r" (buf+64), "r" (delay_ptr)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
942 : "%esi", "%edi"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
943 );
a501627fc6db sse opt
michael
parents: 3552
diff changeset
944 delay_ptr+=128;
a501627fc6db sse opt
michael
parents: 3552
diff changeset
945 // window_ptr-=128;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
946
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
947 asm volatile(
a501627fc6db sse opt
michael
parents: 3552
diff changeset
948 "movl $1024, %%edi \n\t" // 1024
a501627fc6db sse opt
michael
parents: 3552
diff changeset
949 "xorl %%esi, %%esi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
950 ".balign 16 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
951 "1: \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
952 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
953 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
954 "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
955 "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
956 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
957 "mulps 1536+sseWindow(%%esi), %%xmm0 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
958 "movaps %%xmm0, (%1, %%esi) \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
959 "addl $16, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
960 "subl $16, %%edi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
961 "cmpl $512, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
962 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
963 :: "r" (buf), "r" (delay_ptr)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
964 : "%esi", "%edi"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
965 );
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
966 }
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
967 #endif //arch_x86
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
968
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
969 void
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
970 imdct_do_256(sample_t data[],sample_t delay[],sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
971 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
972 int i,k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
973 int p,q;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
974 int m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
975 int two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
976 int two_m_plus_one;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
977
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
978 sample_t tmp_a_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
979 sample_t tmp_a_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
980 sample_t tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
981 sample_t tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
982
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
983 sample_t *data_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
984 sample_t *delay_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
985 sample_t *window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
986
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
987 complex_t *buf_1, *buf_2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
988
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
989 buf_1 = &buf[0];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
990 buf_2 = &buf[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
991
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
992 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
993 for(k=0; k<64; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
994 /* X1[k] = X[2*k] */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
995 /* X2[k] = X[2*k+1] */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
996
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
997 p = 2 * (128-2*k-1);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
998 q = 2 * (2 * k);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
999
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1000 /* Z1[k] = (X1[128-2*k-1] + j * X1[2*k]) * (xcos2[k] + j * xsin2[k]); */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1001 buf_1[k].real = data[p] * xcos2[k] - data[q] * xsin2[k];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1002 buf_1[k].imag = -1.0f * (data[q] * xcos2[k] + data[p] * xsin2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1003 /* Z2[k] = (X2[128-2*k-1] + j * X2[2*k]) * (xcos2[k] + j * xsin2[k]); */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1004 buf_2[k].real = data[p + 1] * xcos2[k] - data[q + 1] * xsin2[k];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1005 buf_2[k].imag = -1.0f * ( data[q + 1] * xcos2[k] + data[p + 1] * xsin2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1006 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1007
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1008 /* IFFT Bit reversed shuffling */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1009 for(i=0; i<64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1010 k = bit_reverse_256[i];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1011 if (k < i) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1012 swap_cmplx(&buf_1[i],&buf_1[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1013 swap_cmplx(&buf_2[i],&buf_2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1014 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1015 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1016
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1017 /* FFT Merge */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1018 for (m=0; m < 6; m++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1019 two_m = (1 << m);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1020 two_m_plus_one = (1 << (m+1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1021
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1022 /* FIXME */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1023 if(m)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1024 two_m = (1 << m);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1025 else
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1026 two_m = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1027
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1028 for(k = 0; k < two_m; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1029 for(i = 0; i < 64; i += two_m_plus_one) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1030 p = k + i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1031 q = p + two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1032 /* Do block 1 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1033 tmp_a_r = buf_1[p].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1034 tmp_a_i = buf_1[p].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1035 tmp_b_r = buf_1[q].real * w[m][k].real - buf_1[q].imag * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1036 tmp_b_i = buf_1[q].imag * w[m][k].real + buf_1[q].real * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1037 buf_1[p].real = tmp_a_r + tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1038 buf_1[p].imag = tmp_a_i + tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1039 buf_1[q].real = tmp_a_r - tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1040 buf_1[q].imag = tmp_a_i - tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1041
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1042 /* Do block 2 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1043 tmp_a_r = buf_2[p].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1044 tmp_a_i = buf_2[p].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1045 tmp_b_r = buf_2[q].real * w[m][k].real - buf_2[q].imag * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1046 tmp_b_i = buf_2[q].imag * w[m][k].real + buf_2[q].real * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1047 buf_2[p].real = tmp_a_r + tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1048 buf_2[p].imag = tmp_a_i + tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1049 buf_2[q].real = tmp_a_r - tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1050 buf_2[q].imag = tmp_a_i - tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1051 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1052 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1053 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1054
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1055 /* Post IFFT complex multiply */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1056 for( i=0; i < 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1057 /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1058 tmp_a_r = buf_1[i].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1059 tmp_a_i = -buf_1[i].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1060 buf_1[i].real =(tmp_a_r * xcos2[i]) - (tmp_a_i * xsin2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1061 buf_1[i].imag =(tmp_a_r * xsin2[i]) + (tmp_a_i * xcos2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1062 /* y2[n] = z2[n] * (xcos2[n] + j * xsin2[n]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1063 tmp_a_r = buf_2[i].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1064 tmp_a_i = -buf_2[i].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1065 buf_2[i].real =(tmp_a_r * xcos2[i]) - (tmp_a_i * xsin2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1066 buf_2[i].imag =(tmp_a_r * xsin2[i]) + (tmp_a_i * xcos2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1067 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1068
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1069 data_ptr = data;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1070 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1071 window_ptr = imdct_window;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1072
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1073 /* Window and convert to real valued signal */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1074 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1075 *data_ptr++ = -buf_1[i].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1076 *data_ptr++ = buf_1[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1077 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1078
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1079 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1080 *data_ptr++ = -buf_1[i].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1081 *data_ptr++ = buf_1[64-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1082 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1083
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1084 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1085
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1086 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1087 *delay_ptr++ = -buf_2[i].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1088 *delay_ptr++ = buf_2[64-i-1].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1089 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1090
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1091 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1092 *delay_ptr++ = buf_2[i].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1093 *delay_ptr++ = -buf_2[64-i-1].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1094 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1095 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1096
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1097 void imdct_init (uint32_t mm_accel)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1098 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1099 #ifdef LIBA52_MLIB
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1100 if (mm_accel & MM_ACCEL_MLIB) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1101 fprintf (stderr, "Using mlib for IMDCT transform\n");
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1102 imdct_512 = imdct_do_512_mlib;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1103 imdct_256 = imdct_do_256_mlib;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1104 } else
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1105 #endif
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1106 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1107 int i, j, k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1108
3908
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3884
diff changeset
1109 if(mm_accel & MM_ACCEL_X86_SSE) fprintf (stderr, "Using SSE optimized IMDCT transform\n");
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3884
diff changeset
1110 else if(mm_accel & MM_ACCEL_X86_3DNOW) fprintf (stderr, "Using 3DNow optimized IMDCT transform\n");
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3884
diff changeset
1111 else fprintf (stderr, "No accelerated IMDCT transform found\n");
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1112
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1113 /* Twiddle factors to turn IFFT into IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1114 for (i = 0; i < 128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1115 xcos1[i] = -cos ((M_PI / 2048) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1116 xsin1[i] = -sin ((M_PI / 2048) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1117 }
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1118 #ifdef ARCH_X86
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
1119 for (i = 0; i < 128; i++) {
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1120 sseSinCos1c[2*i+0]= xcos1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1121 sseSinCos1c[2*i+1]= -xcos1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1122 sseSinCos1d[2*i+0]= xsin1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1123 sseSinCos1d[2*i+1]= xsin1[i];
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
1124 }
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
1125 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1126
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1127 /* More twiddle factors to turn IFFT into IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1128 for (i = 0; i < 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1129 xcos2[i] = -cos ((M_PI / 1024) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1130 xsin2[i] = -sin ((M_PI / 1024) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1131 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1132
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1133 for (i = 0; i < 7; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1134 j = 1 << i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1135 for (k = 0; k < j; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1136 w[i][k].real = cos (-M_PI * k / j);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1137 w[i][k].imag = sin (-M_PI * k / j);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1138 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1139 }
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1140 #ifdef ARCH_X86
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
1141 for (i = 1; i < 7; i++) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1142 j = 1 << i;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1143 for (k = 0; k < j; k+=2) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1144
3483390a902b sse opt
michael
parents: 3529
diff changeset
1145 sseW[i][4*k + 0] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1146 sseW[i][4*k + 1] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1147 sseW[i][4*k + 2] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1148 sseW[i][4*k + 3] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1149
3483390a902b sse opt
michael
parents: 3529
diff changeset
1150 sseW[i][4*k + 4] = -w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1151 sseW[i][4*k + 5] = w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1152 sseW[i][4*k + 6] = -w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1153 sseW[i][4*k + 7] = w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1154
3483390a902b sse opt
michael
parents: 3529
diff changeset
1155 //we multiply more or less uninitalized numbers so we need to use exactly 0.0
3483390a902b sse opt
michael
parents: 3529
diff changeset
1156 if(k==0)
3483390a902b sse opt
michael
parents: 3529
diff changeset
1157 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1158 // sseW[i][4*k + 0]= sseW[i][4*k + 1]= 1.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1159 sseW[i][4*k + 4]= sseW[i][4*k + 5]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1160 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1161
3483390a902b sse opt
michael
parents: 3529
diff changeset
1162 if(2*k == j)
3483390a902b sse opt
michael
parents: 3529
diff changeset
1163 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1164 sseW[i][4*k + 0]= sseW[i][4*k + 1]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1165 // sseW[i][4*k + 4]= -(sseW[i][4*k + 5]= -1.0);
3483390a902b sse opt
michael
parents: 3529
diff changeset
1166 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1167 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1168 }
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1169
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1170 for(i=0; i<128; i++)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1171 {
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1172 sseWindow[2*i+0]= -imdct_window[2*i+0];
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1173 sseWindow[2*i+1]= imdct_window[2*i+1];
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1174 }
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1175
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1176 for(i=0; i<64; i++)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1177 {
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1178 sseWindow[256 + 2*i+0]= -imdct_window[254 - 2*i+1];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1179 sseWindow[256 + 2*i+1]= imdct_window[254 - 2*i+0];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1180 sseWindow[384 + 2*i+0]= imdct_window[126 - 2*i+1];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1181 sseWindow[384 + 2*i+1]= -imdct_window[126 - 2*i+0];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1182 }
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1183 #endif // arch_x86
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1184
3720
120ac80f13c2 Fixed #ifdef discrepancy that was breaking compilation on PPC platform
melanson
parents: 3623
diff changeset
1185 imdct_512 = imdct_do_512;
120ac80f13c2 Fixed #ifdef discrepancy that was breaking compilation on PPC platform
melanson
parents: 3623
diff changeset
1186 #ifdef ARCH_X86
3908
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3884
diff changeset
1187 if(mm_accel & MM_ACCEL_X86_SSE) imdct_512 = imdct_do_512_sse;
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3884
diff changeset
1188 else if(mm_accel & MM_ACCEL_X86_3DNOW) imdct_512 = imdct_do_512_3dnow;
3720
120ac80f13c2 Fixed #ifdef discrepancy that was breaking compilation on PPC platform
melanson
parents: 3623
diff changeset
1189 #endif // arch_x86
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1190 imdct_256 = imdct_do_256;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1191 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1192 }
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1193
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1194 // Stuff below this line is borrowed from libac3
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1195 #include "srfftp.h"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1196
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1197 #ifdef ARCH_X86
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1198
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1199 static void fft_4_3dnow(complex_t *x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1200 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1201 /* delta_p = 1 here */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1202 /* x[k] = sum_{i=0..3} x[i] * w^{i*k}, w=e^{-2*pi/4}
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1203 */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1204 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1205 "movq 24(%1), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1206 "movq 8(%1), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1207 "pxor %2, %%mm3\n\t" /* mm3.re | -mm3.im */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1208 "pxor %3, %%mm1\n\t" /* -mm1.re | mm1.im */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1209 "pfadd %%mm1, %%mm3\n\t" /* vi.im = x[3].re - x[1].re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1210 "movq %%mm3, %%mm4\n\t" /* vi.re =-x[3].im + x[1].im; mm4 = vi */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1211 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1212 "pswapd %%mm4, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1213 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1214 "movq %%mm4, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1215 "psrlq $32, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1216 "punpckldq %%mm5, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1217 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1218 "movq (%1), %%mm5\n\t" /* yb.re = x[0].re - x[2].re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1219 "movq (%1), %%mm6\n\t" /* yt.re = x[0].re + x[2].re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1220 "movq 24(%1), %%mm7\n\t" /* u.re = x[3].re + x[1].re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1221 "pfsub 16(%1), %%mm5\n\t" /* yb.im = x[0].im - x[2].im; mm5 = yb */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1222 "pfadd 16(%1), %%mm6\n\t" /* yt.im = x[0].im + x[2].im; mm6 = yt */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1223 "pfadd 8(%1), %%mm7\n\t" /* u.im = x[3].im + x[1].im; mm7 = u */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1224
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1225 "movq %%mm6, %%mm0\n\t" /* x[0].re = yt.re + u.re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1226 "movq %%mm5, %%mm1\n\t" /* x[1].re = yb.re + vi.re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1227 "pfadd %%mm7, %%mm0\n\t" /*x[0].im = yt.im + u.im; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1228 "pfadd %%mm4, %%mm1\n\t" /* x[1].im = yb.im + vi.im; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1229 "movq %%mm0, (%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1230 "movq %%mm1, 8(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1231
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1232 "pfsub %%mm7, %%mm6\n\t" /* x[2].re = yt.re - u.re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1233 "pfsub %%mm4, %%mm5\n\t" /* x[3].re = yb.re - vi.re; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1234 "movq %%mm6, 16(%0)\n\t" /* x[2].im = yt.im - u.im; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1235 "movq %%mm5, 24(%0)" /* x[3].im = yb.im - vi.im; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1236 :"=r"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1237 :"0"(x),
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1238 "m"(x_plus_minus_3dnow),
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1239 "m"(x_minus_plus_3dnow)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1240 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1241 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1242
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1243 static void fft_8_3dnow(complex_t *x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1244 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1245 /* delta_p = diag{1, sqrt(i)} here */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1246 /* x[k] = sum_{i=0..7} x[i] * w^{i*k}, w=e^{-2*pi/8}
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1247 */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1248 complex_t wT1, wB1, wB2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1249
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1250 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1251 "movq 8(%2), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1252 "movq 24(%2), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1253 "movq %%mm0, %0\n\t" /* wT1 = x[1]; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1254 "movq %%mm1, %1\n\t" /* wB1 = x[3]; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1255 :"=m"(wT1), "=m"(wB1)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1256 :"r"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1257 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1258
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1259 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1260 "movq 16(%0), %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1261 "movq 32(%0), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1262 "movq %%mm2, 8(%0)\n\t" /* x[1] = x[2]; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1263 "movq 48(%0), %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1264 "movq %%mm3, 16(%0)\n\t" /* x[2] = x[4]; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1265 "movq %%mm4, 24(%0)\n\t" /* x[3] = x[6]; */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1266 :"=r"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1267 :"0"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1268 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1269
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1270 fft_4_3dnow(&x[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1271
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1272 /* x[0] x[4] x[2] x[6] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1273
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1274 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1275 "movq 40(%1), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1276 "movq %%mm0, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1277 "movq 56(%1), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1278 "pfadd %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1279 "pfsub %%mm1, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1280 "movq (%2), %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1281 "pfadd %%mm2, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1282 "pfadd %%mm2, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1283 "movq (%3), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1284 "pfadd %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1285 "pfsub %%mm1, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1286 "movq (%1), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1287 "movq 16(%1), %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1288 "movq %%mm1, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1289 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1290 "pswapd %%mm3, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1291 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1292 "movq %%mm3, %%mm6\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1293 "psrlq $32, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1294 "punpckldq %%mm6, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1295 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1296 "pfadd %%mm0, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1297 "movq %%mm4, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1298 "pfsub %%mm0, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1299 "pfadd %%mm3, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1300 "movq %%mm1, (%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1301 "pfsub %%mm3, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1302 "movq %%mm2, 32(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1303 "movd %%mm4, 16(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1304 "movd %%mm5, 48(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1305 "psrlq $32, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1306 "psrlq $32, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1307 "movd %%mm4, 52(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1308 "movd %%mm5, 20(%0)"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1309 :"=r"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1310 :"0"(x), "r"(&wT1), "r"(&wB1)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1311 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1312
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1313 /* x[1] x[5] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1314 __asm__ __volatile__ (
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1315 "movq %6, %%mm6\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1316 "movq %5, %%mm7\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1317 "movq %1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1318 "movq %2, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1319 "movq 56(%3), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1320 "pfsub 40(%3), %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1321 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1322 "pswapd %%mm1, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1323 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1324 "movq %%mm1, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1325 "psrlq $32, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1326 "punpckldq %%mm2,%%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1327 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1328 "pxor %%mm7, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1329 "pfadd %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1330 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1331 "pswapd %%mm3, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1332 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1333 "movq %%mm3, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1334 "psrlq $32, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1335 "punpckldq %%mm2,%%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1336 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1337 "pxor %%mm6, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1338 "pfadd %%mm3, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1339 "movq %%mm0, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1340 "pxor %%mm6, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1341 "pfacc %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1342 "pfmul %4, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1343
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1344 "movq 40(%3), %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1345 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1346 "pswapd %%mm5, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1347 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1348 "movq %%mm5, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1349 "psrlq $32, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1350 "punpckldq %%mm1,%%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1351 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1352 "movq %%mm5, %0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1353
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1354 "movq 8(%3), %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1355 "movq %%mm1, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1356 "pfsub %%mm0, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1357 "pfadd %%mm0, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1358 "movq %%mm1, 40(%3)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1359 "movq %%mm2, 8(%3)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1360 :"=m"(wB2)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1361 :"m"(wT1), "m"(wB1), "r"(x), "m"(HSQRT2_3DNOW),
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1362 "m"(x_plus_minus_3dnow), "m"(x_minus_plus_3dnow)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1363 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1364
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1365
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1366 /* x[3] x[7] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1367 __asm__ __volatile__(
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1368 "movq %1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1369 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1370 "pswapd %3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1371 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1372 "movq %3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1373 "psrlq $32, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1374 "punpckldq %3, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1375 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1376 "pxor %%mm6, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1377 "pfadd %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1378 "movq %2, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1379 "movq 56(%4), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1380 "pxor %%mm7, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1381 "pfadd %%mm3, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1382 #ifdef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1383 "pswapd %%mm2, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1384 #else
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1385 "movq %%mm2, %%mm5\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1386 "psrlq $32, %%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1387 "punpckldq %%mm5,%%mm2\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1388 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1389 "movq 24(%4), %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1390 "pfsub %%mm2, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1391 "movq %%mm3, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1392 "movq %%mm0, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1393 "pxor %%mm6, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1394 "pfacc %%mm1, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1395 "pfmul %5, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1396 "movq %%mm0, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1397 "pxor %%mm6, %%mm1\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1398 "pxor %%mm7, %%mm0\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1399 "pfadd %%mm1, %%mm3\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1400 "pfadd %%mm0, %%mm4\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1401 "movq %%mm4, 24(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1402 "movq %%mm3, 56(%0)\n\t"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1403 :"=r"(x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1404 :"m"(wT1), "m"(wB2), "m"(wB1), "0"(x), "m"(HSQRT2_3DNOW)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1405 :"memory");
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1406 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1407
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1408 static void fft_asmb_3dnow(int k, complex_t *x, complex_t *wTB,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1409 const complex_t *d, const complex_t *d_3)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1410 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1411 register complex_t *x2k, *x3k, *x4k, *wB;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1412
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1413 TRANS_FILL_MM6_MM7_3DNOW();
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1414 x2k = x + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1415 x3k = x2k + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1416 x4k = x3k + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1417 wB = wTB + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1418
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1419 TRANSZERO_3DNOW(x[0],x2k[0],x3k[0],x4k[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1420 TRANS_3DNOW(x[1],x2k[1],x3k[1],x4k[1],wTB[1],wB[1],d[1],d_3[1]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1421
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1422 --k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1423 for(;;) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1424 TRANS_3DNOW(x[2],x2k[2],x3k[2],x4k[2],wTB[2],wB[2],d[2],d_3[2]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1425 TRANS_3DNOW(x[3],x2k[3],x3k[3],x4k[3],wTB[3],wB[3],d[3],d_3[3]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1426 if (!--k) break;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1427 x += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1428 x2k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1429 x3k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1430 x4k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1431 d += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1432 d_3 += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1433 wTB += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1434 wB += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1435 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1436
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1437 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1438
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1439 void fft_asmb16_3dnow(complex_t *x, complex_t *wTB)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1440 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1441 int k = 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1442
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1443 TRANS_FILL_MM6_MM7_3DNOW();
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1444 /* transform x[0], x[8], x[4], x[12] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1445 TRANSZERO_3DNOW(x[0],x[4],x[8],x[12]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1446
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1447 /* transform x[1], x[9], x[5], x[13] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1448 TRANS_3DNOW(x[1],x[5],x[9],x[13],wTB[1],wTB[5],delta16[1],delta16_3[1]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1449
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1450 /* transform x[2], x[10], x[6], x[14] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1451 TRANSHALF_16_3DNOW(x[2],x[6],x[10],x[14]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1452
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1453 /* transform x[3], x[11], x[7], x[15] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1454 TRANS_3DNOW(x[3],x[7],x[11],x[15],wTB[3],wTB[7],delta16[3],delta16_3[3]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1455
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1456 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1457
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1458 static void fft_128p_3dnow(complex_t *a)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1459 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1460 fft_8_3dnow(&a[0]); fft_4_3dnow(&a[8]); fft_4_3dnow(&a[12]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1461 fft_asmb16_3dnow(&a[0], &a[8]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1462
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1463 fft_8_3dnow(&a[16]), fft_8_3dnow(&a[24]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1464 fft_asmb_3dnow(4, &a[0], &a[16],&delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1465
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1466 fft_8_3dnow(&a[32]); fft_4_3dnow(&a[40]); fft_4_3dnow(&a[44]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1467 fft_asmb16_3dnow(&a[32], &a[40]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1468
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1469 fft_8_3dnow(&a[48]); fft_4_3dnow(&a[56]); fft_4_3dnow(&a[60]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1470 fft_asmb16_3dnow(&a[48], &a[56]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1471
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1472 fft_asmb_3dnow(8, &a[0], &a[32],&delta64[0], &delta64_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1473
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1474 fft_8_3dnow(&a[64]); fft_4_3dnow(&a[72]); fft_4_3dnow(&a[76]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1475 /* fft_16(&a[64]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1476 fft_asmb16_3dnow(&a[64], &a[72]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1477
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1478 fft_8_3dnow(&a[80]); fft_8_3dnow(&a[88]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1479
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1480 /* fft_32(&a[64]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1481 fft_asmb_3dnow(4, &a[64], &a[80],&delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1482
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1483 fft_8_3dnow(&a[96]); fft_4_3dnow(&a[104]), fft_4_3dnow(&a[108]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1484 /* fft_16(&a[96]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1485 fft_asmb16_3dnow(&a[96], &a[104]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1486
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1487 fft_8_3dnow(&a[112]), fft_8_3dnow(&a[120]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1488 /* fft_32(&a[96]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1489 fft_asmb_3dnow(4, &a[96], &a[112], &delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1490
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1491 /* fft_128(&a[0]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1492 fft_asmb_3dnow(16, &a[0], &a[64], &delta128[0], &delta128_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1493 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1494 #endif //ARCH_X86
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1495
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1496 static void fft_asmb(int k, complex_t *x, complex_t *wTB,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1497 const complex_t *d, const complex_t *d_3)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1498 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1499 register complex_t *x2k, *x3k, *x4k, *wB;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1500 register float a_r, a_i, a1_r, a1_i, u_r, u_i, v_r, v_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1501
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1502 x2k = x + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1503 x3k = x2k + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1504 x4k = x3k + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1505 wB = wTB + 2 * k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1506
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1507 TRANSZERO(x[0],x2k[0],x3k[0],x4k[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1508 TRANS(x[1],x2k[1],x3k[1],x4k[1],wTB[1],wB[1],d[1],d_3[1]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1509
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1510 --k;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1511 for(;;) {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1512 TRANS(x[2],x2k[2],x3k[2],x4k[2],wTB[2],wB[2],d[2],d_3[2]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1513 TRANS(x[3],x2k[3],x3k[3],x4k[3],wTB[3],wB[3],d[3],d_3[3]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1514 if (!--k) break;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1515 x += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1516 x2k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1517 x3k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1518 x4k += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1519 d += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1520 d_3 += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1521 wTB += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1522 wB += 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1523 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1524
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1525 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1526
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1527 static void fft_asmb16(complex_t *x, complex_t *wTB)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1528 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1529 register float a_r, a_i, a1_r, a1_i, u_r, u_i, v_r, v_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1530 int k = 2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1531
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1532 /* transform x[0], x[8], x[4], x[12] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1533 TRANSZERO(x[0],x[4],x[8],x[12]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1534
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1535 /* transform x[1], x[9], x[5], x[13] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1536 TRANS(x[1],x[5],x[9],x[13],wTB[1],wTB[5],delta16[1],delta16_3[1]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1537
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1538 /* transform x[2], x[10], x[6], x[14] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1539 TRANSHALF_16(x[2],x[6],x[10],x[14]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1540
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1541 /* transform x[3], x[11], x[7], x[15] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1542 TRANS(x[3],x[7],x[11],x[15],wTB[3],wTB[7],delta16[3],delta16_3[3]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1543
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1544 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1545
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1546 static void fft_4(complex_t *x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1547 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1548 /* delta_p = 1 here */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1549 /* x[k] = sum_{i=0..3} x[i] * w^{i*k}, w=e^{-2*pi/4}
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1550 */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1551
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1552 register float yt_r, yt_i, yb_r, yb_i, u_r, u_i, vi_r, vi_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1553
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1554 yt_r = x[0].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1555 yb_r = yt_r - x[2].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1556 yt_r += x[2].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1557
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1558 u_r = x[1].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1559 vi_i = x[3].real - u_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1560 u_r += x[3].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1561
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1562 u_i = x[1].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1563 vi_r = u_i - x[3].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1564 u_i += x[3].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1565
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1566 yt_i = yt_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1567 yt_i += u_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1568 x[0].real = yt_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1569 yt_r -= u_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1570 x[2].real = yt_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1571 yt_i = yb_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1572 yt_i += vi_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1573 x[1].real = yt_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1574 yb_r -= vi_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1575 x[3].real = yb_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1576
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1577 yt_i = x[0].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1578 yb_i = yt_i - x[2].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1579 yt_i += x[2].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1580
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1581 yt_r = yt_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1582 yt_r += u_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1583 x[0].imag = yt_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1584 yt_i -= u_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1585 x[2].imag = yt_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1586 yt_r = yb_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1587 yt_r += vi_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1588 x[1].imag = yt_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1589 yb_i -= vi_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1590 x[3].imag = yb_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1591 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1592
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1593
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1594 static void fft_8(complex_t *x)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1595 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1596 /* delta_p = diag{1, sqrt(i)} here */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1597 /* x[k] = sum_{i=0..7} x[i] * w^{i*k}, w=e^{-2*pi/8}
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1598 */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1599 register float wT1_r, wT1_i, wB1_r, wB1_i, wT2_r, wT2_i, wB2_r, wB2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1600
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1601 wT1_r = x[1].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1602 wT1_i = x[1].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1603 wB1_r = x[3].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1604 wB1_i = x[3].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1605
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1606 x[1] = x[2];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1607 x[2] = x[4];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1608 x[3] = x[6];
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1609 fft_4(&x[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1610
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1611
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1612 /* x[0] x[4] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1613 wT2_r = x[5].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1614 wT2_r += x[7].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1615 wT2_r += wT1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1616 wT2_r += wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1617 wT2_i = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1618 wT2_r += x[0].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1619 wT2_i = x[0].real - wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1620 x[0].real = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1621 x[4].real = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1622
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1623 wT2_i = x[5].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1624 wT2_i += x[7].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1625 wT2_i += wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1626 wT2_i += wB1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1627 wT2_r = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1628 wT2_r += x[0].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1629 wT2_i = x[0].imag - wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1630 x[0].imag = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1631 x[4].imag = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1632
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1633 /* x[2] x[6] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1634 wT2_r = x[5].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1635 wT2_r -= x[7].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1636 wT2_r += wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1637 wT2_r -= wB1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1638 wT2_i = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1639 wT2_r += x[2].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1640 wT2_i = x[2].real - wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1641 x[2].real = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1642 x[6].real = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1643
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1644 wT2_i = x[5].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1645 wT2_i -= x[7].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1646 wT2_i += wT1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1647 wT2_i -= wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1648 wT2_r = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1649 wT2_r += x[2].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1650 wT2_i = x[2].imag - wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1651 x[2].imag = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1652 x[6].imag = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1653
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1654
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1655 /* x[1] x[5] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1656 wT2_r = wT1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1657 wT2_r += wB1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1658 wT2_r -= x[5].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1659 wT2_r -= x[7].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1660 wT2_i = wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1661 wT2_i -= wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1662 wT2_i -= x[5].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1663 wT2_i += x[7].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1664
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1665 wB2_r = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1666 wB2_r += wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1667 wT2_i -= wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1668 wB2_r *= HSQRT2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1669 wT2_i *= HSQRT2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1670 wT2_r = wB2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1671 wB2_r += x[1].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1672 wT2_r = x[1].real - wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1673
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1674 wB2_i = x[5].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1675 x[1].real = wB2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1676 x[5].real = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1677
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1678 wT2_r = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1679 wT2_r += x[1].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1680 wT2_i = x[1].imag - wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1681 wB2_r = x[5].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1682 x[1].imag = wT2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1683 x[5].imag = wT2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1684
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1685 /* x[3] x[7] */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1686 wT1_r -= wB1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1687 wT1_i += wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1688 wB1_r = wB2_i - x[7].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1689 wB1_i = wB2_r + x[7].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1690 wT1_r -= wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1691 wT1_i -= wB1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1692 wB1_r = wT1_r + wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1693 wB1_r *= HSQRT2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1694 wT1_i -= wT1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1695 wT1_i *= HSQRT2;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1696 wB2_r = x[3].real;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1697 wB2_i = wB2_r + wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1698 wB2_r -= wT1_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1699 x[3].real = wB2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1700 x[7].real = wB2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1701 wB2_i = x[3].imag;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1702 wB2_r = wB2_i + wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1703 wB2_i -= wB1_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1704 x[3].imag = wB2_i;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1705 x[7].imag = wB2_r;
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1706 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1707
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1708
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1709 static void fft_128p(complex_t *a)
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1710 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1711 fft_8(&a[0]); fft_4(&a[8]); fft_4(&a[12]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1712 fft_asmb16(&a[0], &a[8]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1713
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1714 fft_8(&a[16]), fft_8(&a[24]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1715 fft_asmb(4, &a[0], &a[16],&delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1716
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1717 fft_8(&a[32]); fft_4(&a[40]); fft_4(&a[44]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1718 fft_asmb16(&a[32], &a[40]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1719
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1720 fft_8(&a[48]); fft_4(&a[56]); fft_4(&a[60]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1721 fft_asmb16(&a[48], &a[56]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1722
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1723 fft_asmb(8, &a[0], &a[32],&delta64[0], &delta64_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1724
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1725 fft_8(&a[64]); fft_4(&a[72]); fft_4(&a[76]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1726 /* fft_16(&a[64]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1727 fft_asmb16(&a[64], &a[72]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1728
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1729 fft_8(&a[80]); fft_8(&a[88]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1730
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1731 /* fft_32(&a[64]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1732 fft_asmb(4, &a[64], &a[80],&delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1733
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1734 fft_8(&a[96]); fft_4(&a[104]), fft_4(&a[108]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1735 /* fft_16(&a[96]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1736 fft_asmb16(&a[96], &a[104]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1737
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1738 fft_8(&a[112]), fft_8(&a[120]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1739 /* fft_32(&a[96]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1740 fft_asmb(4, &a[96], &a[112], &delta32[0], &delta32_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1741
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1742 /* fft_128(&a[0]); */
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1743 fft_asmb(16, &a[0], &a[64], &delta128[0], &delta128_3[0]);
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1744 }
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1745
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1746
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1747