Mercurial > mplayer.hg
annotate libfaad2/common.h @ 25882:2ad528dd42a0
Make some assembler constants global instead of declaring them multiple times.
author | reimar |
---|---|
date | Tue, 29 Jan 2008 14:58:10 +0000 |
parents | 1ac62a61ea56 |
children | 1a5cd79b2e6e |
rev | line source |
---|---|
10725 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
12527 | 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
4 ** | |
10725 | 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. | |
12527 | 9 ** |
10725 | 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. | |
12527 | 14 ** |
10725 | 15 ** You should have received a copy of the GNU General Public License |
12527 | 16 ** along with this program; if not, write to the Free Software |
10725 | 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 ** | |
12625
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
10725 | 26 ** $Id$ |
18783 | 27 ** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
14731 | 28 ** local_changes.diff contains the exact changes to this file. |
10725 | 29 **/ |
30 | |
31 #ifndef __COMMON_H__ | |
32 #define __COMMON_H__ | |
33 | |
34 #ifdef __cplusplus | |
35 extern "C" { | |
36 #endif | |
37 | |
24023 | 38 #ifdef HAVE_CONFIG_H |
39 # include "../config.h" | |
40 #endif | |
41 | |
14729
b4378a6f87a6
Sync missing cosmetics from the 2004-07-12 CVS snapshot.
diego
parents:
13685
diff
changeset
|
42 /* Allow build on Cygwin*/ |
12527 | 43 #if defined(__CYGWIN__) |
44 #define __STRICT_ANSI__ | |
45 #endif | |
10725 | 46 |
47 #define INLINE __inline | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
48 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) |
12527 | 49 #define ALIGN __declspec(align(16)) |
50 #else | |
51 #define ALIGN | |
52 #endif | |
10725 | 53 |
54 #ifndef max | |
55 #define max(a, b) (((a) > (b)) ? (a) : (b)) | |
56 #endif | |
57 #ifndef min | |
58 #define min(a, b) (((a) < (b)) ? (a) : (b)) | |
59 #endif | |
60 | |
61 /* COMPILE TIME DEFINITIONS */ | |
62 | |
63 /* use double precision */ | |
64 /* #define USE_DOUBLE_PRECISION */ | |
65 /* use fixed point reals */ | |
66 //#define FIXED_POINT | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
67 //#define BIG_IQ_TABLE |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
68 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
69 /* Use if target platform has address generators with autoincrement */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
70 //#define PREFER_POINTERS |
10725 | 71 |
16230
ba7a79482bec
prefer FIXED_POINT for ARM - patch by AGAWA Koji <i at atty.sakura.ne.jp>
alex
parents:
15593
diff
changeset
|
72 #if defined(_WIN32_WCE) || defined(__arm__) |
12527 | 73 #define FIXED_POINT |
74 #endif | |
75 | |
76 | |
10725 | 77 #define ERROR_RESILIENCE |
78 | |
79 | |
80 /* Allow decoding of MAIN profile AAC */ | |
81 #define MAIN_DEC | |
82 /* Allow decoding of SSR profile AAC */ | |
83 //#define SSR_DEC | |
84 /* Allow decoding of LTP profile AAC */ | |
85 #define LTP_DEC | |
86 /* Allow decoding of LD profile AAC */ | |
87 #define LD_DEC | |
12527 | 88 /* Allow decoding of scalable profiles */ |
89 //#define SCALABLE_DEC | |
90 /* Allow decoding of Digital Radio Mondiale (DRM) */ | |
91 //#define DRM | |
92 //#define DRM_PS | |
10725 | 93 |
94 /* LD can't do without LTP */ | |
95 #ifdef LD_DEC | |
96 #ifndef ERROR_RESILIENCE | |
97 #define ERROR_RESILIENCE | |
98 #endif | |
99 #ifndef LTP_DEC | |
100 #define LTP_DEC | |
101 #endif | |
102 #endif | |
103 | |
12527 | 104 #define ALLOW_SMALL_FRAMELENGTH |
105 | |
106 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
107 // Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC) |
12527 | 108 //#define LC_ONLY_DECODER |
109 #ifdef LC_ONLY_DECODER | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
110 #undef LD_DEC |
12527 | 111 #undef LTP_DEC |
112 #undef MAIN_DEC | |
113 #undef SSR_DEC | |
114 #undef DRM | |
115 #undef ALLOW_SMALL_FRAMELENGTH | |
116 #undef ERROR_RESILIENCE | |
117 #endif | |
10725 | 118 |
119 #define SBR_DEC | |
120 //#define SBR_LOW_POWER | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
121 #define PS_DEC |
10725 | 122 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
123 /* FIXED POINT: No MAIN decoding */ |
10725 | 124 #ifdef FIXED_POINT |
12527 | 125 # ifdef MAIN_DEC |
126 # undef MAIN_DEC | |
127 # endif | |
13485
93a84777a6b5
SBR code does NOT work with fixed point (uses floats, slow as hell)
rfelker
parents:
13453
diff
changeset
|
128 # ifdef SBR_DEC |
93a84777a6b5
SBR code does NOT work with fixed point (uses floats, slow as hell)
rfelker
parents:
13453
diff
changeset
|
129 # undef SBR_DEC |
93a84777a6b5
SBR code does NOT work with fixed point (uses floats, slow as hell)
rfelker
parents:
13453
diff
changeset
|
130 # endif |
12527 | 131 #endif // FIXED_POINT |
132 | |
133 #ifdef DRM | |
134 # ifndef SCALABLE_DEC | |
135 # define SCALABLE_DEC | |
136 # endif | |
137 #endif | |
138 | |
10725 | 139 |
140 #ifdef FIXED_POINT | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
141 #define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
142 #define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B) |
10725 | 143 #else |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
144 #define DIV_R(A, B) ((A)/(B)) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
145 #define DIV_C(A, B) ((A)/(B)) |
10725 | 146 #endif |
147 | |
148 #ifndef SBR_LOW_POWER | |
149 #define qmf_t complex_t | |
150 #define QMF_RE(A) RE(A) | |
151 #define QMF_IM(A) IM(A) | |
152 #else | |
153 #define qmf_t real_t | |
154 #define QMF_RE(A) (A) | |
12527 | 155 #define QMF_IM(A) |
10725 | 156 #endif |
157 | |
158 | |
159 /* END COMPILE TIME DEFINITIONS */ | |
160 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
161 #if defined(_WIN32) && !defined(__MINGW32__) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
162 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
163 #include <stdlib.h> |
10725 | 164 |
10805
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
165 #if 0 |
10725 | 166 typedef unsigned __int64 uint64_t; |
167 typedef unsigned __int32 uint32_t; | |
168 typedef unsigned __int16 uint16_t; | |
169 typedef unsigned __int8 uint8_t; | |
170 typedef __int64 int64_t; | |
171 typedef __int32 int32_t; | |
172 typedef __int16 int16_t; | |
173 typedef __int8 int8_t; | |
10805
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
174 #else |
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
175 #include <inttypes.h> |
125a35fc47a5
fixed win32 compile problems and broken bigendian support
alex
parents:
10725
diff
changeset
|
176 #endif |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
177 |
10725 | 178 typedef float float32_t; |
179 | |
180 | |
181 #else | |
182 | |
183 #include <stdio.h> | |
184 #if HAVE_SYS_TYPES_H | |
185 # include <sys/types.h> | |
186 #endif | |
187 #if HAVE_SYS_STAT_H | |
188 # include <sys/stat.h> | |
189 #endif | |
190 #if STDC_HEADERS | |
191 # include <stdlib.h> | |
192 # include <stddef.h> | |
193 #else | |
194 # if HAVE_STDLIB_H | |
195 # include <stdlib.h> | |
196 # endif | |
197 #endif | |
198 #if HAVE_STRING_H | |
199 # if !STDC_HEADERS && HAVE_MEMORY_H | |
200 # include <memory.h> | |
201 # endif | |
202 # include <string.h> | |
203 #endif | |
204 #if HAVE_STRINGS_H | |
205 # include <strings.h> | |
206 #endif | |
207 #if HAVE_INTTYPES_H | |
208 # include <inttypes.h> | |
209 #else | |
210 # if HAVE_STDINT_H | |
211 # include <stdint.h> | |
212 # else | |
213 /* we need these... */ | |
214 typedef unsigned long long uint64_t; | |
215 typedef unsigned long uint32_t; | |
216 typedef unsigned short uint16_t; | |
217 typedef unsigned char uint8_t; | |
218 typedef long long int64_t; | |
219 typedef long int32_t; | |
220 typedef short int16_t; | |
221 typedef char int8_t; | |
222 # endif | |
223 #endif | |
224 #if HAVE_UNISTD_H | |
225 # include <unistd.h> | |
226 #endif | |
227 | |
228 #ifndef HAVE_FLOAT32_T | |
229 typedef float float32_t; | |
230 #endif | |
231 | |
232 #if STDC_HEADERS | |
233 # include <string.h> | |
234 #else | |
235 # if !HAVE_STRCHR | |
236 # define strchr index | |
237 # define strrchr rindex | |
238 # endif | |
239 char *strchr(), *strrchr(); | |
240 # if !HAVE_MEMCPY | |
241 # define memcpy(d, s, n) bcopy((s), (d), (n)) | |
242 # define memmove(d, s, n) bcopy((s), (d), (n)) | |
243 # endif | |
244 #endif | |
245 | |
246 #endif | |
247 | |
248 #ifdef WORDS_BIGENDIAN | |
249 #define ARCH_IS_BIG_ENDIAN | |
250 #endif | |
251 | |
252 /* FIXED_POINT doesn't work with MAIN and SSR yet */ | |
253 #ifdef FIXED_POINT | |
254 #undef MAIN_DEC | |
255 #undef SSR_DEC | |
256 #endif | |
257 | |
258 | |
259 #if defined(FIXED_POINT) | |
260 | |
261 #include "fixed.h" | |
262 | |
263 #elif defined(USE_DOUBLE_PRECISION) | |
264 | |
265 typedef double real_t; | |
266 | |
267 #include <math.h> | |
268 | |
12527 | 269 #define MUL_R(A,B) ((A)*(B)) |
270 #define MUL_C(A,B) ((A)*(B)) | |
271 #define MUL_F(A,B) ((A)*(B)) | |
272 | |
273 /* Complex multiplication */ | |
274 static INLINE void ComplexMult(real_t *y1, real_t *y2, | |
275 real_t x1, real_t x2, real_t c1, real_t c2) | |
276 { | |
277 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); | |
278 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); | |
279 } | |
10725 | 280 |
10989 | 281 #define REAL_CONST(A) ((real_t)(A)) |
282 #define COEF_CONST(A) ((real_t)(A)) | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
283 #define Q2_CONST(A) ((real_t)(A)) |
12527 | 284 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
10725 | 285 |
286 #else /* Normal floating point operation */ | |
287 | |
288 typedef float real_t; | |
289 | |
12527 | 290 #define MUL_R(A,B) ((A)*(B)) |
291 #define MUL_C(A,B) ((A)*(B)) | |
292 #define MUL_F(A,B) ((A)*(B)) | |
10725 | 293 |
10989 | 294 #define REAL_CONST(A) ((real_t)(A)) |
295 #define COEF_CONST(A) ((real_t)(A)) | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
296 #define Q2_CONST(A) ((real_t)(A)) |
12527 | 297 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
298 | |
299 /* Complex multiplication */ | |
300 static INLINE void ComplexMult(real_t *y1, real_t *y2, | |
301 real_t x1, real_t x2, real_t c1, real_t c2) | |
302 { | |
303 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); | |
304 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); | |
305 } | |
306 | |
307 | |
15593 | 308 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(HAVE_LRINTF) |
12527 | 309 #define HAS_LRINTF |
310 static INLINE int lrintf(float f) | |
311 { | |
312 int i; | |
313 __asm | |
314 { | |
315 fld f | |
316 fistp i | |
317 } | |
318 return i; | |
319 } | |
18141 | 320 #elif (defined(__i386__) && defined(__GNUC__)) && !defined(HAVE_LRINTF) |
12527 | 321 #define HAS_LRINTF |
322 // from http://www.stereopsis.com/FPU.html | |
323 static INLINE int lrintf(float f) | |
324 { | |
325 int i; | |
326 __asm__ __volatile__ ( | |
327 "flds %1 \n\t" | |
328 "fistpl %0 \n\t" | |
329 : "=m" (i) | |
330 : "m" (f)); | |
331 return i; | |
332 } | |
333 #endif | |
334 | |
10725 | 335 |
336 #ifdef __ICL /* only Intel C compiler has fmath ??? */ | |
337 | |
338 #include <mathf.h> | |
339 | |
340 #define sin sinf | |
341 #define cos cosf | |
342 #define log logf | |
343 #define floor floorf | |
344 #define ceil ceilf | |
345 #define sqrt sqrtf | |
346 | |
347 #else | |
348 | |
13685 | 349 #include <math.h> |
350 | |
12527 | 351 #ifdef HAVE_LRINTF |
352 # define HAS_LRINTF | |
353 # define _ISOC9X_SOURCE 1 | |
354 # define _ISOC99_SOURCE 1 | |
355 # define __USE_ISOC9X 1 | |
356 # define __USE_ISOC99 1 | |
357 #endif | |
358 | |
10725 | 359 #ifdef HAVE_SINF |
360 # define sin sinf | |
361 #error | |
362 #endif | |
363 #ifdef HAVE_COSF | |
364 # define cos cosf | |
365 #endif | |
366 #ifdef HAVE_LOGF | |
367 # define log logf | |
368 #endif | |
369 #ifdef HAVE_EXPF | |
370 # define exp expf | |
371 #endif | |
372 #ifdef HAVE_FLOORF | |
373 # define floor floorf | |
374 #endif | |
375 #ifdef HAVE_CEILF | |
376 # define ceil ceilf | |
377 #endif | |
378 #ifdef HAVE_SQRTF | |
379 # define sqrt sqrtf | |
380 #endif | |
381 | |
382 #endif | |
383 | |
384 #endif | |
385 | |
12527 | 386 #ifndef HAS_LRINTF |
387 /* standard cast */ | |
388 #define lrintf(f) ((int32_t)(f)) | |
389 #endif | |
390 | |
10725 | 391 typedef real_t complex_t[2]; |
392 #define RE(A) A[0] | |
393 #define IM(A) A[1] | |
394 | |
395 | |
396 /* common functions */ | |
12527 | 397 uint8_t cpu_has_sse(void); |
10725 | 398 uint32_t random_int(void); |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
399 uint32_t ones32(uint32_t x); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
400 uint32_t floor_log2(uint32_t x); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
401 uint32_t wl_min_lzc(uint32_t x); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
402 #ifdef FIXED_POINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
403 #define LOG2_MIN_INF REAL_CONST(-10000) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
404 int32_t log2_int(uint32_t val); |
18141 | 405 int32_t log2_fix(uint32_t val); |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
406 int32_t pow2_int(real_t val); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
407 real_t pow2_fix(real_t val); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
408 #endif |
12527 | 409 uint8_t get_sr_index(const uint32_t samplerate); |
410 uint8_t max_pred_sfb(const uint8_t sr_index); | |
411 uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, | |
412 const uint8_t is_short); | |
413 uint32_t get_sample_rate(const uint8_t sr_index); | |
414 int8_t can_decode_ot(const uint8_t object_type); | |
415 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
416 void *faad_malloc(size_t size); |
12527 | 417 void faad_free(void *b); |
418 | |
419 //#define PROFILE | |
420 #ifdef PROFILE | |
421 static int64_t faad_get_ts() | |
422 { | |
423 __asm | |
424 { | |
425 rdtsc | |
426 } | |
427 } | |
428 #endif | |
10725 | 429 |
430 #ifndef M_PI | |
12527 | 431 #define M_PI 3.14159265358979323846 |
10725 | 432 #endif |
433 #ifndef M_PI_2 /* PI/2 */ | |
434 #define M_PI_2 1.57079632679489661923 | |
435 #endif | |
436 | |
437 | |
438 #ifdef __cplusplus | |
439 } | |
440 #endif | |
441 #endif |