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