summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/libwma/wmafixed.c54
-rw-r--r--apps/codecs/libwma/wmafixed.h69
2 files changed, 46 insertions, 77 deletions
diff --git a/apps/codecs/libwma/wmafixed.c b/apps/codecs/libwma/wmafixed.c
index b53a1da607..9c3b211f59 100644
--- a/apps/codecs/libwma/wmafixed.c
+++ b/apps/codecs/libwma/wmafixed.c
@@ -43,56 +43,8 @@ fixed64 Fixed32To64(fixed32 x)
43 return (fixed64)x; 43 return (fixed64)x;
44} 44}
45 45
46
47/*
48 Fixed precision multiply code.
49
50*/
51
52/*Sign-15.16 format */
53#ifdef CPU_ARM
54/* these are defines in wmafixed.h*/
55#elif defined(CPU_COLDFIRE)
56
57#else
58
59fixed32 fixmul32(fixed32 x, fixed32 y)
60{
61 fixed64 temp;
62 temp = x;
63 temp *= y;
64
65 temp >>= PRECISION;
66
67 return (fixed32)temp;
68}
69
70#endif
71/*
72 Special fixmul32 that does a 16.16 x 1.31 multiply that returns a 16.16 value.
73 this is needed because the fft constants are all normalized to be less then 1
74 and can't fit into a 16 bit number without excessive rounding
75
76
77*/
78#ifndef CPU_ARM
79fixed32 fixmul32b(fixed32 x, fixed32 y)
80{
81 fixed64 temp;
82
83 temp = x;
84 temp *= y;
85
86 temp >>= 31; //16+31-16 = 31 bits
87
88 return (fixed32)temp;
89}
90#endif
91
92
93
94/* 46/*
95 Not performance senstitive code here 47 Not performance senstitive code here
96 48
97*/ 49*/
98 50
@@ -204,7 +156,7 @@ static const unsigned long atan_table[] = {
204 156
205/* 157/*
206 158
207 Below here functions do not use standard fixed precision! 159 Below here functions do not use standard fixed precision!
208*/ 160*/
209 161
210 162
@@ -270,7 +222,7 @@ long fsincos(unsigned long phase, fixed32 *cos)
270 222
271 223
272/* 224/*
273 Old trig functions. Still used in 1 place each. 225 Old trig functions. Still used in 1 place each.
274 226
275*/ 227*/
276 228
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);
35fixed32 fixcos32(fixed32 x); 35fixed32 fixcos32(fixed32 x);
36long fsincos(unsigned long phase, fixed32 *cos); 36long 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
79static inline int32_t fixmul32(int32_t x, int32_t y) 70static 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
89static 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
101fixed32 fixmul32b(fixed32 x, fixed32 y);
102#else 100#else
103 101
104fixed32 fixmul32(fixed32 x, fixed32 y); 102static inline fixed32 fixmul32(fixed32 x, fixed32 y)
105fixed32 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
113static 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
110static inline 128static 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
152static inline 169static inline
153void CMUL(fixed32 *pre, 170void CMUL(fixed32 *pre,
154 fixed32 *pim, 171 fixed32 *pim,