Mercurial > mplayer.hg
comparison liba52/liba52_changes.diff @ 18720:4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
part 1: functional changes
author | rathann |
---|---|
date | Thu, 15 Jun 2006 22:58:06 +0000 |
parents | 9de84a73f6d0 |
children | 722ac20fac5f |
comparison
equal
deleted
inserted
replaced
18719:5d01eb066fa3 | 18720:4bad7f00556e |
---|---|
1 --- include/a52.h 2005-03-22 19:58:53.000000000 +0100 | 1 --- liba52-0.7.4/a52.h 2006-06-12 15:04:57.000000000 +0200 |
2 +++ a52.h 2004-03-19 01:15:49.000000000 +0100 | 2 +++ liba52/a52.h 2006-06-05 02:23:02.000000000 +0200 |
3 @@ -19,6 +25,9 @@ | 3 @@ -59,4 +63,9 @@ |
4 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 4 int a52_block (a52_state_t * state); |
5 */ | 5 void a52_free (a52_state_t * state); |
6 | 6 |
7 +#ifndef A52_H | |
8 +#define A52_H | |
9 + | |
10 #ifndef LIBA52_DOUBLE | |
11 typedef float sample_t; | |
12 #else | |
13 @@ -113,3 +122,10 @@ | |
14 void a52_dynrng (a52_state_t * state, | |
15 sample_t (* call) (sample_t, void *), void * data); | |
16 int a52_block (a52_state_t * state, sample_t * samples); | |
17 + | |
18 +void* a52_resample_init(uint32_t mm_accel,int flags,int chans); | 7 +void* a52_resample_init(uint32_t mm_accel,int flags,int chans); |
19 +extern int (* a52_resample) (float * _f, int16_t * s16); | 8 +extern int (* a52_resample) (float * _f, int16_t * s16); |
20 + | 9 + |
21 +uint16_t crc16_block(uint8_t *data,uint32_t num_bytes); | 10 +uint16_t crc16_block(uint8_t *data,uint32_t num_bytes); |
22 + | 11 + |
23 +#endif /* A52_H */ | 12 #endif /* A52_H */ |
24 --- liba52/a52_internal.h 2005-03-22 19:59:35.000000000 +0100 | 13 --- liba52-0.7.4/a52_internal.h 2006-06-12 15:05:07.000000000 +0200 |
25 +++ a52_internal.h 2004-03-19 01:15:49.000000000 +0100 | 14 +++ liba52/a52_internal.h 2006-06-05 02:23:02.000000000 +0200 |
26 @@ -41,11 +43,12 @@ | 15 @@ -103,18 +107,34 @@ |
27 | 16 #define DELTA_BIT_NONE (2) |
28 int downmix_init (int input, int flags, sample_t * level, | 17 #define DELTA_BIT_RESERVED (3) |
18 | |
19 +#ifdef ARCH_X86_64 | |
20 +# define REG_a "rax" | |
21 +# define REG_d "rdx" | |
22 +# define REG_S "rsi" | |
23 +# define REG_D "rdi" | |
24 +# define REG_BP "rbp" | |
25 +#else | |
26 +# define REG_a "eax" | |
27 +# define REG_d "edx" | |
28 +# define REG_S "esi" | |
29 +# define REG_D "edi" | |
30 +# define REG_BP "ebp" | |
31 +#endif | |
32 + | |
33 void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart, | |
34 int start, int end, int fastleak, int slowleak, | |
35 expbap_t * expbap); | |
36 | |
37 int a52_downmix_init (int input, int flags, sample_t * level, | |
29 sample_t clev, sample_t slev); | 38 sample_t clev, sample_t slev); |
30 +void downmix_accel_init(uint32_t mm_accel); | 39 +void downmix_accel_init(uint32_t mm_accel); |
31 int downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level, | 40 int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level, |
32 sample_t clev, sample_t slev); | 41 sample_t clev, sample_t slev); |
33 -void downmix (sample_t * samples, int acmod, int output, sample_t bias, | 42 -void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias, |
34 +extern void (*downmix) (sample_t * samples, int acmod, int output, sample_t bias, | 43 +extern void (*a52_downmix) (sample_t * samples, int acmod, int output, sample_t bias, |
35 sample_t clev, sample_t slev); | 44 sample_t clev, sample_t slev); |
36 -void upmix (sample_t * samples, int acmod, int output); | 45 -void a52_upmix (sample_t * samples, int acmod, int output); |
37 +extern void (*upmix) (sample_t * samples, int acmod, int output); | 46 +extern void (*a52_upmix) (sample_t * samples, int acmod, int output); |
38 | 47 |
39 void imdct_init (uint32_t mm_accel); | 48 void a52_imdct_init (uint32_t mm_accel); |
40 extern void (* imdct_256) (sample_t * data, sample_t * delay, sample_t bias); | 49 void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias); |
41 --- liba52/bitstream.c 2005-03-22 19:59:35.000000000 +0100 | 50 -void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias); |
42 +++ bitstream.c 2004-03-19 01:15:49.000000000 +0100 | 51 +extern void (*a52_imdct_512) (sample_t * data, sample_t * delay, sample_t bias); |
43 @@ -29,7 +35,12 @@ | 52 +void imdct_do_512 (sample_t * data, sample_t * delay, sample_t bias); |
53 --- liba52-0.7.4/bitstream.c 2006-06-12 15:05:07.000000000 +0200 | |
54 +++ liba52/bitstream.c 2006-06-05 02:23:02.000000000 +0200 | |
55 @@ -31,6 +35,10 @@ | |
44 | 56 |
45 #define BUFFER_SIZE 4096 | 57 #define BUFFER_SIZE 4096 |
46 | 58 |
47 +#ifdef ALT_BITSTREAM_READER | 59 +#ifdef ALT_BITSTREAM_READER |
48 +int indx=0; | 60 +int indx=0; |
49 +uint32_t * buffer_start; | |
50 +#else | |
51 static uint32_t * buffer_start; | |
52 +#endif | 61 +#endif |
53 | 62 + |
54 uint32_t bits_left; | 63 void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf) |
55 uint32_t current_word; | 64 { |
56 @@ -41,6 +52,9 @@ | 65 int align; |
57 align = (int)buf & 3; | 66 @@ -38,6 +46,9 @@ |
58 buffer_start = (uint32_t *) (buf - align); | 67 align = (long)buf & 3; |
59 bits_left = 0; | 68 state->buffer_start = (uint32_t *) (buf - align); |
69 state->bits_left = 0; | |
60 +#ifdef ALT_BITSTREAM_READER | 70 +#ifdef ALT_BITSTREAM_READER |
61 + indx=0; | 71 + indx=0; |
62 +#endif | 72 +#endif |
63 bitstream_get (align * 8); | 73 bitstream_get (state, align * 8); |
64 } | 74 } |
65 | 75 |
66 --- liba52/bitstream.h 2005-03-22 19:59:35.000000000 +0100 | 76 --- liba52-0.7.4/bitstream.h 2006-06-12 15:05:07.000000000 +0200 |
67 +++ bitstream.h 2004-03-19 01:15:49.000000000 +0100 | 77 +++ liba52/bitstream.h 2006-06-05 02:23:02.000000000 +0200 |
68 @@ -19,6 +25,48 @@ | 78 @@ -21,6 +25,48 @@ |
69 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 79 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
70 */ | 80 */ |
71 | 81 |
72 +/* code from ffmpeg/libavcodec */ | 82 +/* code from ffmpeg/libavcodec */ |
73 +#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC_ == 3 && __GNUC_MINOR__ > 0) | 83 +#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC_ == 3 && __GNUC_MINOR__ > 0) |
112 +#endif | 122 +#endif |
113 + | 123 + |
114 /* (stolen from the kernel) */ | 124 /* (stolen from the kernel) */ |
115 #ifdef WORDS_BIGENDIAN | 125 #ifdef WORDS_BIGENDIAN |
116 | 126 |
117 @@ -29,7 +77,7 @@ | 127 @@ -28,7 +74,7 @@ |
118 # if defined (__i386__) | 128 |
129 #else | |
130 | |
131 -# if 0 && defined (__i386__) | |
132 +# if defined (__i386__) | |
119 | 133 |
120 # define swab32(x) __i386_swab32(x) | 134 # define swab32(x) __i386_swab32(x) |
121 - static inline const uint32_t __i386_swab32(uint32_t x) | 135 static inline const uint32_t __i386_swab32(uint32_t x) |
122 + static always_inline const uint32_t __i386_swab32(uint32_t x) | 136 @@ -39,19 +85,34 @@ |
123 { | |
124 __asm__("bswap %0" : "=r" (x) : "0" (x)); | |
125 return x; | |
126 @@ -37,25 +85,42 @@ | |
127 | 137 |
128 # else | 138 # else |
129 | 139 |
130 -# define swab32(x)\ | 140 -# define swab32(x)\ |
131 -((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \ | 141 -((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \ |
139 + } | 149 + } |
140 # endif | 150 # endif |
141 #endif | 151 #endif |
142 | 152 |
143 +#ifdef ALT_BITSTREAM_READER | 153 +#ifdef ALT_BITSTREAM_READER |
144 +extern uint32_t *buffer_start; | |
145 +extern int indx; | 154 +extern int indx; |
146 +#else | |
147 extern uint32_t bits_left; | |
148 extern uint32_t current_word; | |
149 +#endif | 155 +#endif |
150 | 156 + |
151 void bitstream_set_ptr (uint8_t * buf); | 157 void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf); |
152 uint32_t bitstream_get_bh(uint32_t num_bits); | 158 uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits); |
153 int32_t bitstream_get_bh_2(uint32_t num_bits); | 159 int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits); |
154 | 160 |
155 + | 161 static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits) |
156 static inline uint32_t | |
157 -bitstream_get(uint32_t num_bits) | |
158 +bitstream_get(uint32_t num_bits) // note num_bits is practically a constant due to inlineing | |
159 { | 162 { |
160 +#ifdef ALT_BITSTREAM_READER | 163 +#ifdef ALT_BITSTREAM_READER |
161 + uint32_t result= swab32( unaligned32(((uint8_t *)buffer_start)+(indx>>3)) ); | 164 + uint32_t result= swab32( unaligned32(((uint8_t *)state->buffer_start)+(indx>>3)) ); |
162 + | 165 + |
163 + result<<= (indx&0x07); | 166 + result<<= (indx&0x07); |
164 + result>>= 32 - num_bits; | 167 + result>>= 32 - num_bits; |
165 + indx+= num_bits; | 168 + indx+= num_bits; |
166 + | 169 + |
167 + return result; | 170 + return result; |
168 +#else | 171 +#else |
169 uint32_t result; | 172 uint32_t result; |
170 - | 173 |
171 + | 174 if (num_bits < state->bits_left) { |
172 if(num_bits < bits_left) { | 175 @@ -61,10 +122,29 @@ |
173 result = (current_word << (32 - bits_left)) >> (32 - num_bits); | |
174 bits_left -= num_bits; | |
175 @@ -63,11 +128,30 @@ | |
176 } | 176 } |
177 | 177 |
178 return bitstream_get_bh(num_bits); | 178 return a52_bitstream_get_bh (state, num_bits); |
179 +#endif | 179 +#endif |
180 +} | 180 +} |
181 + | 181 + |
182 +static inline void bitstream_skip(int num_bits) | 182 +static inline void bitstream_skip(a52_state_t * state, int num_bits) |
183 +{ | 183 +{ |
184 +#ifdef ALT_BITSTREAM_READER | 184 +#ifdef ALT_BITSTREAM_READER |
185 + indx+= num_bits; | 185 + indx+= num_bits; |
186 +#else | 186 +#else |
187 + bitstream_get(num_bits); | 187 + bitstream_get(state, num_bits); |
188 +#endif | 188 +#endif |
189 } | 189 } |
190 | 190 |
191 static inline int32_t | 191 static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits) |
192 bitstream_get_2(uint32_t num_bits) | |
193 { | 192 { |
194 +#ifdef ALT_BITSTREAM_READER | 193 +#ifdef ALT_BITSTREAM_READER |
195 + int32_t result= swab32( unaligned32(((uint8_t *)buffer_start)+(indx>>3)) ); | 194 + int32_t result= swab32( unaligned32(((uint8_t *)state->buffer_start)+(indx>>3)) ); |
196 + | 195 + |
197 + result<<= (indx&0x07); | 196 + result<<= (indx&0x07); |
198 + result>>= 32 - num_bits; | 197 + result>>= 32 - num_bits; |
199 + indx+= num_bits; | 198 + indx+= num_bits; |
200 + | 199 + |
201 + return result; | 200 + return result; |
202 +#else | 201 +#else |
203 int32_t result; | 202 int32_t result; |
204 | 203 |
205 if(num_bits < bits_left) { | 204 if (num_bits < state->bits_left) { |
206 @@ -77,4 +161,5 @@ | 205 @@ -74,4 +154,5 @@ |
207 } | 206 } |
208 | 207 |
209 return bitstream_get_bh_2(num_bits); | 208 return a52_bitstream_get_bh_2 (state, num_bits); |
210 +#endif | 209 +#endif |
211 } | 210 } |
212 --- liba52/downmix.c 2005-03-22 19:59:35.000000000 +0100 | 211 --- liba52-0.7.4/downmix.c 2006-06-12 15:17:53.000000000 +0200 |
213 +++ downmix.c 2004-04-12 18:42:14.000000000 +0200 | 212 +++ liba52/downmix.c 2006-06-05 02:23:02.000000000 +0200 |
214 @@ -17,18 +23,46 @@ | 213 @@ -23,18 +23,47 @@ |
215 * You should have received a copy of the GNU General Public License | 214 * You should have received a copy of the GNU General Public License |
216 * along with this program; if not, write to the Free Software | 215 * along with this program; if not, write to the Free Software |
217 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 216 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
218 + * | 217 + * |
219 + * SSE optimizations from Michael Niedermayer (michaelni@gmx.at) | 218 + * SSE optimizations from Michael Niedermayer (michaelni@gmx.at) |
220 */ | 219 */ |
221 | 220 |
222 #include "config.h" | 221 #include "config.h" |
223 | 222 +#include "asmalign.h" |
224 -#include <inttypes.h> | 223 |
225 #include <string.h> | 224 #include <string.h> |
226 +#include <inttypes.h> | 225 #include <inttypes.h> |
227 | 226 |
228 #include "a52.h" | 227 #include "a52.h" |
229 #include "a52_internal.h" | 228 #include "a52_internal.h" |
230 +#include "mm_accel.h" | 229 +#include "mm_accel.h" |
231 | 230 |
232 #define CONVERT(acmod,output) (((output) << 3) + (acmod)) | 231 #define CONVERT(acmod,output) (((output) << 3) + (acmod)) |
233 | 232 |
234 + | 233 + |
235 +void (*downmix)(sample_t * samples, int acmod, int output, sample_t bias, | 234 +void (*a52_downmix)(sample_t * samples, int acmod, int output, sample_t bias, |
236 + sample_t clev, sample_t slev)= NULL; | 235 + sample_t clev, sample_t slev)= NULL; |
237 +void (*upmix)(sample_t * samples, int acmod, int output)= NULL; | 236 +void (*a52_upmix)(sample_t * samples, int acmod, int output)= NULL; |
238 + | 237 + |
239 +static void downmix_SSE (sample_t * samples, int acmod, int output, sample_t bias, | 238 +static void downmix_SSE (sample_t * samples, int acmod, int output, sample_t bias, |
240 + sample_t clev, sample_t slev); | 239 + sample_t clev, sample_t slev); |
241 +static void downmix_3dnow (sample_t * samples, int acmod, int output, sample_t bias, | 240 +static void downmix_3dnow (sample_t * samples, int acmod, int output, sample_t bias, |
242 + sample_t clev, sample_t slev); | 241 + sample_t clev, sample_t slev); |
245 +static void upmix_MMX (sample_t * samples, int acmod, int output); | 244 +static void upmix_MMX (sample_t * samples, int acmod, int output); |
246 +static void upmix_C (sample_t * samples, int acmod, int output); | 245 +static void upmix_C (sample_t * samples, int acmod, int output); |
247 + | 246 + |
248 +void downmix_accel_init(uint32_t mm_accel) | 247 +void downmix_accel_init(uint32_t mm_accel) |
249 +{ | 248 +{ |
250 + upmix= upmix_C; | 249 + a52_upmix= upmix_C; |
251 + downmix= downmix_C; | 250 + a52_downmix= downmix_C; |
252 +#ifdef ARCH_X86 | 251 +#if defined(ARCH_X86) || defined(ARCH_X86_64) |
253 + if(mm_accel & MM_ACCEL_X86_MMX) upmix= upmix_MMX; | 252 + if(mm_accel & MM_ACCEL_X86_MMX) a52_upmix= upmix_MMX; |
254 + if(mm_accel & MM_ACCEL_X86_SSE) downmix= downmix_SSE; | 253 + if(mm_accel & MM_ACCEL_X86_SSE) a52_downmix= downmix_SSE; |
255 + if(mm_accel & MM_ACCEL_X86_3DNOW) downmix= downmix_3dnow; | 254 + if(mm_accel & MM_ACCEL_X86_3DNOW) a52_downmix= downmix_3dnow; |
256 +#endif | 255 +#endif |
257 +} | 256 +} |
258 + | 257 + |
259 int downmix_init (int input, int flags, sample_t * level, | 258 int a52_downmix_init (int input, int flags, sample_t * level, |
260 sample_t clev, sample_t slev) | 259 sample_t clev, sample_t slev) |
261 { | 260 { |
262 @@ -61,7 +95,7 @@ | 261 @@ -451,7 +480,7 @@ |
263 output = flags & A52_CHANNEL_MASK; | |
264 if (output > A52_DOLBY) | |
265 return -1; | |
266 - | |
267 + | |
268 output = table[output][input & 7]; | |
269 | |
270 if ((output == A52_STEREO) && | |
271 @@ -145,7 +179,6 @@ | |
272 *level *= 1 / (1 + 3 * LEVEL_3DB); | |
273 break; | |
274 } | |
275 - | |
276 return output; | |
277 } | |
278 | |
279 @@ -440,12 +473,11 @@ | |
280 static void zero (sample_t * samples) | |
281 { | |
282 int i; | |
283 - | |
284 for (i = 0; i < 256; i++) | |
285 samples[i] = 0; | 262 samples[i] = 0; |
286 } | 263 } |
287 | 264 |
288 -void downmix (sample_t * samples, int acmod, int output, sample_t bias, | 265 -void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias, |
289 +static void downmix_C (sample_t * samples, int acmod, int output, sample_t bias, | 266 +void downmix_C (sample_t * samples, int acmod, int output, sample_t bias, |
290 sample_t clev, sample_t slev) | 267 sample_t clev, sample_t slev) |
291 { | 268 { |
292 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { | 269 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { |
293 @@ -557,7 +589,7 @@ | 270 @@ -563,7 +592,7 @@ |
294 break; | 271 break; |
295 | 272 |
296 case CONVERT (A52_3F2R, A52_2F1R): | 273 case CONVERT (A52_3F2R, A52_2F1R): |
297 - mix3to2 (samples, bias); | 274 - mix3to2 (samples, bias); |
298 + mix3to2 (samples, bias); //FIXME possible bug? (output doesnt seem to be used) | 275 + mix3to2 (samples, bias); //FIXME possible bug? (output doesnt seem to be used) |
299 move2to1 (samples + 768, samples + 512, bias); | 276 move2to1 (samples + 768, samples + 512, bias); |
300 break; | 277 break; |
301 | 278 |
302 @@ -581,12 +613,12 @@ | 279 @@ -587,12 +616,12 @@ |
303 break; | 280 break; |
304 | 281 |
305 case CONVERT (A52_3F1R, A52_3F2R): | 282 case CONVERT (A52_3F1R, A52_3F2R): |
306 - memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t)); | 283 - memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t)); |
307 + memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); | 284 + memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); |
308 break; | 285 break; |
309 } | 286 } |
310 } | 287 } |
311 | 288 |
312 -void upmix (sample_t * samples, int acmod, int output) | 289 -void a52_upmix (sample_t * samples, int acmod, int output) |
313 +static void upmix_C (sample_t * samples, int acmod, int output) | 290 +void upmix_C (sample_t * samples, int acmod, int output) |
314 { | 291 { |
315 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { | 292 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { |
316 | 293 |
317 @@ -651,3 +683,1137 @@ | 294 @@ -657,3 +686,1137 @@ |
318 goto mix_31to21; | 295 goto mix_31to21; |
319 } | 296 } |
320 } | 297 } |
321 + | 298 + |
322 +#ifdef ARCH_X86 | 299 +#if defined(ARCH_X86) || defined(ARCH_X86_64) |
323 +static void mix2to1_SSE (sample_t * dest, sample_t * src, sample_t bias) | 300 +static void mix2to1_SSE (sample_t * dest, sample_t * src, sample_t bias) |
324 +{ | 301 +{ |
325 + asm volatile( | 302 + asm volatile( |
326 + "movlps %2, %%xmm7 \n\t" | 303 + "movlps %2, %%xmm7 \n\t" |
327 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 304 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
328 + "movl $-1024, %%esi \n\t" | 305 + "mov $-1024, %%"REG_S" \n\t" |
329 + ".balign 16\n\t" | 306 + ASMALIGN16 |
330 + "1: \n\t" | 307 + "1: \n\t" |
331 + "movaps (%0, %%esi), %%xmm0 \n\t" | 308 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
332 + "movaps 16(%0, %%esi), %%xmm1 \n\t" | 309 + "movaps 16(%0, %%"REG_S"), %%xmm1\n\t" |
333 + "addps (%1, %%esi), %%xmm0 \n\t" | 310 + "addps (%1, %%"REG_S"), %%xmm0 \n\t" |
334 + "addps 16(%1, %%esi), %%xmm1 \n\t" | 311 + "addps 16(%1, %%"REG_S"), %%xmm1\n\t" |
335 + "addps %%xmm7, %%xmm0 \n\t" | 312 + "addps %%xmm7, %%xmm0 \n\t" |
336 + "addps %%xmm7, %%xmm1 \n\t" | 313 + "addps %%xmm7, %%xmm1 \n\t" |
337 + "movaps %%xmm0, (%1, %%esi) \n\t" | 314 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
338 + "movaps %%xmm1, 16(%1, %%esi) \n\t" | 315 + "movaps %%xmm1, 16(%1, %%"REG_S")\n\t" |
339 + "addl $32, %%esi \n\t" | 316 + "add $32, %%"REG_S" \n\t" |
340 + " jnz 1b \n\t" | 317 + " jnz 1b \n\t" |
341 + :: "r" (src+256), "r" (dest+256), "m" (bias) | 318 + :: "r" (src+256), "r" (dest+256), "m" (bias) |
342 + : "%esi" | 319 + : "%"REG_S |
343 + ); | 320 + ); |
344 +} | 321 +} |
345 + | 322 + |
346 +static void mix3to1_SSE (sample_t * samples, sample_t bias) | 323 +static void mix3to1_SSE (sample_t * samples, sample_t bias) |
347 +{ | 324 +{ |
348 + asm volatile( | 325 + asm volatile( |
349 + "movlps %1, %%xmm7 \n\t" | 326 + "movlps %1, %%xmm7 \n\t" |
350 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 327 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
351 + "movl $-1024, %%esi \n\t" | 328 + "mov $-1024, %%"REG_S" \n\t" |
352 + ".balign 16\n\t" | 329 + ASMALIGN16 |
353 + "1: \n\t" | 330 + "1: \n\t" |
354 + "movaps (%0, %%esi), %%xmm0 \n\t" | 331 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
355 + "movaps 1024(%0, %%esi), %%xmm1 \n\t" | 332 + "movaps 1024(%0, %%"REG_S"), %%xmm1\n\t" |
356 + "addps 2048(%0, %%esi), %%xmm0 \n\t" | 333 + "addps 2048(%0, %%"REG_S"), %%xmm0\n\t" |
357 + "addps %%xmm7, %%xmm1 \n\t" | 334 + "addps %%xmm7, %%xmm1 \n\t" |
358 + "addps %%xmm1, %%xmm0 \n\t" | 335 + "addps %%xmm1, %%xmm0 \n\t" |
359 + "movaps %%xmm0, (%0, %%esi) \n\t" | 336 + "movaps %%xmm0, (%0, %%"REG_S") \n\t" |
360 + "addl $16, %%esi \n\t" | 337 + "add $16, %%"REG_S" \n\t" |
361 + " jnz 1b \n\t" | 338 + " jnz 1b \n\t" |
362 + :: "r" (samples+256), "m" (bias) | 339 + :: "r" (samples+256), "m" (bias) |
363 + : "%esi" | 340 + : "%"REG_S |
364 + ); | 341 + ); |
365 +} | 342 +} |
366 + | 343 + |
367 +static void mix4to1_SSE (sample_t * samples, sample_t bias) | 344 +static void mix4to1_SSE (sample_t * samples, sample_t bias) |
368 +{ | 345 +{ |
369 + asm volatile( | 346 + asm volatile( |
370 + "movlps %1, %%xmm7 \n\t" | 347 + "movlps %1, %%xmm7 \n\t" |
371 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 348 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
372 + "movl $-1024, %%esi \n\t" | 349 + "mov $-1024, %%"REG_S" \n\t" |
373 + ".balign 16\n\t" | 350 + ASMALIGN16 |
374 + "1: \n\t" | 351 + "1: \n\t" |
375 + "movaps (%0, %%esi), %%xmm0 \n\t" | 352 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
376 + "movaps 1024(%0, %%esi), %%xmm1 \n\t" | 353 + "movaps 1024(%0, %%"REG_S"), %%xmm1\n\t" |
377 + "addps 2048(%0, %%esi), %%xmm0 \n\t" | 354 + "addps 2048(%0, %%"REG_S"), %%xmm0\n\t" |
378 + "addps 3072(%0, %%esi), %%xmm1 \n\t" | 355 + "addps 3072(%0, %%"REG_S"), %%xmm1\n\t" |
379 + "addps %%xmm7, %%xmm0 \n\t" | 356 + "addps %%xmm7, %%xmm0 \n\t" |
380 + "addps %%xmm1, %%xmm0 \n\t" | 357 + "addps %%xmm1, %%xmm0 \n\t" |
381 + "movaps %%xmm0, (%0, %%esi) \n\t" | 358 + "movaps %%xmm0, (%0, %%"REG_S") \n\t" |
382 + "addl $16, %%esi \n\t" | 359 + "add $16, %%"REG_S" \n\t" |
383 + " jnz 1b \n\t" | 360 + " jnz 1b \n\t" |
384 + :: "r" (samples+256), "m" (bias) | 361 + :: "r" (samples+256), "m" (bias) |
385 + : "%esi" | 362 + : "%"REG_S |
386 + ); | 363 + ); |
387 +} | 364 +} |
388 + | 365 + |
389 +static void mix5to1_SSE (sample_t * samples, sample_t bias) | 366 +static void mix5to1_SSE (sample_t * samples, sample_t bias) |
390 +{ | 367 +{ |
391 + asm volatile( | 368 + asm volatile( |
392 + "movlps %1, %%xmm7 \n\t" | 369 + "movlps %1, %%xmm7 \n\t" |
393 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 370 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
394 + "movl $-1024, %%esi \n\t" | 371 + "mov $-1024, %%"REG_S" \n\t" |
395 + ".balign 16\n\t" | 372 + ASMALIGN16 |
396 + "1: \n\t" | 373 + "1: \n\t" |
397 + "movaps (%0, %%esi), %%xmm0 \n\t" | 374 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
398 + "movaps 1024(%0, %%esi), %%xmm1 \n\t" | 375 + "movaps 1024(%0, %%"REG_S"), %%xmm1\n\t" |
399 + "addps 2048(%0, %%esi), %%xmm0 \n\t" | 376 + "addps 2048(%0, %%"REG_S"), %%xmm0\n\t" |
400 + "addps 3072(%0, %%esi), %%xmm1 \n\t" | 377 + "addps 3072(%0, %%"REG_S"), %%xmm1\n\t" |
401 + "addps %%xmm7, %%xmm0 \n\t" | 378 + "addps %%xmm7, %%xmm0 \n\t" |
402 + "addps 4096(%0, %%esi), %%xmm1 \n\t" | 379 + "addps 4096(%0, %%"REG_S"), %%xmm1\n\t" |
403 + "addps %%xmm1, %%xmm0 \n\t" | 380 + "addps %%xmm1, %%xmm0 \n\t" |
404 + "movaps %%xmm0, (%0, %%esi) \n\t" | 381 + "movaps %%xmm0, (%0, %%"REG_S") \n\t" |
405 + "addl $16, %%esi \n\t" | 382 + "add $16, %%"REG_S" \n\t" |
406 + " jnz 1b \n\t" | 383 + " jnz 1b \n\t" |
407 + :: "r" (samples+256), "m" (bias) | 384 + :: "r" (samples+256), "m" (bias) |
408 + : "%esi" | 385 + : "%"REG_S |
409 + ); | 386 + ); |
410 +} | 387 +} |
411 + | 388 + |
412 +static void mix3to2_SSE (sample_t * samples, sample_t bias) | 389 +static void mix3to2_SSE (sample_t * samples, sample_t bias) |
413 +{ | 390 +{ |
414 + asm volatile( | 391 + asm volatile( |
415 + "movlps %1, %%xmm7 \n\t" | 392 + "movlps %1, %%xmm7 \n\t" |
416 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 393 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
417 + "movl $-1024, %%esi \n\t" | 394 + "mov $-1024, %%"REG_S" \n\t" |
418 + ".balign 16\n\t" | 395 + ASMALIGN16 |
419 + "1: \n\t" | 396 + "1: \n\t" |
420 + "movaps 1024(%0, %%esi), %%xmm0 \n\t" | 397 + "movaps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
421 + "addps %%xmm7, %%xmm0 \n\t" //common | 398 + "addps %%xmm7, %%xmm0 \n\t" //common |
422 + "movaps (%0, %%esi), %%xmm1 \n\t" | 399 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
423 + "movaps 2048(%0, %%esi), %%xmm2 \n\t" | 400 + "movaps 2048(%0, %%"REG_S"), %%xmm2\n\t" |
424 + "addps %%xmm0, %%xmm1 \n\t" | 401 + "addps %%xmm0, %%xmm1 \n\t" |
425 + "addps %%xmm0, %%xmm2 \n\t" | 402 + "addps %%xmm0, %%xmm2 \n\t" |
426 + "movaps %%xmm1, (%0, %%esi) \n\t" | 403 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
427 + "movaps %%xmm2, 1024(%0, %%esi) \n\t" | 404 + "movaps %%xmm2, 1024(%0, %%"REG_S")\n\t" |
428 + "addl $16, %%esi \n\t" | 405 + "add $16, %%"REG_S" \n\t" |
429 + " jnz 1b \n\t" | 406 + " jnz 1b \n\t" |
430 + :: "r" (samples+256), "m" (bias) | 407 + :: "r" (samples+256), "m" (bias) |
431 + : "%esi" | 408 + : "%"REG_S |
432 + ); | 409 + ); |
433 +} | 410 +} |
434 + | 411 + |
435 +static void mix21to2_SSE (sample_t * left, sample_t * right, sample_t bias) | 412 +static void mix21to2_SSE (sample_t * left, sample_t * right, sample_t bias) |
436 +{ | 413 +{ |
437 + asm volatile( | 414 + asm volatile( |
438 + "movlps %2, %%xmm7 \n\t" | 415 + "movlps %2, %%xmm7 \n\t" |
439 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 416 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
440 + "movl $-1024, %%esi \n\t" | 417 + "mov $-1024, %%"REG_S" \n\t" |
441 + ".balign 16\n\t" | 418 + ASMALIGN16 |
442 + "1: \n\t" | 419 + "1: \n\t" |
443 + "movaps 1024(%1, %%esi), %%xmm0 \n\t" | 420 + "movaps 1024(%1, %%"REG_S"), %%xmm0\n\t" |
444 + "addps %%xmm7, %%xmm0 \n\t" //common | 421 + "addps %%xmm7, %%xmm0 \n\t" //common |
445 + "movaps (%0, %%esi), %%xmm1 \n\t" | 422 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
446 + "movaps (%1, %%esi), %%xmm2 \n\t" | 423 + "movaps (%1, %%"REG_S"), %%xmm2 \n\t" |
447 + "addps %%xmm0, %%xmm1 \n\t" | 424 + "addps %%xmm0, %%xmm1 \n\t" |
448 + "addps %%xmm0, %%xmm2 \n\t" | 425 + "addps %%xmm0, %%xmm2 \n\t" |
449 + "movaps %%xmm1, (%0, %%esi) \n\t" | 426 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
450 + "movaps %%xmm2, (%1, %%esi) \n\t" | 427 + "movaps %%xmm2, (%1, %%"REG_S") \n\t" |
451 + "addl $16, %%esi \n\t" | 428 + "add $16, %%"REG_S" \n\t" |
452 + " jnz 1b \n\t" | 429 + " jnz 1b \n\t" |
453 + :: "r" (left+256), "r" (right+256), "m" (bias) | 430 + :: "r" (left+256), "r" (right+256), "m" (bias) |
454 + : "%esi" | 431 + : "%"REG_S |
455 + ); | 432 + ); |
456 +} | 433 +} |
457 + | 434 + |
458 +static void mix21toS_SSE (sample_t * samples, sample_t bias) | 435 +static void mix21toS_SSE (sample_t * samples, sample_t bias) |
459 +{ | 436 +{ |
460 + asm volatile( | 437 + asm volatile( |
461 + "movlps %1, %%xmm7 \n\t" | 438 + "movlps %1, %%xmm7 \n\t" |
462 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 439 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
463 + "movl $-1024, %%esi \n\t" | 440 + "mov $-1024, %%"REG_S" \n\t" |
464 + ".balign 16\n\t" | 441 + ASMALIGN16 |
465 + "1: \n\t" | 442 + "1: \n\t" |
466 + "movaps 2048(%0, %%esi), %%xmm0 \n\t" // surround | 443 + "movaps 2048(%0, %%"REG_S"), %%xmm0\n\t" // surround |
467 + "movaps (%0, %%esi), %%xmm1 \n\t" | 444 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
468 + "movaps 1024(%0, %%esi), %%xmm2 \n\t" | 445 + "movaps 1024(%0, %%"REG_S"), %%xmm2\n\t" |
469 + "addps %%xmm7, %%xmm1 \n\t" | 446 + "addps %%xmm7, %%xmm1 \n\t" |
470 + "addps %%xmm7, %%xmm2 \n\t" | 447 + "addps %%xmm7, %%xmm2 \n\t" |
471 + "subps %%xmm0, %%xmm1 \n\t" | 448 + "subps %%xmm0, %%xmm1 \n\t" |
472 + "addps %%xmm0, %%xmm2 \n\t" | 449 + "addps %%xmm0, %%xmm2 \n\t" |
473 + "movaps %%xmm1, (%0, %%esi) \n\t" | 450 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
474 + "movaps %%xmm2, 1024(%0, %%esi) \n\t" | 451 + "movaps %%xmm2, 1024(%0, %%"REG_S")\n\t" |
475 + "addl $16, %%esi \n\t" | 452 + "add $16, %%"REG_S" \n\t" |
476 + " jnz 1b \n\t" | 453 + " jnz 1b \n\t" |
477 + :: "r" (samples+256), "m" (bias) | 454 + :: "r" (samples+256), "m" (bias) |
478 + : "%esi" | 455 + : "%"REG_S |
479 + ); | 456 + ); |
480 +} | 457 +} |
481 + | 458 + |
482 +static void mix31to2_SSE (sample_t * samples, sample_t bias) | 459 +static void mix31to2_SSE (sample_t * samples, sample_t bias) |
483 +{ | 460 +{ |
484 + asm volatile( | 461 + asm volatile( |
485 + "movlps %1, %%xmm7 \n\t" | 462 + "movlps %1, %%xmm7 \n\t" |
486 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 463 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
487 + "movl $-1024, %%esi \n\t" | 464 + "mov $-1024, %%"REG_S" \n\t" |
488 + ".balign 16\n\t" | 465 + ASMALIGN16 |
489 + "1: \n\t" | 466 + "1: \n\t" |
490 + "movaps 1024(%0, %%esi), %%xmm0 \n\t" | 467 + "movaps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
491 + "addps 3072(%0, %%esi), %%xmm0 \n\t" | 468 + "addps 3072(%0, %%"REG_S"), %%xmm0\n\t" |
492 + "addps %%xmm7, %%xmm0 \n\t" // common | 469 + "addps %%xmm7, %%xmm0 \n\t" // common |
493 + "movaps (%0, %%esi), %%xmm1 \n\t" | 470 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
494 + "movaps 2048(%0, %%esi), %%xmm2 \n\t" | 471 + "movaps 2048(%0, %%"REG_S"), %%xmm2\n\t" |
495 + "addps %%xmm0, %%xmm1 \n\t" | 472 + "addps %%xmm0, %%xmm1 \n\t" |
496 + "addps %%xmm0, %%xmm2 \n\t" | 473 + "addps %%xmm0, %%xmm2 \n\t" |
497 + "movaps %%xmm1, (%0, %%esi) \n\t" | 474 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
498 + "movaps %%xmm2, 1024(%0, %%esi) \n\t" | 475 + "movaps %%xmm2, 1024(%0, %%"REG_S")\n\t" |
499 + "addl $16, %%esi \n\t" | 476 + "add $16, %%"REG_S" \n\t" |
500 + " jnz 1b \n\t" | 477 + " jnz 1b \n\t" |
501 + :: "r" (samples+256), "m" (bias) | 478 + :: "r" (samples+256), "m" (bias) |
502 + : "%esi" | 479 + : "%"REG_S |
503 + ); | 480 + ); |
504 +} | 481 +} |
505 + | 482 + |
506 +static void mix31toS_SSE (sample_t * samples, sample_t bias) | 483 +static void mix31toS_SSE (sample_t * samples, sample_t bias) |
507 +{ | 484 +{ |
508 + asm volatile( | 485 + asm volatile( |
509 + "movlps %1, %%xmm7 \n\t" | 486 + "movlps %1, %%xmm7 \n\t" |
510 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 487 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
511 + "movl $-1024, %%esi \n\t" | 488 + "mov $-1024, %%"REG_S" \n\t" |
512 + ".balign 16\n\t" | 489 + ASMALIGN16 |
513 + "1: \n\t" | 490 + "1: \n\t" |
514 + "movaps 1024(%0, %%esi), %%xmm0 \n\t" | 491 + "movaps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
515 + "movaps 3072(%0, %%esi), %%xmm3 \n\t" // surround | 492 + "movaps 3072(%0, %%"REG_S"), %%xmm3\n\t" // surround |
516 + "addps %%xmm7, %%xmm0 \n\t" // common | 493 + "addps %%xmm7, %%xmm0 \n\t" // common |
517 + "movaps (%0, %%esi), %%xmm1 \n\t" | 494 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
518 + "movaps 2048(%0, %%esi), %%xmm2 \n\t" | 495 + "movaps 2048(%0, %%"REG_S"), %%xmm2\n\t" |
519 + "addps %%xmm0, %%xmm1 \n\t" | 496 + "addps %%xmm0, %%xmm1 \n\t" |
520 + "addps %%xmm0, %%xmm2 \n\t" | 497 + "addps %%xmm0, %%xmm2 \n\t" |
521 + "subps %%xmm3, %%xmm1 \n\t" | 498 + "subps %%xmm3, %%xmm1 \n\t" |
522 + "addps %%xmm3, %%xmm2 \n\t" | 499 + "addps %%xmm3, %%xmm2 \n\t" |
523 + "movaps %%xmm1, (%0, %%esi) \n\t" | 500 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
524 + "movaps %%xmm2, 1024(%0, %%esi) \n\t" | 501 + "movaps %%xmm2, 1024(%0, %%"REG_S")\n\t" |
525 + "addl $16, %%esi \n\t" | 502 + "add $16, %%"REG_S" \n\t" |
526 + " jnz 1b \n\t" | 503 + " jnz 1b \n\t" |
527 + :: "r" (samples+256), "m" (bias) | 504 + :: "r" (samples+256), "m" (bias) |
528 + : "%esi" | 505 + : "%"REG_S |
529 + ); | 506 + ); |
530 +} | 507 +} |
531 + | 508 + |
532 +static void mix22toS_SSE (sample_t * samples, sample_t bias) | 509 +static void mix22toS_SSE (sample_t * samples, sample_t bias) |
533 +{ | 510 +{ |
534 + asm volatile( | 511 + asm volatile( |
535 + "movlps %1, %%xmm7 \n\t" | 512 + "movlps %1, %%xmm7 \n\t" |
536 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 513 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
537 + "movl $-1024, %%esi \n\t" | 514 + "mov $-1024, %%"REG_S" \n\t" |
538 + ".balign 16\n\t" | 515 + ASMALIGN16 |
539 + "1: \n\t" | 516 + "1: \n\t" |
540 + "movaps 2048(%0, %%esi), %%xmm0 \n\t" | 517 + "movaps 2048(%0, %%"REG_S"), %%xmm0\n\t" |
541 + "addps 3072(%0, %%esi), %%xmm0 \n\t" // surround | 518 + "addps 3072(%0, %%"REG_S"), %%xmm0\n\t" // surround |
542 + "movaps (%0, %%esi), %%xmm1 \n\t" | 519 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
543 + "movaps 1024(%0, %%esi), %%xmm2 \n\t" | 520 + "movaps 1024(%0, %%"REG_S"), %%xmm2\n\t" |
544 + "addps %%xmm7, %%xmm1 \n\t" | 521 + "addps %%xmm7, %%xmm1 \n\t" |
545 + "addps %%xmm7, %%xmm2 \n\t" | 522 + "addps %%xmm7, %%xmm2 \n\t" |
546 + "subps %%xmm0, %%xmm1 \n\t" | 523 + "subps %%xmm0, %%xmm1 \n\t" |
547 + "addps %%xmm0, %%xmm2 \n\t" | 524 + "addps %%xmm0, %%xmm2 \n\t" |
548 + "movaps %%xmm1, (%0, %%esi) \n\t" | 525 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
549 + "movaps %%xmm2, 1024(%0, %%esi) \n\t" | 526 + "movaps %%xmm2, 1024(%0, %%"REG_S")\n\t" |
550 + "addl $16, %%esi \n\t" | 527 + "add $16, %%"REG_S" \n\t" |
551 + " jnz 1b \n\t" | 528 + " jnz 1b \n\t" |
552 + :: "r" (samples+256), "m" (bias) | 529 + :: "r" (samples+256), "m" (bias) |
553 + : "%esi" | 530 + : "%"REG_S |
554 + ); | 531 + ); |
555 +} | 532 +} |
556 + | 533 + |
557 +static void mix32to2_SSE (sample_t * samples, sample_t bias) | 534 +static void mix32to2_SSE (sample_t * samples, sample_t bias) |
558 +{ | 535 +{ |
559 + asm volatile( | 536 + asm volatile( |
560 + "movlps %1, %%xmm7 \n\t" | 537 + "movlps %1, %%xmm7 \n\t" |
561 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 538 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
562 + "movl $-1024, %%esi \n\t" | 539 + "mov $-1024, %%"REG_S" \n\t" |
563 + ".balign 16\n\t" | 540 + ASMALIGN16 |
564 + "1: \n\t" | 541 + "1: \n\t" |
565 + "movaps 1024(%0, %%esi), %%xmm0 \n\t" | 542 + "movaps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
566 + "addps %%xmm7, %%xmm0 \n\t" // common | 543 + "addps %%xmm7, %%xmm0 \n\t" // common |
567 + "movaps %%xmm0, %%xmm1 \n\t" // common | 544 + "movaps %%xmm0, %%xmm1 \n\t" // common |
568 + "addps (%0, %%esi), %%xmm0 \n\t" | 545 + "addps (%0, %%"REG_S"), %%xmm0 \n\t" |
569 + "addps 2048(%0, %%esi), %%xmm1 \n\t" | 546 + "addps 2048(%0, %%"REG_S"), %%xmm1\n\t" |
570 + "addps 3072(%0, %%esi), %%xmm0 \n\t" | 547 + "addps 3072(%0, %%"REG_S"), %%xmm0\n\t" |
571 + "addps 4096(%0, %%esi), %%xmm1 \n\t" | 548 + "addps 4096(%0, %%"REG_S"), %%xmm1\n\t" |
572 + "movaps %%xmm0, (%0, %%esi) \n\t" | 549 + "movaps %%xmm0, (%0, %%"REG_S") \n\t" |
573 + "movaps %%xmm1, 1024(%0, %%esi) \n\t" | 550 + "movaps %%xmm1, 1024(%0, %%"REG_S")\n\t" |
574 + "addl $16, %%esi \n\t" | 551 + "add $16, %%"REG_S" \n\t" |
575 + " jnz 1b \n\t" | 552 + " jnz 1b \n\t" |
576 + :: "r" (samples+256), "m" (bias) | 553 + :: "r" (samples+256), "m" (bias) |
577 + : "%esi" | 554 + : "%"REG_S |
578 + ); | 555 + ); |
579 +} | 556 +} |
580 + | 557 + |
581 +static void mix32toS_SSE (sample_t * samples, sample_t bias) | 558 +static void mix32toS_SSE (sample_t * samples, sample_t bias) |
582 +{ | 559 +{ |
583 + asm volatile( | 560 + asm volatile( |
584 + "movlps %1, %%xmm7 \n\t" | 561 + "movlps %1, %%xmm7 \n\t" |
585 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 562 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
586 + "movl $-1024, %%esi \n\t" | 563 + "mov $-1024, %%"REG_S" \n\t" |
587 + ".balign 16\n\t" | 564 + ASMALIGN16 |
588 + "1: \n\t" | 565 + "1: \n\t" |
589 + "movaps 1024(%0, %%esi), %%xmm0 \n\t" | 566 + "movaps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
590 + "movaps 3072(%0, %%esi), %%xmm2 \n\t" | 567 + "movaps 3072(%0, %%"REG_S"), %%xmm2\n\t" |
591 + "addps %%xmm7, %%xmm0 \n\t" // common | 568 + "addps %%xmm7, %%xmm0 \n\t" // common |
592 + "addps 4096(%0, %%esi), %%xmm2 \n\t" // surround | 569 + "addps 4096(%0, %%"REG_S"), %%xmm2\n\t" // surround |
593 + "movaps (%0, %%esi), %%xmm1 \n\t" | 570 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
594 + "movaps 2048(%0, %%esi), %%xmm3 \n\t" | 571 + "movaps 2048(%0, %%"REG_S"), %%xmm3\n\t" |
595 + "subps %%xmm2, %%xmm1 \n\t" | 572 + "subps %%xmm2, %%xmm1 \n\t" |
596 + "addps %%xmm2, %%xmm3 \n\t" | 573 + "addps %%xmm2, %%xmm3 \n\t" |
597 + "addps %%xmm0, %%xmm1 \n\t" | 574 + "addps %%xmm0, %%xmm1 \n\t" |
598 + "addps %%xmm0, %%xmm3 \n\t" | 575 + "addps %%xmm0, %%xmm3 \n\t" |
599 + "movaps %%xmm1, (%0, %%esi) \n\t" | 576 + "movaps %%xmm1, (%0, %%"REG_S") \n\t" |
600 + "movaps %%xmm3, 1024(%0, %%esi) \n\t" | 577 + "movaps %%xmm3, 1024(%0, %%"REG_S")\n\t" |
601 + "addl $16, %%esi \n\t" | 578 + "add $16, %%"REG_S" \n\t" |
602 + " jnz 1b \n\t" | 579 + " jnz 1b \n\t" |
603 + :: "r" (samples+256), "m" (bias) | 580 + :: "r" (samples+256), "m" (bias) |
604 + : "%esi" | 581 + : "%"REG_S |
605 + ); | 582 + ); |
606 +} | 583 +} |
607 + | 584 + |
608 +static void move2to1_SSE (sample_t * src, sample_t * dest, sample_t bias) | 585 +static void move2to1_SSE (sample_t * src, sample_t * dest, sample_t bias) |
609 +{ | 586 +{ |
610 + asm volatile( | 587 + asm volatile( |
611 + "movlps %2, %%xmm7 \n\t" | 588 + "movlps %2, %%xmm7 \n\t" |
612 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" | 589 + "shufps $0x00, %%xmm7, %%xmm7 \n\t" |
613 + "movl $-1024, %%esi \n\t" | 590 + "mov $-1024, %%"REG_S" \n\t" |
614 + ".balign 16\n\t" | 591 + ASMALIGN16 |
615 + "1: \n\t" | 592 + "1: \n\t" |
616 + "movaps (%0, %%esi), %%xmm0 \n\t" | 593 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
617 + "movaps 16(%0, %%esi), %%xmm1 \n\t" | 594 + "movaps 16(%0, %%"REG_S"), %%xmm1\n\t" |
618 + "addps 1024(%0, %%esi), %%xmm0 \n\t" | 595 + "addps 1024(%0, %%"REG_S"), %%xmm0\n\t" |
619 + "addps 1040(%0, %%esi), %%xmm1 \n\t" | 596 + "addps 1040(%0, %%"REG_S"), %%xmm1\n\t" |
620 + "addps %%xmm7, %%xmm0 \n\t" | 597 + "addps %%xmm7, %%xmm0 \n\t" |
621 + "addps %%xmm7, %%xmm1 \n\t" | 598 + "addps %%xmm7, %%xmm1 \n\t" |
622 + "movaps %%xmm0, (%1, %%esi) \n\t" | 599 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
623 + "movaps %%xmm1, 16(%1, %%esi) \n\t" | 600 + "movaps %%xmm1, 16(%1, %%"REG_S")\n\t" |
624 + "addl $32, %%esi \n\t" | 601 + "add $32, %%"REG_S" \n\t" |
625 + " jnz 1b \n\t" | 602 + " jnz 1b \n\t" |
626 + :: "r" (src+256), "r" (dest+256), "m" (bias) | 603 + :: "r" (src+256), "r" (dest+256), "m" (bias) |
627 + : "%esi" | 604 + : "%"REG_S |
628 + ); | 605 + ); |
629 +} | 606 +} |
630 + | 607 + |
631 +static void zero_MMX(sample_t * samples) | 608 +static void zero_MMX(sample_t * samples) |
632 +{ | 609 +{ |
633 + asm volatile( | 610 + asm volatile( |
634 + "movl $-1024, %%esi \n\t" | 611 + "mov $-1024, %%"REG_S" \n\t" |
635 + "pxor %%mm0, %%mm0 \n\t" | 612 + "pxor %%mm0, %%mm0 \n\t" |
636 + ".balign 16\n\t" | 613 + ASMALIGN16 |
637 + "1: \n\t" | 614 + "1: \n\t" |
638 + "movq %%mm0, (%0, %%esi) \n\t" | 615 + "movq %%mm0, (%0, %%"REG_S") \n\t" |
639 + "movq %%mm0, 8(%0, %%esi) \n\t" | 616 + "movq %%mm0, 8(%0, %%"REG_S") \n\t" |
640 + "movq %%mm0, 16(%0, %%esi) \n\t" | 617 + "movq %%mm0, 16(%0, %%"REG_S") \n\t" |
641 + "movq %%mm0, 24(%0, %%esi) \n\t" | 618 + "movq %%mm0, 24(%0, %%"REG_S") \n\t" |
642 + "addl $32, %%esi \n\t" | 619 + "add $32, %%"REG_S" \n\t" |
643 + " jnz 1b \n\t" | 620 + " jnz 1b \n\t" |
644 + "emms" | 621 + "emms" |
645 + :: "r" (samples+256) | 622 + :: "r" (samples+256) |
646 + : "%esi" | 623 + : "%"REG_S |
647 + ); | 624 + ); |
648 +} | 625 +} |
649 + | 626 + |
650 +/* | 627 +/* |
651 + I hope dest and src will be at least 8 byte aligned and size | 628 + I hope dest and src will be at least 8 byte aligned and size |
890 +static void mix2to1_3dnow (sample_t * dest, sample_t * src, sample_t bias) | 867 +static void mix2to1_3dnow (sample_t * dest, sample_t * src, sample_t bias) |
891 +{ | 868 +{ |
892 + asm volatile( | 869 + asm volatile( |
893 + "movd %2, %%mm7 \n\t" | 870 + "movd %2, %%mm7 \n\t" |
894 + "punpckldq %2, %%mm7 \n\t" | 871 + "punpckldq %2, %%mm7 \n\t" |
895 + "movl $-1024, %%esi \n\t" | 872 + "mov $-1024, %%"REG_S" \n\t" |
896 + ".balign 16\n\t" | 873 + ASMALIGN16 |
897 + "1: \n\t" | 874 + "1: \n\t" |
898 + "movq (%0, %%esi), %%mm0 \n\t" | 875 + "movq (%0, %%"REG_S"), %%mm0 \n\t" |
899 + "movq 8(%0, %%esi), %%mm1 \n\t" | 876 + "movq 8(%0, %%"REG_S"), %%mm1 \n\t" |
900 + "movq 16(%0, %%esi), %%mm2 \n\t" | 877 + "movq 16(%0, %%"REG_S"), %%mm2 \n\t" |
901 + "movq 24(%0, %%esi), %%mm3 \n\t" | 878 + "movq 24(%0, %%"REG_S"), %%mm3 \n\t" |
902 + "pfadd (%1, %%esi), %%mm0 \n\t" | 879 + "pfadd (%1, %%"REG_S"), %%mm0 \n\t" |
903 + "pfadd 8(%1, %%esi), %%mm1 \n\t" | 880 + "pfadd 8(%1, %%"REG_S"), %%mm1 \n\t" |
904 + "pfadd 16(%1, %%esi), %%mm2 \n\t" | 881 + "pfadd 16(%1, %%"REG_S"), %%mm2 \n\t" |
905 + "pfadd 24(%1, %%esi), %%mm3 \n\t" | 882 + "pfadd 24(%1, %%"REG_S"), %%mm3 \n\t" |
906 + "pfadd %%mm7, %%mm0 \n\t" | 883 + "pfadd %%mm7, %%mm0 \n\t" |
907 + "pfadd %%mm7, %%mm1 \n\t" | 884 + "pfadd %%mm7, %%mm1 \n\t" |
908 + "pfadd %%mm7, %%mm2 \n\t" | 885 + "pfadd %%mm7, %%mm2 \n\t" |
909 + "pfadd %%mm7, %%mm3 \n\t" | 886 + "pfadd %%mm7, %%mm3 \n\t" |
910 + "movq %%mm0, (%1, %%esi) \n\t" | 887 + "movq %%mm0, (%1, %%"REG_S") \n\t" |
911 + "movq %%mm1, 8(%1, %%esi) \n\t" | 888 + "movq %%mm1, 8(%1, %%"REG_S") \n\t" |
912 + "movq %%mm2, 16(%1, %%esi) \n\t" | 889 + "movq %%mm2, 16(%1, %%"REG_S") \n\t" |
913 + "movq %%mm3, 24(%1, %%esi) \n\t" | 890 + "movq %%mm3, 24(%1, %%"REG_S") \n\t" |
914 + "addl $32, %%esi \n\t" | 891 + "add $32, %%"REG_S" \n\t" |
915 + " jnz 1b \n\t" | 892 + " jnz 1b \n\t" |
916 + :: "r" (src+256), "r" (dest+256), "m" (bias) | 893 + :: "r" (src+256), "r" (dest+256), "m" (bias) |
917 + : "%esi" | 894 + : "%"REG_S |
918 + ); | 895 + ); |
919 +} | 896 +} |
920 + | 897 + |
921 +static void mix3to1_3dnow (sample_t * samples, sample_t bias) | 898 +static void mix3to1_3dnow (sample_t * samples, sample_t bias) |
922 +{ | 899 +{ |
923 + asm volatile( | 900 + asm volatile( |
924 + "movd %1, %%mm7 \n\t" | 901 + "movd %1, %%mm7 \n\t" |
925 + "punpckldq %1, %%mm7 \n\t" | 902 + "punpckldq %1, %%mm7 \n\t" |
926 + "movl $-1024, %%esi \n\t" | 903 + "mov $-1024, %%"REG_S" \n\t" |
927 + ".balign 16\n\t" | 904 + ASMALIGN16 |
928 + "1: \n\t" | 905 + "1: \n\t" |
929 + "movq (%0, %%esi), %%mm0 \n\t" | 906 + "movq (%0, %%"REG_S"), %%mm0 \n\t" |
930 + "movq 8(%0, %%esi), %%mm1 \n\t" | 907 + "movq 8(%0, %%"REG_S"), %%mm1 \n\t" |
931 + "movq 1024(%0, %%esi), %%mm2 \n\t" | 908 + "movq 1024(%0, %%"REG_S"), %%mm2\n\t" |
932 + "movq 1032(%0, %%esi), %%mm3 \n\t" | 909 + "movq 1032(%0, %%"REG_S"), %%mm3\n\t" |
933 + "pfadd 2048(%0, %%esi), %%mm0 \n\t" | 910 + "pfadd 2048(%0, %%"REG_S"), %%mm0\n\t" |
934 + "pfadd 2056(%0, %%esi), %%mm1 \n\t" | 911 + "pfadd 2056(%0, %%"REG_S"), %%mm1\n\t" |
935 + "pfadd %%mm7, %%mm0 \n\t" | 912 + "pfadd %%mm7, %%mm0 \n\t" |
936 + "pfadd %%mm7, %%mm1 \n\t" | 913 + "pfadd %%mm7, %%mm1 \n\t" |
937 + "pfadd %%mm2, %%mm0 \n\t" | 914 + "pfadd %%mm2, %%mm0 \n\t" |
938 + "pfadd %%mm3, %%mm1 \n\t" | 915 + "pfadd %%mm3, %%mm1 \n\t" |
939 + "movq %%mm0, (%0, %%esi) \n\t" | 916 + "movq %%mm0, (%0, %%"REG_S") \n\t" |
940 + "movq %%mm1, 8(%0, %%esi) \n\t" | 917 + "movq %%mm1, 8(%0, %%"REG_S") \n\t" |
941 + "addl $16, %%esi \n\t" | 918 + "add $16, %%"REG_S" \n\t" |
942 + " jnz 1b \n\t" | 919 + " jnz 1b \n\t" |
943 + :: "r" (samples+256), "m" (bias) | 920 + :: "r" (samples+256), "m" (bias) |
944 + : "%esi" | 921 + : "%"REG_S |
945 + ); | 922 + ); |
946 +} | 923 +} |
947 + | 924 + |
948 +static void mix4to1_3dnow (sample_t * samples, sample_t bias) | 925 +static void mix4to1_3dnow (sample_t * samples, sample_t bias) |
949 +{ | 926 +{ |
950 + asm volatile( | 927 + asm volatile( |
951 + "movd %1, %%mm7 \n\t" | 928 + "movd %1, %%mm7 \n\t" |
952 + "punpckldq %1, %%mm7 \n\t" | 929 + "punpckldq %1, %%mm7 \n\t" |
953 + "movl $-1024, %%esi \n\t" | 930 + "mov $-1024, %%"REG_S" \n\t" |
954 + ".balign 16\n\t" | 931 + ASMALIGN16 |
955 + "1: \n\t" | 932 + "1: \n\t" |
956 + "movq (%0, %%esi), %%mm0 \n\t" | 933 + "movq (%0, %%"REG_S"), %%mm0 \n\t" |
957 + "movq 8(%0, %%esi), %%mm1 \n\t" | 934 + "movq 8(%0, %%"REG_S"), %%mm1 \n\t" |
958 + "movq 1024(%0, %%esi), %%mm2 \n\t" | 935 + "movq 1024(%0, %%"REG_S"), %%mm2\n\t" |
959 + "movq 1032(%0, %%esi), %%mm3 \n\t" | 936 + "movq 1032(%0, %%"REG_S"), %%mm3\n\t" |
960 + "pfadd 2048(%0, %%esi), %%mm0 \n\t" | 937 + "pfadd 2048(%0, %%"REG_S"), %%mm0\n\t" |
961 + "pfadd 2056(%0, %%esi), %%mm1 \n\t" | 938 + "pfadd 2056(%0, %%"REG_S"), %%mm1\n\t" |
962 + "pfadd 3072(%0, %%esi), %%mm2 \n\t" | 939 + "pfadd 3072(%0, %%"REG_S"), %%mm2\n\t" |
963 + "pfadd 3080(%0, %%esi), %%mm3 \n\t" | 940 + "pfadd 3080(%0, %%"REG_S"), %%mm3\n\t" |
964 + "pfadd %%mm7, %%mm0 \n\t" | 941 + "pfadd %%mm7, %%mm0 \n\t" |
965 + "pfadd %%mm7, %%mm1 \n\t" | 942 + "pfadd %%mm7, %%mm1 \n\t" |
966 + "pfadd %%mm2, %%mm0 \n\t" | 943 + "pfadd %%mm2, %%mm0 \n\t" |
967 + "pfadd %%mm3, %%mm1 \n\t" | 944 + "pfadd %%mm3, %%mm1 \n\t" |
968 + "movq %%mm0, (%0, %%esi) \n\t" | 945 + "movq %%mm0, (%0, %%"REG_S") \n\t" |
969 + "movq %%mm1, 8(%0, %%esi) \n\t" | 946 + "movq %%mm1, 8(%0, %%"REG_S") \n\t" |
970 + "addl $16, %%esi \n\t" | 947 + "add $16, %%"REG_S" \n\t" |
971 + " jnz 1b \n\t" | 948 + " jnz 1b \n\t" |
972 + :: "r" (samples+256), "m" (bias) | 949 + :: "r" (samples+256), "m" (bias) |
973 + : "%esi" | 950 + : "%"REG_S |
974 + ); | 951 + ); |
975 +} | 952 +} |
976 + | 953 + |
977 +static void mix5to1_3dnow (sample_t * samples, sample_t bias) | 954 +static void mix5to1_3dnow (sample_t * samples, sample_t bias) |
978 +{ | 955 +{ |
979 + asm volatile( | 956 + asm volatile( |
980 + "movd %1, %%mm7 \n\t" | 957 + "movd %1, %%mm7 \n\t" |
981 + "punpckldq %1, %%mm7 \n\t" | 958 + "punpckldq %1, %%mm7 \n\t" |
982 + "movl $-1024, %%esi \n\t" | 959 + "mov $-1024, %%"REG_S" \n\t" |
983 + ".balign 16\n\t" | 960 + ASMALIGN16 |
984 + "1: \n\t" | 961 + "1: \n\t" |
985 + "movq (%0, %%esi), %%mm0 \n\t" | 962 + "movq (%0, %%"REG_S"), %%mm0 \n\t" |
986 + "movq 8(%0, %%esi), %%mm1 \n\t" | 963 + "movq 8(%0, %%"REG_S"), %%mm1 \n\t" |
987 + "movq 1024(%0, %%esi), %%mm2 \n\t" | 964 + "movq 1024(%0, %%"REG_S"), %%mm2\n\t" |
988 + "movq 1032(%0, %%esi), %%mm3 \n\t" | 965 + "movq 1032(%0, %%"REG_S"), %%mm3\n\t" |
989 + "pfadd 2048(%0, %%esi), %%mm0 \n\t" | 966 + "pfadd 2048(%0, %%"REG_S"), %%mm0\n\t" |
990 + "pfadd 2056(%0, %%esi), %%mm1 \n\t" | 967 + "pfadd 2056(%0, %%"REG_S"), %%mm1\n\t" |
991 + "pfadd 3072(%0, %%esi), %%mm2 \n\t" | 968 + "pfadd 3072(%0, %%"REG_S"), %%mm2\n\t" |
992 + "pfadd 3080(%0, %%esi), %%mm3 \n\t" | 969 + "pfadd 3080(%0, %%"REG_S"), %%mm3\n\t" |
993 + "pfadd %%mm7, %%mm0 \n\t" | 970 + "pfadd %%mm7, %%mm0 \n\t" |
994 + "pfadd %%mm7, %%mm1 \n\t" | 971 + "pfadd %%mm7, %%mm1 \n\t" |
995 + "pfadd 4096(%0, %%esi), %%mm2 \n\t" | 972 + "pfadd 4096(%0, %%"REG_S"), %%mm2\n\t" |
996 + "pfadd 4104(%0, %%esi), %%mm3 \n\t" | 973 + "pfadd 4104(%0, %%"REG_S"), %%mm3\n\t" |
997 + "pfadd %%mm2, %%mm0 \n\t" | 974 + "pfadd %%mm2, %%mm0 \n\t" |
998 + "pfadd %%mm3, %%mm1 \n\t" | 975 + "pfadd %%mm3, %%mm1 \n\t" |
999 + "movq %%mm0, (%0, %%esi) \n\t" | 976 + "movq %%mm0, (%0, %%"REG_S") \n\t" |
1000 + "movq %%mm1, 8(%0, %%esi) \n\t" | 977 + "movq %%mm1, 8(%0, %%"REG_S") \n\t" |
1001 + "addl $16, %%esi \n\t" | 978 + "add $16, %%"REG_S" \n\t" |
1002 + " jnz 1b \n\t" | 979 + " jnz 1b \n\t" |
1003 + :: "r" (samples+256), "m" (bias) | 980 + :: "r" (samples+256), "m" (bias) |
1004 + : "%esi" | 981 + : "%"REG_S |
1005 + ); | 982 + ); |
1006 +} | 983 +} |
1007 + | 984 + |
1008 +static void mix3to2_3dnow (sample_t * samples, sample_t bias) | 985 +static void mix3to2_3dnow (sample_t * samples, sample_t bias) |
1009 +{ | 986 +{ |
1010 + asm volatile( | 987 + asm volatile( |
1011 + "movd %1, %%mm7 \n\t" | 988 + "movd %1, %%mm7 \n\t" |
1012 + "punpckldq %1, %%mm7 \n\t" | 989 + "punpckldq %1, %%mm7 \n\t" |
1013 + "movl $-1024, %%esi \n\t" | 990 + "mov $-1024, %%"REG_S" \n\t" |
1014 + ".balign 16\n\t" | 991 + ASMALIGN16 |
1015 + "1: \n\t" | 992 + "1: \n\t" |
1016 + "movq 1024(%0, %%esi), %%mm0 \n\t" | 993 + "movq 1024(%0, %%"REG_S"), %%mm0\n\t" |
1017 + "movq 1032(%0, %%esi), %%mm1 \n\t" | 994 + "movq 1032(%0, %%"REG_S"), %%mm1\n\t" |
1018 + "pfadd %%mm7, %%mm0 \n\t" //common | 995 + "pfadd %%mm7, %%mm0 \n\t" //common |
1019 + "pfadd %%mm7, %%mm1 \n\t" //common | 996 + "pfadd %%mm7, %%mm1 \n\t" //common |
1020 + "movq (%0, %%esi), %%mm2 \n\t" | 997 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1021 + "movq 8(%0, %%esi), %%mm3 \n\t" | 998 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1022 + "movq 2048(%0, %%esi), %%mm4 \n\t" | 999 + "movq 2048(%0, %%"REG_S"), %%mm4\n\t" |
1023 + "movq 2056(%0, %%esi), %%mm5 \n\t" | 1000 + "movq 2056(%0, %%"REG_S"), %%mm5\n\t" |
1024 + "pfadd %%mm0, %%mm2 \n\t" | 1001 + "pfadd %%mm0, %%mm2 \n\t" |
1025 + "pfadd %%mm1, %%mm3 \n\t" | 1002 + "pfadd %%mm1, %%mm3 \n\t" |
1026 + "pfadd %%mm0, %%mm4 \n\t" | 1003 + "pfadd %%mm0, %%mm4 \n\t" |
1027 + "pfadd %%mm1, %%mm5 \n\t" | 1004 + "pfadd %%mm1, %%mm5 \n\t" |
1028 + "movq %%mm2, (%0, %%esi) \n\t" | 1005 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1029 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1006 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1030 + "movq %%mm4, 1024(%0, %%esi) \n\t" | 1007 + "movq %%mm4, 1024(%0, %%"REG_S")\n\t" |
1031 + "movq %%mm5, 1032(%0, %%esi) \n\t" | 1008 + "movq %%mm5, 1032(%0, %%"REG_S")\n\t" |
1032 + "addl $16, %%esi \n\t" | 1009 + "add $16, %%"REG_S" \n\t" |
1033 + " jnz 1b \n\t" | 1010 + " jnz 1b \n\t" |
1034 + :: "r" (samples+256), "m" (bias) | 1011 + :: "r" (samples+256), "m" (bias) |
1035 + : "%esi" | 1012 + : "%"REG_S |
1036 + ); | 1013 + ); |
1037 +} | 1014 +} |
1038 + | 1015 + |
1039 +static void mix21to2_3dnow (sample_t * left, sample_t * right, sample_t bias) | 1016 +static void mix21to2_3dnow (sample_t * left, sample_t * right, sample_t bias) |
1040 +{ | 1017 +{ |
1041 + asm volatile( | 1018 + asm volatile( |
1042 + "movd %2, %%mm7 \n\t" | 1019 + "movd %2, %%mm7 \n\t" |
1043 + "punpckldq %2, %%mm7 \n\t" | 1020 + "punpckldq %2, %%mm7 \n\t" |
1044 + "movl $-1024, %%esi \n\t" | 1021 + "mov $-1024, %%"REG_S" \n\t" |
1045 + ".balign 16\n\t" | 1022 + ASMALIGN16 |
1046 + "1: \n\t" | 1023 + "1: \n\t" |
1047 + "movq 1024(%1, %%esi), %%mm0 \n\t" | 1024 + "movq 1024(%1, %%"REG_S"), %%mm0\n\t" |
1048 + "movq 1032(%1, %%esi), %%mm1 \n\t" | 1025 + "movq 1032(%1, %%"REG_S"), %%mm1\n\t" |
1049 + "pfadd %%mm7, %%mm0 \n\t" //common | 1026 + "pfadd %%mm7, %%mm0 \n\t" //common |
1050 + "pfadd %%mm7, %%mm1 \n\t" //common | 1027 + "pfadd %%mm7, %%mm1 \n\t" //common |
1051 + "movq (%0, %%esi), %%mm2 \n\t" | 1028 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1052 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1029 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1053 + "movq (%1, %%esi), %%mm4 \n\t" | 1030 + "movq (%1, %%"REG_S"), %%mm4 \n\t" |
1054 + "movq 8(%1, %%esi), %%mm5 \n\t" | 1031 + "movq 8(%1, %%"REG_S"), %%mm5 \n\t" |
1055 + "pfadd %%mm0, %%mm2 \n\t" | 1032 + "pfadd %%mm0, %%mm2 \n\t" |
1056 + "pfadd %%mm1, %%mm3 \n\t" | 1033 + "pfadd %%mm1, %%mm3 \n\t" |
1057 + "pfadd %%mm0, %%mm4 \n\t" | 1034 + "pfadd %%mm0, %%mm4 \n\t" |
1058 + "pfadd %%mm1, %%mm5 \n\t" | 1035 + "pfadd %%mm1, %%mm5 \n\t" |
1059 + "movq %%mm2, (%0, %%esi) \n\t" | 1036 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1060 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1037 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1061 + "movq %%mm4, (%1, %%esi) \n\t" | 1038 + "movq %%mm4, (%1, %%"REG_S") \n\t" |
1062 + "movq %%mm5, 8(%1, %%esi) \n\t" | 1039 + "movq %%mm5, 8(%1, %%"REG_S") \n\t" |
1063 + "addl $16, %%esi \n\t" | 1040 + "add $16, %%"REG_S" \n\t" |
1064 + " jnz 1b \n\t" | 1041 + " jnz 1b \n\t" |
1065 + :: "r" (left+256), "r" (right+256), "m" (bias) | 1042 + :: "r" (left+256), "r" (right+256), "m" (bias) |
1066 + : "%esi" | 1043 + : "%"REG_S |
1067 + ); | 1044 + ); |
1068 +} | 1045 +} |
1069 + | 1046 + |
1070 +static void mix21toS_3dnow (sample_t * samples, sample_t bias) | 1047 +static void mix21toS_3dnow (sample_t * samples, sample_t bias) |
1071 +{ | 1048 +{ |
1072 + asm volatile( | 1049 + asm volatile( |
1073 + "movd %1, %%mm7 \n\t" | 1050 + "movd %1, %%mm7 \n\t" |
1074 + "punpckldq %1, %%mm7 \n\t" | 1051 + "punpckldq %1, %%mm7 \n\t" |
1075 + "movl $-1024, %%esi \n\t" | 1052 + "mov $-1024, %%"REG_S" \n\t" |
1076 + ".balign 16\n\t" | 1053 + ASMALIGN16 |
1077 + "1: \n\t" | 1054 + "1: \n\t" |
1078 + "movq 2048(%0, %%esi), %%mm0 \n\t" // surround | 1055 + "movq 2048(%0, %%"REG_S"), %%mm0\n\t" // surround |
1079 + "movq 2056(%0, %%esi), %%mm1 \n\t" // surround | 1056 + "movq 2056(%0, %%"REG_S"), %%mm1\n\t" // surround |
1080 + "movq (%0, %%esi), %%mm2 \n\t" | 1057 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1081 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1058 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1082 + "movq 1024(%0, %%esi), %%mm4 \n\t" | 1059 + "movq 1024(%0, %%"REG_S"), %%mm4\n\t" |
1083 + "movq 1032(%0, %%esi), %%mm5 \n\t" | 1060 + "movq 1032(%0, %%"REG_S"), %%mm5\n\t" |
1084 + "pfadd %%mm7, %%mm2 \n\t" | 1061 + "pfadd %%mm7, %%mm2 \n\t" |
1085 + "pfadd %%mm7, %%mm3 \n\t" | 1062 + "pfadd %%mm7, %%mm3 \n\t" |
1086 + "pfadd %%mm7, %%mm4 \n\t" | 1063 + "pfadd %%mm7, %%mm4 \n\t" |
1087 + "pfadd %%mm7, %%mm5 \n\t" | 1064 + "pfadd %%mm7, %%mm5 \n\t" |
1088 + "pfsub %%mm0, %%mm2 \n\t" | 1065 + "pfsub %%mm0, %%mm2 \n\t" |
1089 + "pfsub %%mm1, %%mm3 \n\t" | 1066 + "pfsub %%mm1, %%mm3 \n\t" |
1090 + "pfadd %%mm0, %%mm4 \n\t" | 1067 + "pfadd %%mm0, %%mm4 \n\t" |
1091 + "pfadd %%mm1, %%mm5 \n\t" | 1068 + "pfadd %%mm1, %%mm5 \n\t" |
1092 + "movq %%mm2, (%0, %%esi) \n\t" | 1069 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1093 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1070 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1094 + "movq %%mm4, 1024(%0, %%esi) \n\t" | 1071 + "movq %%mm4, 1024(%0, %%"REG_S")\n\t" |
1095 + "movq %%mm5, 1032(%0, %%esi) \n\t" | 1072 + "movq %%mm5, 1032(%0, %%"REG_S")\n\t" |
1096 + "addl $16, %%esi \n\t" | 1073 + "add $16, %%"REG_S" \n\t" |
1097 + " jnz 1b \n\t" | 1074 + " jnz 1b \n\t" |
1098 + :: "r" (samples+256), "m" (bias) | 1075 + :: "r" (samples+256), "m" (bias) |
1099 + : "%esi" | 1076 + : "%"REG_S |
1100 + ); | 1077 + ); |
1101 +} | 1078 +} |
1102 + | 1079 + |
1103 +static void mix31to2_3dnow (sample_t * samples, sample_t bias) | 1080 +static void mix31to2_3dnow (sample_t * samples, sample_t bias) |
1104 +{ | 1081 +{ |
1105 + asm volatile( | 1082 + asm volatile( |
1106 + "movd %1, %%mm7 \n\t" | 1083 + "movd %1, %%mm7 \n\t" |
1107 + "punpckldq %1, %%mm7 \n\t" | 1084 + "punpckldq %1, %%mm7 \n\t" |
1108 + "movl $-1024, %%esi \n\t" | 1085 + "mov $-1024, %%"REG_S" \n\t" |
1109 + ".balign 16\n\t" | 1086 + ASMALIGN16 |
1110 + "1: \n\t" | 1087 + "1: \n\t" |
1111 + "movq 1024(%0, %%esi), %%mm0 \n\t" | 1088 + "movq 1024(%0, %%"REG_S"), %%mm0\n\t" |
1112 + "movq 1032(%0, %%esi), %%mm1 \n\t" | 1089 + "movq 1032(%0, %%"REG_S"), %%mm1\n\t" |
1113 + "pfadd 3072(%0, %%esi), %%mm0 \n\t" | 1090 + "pfadd 3072(%0, %%"REG_S"), %%mm0\n\t" |
1114 + "pfadd 3080(%0, %%esi), %%mm1 \n\t" | 1091 + "pfadd 3080(%0, %%"REG_S"), %%mm1\n\t" |
1115 + "pfadd %%mm7, %%mm0 \n\t" // common | 1092 + "pfadd %%mm7, %%mm0 \n\t" // common |
1116 + "pfadd %%mm7, %%mm1 \n\t" // common | 1093 + "pfadd %%mm7, %%mm1 \n\t" // common |
1117 + "movq (%0, %%esi), %%mm2 \n\t" | 1094 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1118 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1095 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1119 + "movq 2048(%0, %%esi), %%mm4 \n\t" | 1096 + "movq 2048(%0, %%"REG_S"), %%mm4\n\t" |
1120 + "movq 2056(%0, %%esi), %%mm5 \n\t" | 1097 + "movq 2056(%0, %%"REG_S"), %%mm5\n\t" |
1121 + "pfadd %%mm0, %%mm2 \n\t" | 1098 + "pfadd %%mm0, %%mm2 \n\t" |
1122 + "pfadd %%mm1, %%mm3 \n\t" | 1099 + "pfadd %%mm1, %%mm3 \n\t" |
1123 + "pfadd %%mm0, %%mm4 \n\t" | 1100 + "pfadd %%mm0, %%mm4 \n\t" |
1124 + "pfadd %%mm1, %%mm5 \n\t" | 1101 + "pfadd %%mm1, %%mm5 \n\t" |
1125 + "movq %%mm2, (%0, %%esi) \n\t" | 1102 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1126 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1103 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1127 + "movq %%mm4, 1024(%0, %%esi) \n\t" | 1104 + "movq %%mm4, 1024(%0, %%"REG_S")\n\t" |
1128 + "movq %%mm5, 1032(%0, %%esi) \n\t" | 1105 + "movq %%mm5, 1032(%0, %%"REG_S")\n\t" |
1129 + "addl $16, %%esi \n\t" | 1106 + "add $16, %%"REG_S" \n\t" |
1130 + " jnz 1b \n\t" | 1107 + " jnz 1b \n\t" |
1131 + :: "r" (samples+256), "m" (bias) | 1108 + :: "r" (samples+256), "m" (bias) |
1132 + : "%esi" | 1109 + : "%"REG_S |
1133 + ); | 1110 + ); |
1134 +} | 1111 +} |
1135 + | 1112 + |
1136 +static void mix31toS_3dnow (sample_t * samples, sample_t bias) | 1113 +static void mix31toS_3dnow (sample_t * samples, sample_t bias) |
1137 +{ | 1114 +{ |
1138 + asm volatile( | 1115 + asm volatile( |
1139 + "movd %1, %%mm7 \n\t" | 1116 + "movd %1, %%mm7 \n\t" |
1140 + "punpckldq %1, %%mm7 \n\t" | 1117 + "punpckldq %1, %%mm7 \n\t" |
1141 + "movl $-1024, %%esi \n\t" | 1118 + "mov $-1024, %%"REG_S" \n\t" |
1142 + ".balign 16\n\t" | 1119 + ASMALIGN16 |
1143 + "1: \n\t" | 1120 + "1: \n\t" |
1144 + "movq 1024(%0, %%esi), %%mm0 \n\t" | 1121 + "movq 1024(%0, %%"REG_S"), %%mm0\n\t" |
1145 + "movq 1032(%0, %%esi), %%mm1 \n\t" | 1122 + "movq 1032(%0, %%"REG_S"), %%mm1\n\t" |
1146 + "pfadd %%mm7, %%mm0 \n\t" // common | 1123 + "pfadd %%mm7, %%mm0 \n\t" // common |
1147 + "pfadd %%mm7, %%mm1 \n\t" // common | 1124 + "pfadd %%mm7, %%mm1 \n\t" // common |
1148 + "movq (%0, %%esi), %%mm2 \n\t" | 1125 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1149 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1126 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1150 + "movq 2048(%0, %%esi), %%mm4 \n\t" | 1127 + "movq 2048(%0, %%"REG_S"), %%mm4\n\t" |
1151 + "movq 2056(%0, %%esi), %%mm5 \n\t" | 1128 + "movq 2056(%0, %%"REG_S"), %%mm5\n\t" |
1152 + "pfadd %%mm0, %%mm2 \n\t" | 1129 + "pfadd %%mm0, %%mm2 \n\t" |
1153 + "pfadd %%mm1, %%mm3 \n\t" | 1130 + "pfadd %%mm1, %%mm3 \n\t" |
1154 + "pfadd %%mm0, %%mm4 \n\t" | 1131 + "pfadd %%mm0, %%mm4 \n\t" |
1155 + "pfadd %%mm1, %%mm5 \n\t" | 1132 + "pfadd %%mm1, %%mm5 \n\t" |
1156 + "movq 3072(%0, %%esi), %%mm0 \n\t" // surround | 1133 + "movq 3072(%0, %%"REG_S"), %%mm0\n\t" // surround |
1157 + "movq 3080(%0, %%esi), %%mm1 \n\t" // surround | 1134 + "movq 3080(%0, %%"REG_S"), %%mm1\n\t" // surround |
1158 + "pfsub %%mm0, %%mm2 \n\t" | 1135 + "pfsub %%mm0, %%mm2 \n\t" |
1159 + "pfsub %%mm1, %%mm3 \n\t" | 1136 + "pfsub %%mm1, %%mm3 \n\t" |
1160 + "pfadd %%mm0, %%mm4 \n\t" | 1137 + "pfadd %%mm0, %%mm4 \n\t" |
1161 + "pfadd %%mm1, %%mm5 \n\t" | 1138 + "pfadd %%mm1, %%mm5 \n\t" |
1162 + "movq %%mm2, (%0, %%esi) \n\t" | 1139 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1163 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1140 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1164 + "movq %%mm4, 1024(%0, %%esi) \n\t" | 1141 + "movq %%mm4, 1024(%0, %%"REG_S")\n\t" |
1165 + "movq %%mm5, 1032(%0, %%esi) \n\t" | 1142 + "movq %%mm5, 1032(%0, %%"REG_S")\n\t" |
1166 + "addl $16, %%esi \n\t" | 1143 + "add $16, %%"REG_S" \n\t" |
1167 + " jnz 1b \n\t" | 1144 + " jnz 1b \n\t" |
1168 + :: "r" (samples+256), "m" (bias) | 1145 + :: "r" (samples+256), "m" (bias) |
1169 + : "%esi" | 1146 + : "%"REG_S |
1170 + ); | 1147 + ); |
1171 +} | 1148 +} |
1172 + | 1149 + |
1173 +static void mix22toS_3dnow (sample_t * samples, sample_t bias) | 1150 +static void mix22toS_3dnow (sample_t * samples, sample_t bias) |
1174 +{ | 1151 +{ |
1175 + asm volatile( | 1152 + asm volatile( |
1176 + "movd %1, %%mm7 \n\t" | 1153 + "movd %1, %%mm7 \n\t" |
1177 + "punpckldq %1, %%mm7 \n\t" | 1154 + "punpckldq %1, %%mm7 \n\t" |
1178 + "movl $-1024, %%esi \n\t" | 1155 + "mov $-1024, %%"REG_S" \n\t" |
1179 + ".balign 16\n\t" | 1156 + ASMALIGN16 |
1180 + "1: \n\t" | 1157 + "1: \n\t" |
1181 + "movq 2048(%0, %%esi), %%mm0 \n\t" | 1158 + "movq 2048(%0, %%"REG_S"), %%mm0\n\t" |
1182 + "movq 2056(%0, %%esi), %%mm1 \n\t" | 1159 + "movq 2056(%0, %%"REG_S"), %%mm1\n\t" |
1183 + "pfadd 3072(%0, %%esi), %%mm0 \n\t" // surround | 1160 + "pfadd 3072(%0, %%"REG_S"), %%mm0\n\t" // surround |
1184 + "pfadd 3080(%0, %%esi), %%mm1 \n\t" // surround | 1161 + "pfadd 3080(%0, %%"REG_S"), %%mm1\n\t" // surround |
1185 + "movq (%0, %%esi), %%mm2 \n\t" | 1162 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1186 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1163 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1187 + "movq 1024(%0, %%esi), %%mm4 \n\t" | 1164 + "movq 1024(%0, %%"REG_S"), %%mm4\n\t" |
1188 + "movq 1032(%0, %%esi), %%mm5 \n\t" | 1165 + "movq 1032(%0, %%"REG_S"), %%mm5\n\t" |
1189 + "pfadd %%mm7, %%mm2 \n\t" | 1166 + "pfadd %%mm7, %%mm2 \n\t" |
1190 + "pfadd %%mm7, %%mm3 \n\t" | 1167 + "pfadd %%mm7, %%mm3 \n\t" |
1191 + "pfadd %%mm7, %%mm4 \n\t" | 1168 + "pfadd %%mm7, %%mm4 \n\t" |
1192 + "pfadd %%mm7, %%mm5 \n\t" | 1169 + "pfadd %%mm7, %%mm5 \n\t" |
1193 + "pfsub %%mm0, %%mm2 \n\t" | 1170 + "pfsub %%mm0, %%mm2 \n\t" |
1194 + "pfsub %%mm1, %%mm3 \n\t" | 1171 + "pfsub %%mm1, %%mm3 \n\t" |
1195 + "pfadd %%mm0, %%mm4 \n\t" | 1172 + "pfadd %%mm0, %%mm4 \n\t" |
1196 + "pfadd %%mm1, %%mm5 \n\t" | 1173 + "pfadd %%mm1, %%mm5 \n\t" |
1197 + "movq %%mm2, (%0, %%esi) \n\t" | 1174 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1198 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1175 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1199 + "movq %%mm4, 1024(%0, %%esi) \n\t" | 1176 + "movq %%mm4, 1024(%0, %%"REG_S")\n\t" |
1200 + "movq %%mm5, 1032(%0, %%esi) \n\t" | 1177 + "movq %%mm5, 1032(%0, %%"REG_S")\n\t" |
1201 + "addl $16, %%esi \n\t" | 1178 + "add $16, %%"REG_S" \n\t" |
1202 + " jnz 1b \n\t" | 1179 + " jnz 1b \n\t" |
1203 + :: "r" (samples+256), "m" (bias) | 1180 + :: "r" (samples+256), "m" (bias) |
1204 + : "%esi" | 1181 + : "%"REG_S |
1205 + ); | 1182 + ); |
1206 +} | 1183 +} |
1207 + | 1184 + |
1208 +static void mix32to2_3dnow (sample_t * samples, sample_t bias) | 1185 +static void mix32to2_3dnow (sample_t * samples, sample_t bias) |
1209 +{ | 1186 +{ |
1210 + asm volatile( | 1187 + asm volatile( |
1211 + "movd %1, %%mm7 \n\t" | 1188 + "movd %1, %%mm7 \n\t" |
1212 + "punpckldq %1, %%mm7 \n\t" | 1189 + "punpckldq %1, %%mm7 \n\t" |
1213 + "movl $-1024, %%esi \n\t" | 1190 + "mov $-1024, %%"REG_S" \n\t" |
1214 + ".balign 16\n\t" | 1191 + ASMALIGN16 |
1215 + "1: \n\t" | 1192 + "1: \n\t" |
1216 + "movq 1024(%0, %%esi), %%mm0 \n\t" | 1193 + "movq 1024(%0, %%"REG_S"), %%mm0\n\t" |
1217 + "movq 1032(%0, %%esi), %%mm1 \n\t" | 1194 + "movq 1032(%0, %%"REG_S"), %%mm1\n\t" |
1218 + "pfadd %%mm7, %%mm0 \n\t" // common | 1195 + "pfadd %%mm7, %%mm0 \n\t" // common |
1219 + "pfadd %%mm7, %%mm1 \n\t" // common | 1196 + "pfadd %%mm7, %%mm1 \n\t" // common |
1220 + "movq %%mm0, %%mm2 \n\t" // common | 1197 + "movq %%mm0, %%mm2 \n\t" // common |
1221 + "movq %%mm1, %%mm3 \n\t" // common | 1198 + "movq %%mm1, %%mm3 \n\t" // common |
1222 + "pfadd (%0, %%esi), %%mm0 \n\t" | 1199 + "pfadd (%0, %%"REG_S"), %%mm0 \n\t" |
1223 + "pfadd 8(%0, %%esi), %%mm1 \n\t" | 1200 + "pfadd 8(%0, %%"REG_S"), %%mm1 \n\t" |
1224 + "pfadd 2048(%0, %%esi), %%mm2 \n\t" | 1201 + "pfadd 2048(%0, %%"REG_S"), %%mm2\n\t" |
1225 + "pfadd 2056(%0, %%esi), %%mm3 \n\t" | 1202 + "pfadd 2056(%0, %%"REG_S"), %%mm3\n\t" |
1226 + "pfadd 3072(%0, %%esi), %%mm0 \n\t" | 1203 + "pfadd 3072(%0, %%"REG_S"), %%mm0\n\t" |
1227 + "pfadd 3080(%0, %%esi), %%mm1 \n\t" | 1204 + "pfadd 3080(%0, %%"REG_S"), %%mm1\n\t" |
1228 + "pfadd 4096(%0, %%esi), %%mm2 \n\t" | 1205 + "pfadd 4096(%0, %%"REG_S"), %%mm2\n\t" |
1229 + "pfadd 4104(%0, %%esi), %%mm3 \n\t" | 1206 + "pfadd 4104(%0, %%"REG_S"), %%mm3\n\t" |
1230 + "movq %%mm0, (%0, %%esi) \n\t" | 1207 + "movq %%mm0, (%0, %%"REG_S") \n\t" |
1231 + "movq %%mm1, 8(%0, %%esi) \n\t" | 1208 + "movq %%mm1, 8(%0, %%"REG_S") \n\t" |
1232 + "movq %%mm2, 1024(%0, %%esi) \n\t" | 1209 + "movq %%mm2, 1024(%0, %%"REG_S")\n\t" |
1233 + "movq %%mm3, 1032(%0, %%esi) \n\t" | 1210 + "movq %%mm3, 1032(%0, %%"REG_S")\n\t" |
1234 + "addl $16, %%esi \n\t" | 1211 + "add $16, %%"REG_S" \n\t" |
1235 + " jnz 1b \n\t" | 1212 + " jnz 1b \n\t" |
1236 + :: "r" (samples+256), "m" (bias) | 1213 + :: "r" (samples+256), "m" (bias) |
1237 + : "%esi" | 1214 + : "%"REG_S |
1238 + ); | 1215 + ); |
1239 +} | 1216 +} |
1240 + | 1217 + |
1241 +/* todo: should be optimized better */ | 1218 +/* todo: should be optimized better */ |
1242 +static void mix32toS_3dnow (sample_t * samples, sample_t bias) | 1219 +static void mix32toS_3dnow (sample_t * samples, sample_t bias) |
1243 +{ | 1220 +{ |
1244 + asm volatile( | 1221 + asm volatile( |
1245 + "movl $-1024, %%esi \n\t" | 1222 + "mov $-1024, %%"REG_S" \n\t" |
1246 + ".balign 16\n\t" | 1223 + ASMALIGN16 |
1247 + "1: \n\t" | 1224 + "1: \n\t" |
1248 + "movd %1, %%mm7 \n\t" | 1225 + "movd %1, %%mm7 \n\t" |
1249 + "punpckldq %1, %%mm7 \n\t" | 1226 + "punpckldq %1, %%mm7 \n\t" |
1250 + "movq 1024(%0, %%esi), %%mm0 \n\t" | 1227 + "movq 1024(%0, %%"REG_S"), %%mm0\n\t" |
1251 + "movq 1032(%0, %%esi), %%mm1 \n\t" | 1228 + "movq 1032(%0, %%"REG_S"), %%mm1\n\t" |
1252 + "movq 3072(%0, %%esi), %%mm4 \n\t" | 1229 + "movq 3072(%0, %%"REG_S"), %%mm4\n\t" |
1253 + "movq 3080(%0, %%esi), %%mm5 \n\t" | 1230 + "movq 3080(%0, %%"REG_S"), %%mm5\n\t" |
1254 + "pfadd %%mm7, %%mm0 \n\t" // common | 1231 + "pfadd %%mm7, %%mm0 \n\t" // common |
1255 + "pfadd %%mm7, %%mm1 \n\t" // common | 1232 + "pfadd %%mm7, %%mm1 \n\t" // common |
1256 + "pfadd 4096(%0, %%esi), %%mm4 \n\t" // surround | 1233 + "pfadd 4096(%0, %%"REG_S"), %%mm4\n\t" // surround |
1257 + "pfadd 4104(%0, %%esi), %%mm5 \n\t" // surround | 1234 + "pfadd 4104(%0, %%"REG_S"), %%mm5\n\t" // surround |
1258 + "movq (%0, %%esi), %%mm2 \n\t" | 1235 + "movq (%0, %%"REG_S"), %%mm2 \n\t" |
1259 + "movq 8(%0, %%esi), %%mm3 \n\t" | 1236 + "movq 8(%0, %%"REG_S"), %%mm3 \n\t" |
1260 + "movq 2048(%0, %%esi), %%mm6 \n\t" | 1237 + "movq 2048(%0, %%"REG_S"), %%mm6\n\t" |
1261 + "movq 2056(%0, %%esi), %%mm7 \n\t" | 1238 + "movq 2056(%0, %%"REG_S"), %%mm7\n\t" |
1262 + "pfsub %%mm4, %%mm2 \n\t" | 1239 + "pfsub %%mm4, %%mm2 \n\t" |
1263 + "pfsub %%mm5, %%mm3 \n\t" | 1240 + "pfsub %%mm5, %%mm3 \n\t" |
1264 + "pfadd %%mm4, %%mm6 \n\t" | 1241 + "pfadd %%mm4, %%mm6 \n\t" |
1265 + "pfadd %%mm5, %%mm7 \n\t" | 1242 + "pfadd %%mm5, %%mm7 \n\t" |
1266 + "pfadd %%mm0, %%mm2 \n\t" | 1243 + "pfadd %%mm0, %%mm2 \n\t" |
1267 + "pfadd %%mm1, %%mm3 \n\t" | 1244 + "pfadd %%mm1, %%mm3 \n\t" |
1268 + "pfadd %%mm0, %%mm6 \n\t" | 1245 + "pfadd %%mm0, %%mm6 \n\t" |
1269 + "pfadd %%mm1, %%mm7 \n\t" | 1246 + "pfadd %%mm1, %%mm7 \n\t" |
1270 + "movq %%mm2, (%0, %%esi) \n\t" | 1247 + "movq %%mm2, (%0, %%"REG_S") \n\t" |
1271 + "movq %%mm3, 8(%0, %%esi) \n\t" | 1248 + "movq %%mm3, 8(%0, %%"REG_S") \n\t" |
1272 + "movq %%mm6, 1024(%0, %%esi) \n\t" | 1249 + "movq %%mm6, 1024(%0, %%"REG_S")\n\t" |
1273 + "movq %%mm7, 1032(%0, %%esi) \n\t" | 1250 + "movq %%mm7, 1032(%0, %%"REG_S")\n\t" |
1274 + "addl $16, %%esi \n\t" | 1251 + "add $16, %%"REG_S" \n\t" |
1275 + " jnz 1b \n\t" | 1252 + " jnz 1b \n\t" |
1276 + :: "r" (samples+256), "m" (bias) | 1253 + :: "r" (samples+256), "m" (bias) |
1277 + : "%esi" | 1254 + : "%"REG_S |
1278 + ); | 1255 + ); |
1279 +} | 1256 +} |
1280 + | 1257 + |
1281 +static void move2to1_3dnow (sample_t * src, sample_t * dest, sample_t bias) | 1258 +static void move2to1_3dnow (sample_t * src, sample_t * dest, sample_t bias) |
1282 +{ | 1259 +{ |
1283 + asm volatile( | 1260 + asm volatile( |
1284 + "movd %2, %%mm7 \n\t" | 1261 + "movd %2, %%mm7 \n\t" |
1285 + "punpckldq %2, %%mm7 \n\t" | 1262 + "punpckldq %2, %%mm7 \n\t" |
1286 + "movl $-1024, %%esi \n\t" | 1263 + "mov $-1024, %%"REG_S" \n\t" |
1287 + ".balign 16\n\t" | 1264 + ASMALIGN16 |
1288 + "1: \n\t" | 1265 + "1: \n\t" |
1289 + "movq (%0, %%esi), %%mm0 \n\t" | 1266 + "movq (%0, %%"REG_S"), %%mm0 \n\t" |
1290 + "movq 8(%0, %%esi), %%mm1 \n\t" | 1267 + "movq 8(%0, %%"REG_S"), %%mm1 \n\t" |
1291 + "movq 16(%0, %%esi), %%mm2 \n\t" | 1268 + "movq 16(%0, %%"REG_S"), %%mm2 \n\t" |
1292 + "movq 24(%0, %%esi), %%mm3 \n\t" | 1269 + "movq 24(%0, %%"REG_S"), %%mm3 \n\t" |
1293 + "pfadd 1024(%0, %%esi), %%mm0 \n\t" | 1270 + "pfadd 1024(%0, %%"REG_S"), %%mm0\n\t" |
1294 + "pfadd 1032(%0, %%esi), %%mm1 \n\t" | 1271 + "pfadd 1032(%0, %%"REG_S"), %%mm1\n\t" |
1295 + "pfadd 1040(%0, %%esi), %%mm2 \n\t" | 1272 + "pfadd 1040(%0, %%"REG_S"), %%mm2\n\t" |
1296 + "pfadd 1048(%0, %%esi), %%mm3 \n\t" | 1273 + "pfadd 1048(%0, %%"REG_S"), %%mm3\n\t" |
1297 + "pfadd %%mm7, %%mm0 \n\t" | 1274 + "pfadd %%mm7, %%mm0 \n\t" |
1298 + "pfadd %%mm7, %%mm1 \n\t" | 1275 + "pfadd %%mm7, %%mm1 \n\t" |
1299 + "pfadd %%mm7, %%mm2 \n\t" | 1276 + "pfadd %%mm7, %%mm2 \n\t" |
1300 + "pfadd %%mm7, %%mm3 \n\t" | 1277 + "pfadd %%mm7, %%mm3 \n\t" |
1301 + "movq %%mm0, (%1, %%esi) \n\t" | 1278 + "movq %%mm0, (%1, %%"REG_S") \n\t" |
1302 + "movq %%mm1, 8(%1, %%esi) \n\t" | 1279 + "movq %%mm1, 8(%1, %%"REG_S") \n\t" |
1303 + "movq %%mm2, 16(%1, %%esi) \n\t" | 1280 + "movq %%mm2, 16(%1, %%"REG_S") \n\t" |
1304 + "movq %%mm3, 24(%1, %%esi) \n\t" | 1281 + "movq %%mm3, 24(%1, %%"REG_S") \n\t" |
1305 + "addl $32, %%esi \n\t" | 1282 + "add $32, %%"REG_S" \n\t" |
1306 + " jnz 1b \n\t" | 1283 + " jnz 1b \n\t" |
1307 + :: "r" (src+256), "r" (dest+256), "m" (bias) | 1284 + :: "r" (src+256), "r" (dest+256), "m" (bias) |
1308 + : "%esi" | 1285 + : "%"REG_S |
1309 + ); | 1286 + ); |
1310 +} | 1287 +} |
1311 + | 1288 + |
1312 +static void downmix_3dnow (sample_t * samples, int acmod, int output, sample_t bias, | 1289 +static void downmix_3dnow (sample_t * samples, int acmod, int output, sample_t bias, |
1313 + sample_t clev, sample_t slev) | 1290 + sample_t clev, sample_t slev) |
1449 + break; | 1426 + break; |
1450 + } | 1427 + } |
1451 + __asm __volatile("femms":::"memory"); | 1428 + __asm __volatile("femms":::"memory"); |
1452 +} | 1429 +} |
1453 + | 1430 + |
1454 +#endif //ARCH_X86 | 1431 +#endif // ARCH_X86 || ARCH_X86_64 |
1455 --- liba52/imdct.c 2005-03-22 19:59:35.000000000 +0100 | 1432 --- liba52-0.7.4/imdct.c 2006-06-12 15:18:27.000000000 +0200 |
1456 +++ imdct.c 2004-04-26 22:00:57.000000000 +0200 | 1433 +++ liba52/imdct.c 2006-06-12 19:18:39.000000000 +0200 |
1457 @@ -17,17 +23,32 @@ | 1434 @@ -26,9 +26,15 @@ |
1458 * You should have received a copy of the GNU General Public License | 1435 * You should have received a copy of the GNU General Public License |
1459 * along with this program; if not, write to the Free Software | 1436 * along with this program; if not, write to the Free Software |
1460 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 1437 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1461 + * | 1438 + * |
1462 + * SSE optimizations from Michael Niedermayer (michaelni@gmx.at) | 1439 + * SSE optimizations from Michael Niedermayer (michaelni@gmx.at) |
1464 + * michael did port them from libac3 (untested, perhaps totally broken) | 1441 + * michael did port them from libac3 (untested, perhaps totally broken) |
1465 + * AltiVec optimizations from Romain Dolbeau (romain@dolbeau.org) | 1442 + * AltiVec optimizations from Romain Dolbeau (romain@dolbeau.org) |
1466 */ | 1443 */ |
1467 | 1444 |
1468 #include "config.h" | 1445 #include "config.h" |
1469 | 1446 +#include "asmalign.h" |
1470 -#include <inttypes.h> | 1447 |
1471 #include <math.h> | 1448 #include <math.h> |
1472 #include <stdio.h> | 1449 #include <stdio.h> |
1473 +#ifndef M_PI | 1450 @@ -43,12 +49,49 @@ |
1474 +#define M_PI 3.1415926535897932384626433832795029 | |
1475 +#endif | |
1476 +#include <inttypes.h> | |
1477 | |
1478 #include "a52.h" | 1451 #include "a52.h" |
1479 #include "a52_internal.h" | 1452 #include "a52_internal.h" |
1480 #include "mm_accel.h" | 1453 #include "mm_accel.h" |
1481 +#include "mangle.h" | 1454 +#include "mangle.h" |
1482 + | 1455 + |
1456 +void (*a52_imdct_512) (sample_t * data, sample_t * delay, sample_t bias); | |
1457 + | |
1483 +#ifdef RUNTIME_CPUDETECT | 1458 +#ifdef RUNTIME_CPUDETECT |
1484 +#undef HAVE_3DNOWEX | 1459 +#undef HAVE_3DNOWEX |
1485 +#endif | 1460 +#endif |
1486 + | 1461 |
1487 +#define USE_AC3_C | 1462 typedef struct complex_s { |
1488 | 1463 sample_t real; |
1489 void (* imdct_256) (sample_t data[], sample_t delay[], sample_t bias); | |
1490 void (* imdct_512) (sample_t data[], sample_t delay[], sample_t bias); | |
1491 @@ -37,9 +58,22 @@ | |
1492 sample_t imag; | 1464 sample_t imag; |
1493 } complex_t; | 1465 } complex_t; |
1494 | 1466 |
1495 +static void fft_128p(complex_t *a); | |
1496 + | |
1497 +static const int pm128[128] attribute_used __attribute__((aligned(16))) = | 1467 +static const int pm128[128] attribute_used __attribute__((aligned(16))) = |
1498 +{ | 1468 +{ |
1499 + 0, 16, 32, 48, 64, 80, 96, 112, 8, 40, 72, 104, 24, 56, 88, 120, | 1469 + 0, 16, 32, 48, 64, 80, 96, 112, 8, 40, 72, 104, 24, 56, 88, 120, |
1500 + 4, 20, 36, 52, 68, 84, 100, 116, 12, 28, 44, 60, 76, 92, 108, 124, | 1470 + 4, 20, 36, 52, 68, 84, 100, 116, 12, 28, 44, 60, 76, 92, 108, 124, |
1501 + 2, 18, 34, 50, 66, 82, 98, 114, 10, 42, 74, 106, 26, 58, 90, 122, | 1471 + 2, 18, 34, 50, 66, 82, 98, 114, 10, 42, 74, 106, 26, 58, 90, 122, |
1503 + 1, 17, 33, 49, 65, 81, 97, 113, 9, 41, 73, 105, 25, 57, 89, 121, | 1473 + 1, 17, 33, 49, 65, 81, 97, 113, 9, 41, 73, 105, 25, 57, 89, 121, |
1504 + 5, 21, 37, 53, 69, 85, 101, 117, 13, 29, 45, 61, 77, 93, 109, 125, | 1474 + 5, 21, 37, 53, 69, 85, 101, 117, 13, 29, 45, 61, 77, 93, 109, 125, |
1505 + 3, 19, 35, 51, 67, 83, 99, 115, 11, 43, 75, 107, 27, 59, 91, 123, | 1475 + 3, 19, 35, 51, 67, 83, 99, 115, 11, 43, 75, 107, 27, 59, 91, 123, |
1506 + 7, 23, 39, 55, 71, 87, 103, 119, 15, 31, 47, 63, 79, 95, 111, 127 | 1476 + 7, 23, 39, 55, 71, 87, 103, 119, 15, 31, 47, 63, 79, 95, 111, 127 |
1507 +}; | 1477 +}; |
1508 | 1478 + |
1509 /* 128 point bit-reverse LUT */ | |
1510 -static uint8_t bit_reverse_512[] = { | |
1511 +static uint8_t attribute_used bit_reverse_512[] = { | 1479 +static uint8_t attribute_used bit_reverse_512[] = { |
1512 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70, | 1480 + 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70, |
1513 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78, | 1481 + 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78, |
1514 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74, | 1482 + 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74, |
1515 @@ -67,23 +101,42 @@ | 1483 + 0x0c, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c, |
1516 0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b, | 1484 + 0x02, 0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72, |
1517 0x07, 0x27, 0x17, 0x37, 0x0f, 0x2f, 0x1f, 0x3f}; | 1485 + 0x0a, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a, |
1518 | 1486 + 0x06, 0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76, |
1519 -static complex_t buf[128]; | 1487 + 0x0e, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e, |
1520 +#ifdef ARCH_X86 | 1488 + 0x01, 0x41, 0x21, 0x61, 0x11, 0x51, 0x31, 0x71, |
1489 + 0x09, 0x49, 0x29, 0x69, 0x19, 0x59, 0x39, 0x79, | |
1490 + 0x05, 0x45, 0x25, 0x65, 0x15, 0x55, 0x35, 0x75, | |
1491 + 0x0d, 0x4d, 0x2d, 0x6d, 0x1d, 0x5d, 0x3d, 0x7d, | |
1492 + 0x03, 0x43, 0x23, 0x63, 0x13, 0x53, 0x33, 0x73, | |
1493 + 0x0b, 0x4b, 0x2b, 0x6b, 0x1b, 0x5b, 0x3b, 0x7b, | |
1494 + 0x07, 0x47, 0x27, 0x67, 0x17, 0x57, 0x37, 0x77, | |
1495 + 0x0f, 0x4f, 0x2f, 0x6f, 0x1f, 0x5f, 0x3f, 0x7f}; | |
1496 + | |
1497 static uint8_t fftorder[] = { | |
1498 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176, | |
1499 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88, | |
1500 @@ -60,6 +103,40 @@ | |
1501 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86 | |
1502 }; | |
1503 | |
1504 +static complex_t __attribute__((aligned(16))) buf[128]; | |
1505 + | |
1506 +/* Twiddle factor LUT */ | |
1507 +static complex_t __attribute__((aligned(16))) w_1[1]; | |
1508 +static complex_t __attribute__((aligned(16))) w_2[2]; | |
1509 +static complex_t __attribute__((aligned(16))) w_4[4]; | |
1510 +static complex_t __attribute__((aligned(16))) w_8[8]; | |
1511 +static complex_t __attribute__((aligned(16))) w_16[16]; | |
1512 +static complex_t __attribute__((aligned(16))) w_32[32]; | |
1513 +static complex_t __attribute__((aligned(16))) w_64[64]; | |
1514 +static complex_t __attribute__((aligned(16))) * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64}; | |
1515 + | |
1516 +/* Twiddle factors for IMDCT */ | |
1517 +static sample_t __attribute__((aligned(16))) xcos1[128]; | |
1518 +static sample_t __attribute__((aligned(16))) xsin1[128]; | |
1519 + | |
1520 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
1521 +// NOTE: SSE needs 16byte alignment or it will segfault | 1521 +// NOTE: SSE needs 16byte alignment or it will segfault |
1522 +// | 1522 +// |
1523 +static complex_t __attribute__((aligned(16))) buf[128]; | |
1524 +static float __attribute__((aligned(16))) sseSinCos1c[256]; | 1523 +static float __attribute__((aligned(16))) sseSinCos1c[256]; |
1525 +static float __attribute__((aligned(16))) sseSinCos1d[256]; | 1524 +static float __attribute__((aligned(16))) sseSinCos1d[256]; |
1526 +static float attribute_used __attribute__((aligned(16))) ps111_1[4]={1,1,1,-1}; | 1525 +static float attribute_used __attribute__((aligned(16))) ps111_1[4]={1,1,1,-1}; |
1527 +//static float __attribute__((aligned(16))) sseW0[4]; | 1526 +//static float __attribute__((aligned(16))) sseW0[4]; |
1528 +static float __attribute__((aligned(16))) sseW1[8]; | 1527 +static float __attribute__((aligned(16))) sseW1[8]; |
1532 +static float __attribute__((aligned(16))) sseW5[128]; | 1531 +static float __attribute__((aligned(16))) sseW5[128]; |
1533 +static float __attribute__((aligned(16))) sseW6[256]; | 1532 +static float __attribute__((aligned(16))) sseW6[256]; |
1534 +static float __attribute__((aligned(16))) *sseW[7]= | 1533 +static float __attribute__((aligned(16))) *sseW[7]= |
1535 + {NULL /*sseW0*/,sseW1,sseW2,sseW3,sseW4,sseW5,sseW6}; | 1534 + {NULL /*sseW0*/,sseW1,sseW2,sseW3,sseW4,sseW5,sseW6}; |
1536 +static float __attribute__((aligned(16))) sseWindow[512]; | 1535 +static float __attribute__((aligned(16))) sseWindow[512]; |
1537 +#else | 1536 +#endif |
1538 +static complex_t __attribute__((aligned(16))) buf[128]; | 1537 + |
1539 +#endif | 1538 /* Root values for IFFT */ |
1540 | 1539 static sample_t roots16[3]; |
1541 /* Twiddle factor LUT */ | 1540 static sample_t roots32[7]; |
1542 -static complex_t w_1[1]; | 1541 @@ -245,7 +322,7 @@ |
1543 -static complex_t w_2[2]; | 1542 ifft_pass (buf, roots128 - 32, 32); |
1544 -static complex_t w_4[4]; | 1543 } |
1545 -static complex_t w_8[8]; | 1544 |
1546 -static complex_t w_16[16]; | 1545 -void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias) |
1547 -static complex_t w_32[32]; | 1546 +void imdct_do_512 (sample_t * data, sample_t * delay, sample_t bias) |
1548 -static complex_t w_64[64]; | |
1549 -static complex_t * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64}; | |
1550 +static complex_t __attribute__((aligned(16))) w_1[1]; | |
1551 +static complex_t __attribute__((aligned(16))) w_2[2]; | |
1552 +static complex_t __attribute__((aligned(16))) w_4[4]; | |
1553 +static complex_t __attribute__((aligned(16))) w_8[8]; | |
1554 +static complex_t __attribute__((aligned(16))) w_16[16]; | |
1555 +static complex_t __attribute__((aligned(16))) w_32[32]; | |
1556 +static complex_t __attribute__((aligned(16))) w_64[64]; | |
1557 +static complex_t __attribute__((aligned(16))) * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64}; | |
1558 | |
1559 /* Twiddle factors for IMDCT */ | |
1560 -static sample_t xcos1[128]; | |
1561 -static sample_t xsin1[128]; | |
1562 -static sample_t xcos2[64]; | |
1563 -static sample_t xsin2[64]; | |
1564 +static sample_t __attribute__((aligned(16))) xcos1[128]; | |
1565 +static sample_t __attribute__((aligned(16))) xsin1[128]; | |
1566 +static sample_t __attribute__((aligned(16))) xcos2[64]; | |
1567 +static sample_t __attribute__((aligned(16))) xsin2[64]; | |
1568 | |
1569 /* Windowing function for Modified DCT - Thank you acroread */ | |
1570 sample_t imdct_window[] = { | |
1571 @@ -145,16 +198,19 @@ | |
1572 void | |
1573 imdct_do_512(sample_t data[],sample_t delay[], sample_t bias) | |
1574 { | 1547 { |
1575 - int i,k; | 1548 int i, k; |
1576 + int i; | 1549 sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2; |
1577 +#ifndef USE_AC3_C | 1550 @@ -289,6 +366,714 @@ |
1578 + int k; | |
1579 int p,q; | |
1580 int m; | |
1581 int two_m; | |
1582 int two_m_plus_one; | |
1583 | |
1584 - sample_t tmp_a_i; | |
1585 - sample_t tmp_a_r; | |
1586 sample_t tmp_b_i; | |
1587 sample_t tmp_b_r; | |
1588 +#endif | |
1589 + sample_t tmp_a_i; | |
1590 + sample_t tmp_a_r; | |
1591 | |
1592 sample_t *data_ptr; | |
1593 sample_t *delay_ptr; | |
1594 @@ -162,22 +218,21 @@ | |
1595 | |
1596 /* 512 IMDCT with source and dest data in 'data' */ | |
1597 | |
1598 - /* Pre IFFT complex multiply plus IFFT cmplx conjugate */ | |
1599 + /* Pre IFFT complex multiply plus IFFT cmplx conjugate & reordering*/ | |
1600 for( i=0; i < 128; i++) { | |
1601 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */ | |
1602 - buf[i].real = (data[256-2*i-1] * xcos1[i]) - (data[2*i] * xsin1[i]); | |
1603 - buf[i].imag = -1.0 * ((data[2*i] * xcos1[i]) + (data[256-2*i-1] * xsin1[i])); | |
1604 - } | |
1605 - | |
1606 - /* Bit reversed shuffling */ | |
1607 - for(i=0; i<128; i++) { | |
1608 - k = bit_reverse_512[i]; | |
1609 - if (k < i) | |
1610 - swap_cmplx(&buf[i],&buf[k]); | |
1611 +#ifdef USE_AC3_C | |
1612 + int j= pm128[i]; | |
1613 +#else | |
1614 + int j= bit_reverse_512[i]; | |
1615 +#endif | |
1616 + buf[i].real = (data[256-2*j-1] * xcos1[j]) - (data[2*j] * xsin1[j]); | |
1617 + buf[i].imag = -1.0 * ((data[2*j] * xcos1[j]) + (data[256-2*j-1] * xsin1[j])); | |
1618 } | |
1619 | |
1620 /* FFT Merge */ | |
1621 - for (m=0; m < 7; m++) { | |
1622 +/* unoptimized variant | |
1623 + for (m=1; m < 7; m++) { | |
1624 if(m) | |
1625 two_m = (1 << m); | |
1626 else | |
1627 @@ -185,8 +240,8 @@ | |
1628 | |
1629 two_m_plus_one = (1 << (m+1)); | |
1630 | |
1631 - for(k = 0; k < two_m; k++) { | |
1632 - for(i = 0; i < 128; i += two_m_plus_one) { | |
1633 + for(i = 0; i < 128; i += two_m_plus_one) { | |
1634 + for(k = 0; k < two_m; k++) { | |
1635 p = k + i; | |
1636 q = p + two_m; | |
1637 tmp_a_r = buf[p].real; | |
1638 @@ -200,7 +255,102 @@ | |
1639 } | |
1640 } | |
1641 } | |
1642 +*/ | |
1643 +#ifdef USE_AC3_C | |
1644 + fft_128p (&buf[0]); | |
1645 +#else | |
1646 + | |
1647 + /* 1. iteration */ | |
1648 + for(i = 0; i < 128; i += 2) { | |
1649 + tmp_a_r = buf[i].real; | |
1650 + tmp_a_i = buf[i].imag; | |
1651 + tmp_b_r = buf[i+1].real; | |
1652 + tmp_b_i = buf[i+1].imag; | |
1653 + buf[i].real = tmp_a_r + tmp_b_r; | |
1654 + buf[i].imag = tmp_a_i + tmp_b_i; | |
1655 + buf[i+1].real = tmp_a_r - tmp_b_r; | |
1656 + buf[i+1].imag = tmp_a_i - tmp_b_i; | |
1657 + } | |
1658 + | |
1659 + /* 2. iteration */ | |
1660 + // Note w[1]={{1,0}, {0,-1}} | |
1661 + for(i = 0; i < 128; i += 4) { | |
1662 + tmp_a_r = buf[i].real; | |
1663 + tmp_a_i = buf[i].imag; | |
1664 + tmp_b_r = buf[i+2].real; | |
1665 + tmp_b_i = buf[i+2].imag; | |
1666 + buf[i].real = tmp_a_r + tmp_b_r; | |
1667 + buf[i].imag = tmp_a_i + tmp_b_i; | |
1668 + buf[i+2].real = tmp_a_r - tmp_b_r; | |
1669 + buf[i+2].imag = tmp_a_i - tmp_b_i; | |
1670 + tmp_a_r = buf[i+1].real; | |
1671 + tmp_a_i = buf[i+1].imag; | |
1672 + tmp_b_r = buf[i+3].imag; | |
1673 + tmp_b_i = buf[i+3].real; | |
1674 + buf[i+1].real = tmp_a_r + tmp_b_r; | |
1675 + buf[i+1].imag = tmp_a_i - tmp_b_i; | |
1676 + buf[i+3].real = tmp_a_r - tmp_b_r; | |
1677 + buf[i+3].imag = tmp_a_i + tmp_b_i; | |
1678 + } | |
1679 | |
1680 + /* 3. iteration */ | |
1681 + for(i = 0; i < 128; i += 8) { | |
1682 + tmp_a_r = buf[i].real; | |
1683 + tmp_a_i = buf[i].imag; | |
1684 + tmp_b_r = buf[i+4].real; | |
1685 + tmp_b_i = buf[i+4].imag; | |
1686 + buf[i].real = tmp_a_r + tmp_b_r; | |
1687 + buf[i].imag = tmp_a_i + tmp_b_i; | |
1688 + buf[i+4].real = tmp_a_r - tmp_b_r; | |
1689 + buf[i+4].imag = tmp_a_i - tmp_b_i; | |
1690 + tmp_a_r = buf[1+i].real; | |
1691 + tmp_a_i = buf[1+i].imag; | |
1692 + tmp_b_r = (buf[i+5].real + buf[i+5].imag) * w[2][1].real; | |
1693 + tmp_b_i = (buf[i+5].imag - buf[i+5].real) * w[2][1].real; | |
1694 + buf[1+i].real = tmp_a_r + tmp_b_r; | |
1695 + buf[1+i].imag = tmp_a_i + tmp_b_i; | |
1696 + buf[i+5].real = tmp_a_r - tmp_b_r; | |
1697 + buf[i+5].imag = tmp_a_i - tmp_b_i; | |
1698 + tmp_a_r = buf[i+2].real; | |
1699 + tmp_a_i = buf[i+2].imag; | |
1700 + tmp_b_r = buf[i+6].imag; | |
1701 + tmp_b_i = - buf[i+6].real; | |
1702 + buf[i+2].real = tmp_a_r + tmp_b_r; | |
1703 + buf[i+2].imag = tmp_a_i + tmp_b_i; | |
1704 + buf[i+6].real = tmp_a_r - tmp_b_r; | |
1705 + buf[i+6].imag = tmp_a_i - tmp_b_i; | |
1706 + tmp_a_r = buf[i+3].real; | |
1707 + tmp_a_i = buf[i+3].imag; | |
1708 + tmp_b_r = (buf[i+7].real - buf[i+7].imag) * w[2][3].imag; | |
1709 + tmp_b_i = (buf[i+7].imag + buf[i+7].real) * w[2][3].imag; | |
1710 + buf[i+3].real = tmp_a_r + tmp_b_r; | |
1711 + buf[i+3].imag = tmp_a_i + tmp_b_i; | |
1712 + buf[i+7].real = tmp_a_r - tmp_b_r; | |
1713 + buf[i+7].imag = tmp_a_i - tmp_b_i; | |
1714 + } | |
1715 + | |
1716 + /* 4-7. iterations */ | |
1717 + for (m=3; m < 7; m++) { | |
1718 + two_m = (1 << m); | |
1719 + | |
1720 + two_m_plus_one = two_m<<1; | |
1721 + | |
1722 + for(i = 0; i < 128; i += two_m_plus_one) { | |
1723 + for(k = 0; k < two_m; k++) { | |
1724 + int p = k + i; | |
1725 + int q = p + two_m; | |
1726 + tmp_a_r = buf[p].real; | |
1727 + tmp_a_i = buf[p].imag; | |
1728 + tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag; | |
1729 + tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag; | |
1730 + buf[p].real = tmp_a_r + tmp_b_r; | |
1731 + buf[p].imag = tmp_a_i + tmp_b_i; | |
1732 + buf[q].real = tmp_a_r - tmp_b_r; | |
1733 + buf[q].imag = tmp_a_i - tmp_b_i; | |
1734 + } | |
1735 + } | |
1736 + } | |
1737 +#endif | |
1738 /* Post IFFT complex multiply plus IFFT complex conjugate*/ | |
1739 for( i=0; i < 128; i++) { | |
1740 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */ | |
1741 @@ -219,12 +369,12 @@ | |
1742 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias; | |
1743 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias; | |
1744 } | |
1745 - | |
1746 + | |
1747 for(i=0; i< 64; i++) { | |
1748 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias; | |
1749 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias; | |
1750 } | |
1751 - | |
1752 + | |
1753 /* The trailing edge of the window goes into the delay line */ | |
1754 delay_ptr = delay; | |
1755 | |
1756 @@ -232,13 +382,717 @@ | |
1757 *delay_ptr++ = -buf[64+i].real * *--window_ptr; | |
1758 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr; | |
1759 } | |
1760 - | |
1761 + | |
1762 for(i=0; i<64; i++) { | |
1763 *delay_ptr++ = buf[i].imag * *--window_ptr; | |
1764 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr; | |
1765 } | 1551 } |
1766 } | 1552 } |
1767 | 1553 |
1768 +#ifdef HAVE_ALTIVEC | 1554 +#ifdef HAVE_ALTIVEC |
1769 + | 1555 + |
1816 +{ | 1602 +{ |
1817 + int i; | 1603 + int i; |
1818 + int k; | 1604 + int k; |
1819 + int p,q; | 1605 + int p,q; |
1820 + int m; | 1606 + int m; |
1821 + int two_m; | 1607 + long two_m; |
1822 + int two_m_plus_one; | 1608 + long two_m_plus_one; |
1823 + | 1609 + |
1824 + sample_t tmp_b_i; | 1610 + sample_t tmp_b_i; |
1825 + sample_t tmp_b_r; | 1611 + sample_t tmp_b_r; |
1826 + sample_t tmp_a_i; | 1612 + sample_t tmp_a_i; |
1827 + sample_t tmp_a_r; | 1613 + sample_t tmp_a_r; |
2090 +#endif | 1876 +#endif |
2091 + } | 1877 + } |
2092 + | 1878 + |
2093 + data_ptr = data; | 1879 + data_ptr = data; |
2094 + delay_ptr = delay; | 1880 + delay_ptr = delay; |
2095 + window_ptr = imdct_window; | 1881 + window_ptr = a52_imdct_window; |
2096 + | 1882 + |
2097 + /* Window and convert to real valued signal */ | 1883 + /* Window and convert to real valued signal */ |
2098 + for(i=0; i< 64; i++) { | 1884 + for(i=0; i< 64; i++) { |
2099 + *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias; | 1885 + *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias; |
2100 + *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias; | 1886 + *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias; |
2121 +#endif | 1907 +#endif |
2122 + | 1908 + |
2123 + | 1909 + |
2124 +// Stuff below this line is borrowed from libac3 | 1910 +// Stuff below this line is borrowed from libac3 |
2125 +#include "srfftp.h" | 1911 +#include "srfftp.h" |
2126 +#ifdef ARCH_X86 | 1912 +#if defined(ARCH_X86) || defined(ARCH_X86_64) |
2127 +#ifndef HAVE_3DNOW | 1913 +#ifndef HAVE_3DNOW |
2128 +#define HAVE_3DNOW 1 | 1914 +#define HAVE_3DNOW 1 |
2129 +#endif | 1915 +#endif |
2130 +#include "srfftp_3dnow.h" | 1916 +#include "srfftp_3dnow.h" |
2131 + | 1917 + |
2142 +imdct_do_512_sse(sample_t data[],sample_t delay[], sample_t bias) | 1928 +imdct_do_512_sse(sample_t data[],sample_t delay[], sample_t bias) |
2143 +{ | 1929 +{ |
2144 +/* int i,k; | 1930 +/* int i,k; |
2145 + int p,q;*/ | 1931 + int p,q;*/ |
2146 + int m; | 1932 + int m; |
2147 + int two_m; | 1933 + long two_m; |
2148 + int two_m_plus_one; | 1934 + long two_m_plus_one; |
1935 + long two_m_plus_one_shl3; | |
1936 + complex_t *buf_offset; | |
2149 + | 1937 + |
2150 +/* sample_t tmp_a_i; | 1938 +/* sample_t tmp_a_i; |
2151 + sample_t tmp_a_r; | 1939 + sample_t tmp_a_r; |
2152 + sample_t tmp_b_i; | 1940 + sample_t tmp_b_i; |
2153 + sample_t tmp_b_r;*/ | 1941 + sample_t tmp_b_r;*/ |
2160 + /* see the c version (dct_do_512()), its allmost identical, just in C */ | 1948 + /* see the c version (dct_do_512()), its allmost identical, just in C */ |
2161 + | 1949 + |
2162 + /* Pre IFFT complex multiply plus IFFT cmplx conjugate */ | 1950 + /* Pre IFFT complex multiply plus IFFT cmplx conjugate */ |
2163 + /* Bit reversed shuffling */ | 1951 + /* Bit reversed shuffling */ |
2164 + asm volatile( | 1952 + asm volatile( |
2165 + "xorl %%esi, %%esi \n\t" | 1953 + "xor %%"REG_S", %%"REG_S" \n\t" |
2166 + "leal "MANGLE(bit_reverse_512)", %%eax \n\t" | 1954 + "lea "MANGLE(bit_reverse_512)", %%"REG_a"\n\t" |
2167 + "movl $1008, %%edi \n\t" | 1955 + "mov $1008, %%"REG_D" \n\t" |
2168 + "pushl %%ebp \n\t" //use ebp without telling gcc | 1956 + "push %%"REG_BP" \n\t" //use ebp without telling gcc |
2169 + ".balign 16 \n\t" | 1957 + ASMALIGN16 |
2170 + "1: \n\t" | 1958 + "1: \n\t" |
2171 + "movlps (%0, %%esi), %%xmm0 \n\t" // XXXI | 1959 + "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // XXXI |
2172 + "movhps 8(%0, %%edi), %%xmm0 \n\t" // RXXI | 1960 + "movhps 8(%0, %%"REG_D"), %%xmm0 \n\t" // RXXI |
2173 + "movlps 8(%0, %%esi), %%xmm1 \n\t" // XXXi | 1961 + "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // XXXi |
2174 + "movhps (%0, %%edi), %%xmm1 \n\t" // rXXi | 1962 + "movhps (%0, %%"REG_D"), %%xmm1 \n\t" // rXXi |
2175 + "shufps $0x33, %%xmm1, %%xmm0 \n\t" // irIR | 1963 + "shufps $0x33, %%xmm1, %%xmm0 \n\t" // irIR |
2176 + "movaps "MANGLE(sseSinCos1c)"(%%esi), %%xmm2\n\t" | 1964 + "movaps "MANGLE(sseSinCos1c)"(%%"REG_S"), %%xmm2\n\t" |
2177 + "mulps %%xmm0, %%xmm2 \n\t" | 1965 + "mulps %%xmm0, %%xmm2 \n\t" |
2178 + "shufps $0xB1, %%xmm0, %%xmm0 \n\t" // riRI | 1966 + "shufps $0xB1, %%xmm0, %%xmm0 \n\t" // riRI |
2179 + "mulps "MANGLE(sseSinCos1d)"(%%esi), %%xmm0\n\t" | 1967 + "mulps "MANGLE(sseSinCos1d)"(%%"REG_S"), %%xmm0\n\t" |
2180 + "subps %%xmm0, %%xmm2 \n\t" | 1968 + "subps %%xmm0, %%xmm2 \n\t" |
2181 + "movzbl (%%eax), %%edx \n\t" | 1969 + "movzb (%%"REG_a"), %%"REG_d" \n\t" |
2182 + "movzbl 1(%%eax), %%ebp \n\t" | 1970 + "movzb 1(%%"REG_a"), %%"REG_BP" \n\t" |
2183 + "movlps %%xmm2, (%1, %%edx,8) \n\t" | 1971 + "movlps %%xmm2, (%1, %%"REG_d", 8) \n\t" |
2184 + "movhps %%xmm2, (%1, %%ebp,8) \n\t" | 1972 + "movhps %%xmm2, (%1, %%"REG_BP", 8) \n\t" |
2185 + "addl $16, %%esi \n\t" | 1973 + "add $16, %%"REG_S" \n\t" |
2186 + "addl $2, %%eax \n\t" // avoid complex addressing for P4 crap | 1974 + "add $2, %%"REG_a" \n\t" // avoid complex addressing for P4 crap |
2187 + "subl $16, %%edi \n\t" | 1975 + "sub $16, %%"REG_D" \n\t" |
2188 + " jnc 1b \n\t" | 1976 + " jnc 1b \n\t" |
2189 + "popl %%ebp \n\t"//no we didnt touch ebp *g* | 1977 + "pop %%"REG_BP" \n\t"//no we didnt touch ebp *g* |
2190 + :: "b" (data), "c" (buf) | 1978 + :: "b" (data), "c" (buf) |
2191 + : "%esi", "%edi", "%eax", "%edx" | 1979 + : "%"REG_S, "%"REG_D, "%"REG_a, "%"REG_d |
2192 + ); | 1980 + ); |
2193 + | 1981 + |
2194 + | 1982 + |
2195 + /* FFT Merge */ | 1983 + /* FFT Merge */ |
2196 +/* unoptimized variant | 1984 +/* unoptimized variant |
2222 + /* 1. iteration */ | 2010 + /* 1. iteration */ |
2223 + // Note w[0][0]={1,0} | 2011 + // Note w[0][0]={1,0} |
2224 + asm volatile( | 2012 + asm volatile( |
2225 + "xorps %%xmm1, %%xmm1 \n\t" | 2013 + "xorps %%xmm1, %%xmm1 \n\t" |
2226 + "xorps %%xmm2, %%xmm2 \n\t" | 2014 + "xorps %%xmm2, %%xmm2 \n\t" |
2227 + "movl %0, %%esi \n\t" | 2015 + "mov %0, %%"REG_S" \n\t" |
2228 + ".balign 16 \n\t" | 2016 + ASMALIGN16 |
2229 + "1: \n\t" | 2017 + "1: \n\t" |
2230 + "movlps (%%esi), %%xmm0 \n\t" //buf[p] | 2018 + "movlps (%%"REG_S"), %%xmm0\n\t" //buf[p] |
2231 + "movlps 8(%%esi), %%xmm1\n\t" //buf[q] | 2019 + "movlps 8(%%"REG_S"), %%xmm1\n\t" //buf[q] |
2232 + "movhps (%%esi), %%xmm0 \n\t" //buf[p] | 2020 + "movhps (%%"REG_S"), %%xmm0\n\t" //buf[p] |
2233 + "movhps 8(%%esi), %%xmm2\n\t" //buf[q] | 2021 + "movhps 8(%%"REG_S"), %%xmm2\n\t" //buf[q] |
2234 + "addps %%xmm1, %%xmm0 \n\t" | 2022 + "addps %%xmm1, %%xmm0 \n\t" |
2235 + "subps %%xmm2, %%xmm0 \n\t" | 2023 + "subps %%xmm2, %%xmm0 \n\t" |
2236 + "movaps %%xmm0, (%%esi) \n\t" | 2024 + "movaps %%xmm0, (%%"REG_S")\n\t" |
2237 + "addl $16, %%esi \n\t" | 2025 + "add $16, %%"REG_S" \n\t" |
2238 + "cmpl %1, %%esi \n\t" | 2026 + "cmp %1, %%"REG_S" \n\t" |
2239 + " jb 1b \n\t" | 2027 + " jb 1b \n\t" |
2240 + :: "g" (buf), "r" (buf + 128) | 2028 + :: "g" (buf), "r" (buf + 128) |
2241 + : "%esi" | 2029 + : "%"REG_S |
2242 + ); | 2030 + ); |
2243 + | 2031 + |
2244 + /* 2. iteration */ | 2032 + /* 2. iteration */ |
2245 + // Note w[1]={{1,0}, {0,-1}} | 2033 + // Note w[1]={{1,0}, {0,-1}} |
2246 + asm volatile( | 2034 + asm volatile( |
2247 + "movaps "MANGLE(ps111_1)", %%xmm7\n\t" // 1,1,1,-1 | 2035 + "movaps "MANGLE(ps111_1)", %%xmm7\n\t" // 1,1,1,-1 |
2248 + "movl %0, %%esi \n\t" | 2036 + "mov %0, %%"REG_S" \n\t" |
2249 + ".balign 16 \n\t" | 2037 + ASMALIGN16 |
2250 + "1: \n\t" | 2038 + "1: \n\t" |
2251 + "movaps 16(%%esi), %%xmm2 \n\t" //r2,i2,r3,i3 | 2039 + "movaps 16(%%"REG_S"), %%xmm2 \n\t" //r2,i2,r3,i3 |
2252 + "shufps $0xB4, %%xmm2, %%xmm2 \n\t" //r2,i2,i3,r3 | 2040 + "shufps $0xB4, %%xmm2, %%xmm2 \n\t" //r2,i2,i3,r3 |
2253 + "mulps %%xmm7, %%xmm2 \n\t" //r2,i2,i3,-r3 | 2041 + "mulps %%xmm7, %%xmm2 \n\t" //r2,i2,i3,-r3 |
2254 + "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1 | 2042 + "movaps (%%"REG_S"), %%xmm0 \n\t" //r0,i0,r1,i1 |
2255 + "movaps (%%esi), %%xmm1 \n\t" //r0,i0,r1,i1 | 2043 + "movaps (%%"REG_S"), %%xmm1 \n\t" //r0,i0,r1,i1 |
2256 + "addps %%xmm2, %%xmm0 \n\t" | 2044 + "addps %%xmm2, %%xmm0 \n\t" |
2257 + "subps %%xmm2, %%xmm1 \n\t" | 2045 + "subps %%xmm2, %%xmm1 \n\t" |
2258 + "movaps %%xmm0, (%%esi) \n\t" | 2046 + "movaps %%xmm0, (%%"REG_S") \n\t" |
2259 + "movaps %%xmm1, 16(%%esi) \n\t" | 2047 + "movaps %%xmm1, 16(%%"REG_S") \n\t" |
2260 + "addl $32, %%esi \n\t" | 2048 + "add $32, %%"REG_S" \n\t" |
2261 + "cmpl %1, %%esi \n\t" | 2049 + "cmp %1, %%"REG_S" \n\t" |
2262 + " jb 1b \n\t" | 2050 + " jb 1b \n\t" |
2263 + :: "g" (buf), "r" (buf + 128) | 2051 + :: "g" (buf), "r" (buf + 128) |
2264 + : "%esi" | 2052 + : "%"REG_S |
2265 + ); | 2053 + ); |
2266 + | 2054 + |
2267 + /* 3. iteration */ | 2055 + /* 3. iteration */ |
2268 +/* | 2056 +/* |
2269 + Note sseW2+0={1,1,sqrt(2),sqrt(2)) | 2057 + Note sseW2+0={1,1,sqrt(2),sqrt(2)) |
2274 + asm volatile( | 2062 + asm volatile( |
2275 + "movaps 48+"MANGLE(sseW2)", %%xmm6\n\t" | 2063 + "movaps 48+"MANGLE(sseW2)", %%xmm6\n\t" |
2276 + "movaps 16+"MANGLE(sseW2)", %%xmm7\n\t" | 2064 + "movaps 16+"MANGLE(sseW2)", %%xmm7\n\t" |
2277 + "xorps %%xmm5, %%xmm5 \n\t" | 2065 + "xorps %%xmm5, %%xmm5 \n\t" |
2278 + "xorps %%xmm2, %%xmm2 \n\t" | 2066 + "xorps %%xmm2, %%xmm2 \n\t" |
2279 + "movl %0, %%esi \n\t" | 2067 + "mov %0, %%"REG_S" \n\t" |
2280 + ".balign 16 \n\t" | 2068 + ASMALIGN16 |
2281 + "1: \n\t" | 2069 + "1: \n\t" |
2282 + "movaps 32(%%esi), %%xmm2 \n\t" //r4,i4,r5,i5 | 2070 + "movaps 32(%%"REG_S"), %%xmm2 \n\t" //r4,i4,r5,i5 |
2283 + "movaps 48(%%esi), %%xmm3 \n\t" //r6,i6,r7,i7 | 2071 + "movaps 48(%%"REG_S"), %%xmm3 \n\t" //r6,i6,r7,i7 |
2284 + "movaps "MANGLE(sseW2)", %%xmm4 \n\t" //r4,i4,r5,i5 | 2072 + "movaps "MANGLE(sseW2)", %%xmm4 \n\t" //r4,i4,r5,i5 |
2285 + "movaps 32+"MANGLE(sseW2)", %%xmm5\n\t" //r6,i6,r7,i7 | 2073 + "movaps 32+"MANGLE(sseW2)", %%xmm5\n\t" //r6,i6,r7,i7 |
2286 + "mulps %%xmm2, %%xmm4 \n\t" | 2074 + "mulps %%xmm2, %%xmm4 \n\t" |
2287 + "mulps %%xmm3, %%xmm5 \n\t" | 2075 + "mulps %%xmm3, %%xmm5 \n\t" |
2288 + "shufps $0xB1, %%xmm2, %%xmm2 \n\t" //i4,r4,i5,r5 | 2076 + "shufps $0xB1, %%xmm2, %%xmm2 \n\t" //i4,r4,i5,r5 |
2289 + "shufps $0xB1, %%xmm3, %%xmm3 \n\t" //i6,r6,i7,r7 | 2077 + "shufps $0xB1, %%xmm3, %%xmm3 \n\t" //i6,r6,i7,r7 |
2290 + "mulps %%xmm6, %%xmm3 \n\t" | 2078 + "mulps %%xmm6, %%xmm3 \n\t" |
2291 + "mulps %%xmm7, %%xmm2 \n\t" | 2079 + "mulps %%xmm7, %%xmm2 \n\t" |
2292 + "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1 | 2080 + "movaps (%%"REG_S"), %%xmm0 \n\t" //r0,i0,r1,i1 |
2293 + "movaps 16(%%esi), %%xmm1 \n\t" //r2,i2,r3,i3 | 2081 + "movaps 16(%%"REG_S"), %%xmm1 \n\t" //r2,i2,r3,i3 |
2294 + "addps %%xmm4, %%xmm2 \n\t" | 2082 + "addps %%xmm4, %%xmm2 \n\t" |
2295 + "addps %%xmm5, %%xmm3 \n\t" | 2083 + "addps %%xmm5, %%xmm3 \n\t" |
2296 + "movaps %%xmm2, %%xmm4 \n\t" | 2084 + "movaps %%xmm2, %%xmm4 \n\t" |
2297 + "movaps %%xmm3, %%xmm5 \n\t" | 2085 + "movaps %%xmm3, %%xmm5 \n\t" |
2298 + "addps %%xmm0, %%xmm2 \n\t" | 2086 + "addps %%xmm0, %%xmm2 \n\t" |
2299 + "addps %%xmm1, %%xmm3 \n\t" | 2087 + "addps %%xmm1, %%xmm3 \n\t" |
2300 + "subps %%xmm4, %%xmm0 \n\t" | 2088 + "subps %%xmm4, %%xmm0 \n\t" |
2301 + "subps %%xmm5, %%xmm1 \n\t" | 2089 + "subps %%xmm5, %%xmm1 \n\t" |
2302 + "movaps %%xmm2, (%%esi) \n\t" | 2090 + "movaps %%xmm2, (%%"REG_S") \n\t" |
2303 + "movaps %%xmm3, 16(%%esi) \n\t" | 2091 + "movaps %%xmm3, 16(%%"REG_S") \n\t" |
2304 + "movaps %%xmm0, 32(%%esi) \n\t" | 2092 + "movaps %%xmm0, 32(%%"REG_S") \n\t" |
2305 + "movaps %%xmm1, 48(%%esi) \n\t" | 2093 + "movaps %%xmm1, 48(%%"REG_S") \n\t" |
2306 + "addl $64, %%esi \n\t" | 2094 + "add $64, %%"REG_S" \n\t" |
2307 + "cmpl %1, %%esi \n\t" | 2095 + "cmp %1, %%"REG_S" \n\t" |
2308 + " jb 1b \n\t" | 2096 + " jb 1b \n\t" |
2309 + :: "g" (buf), "r" (buf + 128) | 2097 + :: "g" (buf), "r" (buf + 128) |
2310 + : "%esi" | 2098 + : "%"REG_S |
2311 + ); | 2099 + ); |
2312 + | 2100 + |
2313 + /* 4-7. iterations */ | 2101 + /* 4-7. iterations */ |
2314 + for (m=3; m < 7; m++) { | 2102 + for (m=3; m < 7; m++) { |
2315 + two_m = (1 << m); | 2103 + two_m = (1 << m); |
2316 + two_m_plus_one = two_m<<1; | 2104 + two_m_plus_one = two_m<<1; |
2317 + asm volatile( | 2105 + two_m_plus_one_shl3 = (two_m_plus_one<<3); |
2318 + "movl %0, %%esi \n\t" | 2106 + buf_offset = buf+128; |
2319 + ".balign 16 \n\t" | 2107 + asm volatile( |
2108 + "mov %0, %%"REG_S" \n\t" | |
2109 + ASMALIGN16 | |
2320 + "1: \n\t" | 2110 + "1: \n\t" |
2321 + "xorl %%edi, %%edi \n\t" // k | 2111 + "xor %%"REG_D", %%"REG_D" \n\t" // k |
2322 + "leal (%%esi, %3), %%edx \n\t" | 2112 + "lea (%%"REG_S", %3), %%"REG_d" \n\t" |
2323 + "2: \n\t" | 2113 + "2: \n\t" |
2324 + "movaps (%%edx, %%edi), %%xmm1 \n\t" | 2114 + "movaps (%%"REG_d", %%"REG_D"), %%xmm1 \n\t" |
2325 + "movaps (%4, %%edi, 2), %%xmm2 \n\t" | 2115 + "movaps (%4, %%"REG_D", 2), %%xmm2 \n\t" |
2326 + "mulps %%xmm1, %%xmm2 \n\t" | 2116 + "mulps %%xmm1, %%xmm2 \n\t" |
2327 + "shufps $0xB1, %%xmm1, %%xmm1 \n\t" | 2117 + "shufps $0xB1, %%xmm1, %%xmm1 \n\t" |
2328 + "mulps 16(%4, %%edi, 2), %%xmm1 \n\t" | 2118 + "mulps 16(%4, %%"REG_D", 2), %%xmm1 \n\t" |
2329 + "movaps (%%esi, %%edi), %%xmm0 \n\t" | 2119 + "movaps (%%"REG_S", %%"REG_D"), %%xmm0 \n\t" |
2330 + "addps %%xmm2, %%xmm1 \n\t" | 2120 + "addps %%xmm2, %%xmm1 \n\t" |
2331 + "movaps %%xmm1, %%xmm2 \n\t" | 2121 + "movaps %%xmm1, %%xmm2 \n\t" |
2332 + "addps %%xmm0, %%xmm1 \n\t" | 2122 + "addps %%xmm0, %%xmm1 \n\t" |
2333 + "subps %%xmm2, %%xmm0 \n\t" | 2123 + "subps %%xmm2, %%xmm0 \n\t" |
2334 + "movaps %%xmm1, (%%esi, %%edi) \n\t" | 2124 + "movaps %%xmm1, (%%"REG_S", %%"REG_D") \n\t" |
2335 + "movaps %%xmm0, (%%edx, %%edi) \n\t" | 2125 + "movaps %%xmm0, (%%"REG_d", %%"REG_D") \n\t" |
2336 + "addl $16, %%edi \n\t" | 2126 + "add $16, %%"REG_D" \n\t" |
2337 + "cmpl %3, %%edi \n\t" //FIXME (opt) count against 0 | 2127 + "cmp %3, %%"REG_D" \n\t" //FIXME (opt) count against 0 |
2338 + " jb 2b \n\t" | 2128 + " jb 2b \n\t" |
2339 + "addl %2, %%esi \n\t" | 2129 + "add %2, %%"REG_S" \n\t" |
2340 + "cmpl %1, %%esi \n\t" | 2130 + "cmp %1, %%"REG_S" \n\t" |
2341 + " jb 1b \n\t" | 2131 + " jb 1b \n\t" |
2342 + :: "g" (buf), "m" (buf+128), "m" (two_m_plus_one<<3), "r" (two_m<<3), | 2132 + :: "g" (buf), "m" (buf_offset), "m" (two_m_plus_one_shl3), "r" (two_m<<3), |
2343 + "r" (sseW[m]) | 2133 + "r" (sseW[m]) |
2344 + : "%esi", "%edi", "%edx" | 2134 + : "%"REG_S, "%"REG_D, "%"REG_d |
2345 + ); | 2135 + ); |
2346 + } | 2136 + } |
2347 + | 2137 + |
2348 + /* Post IFFT complex multiply plus IFFT complex conjugate*/ | 2138 + /* Post IFFT complex multiply plus IFFT complex conjugate*/ |
2349 + asm volatile( | 2139 + asm volatile( |
2350 + "movl $-1024, %%esi \n\t" | 2140 + "mov $-1024, %%"REG_S" \n\t" |
2351 + ".balign 16 \n\t" | 2141 + ASMALIGN16 |
2352 + "1: \n\t" | 2142 + "1: \n\t" |
2353 + "movaps (%0, %%esi), %%xmm0 \n\t" | 2143 + "movaps (%0, %%"REG_S"), %%xmm0 \n\t" |
2354 + "movaps (%0, %%esi), %%xmm1 \n\t" | 2144 + "movaps (%0, %%"REG_S"), %%xmm1 \n\t" |
2355 + "shufps $0xB1, %%xmm0, %%xmm0 \n\t" | 2145 + "shufps $0xB1, %%xmm0, %%xmm0 \n\t" |
2356 + "mulps 1024+"MANGLE(sseSinCos1c)"(%%esi), %%xmm1\n\t" | 2146 + "mulps 1024+"MANGLE(sseSinCos1c)"(%%"REG_S"), %%xmm1\n\t" |
2357 + "mulps 1024+"MANGLE(sseSinCos1d)"(%%esi), %%xmm0\n\t" | 2147 + "mulps 1024+"MANGLE(sseSinCos1d)"(%%"REG_S"), %%xmm0\n\t" |
2358 + "addps %%xmm1, %%xmm0 \n\t" | 2148 + "addps %%xmm1, %%xmm0 \n\t" |
2359 + "movaps %%xmm0, (%0, %%esi) \n\t" | 2149 + "movaps %%xmm0, (%0, %%"REG_S") \n\t" |
2360 + "addl $16, %%esi \n\t" | 2150 + "add $16, %%"REG_S" \n\t" |
2361 + " jnz 1b \n\t" | 2151 + " jnz 1b \n\t" |
2362 + :: "r" (buf+128) | 2152 + :: "r" (buf+128) |
2363 + : "%esi" | 2153 + : "%"REG_S |
2364 + ); | 2154 + ); |
2365 + | 2155 + |
2366 + | 2156 + |
2367 + data_ptr = data; | 2157 + data_ptr = data; |
2368 + delay_ptr = delay; | 2158 + delay_ptr = delay; |
2369 + window_ptr = imdct_window; | 2159 + window_ptr = a52_imdct_window; |
2370 + | 2160 + |
2371 + /* Window and convert to real valued signal */ | 2161 + /* Window and convert to real valued signal */ |
2372 + asm volatile( | 2162 + asm volatile( |
2373 + "xorl %%edi, %%edi \n\t" // 0 | 2163 + "xor %%"REG_D", %%"REG_D" \n\t" // 0 |
2374 + "xorl %%esi, %%esi \n\t" // 0 | 2164 + "xor %%"REG_S", %%"REG_S" \n\t" // 0 |
2375 + "movss %3, %%xmm2 \n\t" // bias | 2165 + "movss %3, %%xmm2 \n\t" // bias |
2376 + "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ... | 2166 + "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ... |
2377 + ".balign 16 \n\t" | 2167 + ASMALIGN16 |
2378 + "1: \n\t" | 2168 + "1: \n\t" |
2379 + "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ? | 2169 + "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? A ? |
2380 + "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ? | 2170 + "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? C ? |
2381 + "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ? | 2171 + "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // ? D C ? |
2382 + "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ? | 2172 + "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // ? B A ? |
2383 + "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A | 2173 + "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A |
2384 + "mulps "MANGLE(sseWindow)"(%%esi), %%xmm0\n\t" | 2174 + "mulps "MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t" |
2385 + "addps (%2, %%esi), %%xmm0 \n\t" | 2175 + "addps (%2, %%"REG_S"), %%xmm0 \n\t" |
2386 + "addps %%xmm2, %%xmm0 \n\t" | 2176 + "addps %%xmm2, %%xmm0 \n\t" |
2387 + "movaps %%xmm0, (%1, %%esi) \n\t" | 2177 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
2388 + "addl $16, %%esi \n\t" | 2178 + "add $16, %%"REG_S" \n\t" |
2389 + "subl $16, %%edi \n\t" | 2179 + "sub $16, %%"REG_D" \n\t" |
2390 + "cmpl $512, %%esi \n\t" | 2180 + "cmp $512, %%"REG_S" \n\t" |
2391 + " jb 1b \n\t" | 2181 + " jb 1b \n\t" |
2392 + :: "r" (buf+64), "r" (data_ptr), "r" (delay_ptr), "m" (bias) | 2182 + :: "r" (buf+64), "r" (data_ptr), "r" (delay_ptr), "m" (bias) |
2393 + : "%esi", "%edi" | 2183 + : "%"REG_S, "%"REG_D |
2394 + ); | 2184 + ); |
2395 + data_ptr+=128; | 2185 + data_ptr+=128; |
2396 + delay_ptr+=128; | 2186 + delay_ptr+=128; |
2397 +// window_ptr+=128; | 2187 +// window_ptr+=128; |
2398 + | 2188 + |
2399 + asm volatile( | 2189 + asm volatile( |
2400 + "movl $1024, %%edi \n\t" // 512 | 2190 + "mov $1024, %%"REG_D" \n\t" // 512 |
2401 + "xorl %%esi, %%esi \n\t" // 0 | 2191 + "xor %%"REG_S", %%"REG_S" \n\t" // 0 |
2402 + "movss %3, %%xmm2 \n\t" // bias | 2192 + "movss %3, %%xmm2 \n\t" // bias |
2403 + "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ... | 2193 + "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ... |
2404 + ".balign 16 \n\t" | 2194 + ASMALIGN16 |
2405 + "1: \n\t" | 2195 + "1: \n\t" |
2406 + "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A | 2196 + "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? ? A |
2407 + "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C | 2197 + "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? ? C |
2408 + "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C | 2198 + "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // D ? ? C |
2409 + "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A | 2199 + "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // B ? ? A |
2410 + "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A | 2200 + "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A |
2411 + "mulps 512+"MANGLE(sseWindow)"(%%esi), %%xmm0\n\t" | 2201 + "mulps 512+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t" |
2412 + "addps (%2, %%esi), %%xmm0 \n\t" | 2202 + "addps (%2, %%"REG_S"), %%xmm0 \n\t" |
2413 + "addps %%xmm2, %%xmm0 \n\t" | 2203 + "addps %%xmm2, %%xmm0 \n\t" |
2414 + "movaps %%xmm0, (%1, %%esi) \n\t" | 2204 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
2415 + "addl $16, %%esi \n\t" | 2205 + "add $16, %%"REG_S" \n\t" |
2416 + "subl $16, %%edi \n\t" | 2206 + "sub $16, %%"REG_D" \n\t" |
2417 + "cmpl $512, %%esi \n\t" | 2207 + "cmp $512, %%"REG_S" \n\t" |
2418 + " jb 1b \n\t" | 2208 + " jb 1b \n\t" |
2419 + :: "r" (buf), "r" (data_ptr), "r" (delay_ptr), "m" (bias) | 2209 + :: "r" (buf), "r" (data_ptr), "r" (delay_ptr), "m" (bias) |
2420 + : "%esi", "%edi" | 2210 + : "%"REG_S, "%"REG_D |
2421 + ); | 2211 + ); |
2422 + data_ptr+=128; | 2212 + data_ptr+=128; |
2423 +// window_ptr+=128; | 2213 +// window_ptr+=128; |
2424 + | 2214 + |
2425 + /* The trailing edge of the window goes into the delay line */ | 2215 + /* The trailing edge of the window goes into the delay line */ |
2426 + delay_ptr = delay; | 2216 + delay_ptr = delay; |
2427 + | 2217 + |
2428 + asm volatile( | 2218 + asm volatile( |
2429 + "xorl %%edi, %%edi \n\t" // 0 | 2219 + "xor %%"REG_D", %%"REG_D" \n\t" // 0 |
2430 + "xorl %%esi, %%esi \n\t" // 0 | 2220 + "xor %%"REG_S", %%"REG_S" \n\t" // 0 |
2431 + ".balign 16 \n\t" | 2221 + ASMALIGN16 |
2432 + "1: \n\t" | 2222 + "1: \n\t" |
2433 + "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A | 2223 + "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? ? A |
2434 + "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C | 2224 + "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? ? C |
2435 + "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C | 2225 + "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // D ? ? C |
2436 + "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A | 2226 + "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // B ? ? A |
2437 + "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A | 2227 + "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A |
2438 + "mulps 1024+"MANGLE(sseWindow)"(%%esi), %%xmm0\n\t" | 2228 + "mulps 1024+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t" |
2439 + "movaps %%xmm0, (%1, %%esi) \n\t" | 2229 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
2440 + "addl $16, %%esi \n\t" | 2230 + "add $16, %%"REG_S" \n\t" |
2441 + "subl $16, %%edi \n\t" | 2231 + "sub $16, %%"REG_D" \n\t" |
2442 + "cmpl $512, %%esi \n\t" | 2232 + "cmp $512, %%"REG_S" \n\t" |
2443 + " jb 1b \n\t" | 2233 + " jb 1b \n\t" |
2444 + :: "r" (buf+64), "r" (delay_ptr) | 2234 + :: "r" (buf+64), "r" (delay_ptr) |
2445 + : "%esi", "%edi" | 2235 + : "%"REG_S, "%"REG_D |
2446 + ); | 2236 + ); |
2447 + delay_ptr+=128; | 2237 + delay_ptr+=128; |
2448 +// window_ptr-=128; | 2238 +// window_ptr-=128; |
2449 + | 2239 + |
2450 + asm volatile( | 2240 + asm volatile( |
2451 + "movl $1024, %%edi \n\t" // 1024 | 2241 + "mov $1024, %%"REG_D" \n\t" // 1024 |
2452 + "xorl %%esi, %%esi \n\t" // 0 | 2242 + "xor %%"REG_S", %%"REG_S" \n\t" // 0 |
2453 + ".balign 16 \n\t" | 2243 + ASMALIGN16 |
2454 + "1: \n\t" | 2244 + "1: \n\t" |
2455 + "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ? | 2245 + "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? A ? |
2456 + "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ? | 2246 + "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? C ? |
2457 + "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ? | 2247 + "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // ? D C ? |
2458 + "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ? | 2248 + "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // ? B A ? |
2459 + "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A | 2249 + "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A |
2460 + "mulps 1536+"MANGLE(sseWindow)"(%%esi), %%xmm0\n\t" | 2250 + "mulps 1536+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t" |
2461 + "movaps %%xmm0, (%1, %%esi) \n\t" | 2251 + "movaps %%xmm0, (%1, %%"REG_S") \n\t" |
2462 + "addl $16, %%esi \n\t" | 2252 + "add $16, %%"REG_S" \n\t" |
2463 + "subl $16, %%edi \n\t" | 2253 + "sub $16, %%"REG_D" \n\t" |
2464 + "cmpl $512, %%esi \n\t" | 2254 + "cmp $512, %%"REG_S" \n\t" |
2465 + " jb 1b \n\t" | 2255 + " jb 1b \n\t" |
2466 + :: "r" (buf), "r" (delay_ptr) | 2256 + :: "r" (buf), "r" (delay_ptr) |
2467 + : "%esi", "%edi" | 2257 + : "%"REG_S, "%"REG_D |
2468 + ); | 2258 + ); |
2469 +} | 2259 +} |
2470 +#endif //arch_x86 | 2260 +#endif // ARCH_X86 || ARCH_X86_64 |
2471 + | 2261 + |
2472 void | 2262 void a52_imdct_256(sample_t * data, sample_t * delay, sample_t bias) |
2473 imdct_do_256(sample_t data[],sample_t delay[],sample_t bias) | |
2474 { | 2263 { |
2475 @@ -379,13 +1233,19 @@ | 2264 int i, k; |
2265 @@ -368,7 +1153,7 @@ | |
2266 | |
2267 void a52_imdct_init (uint32_t mm_accel) | |
2476 { | 2268 { |
2477 int i, j, k; | 2269 - int i, k; |
2478 | 2270 + int i, j, k; |
2479 - fprintf (stderr, "No accelerated IMDCT transform found\n"); | 2271 double sum; |
2480 - | 2272 |
2481 /* Twiddle factors to turn IFFT into IMDCT */ | 2273 /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */ |
2482 for (i = 0; i < 128; i++) { | 2274 @@ -420,6 +1205,99 @@ |
2483 xcos1[i] = -cos ((M_PI / 2048) * (8 * i + 1)); | 2275 post2[i].real = cos ((M_PI / 128) * (i + 0.5)); |
2484 xsin1[i] = -sin ((M_PI / 2048) * (8 * i + 1)); | 2276 post2[i].imag = sin ((M_PI / 128) * (i + 0.5)); |
2485 } | 2277 } |
2486 +#ifdef ARCH_X86 | 2278 + for (i = 0; i < 128; i++) { |
2279 + xcos1[i] = -cos ((M_PI / 2048) * (8 * i + 1)); | |
2280 + xsin1[i] = -sin ((M_PI / 2048) * (8 * i + 1)); | |
2281 + } | |
2282 + for (i = 0; i < 7; i++) { | |
2283 + j = 1 << i; | |
2284 + for (k = 0; k < j; k++) { | |
2285 + w[i][k].real = cos (-M_PI * k / j); | |
2286 + w[i][k].imag = sin (-M_PI * k / j); | |
2287 + } | |
2288 + } | |
2289 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
2487 + for (i = 0; i < 128; i++) { | 2290 + for (i = 0; i < 128; i++) { |
2488 + sseSinCos1c[2*i+0]= xcos1[i]; | 2291 + sseSinCos1c[2*i+0]= xcos1[i]; |
2489 + sseSinCos1c[2*i+1]= -xcos1[i]; | 2292 + sseSinCos1c[2*i+1]= -xcos1[i]; |
2490 + sseSinCos1d[2*i+0]= xsin1[i]; | 2293 + sseSinCos1d[2*i+0]= xsin1[i]; |
2491 + sseSinCos1d[2*i+1]= xsin1[i]; | 2294 + sseSinCos1d[2*i+1]= xsin1[i]; |
2492 + } | 2295 + } |
2493 +#endif | |
2494 | |
2495 /* More twiddle factors to turn IFFT into IMDCT */ | |
2496 for (i = 0; i < 64; i++) { | |
2497 @@ -400,7 +1260,334 @@ | |
2498 w[i][k].imag = sin (-M_PI * k / j); | |
2499 } | |
2500 } | |
2501 +#ifdef ARCH_X86 | |
2502 + for (i = 1; i < 7; i++) { | 2296 + for (i = 1; i < 7; i++) { |
2503 + j = 1 << i; | 2297 + j = 1 << i; |
2504 + for (k = 0; k < j; k+=2) { | 2298 + for (k = 0; k < j; k+=2) { |
2505 + | 2299 + |
2506 + sseW[i][4*k + 0] = w[i][k+0].real; | 2300 + sseW[i][4*k + 0] = w[i][k+0].real; |
2528 + } | 2322 + } |
2529 + } | 2323 + } |
2530 + | 2324 + |
2531 + for(i=0; i<128; i++) | 2325 + for(i=0; i<128; i++) |
2532 + { | 2326 + { |
2533 + sseWindow[2*i+0]= -imdct_window[2*i+0]; | 2327 + sseWindow[2*i+0]= -a52_imdct_window[2*i+0]; |
2534 + sseWindow[2*i+1]= imdct_window[2*i+1]; | 2328 + sseWindow[2*i+1]= a52_imdct_window[2*i+1]; |
2535 + } | 2329 + } |
2536 + | 2330 + |
2537 + for(i=0; i<64; i++) | 2331 + for(i=0; i<64; i++) |
2538 + { | 2332 + { |
2539 + sseWindow[256 + 2*i+0]= -imdct_window[254 - 2*i+1]; | 2333 + sseWindow[256 + 2*i+0]= -a52_imdct_window[254 - 2*i+1]; |
2540 + sseWindow[256 + 2*i+1]= imdct_window[254 - 2*i+0]; | 2334 + sseWindow[256 + 2*i+1]= a52_imdct_window[254 - 2*i+0]; |
2541 + sseWindow[384 + 2*i+0]= imdct_window[126 - 2*i+1]; | 2335 + sseWindow[384 + 2*i+0]= a52_imdct_window[126 - 2*i+1]; |
2542 + sseWindow[384 + 2*i+1]= -imdct_window[126 - 2*i+0]; | 2336 + sseWindow[384 + 2*i+1]= -a52_imdct_window[126 - 2*i+0]; |
2543 + } | 2337 + } |
2544 +#endif // arch_x86 | 2338 +#endif |
2545 + | 2339 + a52_imdct_512 = imdct_do_512; |
2546 imdct_512 = imdct_do_512; | 2340 + ifft128 = ifft128_c; |
2547 +#ifdef ARCH_X86 | 2341 + ifft64 = ifft64_c; |
2342 + | |
2343 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
2548 + if(mm_accel & MM_ACCEL_X86_SSE) | 2344 + if(mm_accel & MM_ACCEL_X86_SSE) |
2549 + { | 2345 + { |
2550 + fprintf (stderr, "Using SSE optimized IMDCT transform\n"); | 2346 + fprintf (stderr, "Using SSE optimized IMDCT transform\n"); |
2551 + imdct_512 = imdct_do_512_sse; | 2347 + a52_imdct_512 = imdct_do_512_sse; |
2552 + } | 2348 + } |
2553 + else | 2349 + else |
2554 + if(mm_accel & MM_ACCEL_X86_3DNOWEXT) | 2350 + if(mm_accel & MM_ACCEL_X86_3DNOWEXT) |
2555 + { | 2351 + { |
2556 + fprintf (stderr, "Using 3DNowEx optimized IMDCT transform\n"); | 2352 + fprintf (stderr, "Using 3DNowEx optimized IMDCT transform\n"); |
2557 + imdct_512 = imdct_do_512_3dnowex; | 2353 + a52_imdct_512 = imdct_do_512_3dnowex; |
2558 + } | 2354 + } |
2559 + else | 2355 + else |
2560 + if(mm_accel & MM_ACCEL_X86_3DNOW) | 2356 + if(mm_accel & MM_ACCEL_X86_3DNOW) |
2561 + { | 2357 + { |
2562 + fprintf (stderr, "Using 3DNow optimized IMDCT transform\n"); | 2358 + fprintf (stderr, "Using 3DNow optimized IMDCT transform\n"); |
2563 + imdct_512 = imdct_do_512_3dnow; | 2359 + a52_imdct_512 = imdct_do_512_3dnow; |
2564 + } | 2360 + } |
2565 + else | 2361 + else |
2566 +#endif // arch_x86 | 2362 +#endif // ARCH_X86 || ARCH_X86_64 |
2567 +#ifdef HAVE_ALTIVEC | 2363 +#ifdef HAVE_ALTIVEC |
2568 + if (mm_accel & MM_ACCEL_PPC_ALTIVEC) | 2364 + if (mm_accel & MM_ACCEL_PPC_ALTIVEC) |
2569 + { | 2365 + { |
2570 + fprintf(stderr, "Using AltiVec optimized IMDCT transform\n"); | 2366 + fprintf(stderr, "Using AltiVec optimized IMDCT transform\n"); |
2571 + imdct_512 = imdct_do_512_altivec; | 2367 + a52_imdct_512 = imdct_do_512_altivec; |
2572 + } | 2368 + } |
2573 + else | 2369 + else |
2574 +#endif | 2370 +#endif |
2575 + fprintf (stderr, "No accelerated IMDCT transform found\n"); | 2371 |
2576 imdct_256 = imdct_do_256; | 2372 #ifdef LIBA52_DJBFFT |
2373 if (mm_accel & MM_ACCEL_DJBFFT) { | |
2374 @@ -430,7 +1308,5 @@ | |
2375 #endif | |
2376 { | |
2377 fprintf (stderr, "No accelerated IMDCT transform found\n"); | |
2378 - ifft128 = ifft128_c; | |
2379 - ifft64 = ifft64_c; | |
2577 } | 2380 } |
2578 } | 2381 } |
2579 + | 2382 --- liba52-0.7.4/mm_accel.h 2006-06-12 15:05:00.000000000 +0200 |
2580 +static void fft_asmb(int k, complex_t *x, complex_t *wTB, | 2383 +++ liba52/mm_accel.h 2006-06-05 02:23:04.000000000 +0200 |
2581 + const complex_t *d, const complex_t *d_3) | 2384 @@ -30,7 +34,12 @@ |
2582 +{ | |
2583 + register complex_t *x2k, *x3k, *x4k, *wB; | |
2584 + register float a_r, a_i, a1_r, a1_i, u_r, u_i, v_r, v_i; | |
2585 + | |
2586 + x2k = x + 2 * k; | |
2587 + x3k = x2k + 2 * k; | |
2588 + x4k = x3k + 2 * k; | |
2589 + wB = wTB + 2 * k; | |
2590 + | |
2591 + TRANSZERO(x[0],x2k[0],x3k[0],x4k[0]); | |
2592 + TRANS(x[1],x2k[1],x3k[1],x4k[1],wTB[1],wB[1],d[1],d_3[1]); | |
2593 + | |
2594 + --k; | |
2595 + for(;;) { | |
2596 + TRANS(x[2],x2k[2],x3k[2],x4k[2],wTB[2],wB[2],d[2],d_3[2]); | |
2597 + TRANS(x[3],x2k[3],x3k[3],x4k[3],wTB[3],wB[3],d[3],d_3[3]); | |
2598 + if (!--k) break; | |
2599 + x += 2; | |
2600 + x2k += 2; | |
2601 + x3k += 2; | |
2602 + x4k += 2; | |
2603 + d += 2; | |
2604 + d_3 += 2; | |
2605 + wTB += 2; | |
2606 + wB += 2; | |
2607 + } | |
2608 + | |
2609 +} | |
2610 + | |
2611 +static void fft_asmb16(complex_t *x, complex_t *wTB) | |
2612 +{ | |
2613 + register float a_r, a_i, a1_r, a1_i, u_r, u_i, v_r, v_i; | |
2614 + int k = 2; | |
2615 + | |
2616 + /* transform x[0], x[8], x[4], x[12] */ | |
2617 + TRANSZERO(x[0],x[4],x[8],x[12]); | |
2618 + | |
2619 + /* transform x[1], x[9], x[5], x[13] */ | |
2620 + TRANS(x[1],x[5],x[9],x[13],wTB[1],wTB[5],delta16[1],delta16_3[1]); | |
2621 + | |
2622 + /* transform x[2], x[10], x[6], x[14] */ | |
2623 + TRANSHALF_16(x[2],x[6],x[10],x[14]); | |
2624 + | |
2625 + /* transform x[3], x[11], x[7], x[15] */ | |
2626 + TRANS(x[3],x[7],x[11],x[15],wTB[3],wTB[7],delta16[3],delta16_3[3]); | |
2627 + | |
2628 +} | |
2629 + | |
2630 +static void fft_4(complex_t *x) | |
2631 +{ | |
2632 + /* delta_p = 1 here */ | |
2633 + /* x[k] = sum_{i=0..3} x[i] * w^{i*k}, w=e^{-2*pi/4} | |
2634 + */ | |
2635 + | |
2636 + register float yt_r, yt_i, yb_r, yb_i, u_r, u_i, vi_r, vi_i; | |
2637 + | |
2638 + yt_r = x[0].real; | |
2639 + yb_r = yt_r - x[2].real; | |
2640 + yt_r += x[2].real; | |
2641 + | |
2642 + u_r = x[1].real; | |
2643 + vi_i = x[3].real - u_r; | |
2644 + u_r += x[3].real; | |
2645 + | |
2646 + u_i = x[1].imag; | |
2647 + vi_r = u_i - x[3].imag; | |
2648 + u_i += x[3].imag; | |
2649 + | |
2650 + yt_i = yt_r; | |
2651 + yt_i += u_r; | |
2652 + x[0].real = yt_i; | |
2653 + yt_r -= u_r; | |
2654 + x[2].real = yt_r; | |
2655 + yt_i = yb_r; | |
2656 + yt_i += vi_r; | |
2657 + x[1].real = yt_i; | |
2658 + yb_r -= vi_r; | |
2659 + x[3].real = yb_r; | |
2660 + | |
2661 + yt_i = x[0].imag; | |
2662 + yb_i = yt_i - x[2].imag; | |
2663 + yt_i += x[2].imag; | |
2664 + | |
2665 + yt_r = yt_i; | |
2666 + yt_r += u_i; | |
2667 + x[0].imag = yt_r; | |
2668 + yt_i -= u_i; | |
2669 + x[2].imag = yt_i; | |
2670 + yt_r = yb_i; | |
2671 + yt_r += vi_i; | |
2672 + x[1].imag = yt_r; | |
2673 + yb_i -= vi_i; | |
2674 + x[3].imag = yb_i; | |
2675 +} | |
2676 + | |
2677 + | |
2678 +static void fft_8(complex_t *x) | |
2679 +{ | |
2680 + /* delta_p = diag{1, sqrt(i)} here */ | |
2681 + /* x[k] = sum_{i=0..7} x[i] * w^{i*k}, w=e^{-2*pi/8} | |
2682 + */ | |
2683 + register float wT1_r, wT1_i, wB1_r, wB1_i, wT2_r, wT2_i, wB2_r, wB2_i; | |
2684 + | |
2685 + wT1_r = x[1].real; | |
2686 + wT1_i = x[1].imag; | |
2687 + wB1_r = x[3].real; | |
2688 + wB1_i = x[3].imag; | |
2689 + | |
2690 + x[1] = x[2]; | |
2691 + x[2] = x[4]; | |
2692 + x[3] = x[6]; | |
2693 + fft_4(&x[0]); | |
2694 + | |
2695 + | |
2696 + /* x[0] x[4] */ | |
2697 + wT2_r = x[5].real; | |
2698 + wT2_r += x[7].real; | |
2699 + wT2_r += wT1_r; | |
2700 + wT2_r += wB1_r; | |
2701 + wT2_i = wT2_r; | |
2702 + wT2_r += x[0].real; | |
2703 + wT2_i = x[0].real - wT2_i; | |
2704 + x[0].real = wT2_r; | |
2705 + x[4].real = wT2_i; | |
2706 + | |
2707 + wT2_i = x[5].imag; | |
2708 + wT2_i += x[7].imag; | |
2709 + wT2_i += wT1_i; | |
2710 + wT2_i += wB1_i; | |
2711 + wT2_r = wT2_i; | |
2712 + wT2_r += x[0].imag; | |
2713 + wT2_i = x[0].imag - wT2_i; | |
2714 + x[0].imag = wT2_r; | |
2715 + x[4].imag = wT2_i; | |
2716 + | |
2717 + /* x[2] x[6] */ | |
2718 + wT2_r = x[5].imag; | |
2719 + wT2_r -= x[7].imag; | |
2720 + wT2_r += wT1_i; | |
2721 + wT2_r -= wB1_i; | |
2722 + wT2_i = wT2_r; | |
2723 + wT2_r += x[2].real; | |
2724 + wT2_i = x[2].real - wT2_i; | |
2725 + x[2].real = wT2_r; | |
2726 + x[6].real = wT2_i; | |
2727 + | |
2728 + wT2_i = x[5].real; | |
2729 + wT2_i -= x[7].real; | |
2730 + wT2_i += wT1_r; | |
2731 + wT2_i -= wB1_r; | |
2732 + wT2_r = wT2_i; | |
2733 + wT2_r += x[2].imag; | |
2734 + wT2_i = x[2].imag - wT2_i; | |
2735 + x[2].imag = wT2_i; | |
2736 + x[6].imag = wT2_r; | |
2737 + | |
2738 + | |
2739 + /* x[1] x[5] */ | |
2740 + wT2_r = wT1_r; | |
2741 + wT2_r += wB1_i; | |
2742 + wT2_r -= x[5].real; | |
2743 + wT2_r -= x[7].imag; | |
2744 + wT2_i = wT1_i; | |
2745 + wT2_i -= wB1_r; | |
2746 + wT2_i -= x[5].imag; | |
2747 + wT2_i += x[7].real; | |
2748 + | |
2749 + wB2_r = wT2_r; | |
2750 + wB2_r += wT2_i; | |
2751 + wT2_i -= wT2_r; | |
2752 + wB2_r *= HSQRT2; | |
2753 + wT2_i *= HSQRT2; | |
2754 + wT2_r = wB2_r; | |
2755 + wB2_r += x[1].real; | |
2756 + wT2_r = x[1].real - wT2_r; | |
2757 + | |
2758 + wB2_i = x[5].real; | |
2759 + x[1].real = wB2_r; | |
2760 + x[5].real = wT2_r; | |
2761 + | |
2762 + wT2_r = wT2_i; | |
2763 + wT2_r += x[1].imag; | |
2764 + wT2_i = x[1].imag - wT2_i; | |
2765 + wB2_r = x[5].imag; | |
2766 + x[1].imag = wT2_r; | |
2767 + x[5].imag = wT2_i; | |
2768 + | |
2769 + /* x[3] x[7] */ | |
2770 + wT1_r -= wB1_i; | |
2771 + wT1_i += wB1_r; | |
2772 + wB1_r = wB2_i - x[7].imag; | |
2773 + wB1_i = wB2_r + x[7].real; | |
2774 + wT1_r -= wB1_r; | |
2775 + wT1_i -= wB1_i; | |
2776 + wB1_r = wT1_r + wT1_i; | |
2777 + wB1_r *= HSQRT2; | |
2778 + wT1_i -= wT1_r; | |
2779 + wT1_i *= HSQRT2; | |
2780 + wB2_r = x[3].real; | |
2781 + wB2_i = wB2_r + wT1_i; | |
2782 + wB2_r -= wT1_i; | |
2783 + x[3].real = wB2_i; | |
2784 + x[7].real = wB2_r; | |
2785 + wB2_i = x[3].imag; | |
2786 + wB2_r = wB2_i + wB1_r; | |
2787 + wB2_i -= wB1_r; | |
2788 + x[3].imag = wB2_i; | |
2789 + x[7].imag = wB2_r; | |
2790 +} | |
2791 + | |
2792 + | |
2793 +static void fft_128p(complex_t *a) | |
2794 +{ | |
2795 + fft_8(&a[0]); fft_4(&a[8]); fft_4(&a[12]); | |
2796 + fft_asmb16(&a[0], &a[8]); | |
2797 + | |
2798 + fft_8(&a[16]), fft_8(&a[24]); | |
2799 + fft_asmb(4, &a[0], &a[16],&delta32[0], &delta32_3[0]); | |
2800 + | |
2801 + fft_8(&a[32]); fft_4(&a[40]); fft_4(&a[44]); | |
2802 + fft_asmb16(&a[32], &a[40]); | |
2803 + | |
2804 + fft_8(&a[48]); fft_4(&a[56]); fft_4(&a[60]); | |
2805 + fft_asmb16(&a[48], &a[56]); | |
2806 + | |
2807 + fft_asmb(8, &a[0], &a[32],&delta64[0], &delta64_3[0]); | |
2808 + | |
2809 + fft_8(&a[64]); fft_4(&a[72]); fft_4(&a[76]); | |
2810 + /* fft_16(&a[64]); */ | |
2811 + fft_asmb16(&a[64], &a[72]); | |
2812 + | |
2813 + fft_8(&a[80]); fft_8(&a[88]); | |
2814 + | |
2815 + /* fft_32(&a[64]); */ | |
2816 + fft_asmb(4, &a[64], &a[80],&delta32[0], &delta32_3[0]); | |
2817 + | |
2818 + fft_8(&a[96]); fft_4(&a[104]), fft_4(&a[108]); | |
2819 + /* fft_16(&a[96]); */ | |
2820 + fft_asmb16(&a[96], &a[104]); | |
2821 + | |
2822 + fft_8(&a[112]), fft_8(&a[120]); | |
2823 + /* fft_32(&a[96]); */ | |
2824 + fft_asmb(4, &a[96], &a[112], &delta32[0], &delta32_3[0]); | |
2825 + | |
2826 + /* fft_128(&a[0]); */ | |
2827 + fft_asmb(16, &a[0], &a[64], &delta128[0], &delta128_3[0]); | |
2828 +} | |
2829 + | |
2830 + | |
2831 + | |
2832 --- liba52/imdct_mlib.c 2005-03-22 19:59:35.000000000 +0100 | |
2833 +++ imdct_mlib.c 2004-03-19 01:15:51.000000000 +0100 | |
2834 @@ -23,11 +29,11 @@ | |
2835 | |
2836 #ifdef LIBA52_MLIB | |
2837 | |
2838 -#include <inttypes.h> | |
2839 -#include <string.h> | |
2840 #include <mlib_types.h> | |
2841 #include <mlib_status.h> | |
2842 #include <mlib_signal.h> | |
2843 +#include <string.h> | |
2844 +#include <inttypes.h> | |
2845 | |
2846 #include "a52.h" | |
2847 #include "a52_internal.h" | |
2848 @@ -42,7 +48,7 @@ | |
2849 sample_t *data_ptr; | |
2850 sample_t *delay_ptr; | |
2851 sample_t *window_ptr; | |
2852 - sample_t tmp[256] __attribute__ ((__aligned__ (16))); | |
2853 + sample_t tmp[256] __attribute__((aligned(16))); | |
2854 int i; | |
2855 | |
2856 memcpy(tmp, data, 256 * sizeof(sample_t)); | |
2857 @@ -91,7 +97,7 @@ | |
2858 sample_t *data_ptr; | |
2859 sample_t *delay_ptr; | |
2860 sample_t *window_ptr; | |
2861 - sample_t tmp[256] __attribute__ ((__aligned__ (16))); | |
2862 + sample_t tmp[256] __attribute__((aligned(16))); | |
2863 int i; | |
2864 | |
2865 memcpy(tmp, data, 256 * sizeof(sample_t)); | |
2866 --- include/mm_accel.h 2005-03-22 19:58:53.000000000 +0100 | |
2867 +++ mm_accel.h 2004-03-19 01:15:52.000000000 +0100 | |
2868 @@ -19,12 +25,22 @@ | |
2869 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
2870 */ | |
2871 | |
2872 +#ifndef MM_ACCEL_H | |
2873 +#define MM_ACCEL_H | |
2874 + | |
2875 /* generic accelerations */ | |
2876 #define MM_ACCEL_MLIB 0x00000001 | |
2877 | |
2878 /* x86 accelerations */ | 2385 /* x86 accelerations */ |
2879 #define MM_ACCEL_X86_MMX 0x80000000 | 2386 #define MM_ACCEL_X86_MMX 0x80000000 |
2880 #define MM_ACCEL_X86_3DNOW 0x40000000 | 2387 #define MM_ACCEL_X86_3DNOW 0x40000000 |
2881 +#define MM_ACCEL_X86_3DNOWEXT 0x08000000 | 2388 +#define MM_ACCEL_X86_3DNOWEXT 0x08000000 |
2882 #define MM_ACCEL_X86_MMXEXT 0x20000000 | 2389 #define MM_ACCEL_X86_MMXEXT 0x20000000 |
2884 + | 2391 + |
2885 +/* PPC accelerations */ | 2392 +/* PPC accelerations */ |
2886 +#define MM_ACCEL_PPC_ALTIVEC 0x00010000 | 2393 +#define MM_ACCEL_PPC_ALTIVEC 0x00010000 |
2887 | 2394 |
2888 uint32_t mm_accel (void); | 2395 uint32_t mm_accel (void); |
2889 + | 2396 |
2890 +#endif /* MM_ACCEL_H */ | 2397 --- liba52-0.7.4/parse.c 2006-06-12 15:05:07.000000000 +0200 |
2891 --- liba52/parse.c 2005-03-22 19:59:35.000000000 +0100 | 2398 +++ liba52/parse.c 2006-06-12 14:51:33.000000000 +0200 |
2892 +++ parse.c 2004-04-01 15:41:29.000000000 +0200 | 2399 @@ -24,6 +28,7 @@ |
2893 @@ -21,21 +27,19 @@ | |
2894 | |
2895 #include "config.h" | 2400 #include "config.h" |
2896 | 2401 |
2897 -#include <inttypes.h> | |
2898 #include <stdlib.h> | 2402 #include <stdlib.h> |
2403 +#include <stdio.h> | |
2899 #include <string.h> | 2404 #include <string.h> |
2900 +#include <inttypes.h> | 2405 #include <inttypes.h> |
2901 | 2406 |
2902 #include "a52.h" | 2407 @@ -31,13 +36,11 @@ |
2903 #include "a52_internal.h" | 2408 #include "a52_internal.h" |
2904 #include "bitstream.h" | 2409 #include "bitstream.h" |
2905 #include "tables.h" | 2410 #include "tables.h" |
2906 +#include "mm_accel.h" | 2411 +#include "mm_accel.h" |
2907 | 2412 |
2912 -/* assume malloc alignment is sufficient */ | 2417 -/* assume malloc alignment is sufficient */ |
2913 -#define memalign(align,size) malloc (size) | 2418 -#define memalign(align,size) malloc (size) |
2914 #endif | 2419 #endif |
2915 | 2420 |
2916 typedef struct { | 2421 typedef struct { |
2917 @@ -54,12 +58,28 @@ | 2422 @@ -61,6 +64,21 @@ |
2918 sample_t * samples; | 2423 return NULL; |
2919 int i; | 2424 |
2920 | 2425 state->samples = memalign (16, 256 * 12 * sizeof (sample_t)); |
2921 - imdct_init (mm_accel); | |
2922 - | |
2923 samples = memalign (16, 256 * 12 * sizeof (sample_t)); | |
2924 +#if defined(__MINGW32__) && defined(HAVE_SSE) | 2426 +#if defined(__MINGW32__) && defined(HAVE_SSE) |
2925 + for(i=0;i<10;i++){ | 2427 + for(i=0;i<10;i++){ |
2926 + if((int)samples%16){ | 2428 + if((int)state->samples%16){ |
2927 + sample_t* samplestmp=malloc(256 * 12 * sizeof (sample_t)); | 2429 + sample_t* samplestmp=malloc(256 * 12 * sizeof (sample_t)); |
2928 + free(samples); | 2430 + free(state->samples); |
2929 + samples = samplestmp; | 2431 + state->samples = samplestmp; |
2930 + } | 2432 + } |
2931 + else break; | 2433 + else break; |
2932 + } | 2434 + } |
2933 +#endif | 2435 +#endif |
2934 + if(((int)samples%16) && (mm_accel&MM_ACCEL_X86_SSE)){ | 2436 + if(((int)state->samples%16) && (mm_accel&MM_ACCEL_X86_SSE)){ |
2935 + mm_accel &=~MM_ACCEL_X86_SSE; | 2437 + mm_accel &=~MM_ACCEL_X86_SSE; |
2936 + printf("liba52: unable to get 16 byte aligned memory disabling usage of SSE instructions\n"); | 2438 + fprintf(stderr, "liba52: unable to get 16 byte aligned memory disabling usage of SSE instructions\n"); |
2937 + } | 2439 + } |
2938 + | 2440 + |
2939 if (samples == NULL) | 2441 if (state->samples == NULL) { |
2940 - return NULL; | 2442 free (state); |
2941 - | 2443 return NULL; |
2942 + return NULL; | 2444 @@ -74,6 +92,7 @@ |
2943 + | 2445 state->lfsr_state = 1; |
2944 + imdct_init (mm_accel); | 2446 |
2447 a52_imdct_init (mm_accel); | |
2945 + downmix_accel_init(mm_accel); | 2448 + downmix_accel_init(mm_accel); |
2946 + | 2449 |
2947 for (i = 0; i < 256 * 12; i++) | 2450 return state; |
2948 samples[i] = 0; | 2451 } |
2949 | 2452 @@ -141,7 +160,7 @@ |
2950 @@ -124,7 +144,7 @@ | |
2951 state->acmod = acmod = buf[6] >> 5; | 2453 state->acmod = acmod = buf[6] >> 5; |
2952 | 2454 |
2953 bitstream_set_ptr (buf + 6); | 2455 a52_bitstream_set_ptr (state, buf + 6); |
2954 - bitstream_get (3); /* skip acmod we already parsed */ | 2456 - bitstream_get (state, 3); /* skip acmod we already parsed */ |
2955 + bitstream_skip (3); /* skip acmod we already parsed */ | 2457 + bitstream_skip (state, 3); /* skip acmod we already parsed */ |
2956 | 2458 |
2957 if ((acmod == 2) && (bitstream_get (2) == 2)) /* dsurmod */ | 2459 if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */ |
2958 acmod = A52_DOLBY; | 2460 acmod = A52_DOLBY; |
2959 @@ -144,7 +164,7 @@ | 2461 @@ -172,28 +191,28 @@ |
2960 if (state->lfeon && (*flags & A52_LFE)) | |
2961 state->output |= A52_LFE; | |
2962 *flags = state->output; | |
2963 - // the 2* compensates for differences in imdct | |
2964 + /* the 2* compensates for differences in imdct */ | |
2965 state->dynrng = state->level = 2 * *level; | |
2966 state->bias = bias; | |
2967 state->dynrnge = 1; | |
2968 @@ -152,28 +172,28 @@ | |
2969 | 2462 |
2970 chaninfo = !acmod; | 2463 chaninfo = !acmod; |
2971 do { | 2464 do { |
2972 - bitstream_get (5); /* dialnorm */ | 2465 - bitstream_get (state, 5); /* dialnorm */ |
2973 + bitstream_skip (5); /* dialnorm */ | 2466 + bitstream_skip (state, 5); /* dialnorm */ |
2974 if (bitstream_get (1)) /* compre */ | 2467 if (bitstream_get (state, 1)) /* compre */ |
2975 - bitstream_get (8); /* compr */ | 2468 - bitstream_get (state, 8); /* compr */ |
2976 + bitstream_skip (8); /* compr */ | 2469 + bitstream_skip (state, 8); /* compr */ |
2977 if (bitstream_get (1)) /* langcode */ | 2470 if (bitstream_get (state, 1)) /* langcode */ |
2978 - bitstream_get (8); /* langcod */ | 2471 - bitstream_get (state, 8); /* langcod */ |
2979 + bitstream_skip (8); /* langcod */ | 2472 + bitstream_skip (state, 8); /* langcod */ |
2980 if (bitstream_get (1)) /* audprodie */ | 2473 if (bitstream_get (state, 1)) /* audprodie */ |
2981 - bitstream_get (7); /* mixlevel + roomtyp */ | 2474 - bitstream_get (state, 7); /* mixlevel + roomtyp */ |
2982 + bitstream_skip (7); /* mixlevel + roomtyp */ | 2475 + bitstream_skip (state, 7); /* mixlevel + roomtyp */ |
2983 } while (chaninfo--); | 2476 } while (chaninfo--); |
2984 | 2477 |
2985 - bitstream_get (2); /* copyrightb + origbs */ | 2478 - bitstream_get (state, 2); /* copyrightb + origbs */ |
2986 + bitstream_skip (2); /* copyrightb + origbs */ | 2479 + bitstream_skip (state, 2); /* copyrightb + origbs */ |
2987 | 2480 |
2988 if (bitstream_get (1)) /* timecod1e */ | 2481 if (bitstream_get (state, 1)) /* timecod1e */ |
2989 - bitstream_get (14); /* timecod1 */ | 2482 - bitstream_get (state, 14); /* timecod1 */ |
2990 + bitstream_skip (14); /* timecod1 */ | 2483 + bitstream_skip (state, 14); /* timecod1 */ |
2991 if (bitstream_get (1)) /* timecod2e */ | 2484 if (bitstream_get (state, 1)) /* timecod2e */ |
2992 - bitstream_get (14); /* timecod2 */ | 2485 - bitstream_get (state, 14); /* timecod2 */ |
2993 + bitstream_skip (14); /* timecod2 */ | 2486 + bitstream_skip (state, 14); /* timecod2 */ |
2994 | 2487 |
2995 if (bitstream_get (1)) { /* addbsie */ | 2488 if (bitstream_get (state, 1)) { /* addbsie */ |
2996 int addbsil; | 2489 int addbsil; |
2997 | 2490 |
2998 addbsil = bitstream_get (6); | 2491 addbsil = bitstream_get (state, 6); |
2999 do { | 2492 do { |
3000 - bitstream_get (8); /* addbsi */ | 2493 - bitstream_get (state, 8); /* addbsi */ |
3001 + bitstream_skip (8); /* addbsi */ | 2494 + bitstream_skip (state, 8); /* addbsi */ |
3002 } while (addbsil--); | 2495 } while (addbsil--); |
3003 } | 2496 } |
3004 | 2497 |
3005 @@ -647,7 +667,7 @@ | 2498 @@ -680,7 +699,7 @@ |
3006 if (parse_exponents (chexpstr[i], nchgrps, state->fbw_exp[i][0], | 2499 state->fbw_expbap[i].exp[0], |
3007 state->fbw_exp[i] + 1)) | 2500 state->fbw_expbap[i].exp + 1)) |
3008 return 1; | 2501 return 1; |
3009 - bitstream_get (2); /* gainrng */ | 2502 - bitstream_get (state, 2); /* gainrng */ |
3010 + bitstream_skip (2); /* gainrng */ | 2503 + bitstream_skip (state, 2); /* gainrng */ |
3011 } | 2504 } |
3012 if (lfeexpstr != EXP_REUSE) { | 2505 if (lfeexpstr != EXP_REUSE) { |
3013 do_bit_alloc |= 32; | 2506 do_bit_alloc |= 32; |
3014 @@ -729,7 +749,7 @@ | 2507 @@ -755,7 +774,7 @@ |
3015 if (bitstream_get (1)) { /* skiple */ | 2508 if (bitstream_get (state, 1)) { /* skiple */ |
3016 i = bitstream_get (9); /* skipl */ | 2509 i = bitstream_get (state, 9); /* skipl */ |
3017 while (i--) | 2510 while (i--) |
3018 - bitstream_get (8); | 2511 - bitstream_get (state, 8); |
3019 + bitstream_skip (8); | 2512 + bitstream_skip (state, 8); |
3020 } | 2513 } |
3021 | 2514 |
3022 if (state->output & A52_LFE) | 2515 samples = state->samples; |
3023 |