annotate libfaad2/fixed.h @ 11516:f686c2a2b64c

Support arbitrary compression level in ZLIB. Fix some debug mp_msg type sizes.
author rtognimp
date Mon, 24 Nov 2003 20:03:10 +0000
parents 3185f64f6350
children 4a370c80fe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
25 ** $Id: fixed.h,v 1.1 2003/08/30 22:30:21 arpi Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 #ifndef __FIXED_H__
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #define __FIXED_H__
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #ifdef __cplusplus
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 extern "C" {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #define COEF_BITS 28
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #define COEF_PRECISION (1 << COEF_BITS)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
38 #define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #define REAL_PRECISION (1 << REAL_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 typedef int32_t real_t;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
45 #define REAL_CONST(A) ((real_t)((A)*(REAL_PRECISION)))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
46 #define COEF_CONST(A) ((real_t)((A)*(COEF_PRECISION)))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 #if defined(_WIN32) && !defined(_WIN32_WCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 /* multiply real with real */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 static INLINE MUL(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 _asm {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 mov eax,A
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 imul B
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 shrd eax,edx,REAL_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 shr eax,REAL_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 shl edx,(32-REAL_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 or eax,edx
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 /* multiply coef with coef */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 static INLINE MUL_C_C(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 _asm {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 mov eax,A
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 imul B
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 shrd eax,edx,COEF_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 shr eax,COEF_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 shl edx,(32-COEF_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 or eax,edx
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 /* multiply real with coef */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 static INLINE MUL_R_C(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 _asm {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 mov eax,A
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 imul B
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 shrd eax,edx,COEF_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 shr eax,COEF_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 shl edx,(32-COEF_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 or eax,edx
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 #elif defined(__GNUC__) && defined (__arm__)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 /* taken from MAD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 #define arm_mul(x, y, SCALEBITS) \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 ({ uint32_t __hi; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 uint32_t __lo; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 uint32_t __result; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 asm ("smull %0, %1, %3, %4\n\t" \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 "movs %0, %0, lsr %5\n\t" \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 "adc %2, %0, %1, lsl %6" \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 : "%r" (x), "r" (y), \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 "M" (SCALEBITS), "M" (32 - (SCALEBITS)) \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 : "cc"); \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 __result; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 })
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 static INLINE real_t MUL(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 return arm_mul( A, B, REAL_BITS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 static INLINE real_t MUL_C_C(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 return arm_mul( A, B, COEF_BITS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 static INLINE real_t MUL_R_C(real_t A, real_t B)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 return arm_mul( A, B, COEF_BITS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 /* multiply real with real */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 #define MUL(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 /* multiply coef with coef */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 #define MUL_C_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 /* multiply real with coef */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 #define MUL_R_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 #ifdef __cplusplus
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 #endif