forked from nostar/imbe_vocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_sub.h
130 lines (120 loc) · 3.7 KB
/
math_sub.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Project 25 IMBE Encoder/Decoder Fixed-Point implementation
* Developed by Pavel Yazev E-mail: [email protected]
* Version 1.0 (c) Copyright 2009
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* The software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
* 02110-1301, USA.
*/
#ifndef _MATH_SUB
#define _MATH_SUB
#define X05_Q15 16384 // (0.5*(1<<15))
#define ONE_Q15 32767 // ((1<<15)-1)
//-----------------------------------------------------------------------------
// PURPOSE:
// Computes the cosine of x whose value is expressed in radians/PI.
//
// INPUT:
// x - argument in Q1.15
//
// OUTPUT:
// None
//
// RETURN:
// Result in Q1.15
//
//-----------------------------------------------------------------------------
Word16 cos_fxp(Word16 x);
//-----------------------------------------------------------------------------
// PURPOSE:
// Computes the sinus of x whose value is expressed in radians/PI.
//
// INPUT:
// x - argument in Q1.15
//
// OUTPUT:
// None
//
// RETURN:
// Result in Q1.15
//
//-----------------------------------------------------------------------------
Word16 sin_fxp(Word16 x);
//-----------------------------------------------------------------------------
// PURPOSE:
// Multiply a 32 bit number (L_var2) and a 16 bit
// number (var1) returning a 32 bit result. L_var2
// is truncated to 31 bits prior to executing the
// multiply.
//
// INPUT:
// L_var2 - A Word32 input variable
// var1 - A Word16 input variable
//
// OUTPUT:
// None
//
// RETURN:
// A Word32 value
//
//-----------------------------------------------------------------------------
Word32 L_mpy_ls(Word32 L_var2, Word16 var1);
//-----------------------------------------------------------------------------
// PURPOSE:
// Computes pow(2.0, x)
//
// INPUT:
// x - In signed Q10.22 format
//
// OUTPUT:
// None
//
// RETURN:
// Result in signed Q14.2 format
//
//-----------------------------------------------------------------------------
Word16 Pow2 (Word32 x);
//-----------------------------------------------------------------------------
// PURPOSE:
// Computes sqrt(L_x), where L_x is positive.
//
// INPUT:
// L_x - argument in Q1.31
// *exp - pointer to save denormalization exponent
// OUTPUT:
// Right shift to be applied to result, Q16.0
//
// RETURN:
// Result in Q1.31
// Right shift should be applied to it!
//
//-----------------------------------------------------------------------------
Word32 sqrt_l_exp (Word32 L_x, Word16 *exp);
//-----------------------------------------------------------------------------
// PURPOSE:
// Computes log2 of x
//
// INPUT:
// x - argument in Q14.2
//
// OUTPUT:
// None
//
// RETURN:
// Result in Q10.22
//
//-----------------------------------------------------------------------------
Word32 Log2(Word16 x);
#endif