Mercurial > audlegacy
comparison Plugins/Input/aac/libfaad2/common.h @ 1010:29feaace84d0 trunk
[svn] - synchronize audacious-faad with FAAD2 CVS.
author | nenolod |
---|---|
date | Mon, 08 May 2006 06:56:47 -0700 |
parents | bcc2b616017b |
children | 46fa5a29eae1 |
comparison
equal
deleted
inserted
replaced
1009:1008da26c12d | 1010:29feaace84d0 |
---|---|
20 ** forbidden. | 20 ** forbidden. |
21 ** | 21 ** |
22 ** Commercial non-GPL licensing of this software is possible. | 22 ** Commercial non-GPL licensing of this software is possible. |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
24 ** | 24 ** |
25 ** $Id: common.h,v 1.65 2004/09/08 09:43:11 gcp Exp $ | 25 ** $Id: common.h,v 1.50 2004/02/06 12:55:24 menno Exp $ |
26 **/ | 26 **/ |
27 | 27 |
28 #ifndef __COMMON_H__ | 28 #ifndef __COMMON_H__ |
29 #define __COMMON_H__ | 29 #define __COMMON_H__ |
30 | 30 |
31 #ifdef __cplusplus | 31 #ifdef __cplusplus |
32 extern "C" { | 32 extern "C" { |
33 #endif | 33 #endif |
34 | 34 |
35 #ifdef HAVE_CONFIG_H | |
36 # include "config.h" | |
37 #endif | |
38 | |
39 #define INLINE __inline | 35 #define INLINE __inline |
40 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) | 36 #if defined(_WIN32) && !defined(_WIN32_WCE) |
41 #define ALIGN __declspec(align(16)) | 37 #define ALIGN __declspec(align(16)) |
42 #else | 38 #else |
43 #define ALIGN | 39 #define ALIGN |
44 #endif | 40 #endif |
45 | 41 |
54 | 50 |
55 /* use double precision */ | 51 /* use double precision */ |
56 /* #define USE_DOUBLE_PRECISION */ | 52 /* #define USE_DOUBLE_PRECISION */ |
57 /* use fixed point reals */ | 53 /* use fixed point reals */ |
58 //#define FIXED_POINT | 54 //#define FIXED_POINT |
59 //#define BIG_IQ_TABLE | |
60 | |
61 /* Use if target platform has address generators with autoincrement */ | |
62 //#define PREFER_POINTERS | |
63 | 55 |
64 #ifdef _WIN32_WCE | 56 #ifdef _WIN32_WCE |
65 #define FIXED_POINT | 57 #define FIXED_POINT |
66 #endif | 58 #endif |
67 | 59 |
94 #endif | 86 #endif |
95 | 87 |
96 #define ALLOW_SMALL_FRAMELENGTH | 88 #define ALLOW_SMALL_FRAMELENGTH |
97 | 89 |
98 | 90 |
99 // Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC) | 91 // Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC) |
100 //#define LC_ONLY_DECODER | 92 //#define LC_ONLY_DECODER |
101 #ifdef LC_ONLY_DECODER | 93 #ifdef LC_ONLY_DECODER |
102 #undef LD_DEC | |
103 #undef LTP_DEC | 94 #undef LTP_DEC |
104 #undef MAIN_DEC | 95 #undef MAIN_DEC |
105 #undef SSR_DEC | 96 #undef SSR_DEC |
106 #undef DRM | 97 #undef DRM |
107 #undef ALLOW_SMALL_FRAMELENGTH | 98 #undef ALLOW_SMALL_FRAMELENGTH |
108 #undef ERROR_RESILIENCE | 99 #undef ERROR_RESILIENCE |
109 #endif | 100 #endif |
110 | 101 |
111 #define SBR_DEC | 102 #define SBR_DEC |
112 //#define SBR_LOW_POWER | 103 //#define SBR_LOW_POWER |
113 #define PS_DEC | 104 //#define PS_DEC |
114 | 105 |
115 /* FIXED POINT: No MAIN decoding */ | 106 /* FIXED POINT: No MAIN decoding, no SBR decoding */ |
116 #ifdef FIXED_POINT | 107 #ifdef FIXED_POINT |
117 # ifdef MAIN_DEC | 108 # ifdef MAIN_DEC |
118 # undef MAIN_DEC | 109 # undef MAIN_DEC |
119 # endif | 110 # endif |
111 //# ifndef SBR_LOW_POWER | |
112 //# define SBR_LOW_POWER | |
113 //# endif | |
114 # ifdef SBR_DEC | |
115 # undef SBR_DEC | |
116 # endif | |
120 #endif // FIXED_POINT | 117 #endif // FIXED_POINT |
121 | 118 |
122 #ifdef DRM | 119 #ifdef DRM |
123 # ifndef SCALABLE_DEC | 120 # ifndef SCALABLE_DEC |
124 # define SCALABLE_DEC | 121 # define SCALABLE_DEC |
125 # endif | 122 # endif |
126 #endif | 123 #endif |
127 | 124 |
125 #if ((defined(_WIN32) && !defined(_WIN32_WCE)) /* || ((__GNUC__ >= 3) && defined(__i386__)) */ ) | |
126 #ifndef FIXED_POINT | |
127 /* includes <xmmintrin.h> to enable SSE intrinsics */ | |
128 //#define USE_SSE | |
129 #endif | |
130 #endif | |
128 | 131 |
129 #ifdef FIXED_POINT | 132 #ifdef FIXED_POINT |
130 #define DIV_R(A, B) (((int64_t)A << REAL_BITS)/B) | 133 #define SBR_DIV(A, B) (((int64_t)A << REAL_BITS)/B) |
131 #define DIV_C(A, B) (((int64_t)A << COEF_BITS)/B) | 134 #else |
132 #else | 135 #define SBR_DIV(A, B) ((A)/(B)) |
133 #define DIV_R(A, B) ((A)/(B)) | |
134 #define DIV_C(A, B) ((A)/(B)) | |
135 #endif | 136 #endif |
136 | 137 |
137 #ifndef SBR_LOW_POWER | 138 #ifndef SBR_LOW_POWER |
138 #define qmf_t complex_t | 139 #define qmf_t complex_t |
139 #define QMF_RE(A) RE(A) | 140 #define QMF_RE(A) RE(A) |
145 #endif | 146 #endif |
146 | 147 |
147 | 148 |
148 /* END COMPILE TIME DEFINITIONS */ | 149 /* END COMPILE TIME DEFINITIONS */ |
149 | 150 |
150 #if defined(_WIN32) && !defined(__MINGW32__) | 151 #if defined(_WIN32) |
151 | 152 |
152 #include <stdlib.h> | |
153 | 153 |
154 typedef unsigned __int64 uint64_t; | 154 typedef unsigned __int64 uint64_t; |
155 typedef unsigned __int32 uint32_t; | 155 typedef unsigned __int32 uint32_t; |
156 typedef unsigned __int16 uint16_t; | 156 typedef unsigned __int16 uint16_t; |
157 typedef unsigned __int8 uint8_t; | 157 typedef unsigned __int8 uint8_t; |
161 typedef __int8 int8_t; | 161 typedef __int8 int8_t; |
162 typedef float float32_t; | 162 typedef float float32_t; |
163 | 163 |
164 | 164 |
165 #else | 165 #else |
166 | |
167 #ifdef HAVE_CONFIG_H | |
168 # include "config.h" | |
169 #endif | |
166 | 170 |
167 #include <stdio.h> | 171 #include <stdio.h> |
168 #if HAVE_SYS_TYPES_H | 172 #if HAVE_SYS_TYPES_H |
169 # include <sys/types.h> | 173 # include <sys/types.h> |
170 #endif | 174 #endif |
262 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); | 266 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); |
263 } | 267 } |
264 | 268 |
265 #define REAL_CONST(A) ((real_t)(A)) | 269 #define REAL_CONST(A) ((real_t)(A)) |
266 #define COEF_CONST(A) ((real_t)(A)) | 270 #define COEF_CONST(A) ((real_t)(A)) |
267 #define Q2_CONST(A) ((real_t)(A)) | |
268 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ | 271 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
269 | 272 |
270 #else /* Normal floating point operation */ | 273 #else /* Normal floating point operation */ |
271 | 274 |
272 typedef float real_t; | 275 typedef float real_t; |
276 | |
277 #ifdef USE_SSE | |
278 # include <xmmintrin.h> | |
279 #endif | |
273 | 280 |
274 #define MUL_R(A,B) ((A)*(B)) | 281 #define MUL_R(A,B) ((A)*(B)) |
275 #define MUL_C(A,B) ((A)*(B)) | 282 #define MUL_C(A,B) ((A)*(B)) |
276 #define MUL_F(A,B) ((A)*(B)) | 283 #define MUL_F(A,B) ((A)*(B)) |
277 | 284 |
278 #define REAL_CONST(A) ((real_t)(A)) | 285 #define REAL_CONST(A) ((real_t)(A)) |
279 #define COEF_CONST(A) ((real_t)(A)) | 286 #define COEF_CONST(A) ((real_t)(A)) |
280 #define Q2_CONST(A) ((real_t)(A)) | |
281 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ | 287 #define FRAC_CONST(A) ((real_t)(A)) /* pure fractional part */ |
282 | 288 |
283 /* Complex multiplication */ | 289 /* Complex multiplication */ |
284 static INLINE void ComplexMult(real_t *y1, real_t *y2, | 290 static INLINE void ComplexMult(real_t *y1, real_t *y2, |
285 real_t x1, real_t x2, real_t c1, real_t c2) | 291 real_t x1, real_t x2, real_t c1, real_t c2) |
287 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); | 293 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); |
288 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); | 294 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); |
289 } | 295 } |
290 | 296 |
291 | 297 |
298 #ifdef _WIN32 | |
299 #define HAS_LRINTF | |
300 static INLINE int lrintf(float f) | |
301 { | |
302 int i; | |
303 __asm | |
304 { | |
305 fld f | |
306 fistp i | |
307 } | |
308 return i; | |
309 } | |
310 #elif (defined(__i386__) && defined(__GNUC__)) | |
311 #define HAS_LRINTF | |
312 // from http://www.stereopsis.com/FPU.html | |
313 static INLINE int lrintf(float f) | |
314 { | |
315 int i; | |
316 __asm__ __volatile__ ( | |
317 "flds %1 \n\t" | |
318 "fistpl %0 \n\t" | |
319 : "=m" (i) | |
320 : "m" (f)); | |
321 return i; | |
322 } | |
323 #endif | |
324 | |
325 | |
292 #ifdef __ICL /* only Intel C compiler has fmath ??? */ | 326 #ifdef __ICL /* only Intel C compiler has fmath ??? */ |
293 | 327 |
294 #include <mathf.h> | 328 #include <mathf.h> |
295 | 329 |
296 #define sin sinf | 330 #define sin sinf |
350 | 384 |
351 | 385 |
352 /* common functions */ | 386 /* common functions */ |
353 uint8_t cpu_has_sse(void); | 387 uint8_t cpu_has_sse(void); |
354 uint32_t random_int(void); | 388 uint32_t random_int(void); |
355 uint32_t ones32(uint32_t x); | |
356 uint32_t floor_log2(uint32_t x); | |
357 uint32_t wl_min_lzc(uint32_t x); | |
358 #ifdef FIXED_POINT | |
359 #define LOG2_MIN_INF REAL_CONST(-10000) | |
360 int32_t log2_int(uint32_t val); | |
361 int32_t log2_fix(uint32_t val); | |
362 int32_t pow2_int(real_t val); | |
363 real_t pow2_fix(real_t val); | |
364 #endif | |
365 uint8_t get_sr_index(const uint32_t samplerate); | 389 uint8_t get_sr_index(const uint32_t samplerate); |
366 uint8_t max_pred_sfb(const uint8_t sr_index); | 390 uint8_t max_pred_sfb(const uint8_t sr_index); |
367 uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, | 391 uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, |
368 const uint8_t is_short); | 392 const uint8_t is_short); |
369 uint32_t get_sample_rate(const uint8_t sr_index); | 393 uint32_t get_sample_rate(const uint8_t sr_index); |
370 int8_t can_decode_ot(const uint8_t object_type); | 394 int8_t can_decode_ot(const uint8_t object_type); |
371 | 395 |
372 void *faad_malloc(size_t size); | 396 void *faad_malloc(int32_t size); |
373 void faad_free(void *b); | 397 void faad_free(void *b); |
374 | 398 |
375 //#define PROFILE | 399 //#define PROFILE |
376 #ifdef PROFILE | 400 #ifdef PROFILE |
377 static int64_t faad_get_ts() | 401 static int64_t faad_get_ts() |