Mercurial > mplayer.hg
comparison mp3lib/dct64_altivec.c @ 9122:5ba896a38d75
The two attached patches *should* allow for proper
compilation of the AltiVec stuff on both Darwin
and non-Darwin system. They've only been tested
for compilation on Debian using Debian's gcc-3.2.
Romain Dolbeau <dolbeau@irisa.fr>
author | arpi |
---|---|
date | Mon, 27 Jan 2003 21:47:25 +0000 |
parents | 60d144a16088 |
children | 72256bd9557b |
comparison
equal
deleted
inserted
replaced
9121:57605e30cda4 | 9122:5ba896a38d75 |
---|---|
10 #define real float | 10 #define real float |
11 | 11 |
12 #include "mpg123.h" | 12 #include "mpg123.h" |
13 | 13 |
14 #ifdef HAVE_ALTIVEC | 14 #ifdef HAVE_ALTIVEC |
15 | |
16 #ifndef SYS_DARWIN | |
17 #include <altivec.h> | |
18 #endif | |
15 | 19 |
16 // used to build registers permutation vectors (vcprm) | 20 // used to build registers permutation vectors (vcprm) |
17 // the 's' are for words in the _s_econd vector | 21 // the 's' are for words in the _s_econd vector |
18 #define WORD_0 0x00,0x01,0x02,0x03 | 22 #define WORD_0 0x00,0x01,0x02,0x03 |
19 #define WORD_1 0x04,0x05,0x06,0x07 | 23 #define WORD_1 0x04,0x05,0x06,0x07 |
22 #define WORD_s0 0x10,0x11,0x12,0x13 | 26 #define WORD_s0 0x10,0x11,0x12,0x13 |
23 #define WORD_s1 0x14,0x15,0x16,0x17 | 27 #define WORD_s1 0x14,0x15,0x16,0x17 |
24 #define WORD_s2 0x18,0x19,0x1a,0x1b | 28 #define WORD_s2 0x18,0x19,0x1a,0x1b |
25 #define WORD_s3 0x1c,0x1d,0x1e,0x1f | 29 #define WORD_s3 0x1c,0x1d,0x1e,0x1f |
26 | 30 |
31 #ifdef SYS_DARWIN | |
27 #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) | 32 #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) |
33 #else | |
34 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d} | |
35 #endif | |
28 | 36 |
29 // vcprmle is used to keep the same index as in the SSE version. | 37 // vcprmle is used to keep the same index as in the SSE version. |
30 // it's the same as vcprm, with the index inversed | 38 // it's the same as vcprm, with the index inversed |
31 // ('le' is Little Endian) | 39 // ('le' is Little Endian) |
32 #define vcprmle(a,b,c,d) vcprm(d,c,b,a) | 40 #define vcprmle(a,b,c,d) vcprm(d,c,b,a) |
34 // used to build inverse/identity vectors (vcii) | 42 // used to build inverse/identity vectors (vcii) |
35 // n is _n_egative, p is _p_ositive | 43 // n is _n_egative, p is _p_ositive |
36 #define FLOAT_n -1. | 44 #define FLOAT_n -1. |
37 #define FLOAT_p 1. | 45 #define FLOAT_p 1. |
38 | 46 |
47 #ifdef SYS_DARWIN | |
39 #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) | 48 #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) |
49 #else | |
50 #define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d} | |
51 #endif | |
52 | |
53 #ifdef SYS_DARWIN | |
54 #define FOUROF(a) (a) | |
55 #else | |
56 #define FOUROF(a) {a,a,a,a} | |
57 #endif | |
40 | 58 |
41 void dct64_altivec(real *a,real *b,real *c) | 59 void dct64_altivec(real *a,real *b,real *c) |
42 { | 60 { |
43 real __attribute__ ((aligned(16))) b1[0x20]; | 61 real __attribute__ ((aligned(16))) b1[0x20]; |
44 real __attribute__ ((aligned(16))) b2[0x20]; | 62 real __attribute__ ((aligned(16))) b2[0x20]; |
45 | 63 |
46 real *out0 = a; | 64 real *out0 = a; |
47 real *out1 = b; | 65 real *out1 = b; |
48 real *samples = c; | 66 real *samples = c; |
49 | 67 |
50 const vector float vczero = (const vector float)(0.); | 68 const vector float vczero = (const vector float)FOUROF(0.); |
51 const vector unsigned char reverse = (const vector unsigned char)vcprm(3,2,1,0); | 69 const vector unsigned char reverse = (const vector unsigned char)vcprm(3,2,1,0); |
52 | 70 |
53 | 71 |
54 if (((unsigned long)b1 & 0x0000000F) || | 72 if (((unsigned long)b1 & 0x0000000F) || |
55 ((unsigned long)b2 & 0x0000000F)) | 73 ((unsigned long)b2 & 0x0000000F)) |
519 out1[0x10*11] = b1[0x1B] + b1[0x17]; | 537 out1[0x10*11] = b1[0x1B] + b1[0x17]; |
520 out1[0x10*13] = b1[0x17] + b1[0x1F]; | 538 out1[0x10*13] = b1[0x17] + b1[0x1F]; |
521 out1[0x10*15] = b1[0x1F]; | 539 out1[0x10*15] = b1[0x1F]; |
522 } | 540 } |
523 | 541 |
524 #endif HAVE_ALTIVEC | 542 #endif /* HAVE_ALTIVEC */ |
525 | 543 |