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