diff options
Diffstat (limited to 'apps/codecs/libwma/wmafixed.h')
-rw-r--r-- | apps/codecs/libwma/wmafixed.h | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/apps/codecs/libwma/wmafixed.h b/apps/codecs/libwma/wmafixed.h index 32386dc9bd..b92c12a50a 100644 --- a/apps/codecs/libwma/wmafixed.h +++ b/apps/codecs/libwma/wmafixed.h | |||
@@ -1,9 +1,9 @@ | |||
1 | /* fixed precision code. We use a combination of Sign 15.16 and Sign.31 | 1 | /* fixed precision code. We use a combination of Sign 15.16 and Sign.31 |
2 | precision here. | 2 | precision here. |
3 | 3 | ||
4 | The WMA decoder does not always follow this convention, and occasionally | 4 | The WMA decoder does not always follow this convention, and occasionally |
5 | renormalizes values to other formats in order to maximize precision. | 5 | renormalizes values to other formats in order to maximize precision. |
6 | However, only the two precisions above are provided in this file. | 6 | However, only the two precisions above are provided in this file. |
7 | 7 | ||
8 | */ | 8 | */ |
9 | 9 | ||
@@ -35,17 +35,8 @@ fixed32 fixsin32(fixed32 x); | |||
35 | fixed32 fixcos32(fixed32 x); | 35 | fixed32 fixcos32(fixed32 x); |
36 | long fsincos(unsigned long phase, fixed32 *cos); | 36 | long fsincos(unsigned long phase, fixed32 *cos); |
37 | 37 | ||
38 | |||
39 | |||
40 | |||
41 | |||
42 | #ifdef CPU_ARM | 38 | #ifdef CPU_ARM |
43 | 39 | ||
44 | /* | ||
45 | Fixed precision multiply code ASM. | ||
46 | |||
47 | */ | ||
48 | |||
49 | /*Sign-15.16 format */ | 40 | /*Sign-15.16 format */ |
50 | 41 | ||
51 | #define fixmul32(x, y) \ | 42 | #define fixmul32(x, y) \ |
@@ -62,8 +53,7 @@ long fsincos(unsigned long phase, fixed32 *cos); | |||
62 | __result; \ | 53 | __result; \ |
63 | }) | 54 | }) |
64 | 55 | ||
65 | 56 | #define fixmul32b(x, y) \ | |
66 | #define fixmul32b(x, y) \ | ||
67 | ({ int32_t __hi; \ | 57 | ({ int32_t __hi; \ |
68 | uint32_t __lo; \ | 58 | uint32_t __lo; \ |
69 | int32_t __result; \ | 59 | int32_t __result; \ |
@@ -76,6 +66,7 @@ long fsincos(unsigned long phase, fixed32 *cos); | |||
76 | }) | 66 | }) |
77 | 67 | ||
78 | #elif defined(CPU_COLDFIRE) | 68 | #elif defined(CPU_COLDFIRE) |
69 | |||
79 | static inline int32_t fixmul32(int32_t x, int32_t y) | 70 | static inline int32_t fixmul32(int32_t x, int32_t y) |
80 | { | 71 | { |
81 | #if PRECISION != 16 | 72 | #if PRECISION != 16 |
@@ -89,22 +80,49 @@ static inline int32_t fixmul32(int32_t x, int32_t y) | |||
89 | "lsr.l #1, %[t1] \n" | 80 | "lsr.l #1, %[t1] \n" |
90 | "move.w %[t1], %[x] \n" | 81 | "move.w %[t1], %[x] \n" |
91 | "swap %[x] \n" | 82 | "swap %[x] \n" |
92 | : /* outputs */ | 83 | : [t1] "=&d" (t1), [x] "+d" (x) |
93 | [t1]"=&d"(t1), | 84 | : [y] "d" (y) |
94 | [x] "+d" (x) | 85 | ); |
95 | : /* inputs */ | 86 | return x; |
96 | [y] "d" (y) | 87 | } |
88 | |||
89 | static inline int32_t fixmul32b(int32_t x, int32_t y) | ||
90 | { | ||
91 | asm ( | ||
92 | "mac.l %[x], %[y], %%acc0 \n" /* multiply */ | ||
93 | "movclr.l %%acc0, %[x] \n" /* get higher half */ | ||
94 | : [x] "+d" (x) | ||
95 | : [y] "d" (y) | ||
97 | ); | 96 | ); |
98 | return x; | 97 | return x; |
99 | } | 98 | } |
100 | 99 | ||
101 | fixed32 fixmul32b(fixed32 x, fixed32 y); | ||
102 | #else | 100 | #else |
103 | 101 | ||
104 | fixed32 fixmul32(fixed32 x, fixed32 y); | 102 | static inline fixed32 fixmul32(fixed32 x, fixed32 y) |
105 | fixed32 fixmul32b(fixed32 x, fixed32 y); | 103 | { |
106 | #endif | 104 | fixed64 temp; |
105 | temp = x; | ||
106 | temp *= y; | ||
107 | |||
108 | temp >>= PRECISION; | ||
109 | |||
110 | return (fixed32)temp; | ||
111 | } | ||
107 | 112 | ||
113 | static inline fixed32 fixmul32b(fixed32 x, fixed32 y) | ||
114 | { | ||
115 | fixed64 temp; | ||
116 | |||
117 | temp = x; | ||
118 | temp *= y; | ||
119 | |||
120 | temp >>= 31; //16+31-16 = 31 bits | ||
121 | |||
122 | return (fixed32)temp; | ||
123 | } | ||
124 | |||
125 | #endif | ||
108 | 126 | ||
109 | #ifdef CPU_ARM | 127 | #ifdef CPU_ARM |
110 | static inline | 128 | static inline |
@@ -148,7 +166,6 @@ void CMUL(fixed32 *x, fixed32 *y, | |||
148 | : "cc", "memory"); | 166 | : "cc", "memory"); |
149 | } | 167 | } |
150 | #else | 168 | #else |
151 | // PJJ : reinstate macro | ||
152 | static inline | 169 | static inline |
153 | void CMUL(fixed32 *pre, | 170 | void CMUL(fixed32 *pre, |
154 | fixed32 *pim, | 171 | fixed32 *pim, |