Mercurial > mplayer.hg
annotate libfaad2/common.h @ 11348:e740b4a7a194
cosmetics
author | diego |
---|---|
date | Fri, 31 Oct 2003 23:00:45 +0000 |
parents | 3185f64f6350 |
children | 4a370c80fe5c |
rev | line source |
---|---|
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 | |
10805
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
112 #if 0 |
10725 | 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; | |
10805
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
121 #else |
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
122 #include <inttypes.h> |
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
123 #endif |
10725 | 124 typedef float float32_t; |
125 | |
126 | |
127 #else | |
128 | |
129 /* Define if needed */ | |
130 /* #undef HAVE_FLOAT32_T */ | |
131 | |
132 /* Define if you have the <inttypes.h> header file. */ | |
133 #define HAVE_INTTYPES_H 1 | |
134 | |
135 /* Define if you have the `memcpy' function. */ | |
136 #define HAVE_MEMCPY 1 | |
137 | |
138 /* Define if you have the <stdint.h> header file. */ | |
139 #define HAVE_STDINT_H 1 | |
140 | |
141 /* Define if you have the `strchr' function. */ | |
142 #define HAVE_STRCHR 1 | |
143 | |
144 /* Define if you have the ANSI C header files. */ | |
145 #define STDC_HEADERS 1 | |
146 | |
147 | |
148 | |
149 #include <stdio.h> | |
150 #if HAVE_SYS_TYPES_H | |
151 # include <sys/types.h> | |
152 #endif | |
153 #if HAVE_SYS_STAT_H | |
154 # include <sys/stat.h> | |
155 #endif | |
156 #if STDC_HEADERS | |
157 # include <stdlib.h> | |
158 # include <stddef.h> | |
159 #else | |
160 # if HAVE_STDLIB_H | |
161 # include <stdlib.h> | |
162 # endif | |
163 #endif | |
164 #if HAVE_STRING_H | |
165 # if !STDC_HEADERS && HAVE_MEMORY_H | |
166 # include <memory.h> | |
167 # endif | |
168 # include <string.h> | |
169 #endif | |
170 #if HAVE_STRINGS_H | |
171 # include <strings.h> | |
172 #endif | |
173 #if HAVE_INTTYPES_H | |
174 # include <inttypes.h> | |
175 #else | |
176 # if HAVE_STDINT_H | |
177 # include <stdint.h> | |
178 # else | |
179 /* we need these... */ | |
180 typedef unsigned long long uint64_t; | |
181 typedef unsigned long uint32_t; | |
182 typedef unsigned short uint16_t; | |
183 typedef unsigned char uint8_t; | |
184 typedef long long int64_t; | |
185 typedef long int32_t; | |
186 typedef short int16_t; | |
187 typedef char int8_t; | |
188 # endif | |
189 #endif | |
190 #if HAVE_UNISTD_H | |
191 # include <unistd.h> | |
192 #endif | |
193 | |
194 #ifndef HAVE_FLOAT32_T | |
195 typedef float float32_t; | |
196 #endif | |
197 | |
198 #if STDC_HEADERS | |
199 # include <string.h> | |
200 #else | |
201 # if !HAVE_STRCHR | |
202 # define strchr index | |
203 # define strrchr rindex | |
204 # endif | |
205 char *strchr(), *strrchr(); | |
206 # if !HAVE_MEMCPY | |
207 # define memcpy(d, s, n) bcopy((s), (d), (n)) | |
208 # define memmove(d, s, n) bcopy((s), (d), (n)) | |
209 # endif | |
210 #endif | |
211 | |
212 #endif | |
213 | |
214 #ifdef WORDS_BIGENDIAN | |
215 #define ARCH_IS_BIG_ENDIAN | |
216 #endif | |
217 | |
218 /* FIXED_POINT doesn't work with MAIN and SSR yet */ | |
219 #ifdef FIXED_POINT | |
220 #undef MAIN_DEC | |
221 #undef SSR_DEC | |
222 #endif | |
223 | |
224 | |
225 #if defined(FIXED_POINT) | |
226 | |
227 #ifdef HAS_MATHF_H | |
228 #include <mathf.h> | |
229 #else | |
230 #include <math.h> | |
231 #endif | |
232 | |
233 #include "fixed.h" | |
234 | |
235 #elif defined(USE_DOUBLE_PRECISION) | |
236 | |
237 typedef double real_t; | |
238 | |
239 #include <math.h> | |
240 | |
241 #define MUL(A,B) ((A)*(B)) | |
242 #define MUL_C_C(A,B) ((A)*(B)) | |
243 #define MUL_R_C(A,B) ((A)*(B)) | |
244 | |
10989 | 245 #define REAL_CONST(A) ((real_t)(A)) |
246 #define COEF_CONST(A) ((real_t)(A)) | |
10725 | 247 |
248 #else /* Normal floating point operation */ | |
249 | |
250 typedef float real_t; | |
251 | |
252 #define MUL(A,B) ((A)*(B)) | |
253 #define MUL_C_C(A,B) ((A)*(B)) | |
254 #define MUL_R_C(A,B) ((A)*(B)) | |
255 | |
10989 | 256 #define REAL_CONST(A) ((real_t)(A)) |
257 #define COEF_CONST(A) ((real_t)(A)) | |
10725 | 258 |
259 #ifdef __ICL /* only Intel C compiler has fmath ??? */ | |
260 | |
261 #include <mathf.h> | |
262 | |
263 #define sin sinf | |
264 #define cos cosf | |
265 #define log logf | |
266 #define floor floorf | |
267 #define ceil ceilf | |
268 #define sqrt sqrtf | |
269 | |
270 #else | |
271 | |
272 #include <math.h> | |
273 | |
274 #ifdef HAVE_SINF | |
275 # define sin sinf | |
276 #error | |
277 #endif | |
278 #ifdef HAVE_COSF | |
279 # define cos cosf | |
280 #endif | |
281 #ifdef HAVE_LOGF | |
282 # define log logf | |
283 #endif | |
284 #ifdef HAVE_EXPF | |
285 # define exp expf | |
286 #endif | |
287 #ifdef HAVE_FLOORF | |
288 # define floor floorf | |
289 #endif | |
290 #ifdef HAVE_CEILF | |
291 # define ceil ceilf | |
292 #endif | |
293 #ifdef HAVE_SQRTF | |
294 # define sqrt sqrtf | |
295 #endif | |
296 | |
297 #endif | |
298 | |
299 #endif | |
300 | |
301 typedef real_t complex_t[2]; | |
302 #define RE(A) A[0] | |
303 #define IM(A) A[1] | |
304 | |
305 | |
306 /* common functions */ | |
307 int32_t int_log2(int32_t val); | |
308 uint32_t random_int(void); | |
309 uint8_t get_sr_index(uint32_t samplerate); | |
10989 | 310 uint32_t get_sample_rate(uint8_t sr_index); |
10725 | 311 int8_t can_decode_ot(uint8_t object_type); |
312 | |
313 #ifndef M_PI | |
314 #define M_PI 3.14159265358979323846f | |
315 #endif | |
316 #ifndef M_PI_2 /* PI/2 */ | |
317 #define M_PI_2 1.57079632679489661923 | |
318 #endif | |
319 | |
320 | |
321 #ifdef __cplusplus | |
322 } | |
323 #endif | |
324 #endif |