10725
|
1 /*
|
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
|
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
|
|
4 **
|
|
5 ** This program is free software; you can redistribute it and/or modify
|
|
6 ** it under the terms of the GNU General Public License as published by
|
|
7 ** the Free Software Foundation; either version 2 of the License, or
|
|
8 ** (at your option) any later version.
|
|
9 **
|
|
10 ** This program is distributed in the hope that it will be useful,
|
|
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ** GNU General Public License for more details.
|
|
14 **
|
|
15 ** You should have received a copy of the GNU General Public License
|
|
16 ** along with this program; if not, write to the Free Software
|
|
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
18 **
|
|
19 ** Any non-GPL usage of this software or parts of this software is strictly
|
|
20 ** forbidden.
|
|
21 **
|
|
22 ** Commercial non-GPL licensing of this software is possible.
|
|
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
|
|
24 **
|
|
25 ** $Id$
|
|
26 **/
|
|
27
|
|
28 #ifndef __COMMON_H__
|
|
29 #define __COMMON_H__
|
|
30
|
|
31 #ifdef __cplusplus
|
|
32 extern "C" {
|
|
33 #endif
|
|
34
|
|
35 # include "../config.h"
|
|
36
|
|
37 #define INLINE __inline
|
|
38
|
|
39 #ifndef max
|
|
40 #define max(a, b) (((a) > (b)) ? (a) : (b))
|
|
41 #endif
|
|
42 #ifndef min
|
|
43 #define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
44 #endif
|
|
45
|
|
46
|
|
47 /* COMPILE TIME DEFINITIONS */
|
|
48
|
|
49 /* use double precision */
|
|
50 /* #define USE_DOUBLE_PRECISION */
|
|
51 /* use fixed point reals */
|
|
52 //#define FIXED_POINT
|
|
53
|
|
54 #define ERROR_RESILIENCE
|
|
55
|
|
56
|
|
57 /* Allow decoding of MAIN profile AAC */
|
|
58 #define MAIN_DEC
|
|
59 /* Allow decoding of SSR profile AAC */
|
|
60 //#define SSR_DEC
|
|
61 /* Allow decoding of LTP profile AAC */
|
|
62 #define LTP_DEC
|
|
63 /* Allow decoding of LD profile AAC */
|
|
64 #define LD_DEC
|
|
65
|
|
66 /* LD can't do without LTP */
|
|
67 #ifdef LD_DEC
|
|
68 #ifndef ERROR_RESILIENCE
|
|
69 #define ERROR_RESILIENCE
|
|
70 #endif
|
|
71 #ifndef LTP_DEC
|
|
72 #define LTP_DEC
|
|
73 #endif
|
|
74 #endif
|
|
75
|
|
76
|
|
77 #define SBR_DEC
|
|
78 //#define SBR_LOW_POWER
|
|
79
|
|
80 #ifdef FIXED_POINT
|
|
81 #ifndef SBR_LOW_POWER
|
|
82 #define SBR_LOW_POWER
|
|
83 #endif
|
|
84 #endif
|
|
85
|
|
86 #ifdef FIXED_POINT
|
|
87 #define SBR_DIV(A, B) (((int64_t)A << REAL_BITS)/B)
|
|
88 #else
|
|
89 #define SBR_DIV(A, B) ((A)/(B))
|
|
90 #endif
|
|
91
|
|
92 #ifndef SBR_LOW_POWER
|
|
93 #define qmf_t complex_t
|
|
94 #define QMF_RE(A) RE(A)
|
|
95 #define QMF_IM(A) IM(A)
|
|
96 #else
|
|
97 #define qmf_t real_t
|
|
98 #define QMF_RE(A) (A)
|
|
99 #define QMF_IM(A) 0
|
|
100 #endif
|
|
101
|
|
102
|
|
103 /* END COMPILE TIME DEFINITIONS */
|
|
104
|
|
105 #ifndef FIXED_POINT
|
|
106 #define POW_TABLE_SIZE 200
|
|
107 #endif
|
|
108
|
|
109
|
|
110 #if defined(_WIN32)
|
|
111
|
|
112
|
|
113 typedef unsigned __int64 uint64_t;
|
|
114 typedef unsigned __int32 uint32_t;
|
|
115 typedef unsigned __int16 uint16_t;
|
|
116 typedef unsigned __int8 uint8_t;
|
|
117 typedef __int64 int64_t;
|
|
118 typedef __int32 int32_t;
|
|
119 typedef __int16 int16_t;
|
|
120 typedef __int8 int8_t;
|
|
121 typedef float float32_t;
|
|
122
|
|
123
|
|
124 #else
|
|
125
|
|
126 /* Define if needed */
|
|
127 /* #undef HAVE_FLOAT32_T */
|
|
128
|
|
129 /* Define if you have the <inttypes.h> header file. */
|
|
130 #define HAVE_INTTYPES_H 1
|
|
131
|
|
132 /* Define if you have the `memcpy' function. */
|
|
133 #define HAVE_MEMCPY 1
|
|
134
|
|
135 /* Define if you have the <stdint.h> header file. */
|
|
136 #define HAVE_STDINT_H 1
|
|
137
|
|
138 /* Define if you have the `strchr' function. */
|
|
139 #define HAVE_STRCHR 1
|
|
140
|
|
141 /* Define if you have the ANSI C header files. */
|
|
142 #define STDC_HEADERS 1
|
|
143
|
|
144
|
|
145
|
|
146 #include <stdio.h>
|
|
147 #if HAVE_SYS_TYPES_H
|
|
148 # include <sys/types.h>
|
|
149 #endif
|
|
150 #if HAVE_SYS_STAT_H
|
|
151 # include <sys/stat.h>
|
|
152 #endif
|
|
153 #if STDC_HEADERS
|
|
154 # include <stdlib.h>
|
|
155 # include <stddef.h>
|
|
156 #else
|
|
157 # if HAVE_STDLIB_H
|
|
158 # include <stdlib.h>
|
|
159 # endif
|
|
160 #endif
|
|
161 #if HAVE_STRING_H
|
|
162 # if !STDC_HEADERS && HAVE_MEMORY_H
|
|
163 # include <memory.h>
|
|
164 # endif
|
|
165 # include <string.h>
|
|
166 #endif
|
|
167 #if HAVE_STRINGS_H
|
|
168 # include <strings.h>
|
|
169 #endif
|
|
170 #if HAVE_INTTYPES_H
|
|
171 # include <inttypes.h>
|
|
172 #else
|
|
173 # if HAVE_STDINT_H
|
|
174 # include <stdint.h>
|
|
175 # else
|
|
176 /* we need these... */
|
|
177 typedef unsigned long long uint64_t;
|
|
178 typedef unsigned long uint32_t;
|
|
179 typedef unsigned short uint16_t;
|
|
180 typedef unsigned char uint8_t;
|
|
181 typedef long long int64_t;
|
|
182 typedef long int32_t;
|
|
183 typedef short int16_t;
|
|
184 typedef char int8_t;
|
|
185 # endif
|
|
186 #endif
|
|
187 #if HAVE_UNISTD_H
|
|
188 # include <unistd.h>
|
|
189 #endif
|
|
190
|
|
191 #ifndef HAVE_FLOAT32_T
|
|
192 typedef float float32_t;
|
|
193 #endif
|
|
194
|
|
195 #if STDC_HEADERS
|
|
196 # include <string.h>
|
|
197 #else
|
|
198 # if !HAVE_STRCHR
|
|
199 # define strchr index
|
|
200 # define strrchr rindex
|
|
201 # endif
|
|
202 char *strchr(), *strrchr();
|
|
203 # if !HAVE_MEMCPY
|
|
204 # define memcpy(d, s, n) bcopy((s), (d), (n))
|
|
205 # define memmove(d, s, n) bcopy((s), (d), (n))
|
|
206 # endif
|
|
207 #endif
|
|
208
|
|
209 #endif
|
|
210
|
|
211 #ifdef WORDS_BIGENDIAN
|
|
212 #define ARCH_IS_BIG_ENDIAN
|
|
213 #endif
|
|
214
|
|
215 /* FIXED_POINT doesn't work with MAIN and SSR yet */
|
|
216 #ifdef FIXED_POINT
|
|
217 #undef MAIN_DEC
|
|
218 #undef SSR_DEC
|
|
219 #endif
|
|
220
|
|
221
|
|
222 #if defined(FIXED_POINT)
|
|
223
|
|
224 #ifdef HAS_MATHF_H
|
|
225 #include <mathf.h>
|
|
226 #else
|
|
227 #include <math.h>
|
|
228 #endif
|
|
229
|
|
230 #include "fixed.h"
|
|
231
|
|
232 #elif defined(USE_DOUBLE_PRECISION)
|
|
233
|
|
234 typedef double real_t;
|
|
235
|
|
236 #include <math.h>
|
|
237
|
|
238 #define MUL(A,B) ((A)*(B))
|
|
239 #define MUL_C_C(A,B) ((A)*(B))
|
|
240 #define MUL_R_C(A,B) ((A)*(B))
|
|
241
|
|
242 #define REAL_CONST(A) ((real_t)A)
|
|
243 #define COEF_CONST(A) ((real_t)A)
|
|
244
|
|
245 #else /* Normal floating point operation */
|
|
246
|
|
247 typedef float real_t;
|
|
248
|
|
249 #define MUL(A,B) ((A)*(B))
|
|
250 #define MUL_C_C(A,B) ((A)*(B))
|
|
251 #define MUL_R_C(A,B) ((A)*(B))
|
|
252
|
|
253 #define REAL_CONST(A) ((real_t)A)
|
|
254 #define COEF_CONST(A) ((real_t)A)
|
|
255
|
|
256 #ifdef __ICL /* only Intel C compiler has fmath ??? */
|
|
257
|
|
258 #include <mathf.h>
|
|
259
|
|
260 #define sin sinf
|
|
261 #define cos cosf
|
|
262 #define log logf
|
|
263 #define floor floorf
|
|
264 #define ceil ceilf
|
|
265 #define sqrt sqrtf
|
|
266
|
|
267 #else
|
|
268
|
|
269 #include <math.h>
|
|
270
|
|
271 #ifdef HAVE_SINF
|
|
272 # define sin sinf
|
|
273 #error
|
|
274 #endif
|
|
275 #ifdef HAVE_COSF
|
|
276 # define cos cosf
|
|
277 #endif
|
|
278 #ifdef HAVE_LOGF
|
|
279 # define log logf
|
|
280 #endif
|
|
281 #ifdef HAVE_EXPF
|
|
282 # define exp expf
|
|
283 #endif
|
|
284 #ifdef HAVE_FLOORF
|
|
285 # define floor floorf
|
|
286 #endif
|
|
287 #ifdef HAVE_CEILF
|
|
288 # define ceil ceilf
|
|
289 #endif
|
|
290 #ifdef HAVE_SQRTF
|
|
291 # define sqrt sqrtf
|
|
292 #endif
|
|
293
|
|
294 #endif
|
|
295
|
|
296 #endif
|
|
297
|
|
298 typedef real_t complex_t[2];
|
|
299 #define RE(A) A[0]
|
|
300 #define IM(A) A[1]
|
|
301
|
|
302
|
|
303 /* common functions */
|
|
304 int32_t int_log2(int32_t val);
|
|
305 uint32_t random_int(void);
|
|
306 uint8_t get_sr_index(uint32_t samplerate);
|
|
307 int8_t can_decode_ot(uint8_t object_type);
|
|
308
|
|
309 #ifndef M_PI
|
|
310 #define M_PI 3.14159265358979323846f
|
|
311 #endif
|
|
312 #ifndef M_PI_2 /* PI/2 */
|
|
313 #define M_PI_2 1.57079632679489661923
|
|
314 #endif
|
|
315
|
|
316
|
|
317 #ifdef __cplusplus
|
|
318 }
|
|
319 #endif
|
|
320 #endif
|