diff options
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/arch.h')
-rw-r--r-- | lib/rbcodec/codecs/libspeex/arch.h | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libspeex/arch.h b/lib/rbcodec/codecs/libspeex/arch.h new file mode 100644 index 0000000000..35b5363837 --- /dev/null +++ b/lib/rbcodec/codecs/libspeex/arch.h | |||
@@ -0,0 +1,242 @@ | |||
1 | /* Copyright (C) 2003 Jean-Marc Valin */ | ||
2 | /** | ||
3 | @file arch.h | ||
4 | @brief Various architecture definitions Speex | ||
5 | */ | ||
6 | /* | ||
7 | Redistribution and use in source and binary forms, with or without | ||
8 | modification, are permitted provided that the following conditions | ||
9 | are met: | ||
10 | |||
11 | - Redistributions of source code must retain the above copyright | ||
12 | notice, this list of conditions and the following disclaimer. | ||
13 | |||
14 | - Redistributions in binary form must reproduce the above copyright | ||
15 | notice, this list of conditions and the following disclaimer in the | ||
16 | documentation and/or other materials provided with the distribution. | ||
17 | |||
18 | - Neither the name of the Xiph.org Foundation nor the names of its | ||
19 | contributors may be used to endorse or promote products derived from | ||
20 | this software without specific prior written permission. | ||
21 | |||
22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #ifndef ARCH_H | ||
36 | #define ARCH_H | ||
37 | |||
38 | #include "config-speex.h" | ||
39 | |||
40 | #ifndef SPEEX_VERSION | ||
41 | #define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ | ||
42 | #define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ | ||
43 | #define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ | ||
44 | #define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ | ||
45 | #define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */ | ||
46 | #endif | ||
47 | |||
48 | /* A couple test to catch stupid option combinations */ | ||
49 | #ifdef FIXED_POINT | ||
50 | |||
51 | #ifdef FLOATING_POINT | ||
52 | #error You cannot compile as floating point and fixed point at the same time | ||
53 | #endif | ||
54 | #ifdef _USE_SSE | ||
55 | #error SSE is only for floating-point | ||
56 | #endif | ||
57 | #if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM)) | ||
58 | #error Make up your mind. What CPU do you have? | ||
59 | #endif | ||
60 | #ifdef VORBIS_PSYCHO | ||
61 | #error Vorbis-psy model currently not implemented in fixed-point | ||
62 | #endif | ||
63 | |||
64 | #else | ||
65 | |||
66 | #ifndef FLOATING_POINT | ||
67 | #error You now need to define either FIXED_POINT or FLOATING_POINT | ||
68 | #endif | ||
69 | #if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) | ||
70 | #error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? | ||
71 | #endif | ||
72 | #ifdef FIXED_POINT_DEBUG | ||
73 | #error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?" | ||
74 | #endif | ||
75 | |||
76 | |||
77 | #endif | ||
78 | |||
79 | #ifndef OUTSIDE_SPEEX | ||
80 | #include "speex/speex_types.h" | ||
81 | #endif | ||
82 | |||
83 | #undef ABS | ||
84 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ | ||
85 | #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ | ||
86 | #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ | ||
87 | #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ | ||
88 | #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ | ||
89 | #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ | ||
90 | #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ | ||
91 | |||
92 | #ifdef FIXED_POINT | ||
93 | |||
94 | typedef spx_int16_t spx_word16_t; | ||
95 | typedef spx_int32_t spx_word32_t; | ||
96 | typedef spx_word32_t spx_mem_t; | ||
97 | typedef spx_word16_t spx_coef_t; | ||
98 | typedef spx_word16_t spx_lsp_t; | ||
99 | typedef spx_word32_t spx_sig_t; | ||
100 | |||
101 | #define Q15ONE 32767 | ||
102 | |||
103 | #define LPC_SCALING 8192 | ||
104 | #define SIG_SCALING 16384 | ||
105 | #define LSP_SCALING 8192. | ||
106 | #define GAMMA_SCALING 32768. | ||
107 | #define GAIN_SCALING 64 | ||
108 | #define GAIN_SCALING_1 0.015625 | ||
109 | |||
110 | #define LPC_SHIFT 13 | ||
111 | #define LSP_SHIFT 13 | ||
112 | #define SIG_SHIFT 14 | ||
113 | #define GAIN_SHIFT 6 | ||
114 | |||
115 | #define VERY_SMALL 0 | ||
116 | #define VERY_LARGE32 ((spx_word32_t)2147483647) | ||
117 | #define VERY_LARGE16 ((spx_word16_t)32767) | ||
118 | #define Q15_ONE ((spx_word16_t)32767) | ||
119 | |||
120 | |||
121 | #ifdef FIXED_DEBUG | ||
122 | #include "fixed_debug.h" | ||
123 | #else | ||
124 | |||
125 | #include "fixed_generic.h" | ||
126 | |||
127 | #ifdef ARM5E_ASM | ||
128 | #include "fixed_arm5e.h" | ||
129 | #elif defined (ARM4_ASM) | ||
130 | #include "fixed_arm4.h" | ||
131 | #elif defined (BFIN_ASM) | ||
132 | #include "fixed_bfin.h" | ||
133 | #endif | ||
134 | |||
135 | #endif | ||
136 | |||
137 | |||
138 | #else | ||
139 | |||
140 | typedef float spx_mem_t; | ||
141 | typedef float spx_coef_t; | ||
142 | typedef float spx_lsp_t; | ||
143 | typedef float spx_sig_t; | ||
144 | typedef float spx_word16_t; | ||
145 | typedef float spx_word32_t; | ||
146 | |||
147 | #define Q15ONE 1.0f | ||
148 | #define LPC_SCALING 1.f | ||
149 | #define SIG_SCALING 1.f | ||
150 | #define LSP_SCALING 1.f | ||
151 | #define GAMMA_SCALING 1.f | ||
152 | #define GAIN_SCALING 1.f | ||
153 | #define GAIN_SCALING_1 1.f | ||
154 | |||
155 | |||
156 | #define VERY_SMALL 1e-15f | ||
157 | #define VERY_LARGE32 1e15f | ||
158 | #define VERY_LARGE16 1e15f | ||
159 | #define Q15_ONE ((spx_word16_t)1.f) | ||
160 | |||
161 | #define QCONST16(x,bits) (x) | ||
162 | #define QCONST32(x,bits) (x) | ||
163 | |||
164 | #define NEG16(x) (-(x)) | ||
165 | #define NEG32(x) (-(x)) | ||
166 | #define EXTRACT16(x) (x) | ||
167 | #define EXTEND32(x) (x) | ||
168 | #define SHR16(a,shift) (a) | ||
169 | #define SHL16(a,shift) (a) | ||
170 | #define SHR32(a,shift) (a) | ||
171 | #define SHL32(a,shift) (a) | ||
172 | #define PSHR16(a,shift) (a) | ||
173 | #define PSHR32(a,shift) (a) | ||
174 | #define VSHR32(a,shift) (a) | ||
175 | #define SATURATE16(x,a) (x) | ||
176 | #define SATURATE32(x,a) (x) | ||
177 | |||
178 | #define PSHR(a,shift) (a) | ||
179 | #define SHR(a,shift) (a) | ||
180 | #define SHL(a,shift) (a) | ||
181 | #define SATURATE(x,a) (x) | ||
182 | |||
183 | #define ADD16(a,b) ((a)+(b)) | ||
184 | #define SUB16(a,b) ((a)-(b)) | ||
185 | #define ADD32(a,b) ((a)+(b)) | ||
186 | #define SUB32(a,b) ((a)-(b)) | ||
187 | #define MULT16_16_16(a,b) ((a)*(b)) | ||
188 | #define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) | ||
189 | #define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) | ||
190 | |||
191 | #define MULT16_32_Q11(a,b) ((a)*(b)) | ||
192 | #define MULT16_32_Q13(a,b) ((a)*(b)) | ||
193 | #define MULT16_32_Q14(a,b) ((a)*(b)) | ||
194 | #define MULT16_32_Q15(a,b) ((a)*(b)) | ||
195 | #define MULT16_32_P15(a,b) ((a)*(b)) | ||
196 | |||
197 | #define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) | ||
198 | #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) | ||
199 | |||
200 | #define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) | ||
201 | #define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) | ||
202 | #define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) | ||
203 | #define MULT16_16_Q11_32(a,b) ((a)*(b)) | ||
204 | #define MULT16_16_Q13(a,b) ((a)*(b)) | ||
205 | #define MULT16_16_Q14(a,b) ((a)*(b)) | ||
206 | #define MULT16_16_Q15(a,b) ((a)*(b)) | ||
207 | #define MULT16_16_P15(a,b) ((a)*(b)) | ||
208 | #define MULT16_16_P13(a,b) ((a)*(b)) | ||
209 | #define MULT16_16_P14(a,b) ((a)*(b)) | ||
210 | |||
211 | #define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) | ||
212 | #define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) | ||
213 | #define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) | ||
214 | #define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) | ||
215 | |||
216 | |||
217 | #endif | ||
218 | |||
219 | |||
220 | #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) | ||
221 | |||
222 | /* 2 on TI C5x DSP */ | ||
223 | #define BYTES_PER_CHAR 2 | ||
224 | #define BITS_PER_CHAR 16 | ||
225 | #define LOG2_BITS_PER_CHAR 4 | ||
226 | |||
227 | #else | ||
228 | |||
229 | #define BYTES_PER_CHAR 1 | ||
230 | #define BITS_PER_CHAR 8 | ||
231 | #define LOG2_BITS_PER_CHAR 3 | ||
232 | |||
233 | #endif | ||
234 | |||
235 | |||
236 | |||
237 | #ifdef FIXED_DEBUG | ||
238 | long long spx_mips=0; | ||
239 | #endif | ||
240 | |||
241 | |||
242 | #endif | ||