diff options
Diffstat (limited to 'apps/codecs/libwmapro/wmapro_math.h')
-rw-r--r-- | apps/codecs/libwmapro/wmapro_math.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/codecs/libwmapro/wmapro_math.h b/apps/codecs/libwmapro/wmapro_math.h new file mode 100644 index 0000000000..83fbb40a66 --- /dev/null +++ b/apps/codecs/libwmapro/wmapro_math.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #include <inttypes.h> | ||
2 | #include "types.h" | ||
3 | |||
4 | #define fixtof16(x) (float)((float)(x) / (float)(1 << 16)) | ||
5 | #define ftofix16(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5:0.5))) | ||
6 | |||
7 | static inline FIXED fixmulshift(FIXED x, FIXED y, int shamt) | ||
8 | { | ||
9 | int64_t temp; | ||
10 | temp = x; | ||
11 | temp *= y; | ||
12 | |||
13 | temp >>= shamt; | ||
14 | |||
15 | return (int32_t)temp; | ||
16 | } | ||
17 | |||
18 | |||
19 | static inline void vector_fixmul_window(FIXED *dst, const FIXED *src0, | ||
20 | const FIXED *src1, const FIXED *win, | ||
21 | FIXED add_bias, int len) | ||
22 | { | ||
23 | int i, j; | ||
24 | dst += len; | ||
25 | win += len; | ||
26 | src0+= len; | ||
27 | for(i=-len, j=len-1; i<0; i++, j--) { | ||
28 | FIXED s0 = src0[i]; | ||
29 | FIXED s1 = src1[j]; | ||
30 | FIXED wi = win[i]; | ||
31 | FIXED wj = win[j]; | ||
32 | dst[i] = fixmulshift(s0,-1*wj,31) - fixmulshift(s1,-1*wi,31) + (add_bias<<16); | ||
33 | dst[j] = fixmulshift(s0,-1*wi,31) + fixmulshift(s1,-1*wj,31) + (add_bias<<16); | ||
34 | } | ||
35 | |||
36 | } | ||
37 | |||
38 | static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul, | ||
39 | int len) | ||
40 | { | ||
41 | int i; | ||
42 | for(i=0; i<len; i++) { | ||
43 | dst[i] = fixmulshift(src[i],mul,32); | ||
44 | } | ||
45 | |||
46 | } | ||