Mercurial > mplayer.hg
comparison libfaad2/fixed.h @ 13453:6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
patch by adland <adland123 at yahoo dot com>
author | diego |
---|---|
date | Fri, 24 Sep 2004 17:31:36 +0000 |
parents | d81145997036 |
children | 2ae5ab4331ca |
comparison
equal
deleted
inserted
replaced
13452:c364b7c13dd8 | 13453:6d50ef45a058 |
---|---|
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 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 | 25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
26 ** $Id: fixed.h,v 1.3 2004/06/02 22:59:03 diego Exp $ | 26 ** $Id: fixed.h,v 1.4 2004/06/23 13:50:50 diego Exp $ |
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ | 27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
28 **/ | 28 **/ |
29 | 29 |
30 #ifndef __FIXED_H__ | 30 #ifndef __FIXED_H__ |
31 #define __FIXED_H__ | 31 #define __FIXED_H__ |
32 | 32 |
33 #ifdef __cplusplus | 33 #ifdef __cplusplus |
34 extern "C" { | 34 extern "C" { |
35 #endif | 35 #endif |
36 | 36 |
37 #ifdef _WIN32_WCE | 37 #if defined(_WIN32_WCE) && defined(_ARM_) |
38 #include <cmnintrin.h> | 38 #include <cmnintrin.h> |
39 #endif | 39 #endif |
40 | 40 |
41 #define COEF_BITS 28 | 41 #define COEF_BITS 28 |
42 #define COEF_PRECISION (1 << COEF_BITS) | 42 #define COEF_PRECISION (1 << COEF_BITS) |
53 | 53 |
54 | 54 |
55 #define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5))) | 55 #define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5))) |
56 #define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5))) | 56 #define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5))) |
57 #define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))) | 57 #define FRAC_CONST(A) (((A) == 1.00) ? ((real_t)FRAC_MAX) : (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))) |
58 //#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5))) | |
59 | |
60 #define Q2_BITS 22 | |
61 #define Q2_PRECISION (1 << Q2_BITS) | |
62 #define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A)*(Q2_PRECISION)+0.5)) : ((real_t)((A)*(Q2_PRECISION)-0.5))) | |
58 | 63 |
59 #if defined(_WIN32) && !defined(_WIN32_WCE) | 64 #if defined(_WIN32) && !defined(_WIN32_WCE) |
60 | 65 |
61 /* multiply with real shift */ | 66 /* multiply with real shift */ |
62 static INLINE real_t MUL_R(real_t A, real_t B) | 67 static INLINE real_t MUL_R(real_t A, real_t B) |
76 imul B | 81 imul B |
77 shrd eax,edx,COEF_BITS | 82 shrd eax,edx,COEF_BITS |
78 } | 83 } |
79 } | 84 } |
80 | 85 |
86 static INLINE real_t MUL_Q2(real_t A, real_t B) | |
87 { | |
88 _asm { | |
89 mov eax,A | |
90 imul B | |
91 shrd eax,edx,Q2_BITS | |
92 } | |
93 } | |
94 | |
95 static INLINE real_t MUL_SHIFT6(real_t A, real_t B) | |
96 { | |
97 _asm { | |
98 mov eax,A | |
99 imul B | |
100 shrd eax,edx,6 | |
101 } | |
102 } | |
103 | |
104 static INLINE real_t MUL_SHIFT23(real_t A, real_t B) | |
105 { | |
106 _asm { | |
107 mov eax,A | |
108 imul B | |
109 shrd eax,edx,23 | |
110 } | |
111 } | |
112 | |
113 #if 1 | |
81 static INLINE real_t _MulHigh(real_t A, real_t B) | 114 static INLINE real_t _MulHigh(real_t A, real_t B) |
82 { | 115 { |
83 _asm { | 116 _asm { |
84 mov eax,A | 117 mov eax,A |
85 imul B | 118 imul B |
98 real_t x1, real_t x2, real_t c1, real_t c2) | 131 real_t x1, real_t x2, real_t c1, real_t c2) |
99 { | 132 { |
100 *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS); | 133 *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS); |
101 *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS); | 134 *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS); |
102 } | 135 } |
136 #else | |
137 static INLINE real_t MUL_F(real_t A, real_t B) | |
138 { | |
139 _asm { | |
140 mov eax,A | |
141 imul B | |
142 shrd eax,edx,FRAC_BITS | |
143 } | |
144 } | |
145 | |
146 /* Complex multiplication */ | |
147 static INLINE void ComplexMult(real_t *y1, real_t *y2, | |
148 real_t x1, real_t x2, real_t c1, real_t c2) | |
149 { | |
150 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2); | |
151 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2); | |
152 } | |
153 #endif | |
103 | 154 |
104 #elif defined(__GNUC__) && defined (__arm__) | 155 #elif defined(__GNUC__) && defined (__arm__) |
105 | 156 |
106 /* taken from MAD */ | 157 /* taken from MAD */ |
107 #define arm_mul(x, y, SCALEBITS) \ | 158 #define arm_mul(x, y, SCALEBITS) \ |
127 static INLINE real_t MUL_C(real_t A, real_t B) | 178 static INLINE real_t MUL_C(real_t A, real_t B) |
128 { | 179 { |
129 return arm_mul(A, B, COEF_BITS); | 180 return arm_mul(A, B, COEF_BITS); |
130 } | 181 } |
131 | 182 |
183 static INLINE real_t MUL_Q2(real_t A, real_t B) | |
184 { | |
185 return arm_mul(A, B, Q2_BITS); | |
186 } | |
187 | |
188 static INLINE real_t MUL_SHIFT6(real_t A, real_t B) | |
189 { | |
190 return arm_mul(A, B, 6); | |
191 } | |
192 | |
193 static INLINE real_t MUL_SHIFT23(real_t A, real_t B) | |
194 { | |
195 return arm_mul(A, B, 23); | |
196 } | |
197 | |
132 static INLINE real_t _MulHigh(real_t x, real_t y) | 198 static INLINE real_t _MulHigh(real_t x, real_t y) |
133 { | 199 { |
134 uint32_t __lo; | 200 uint32_t __lo; |
135 uint32_t __hi; | 201 uint32_t __hi; |
136 asm("smull\t%0, %1, %2, %3" | 202 asm("smull\t%0, %1, %2, %3" |
167 /* multiply with real shift */ | 233 /* multiply with real shift */ |
168 #define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS) | 234 #define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS) |
169 /* multiply with coef shift */ | 235 /* multiply with coef shift */ |
170 #define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS) | 236 #define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS) |
171 /* multiply with fractional shift */ | 237 /* multiply with fractional shift */ |
172 #ifndef _WIN32_WCE | 238 #if defined(_WIN32_WCE) && defined(_ARM_) |
173 #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE) | |
174 #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS) | |
175 #else | |
176 /* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */ | 239 /* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */ |
177 static INLINE real_t MUL_F(real_t A, real_t B) | 240 static INLINE real_t MUL_F(real_t A, real_t B) |
178 { | 241 { |
179 return _MulHigh(A,B) << (32-FRAC_BITS); | 242 return _MulHigh(A,B) << (32-FRAC_BITS); |
180 } | 243 } |
181 #endif | 244 #else |
245 #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE) | |
246 #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS) | |
247 #endif | |
248 #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) | |
249 #define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6) | |
250 #define MUL_SHIFT23(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (23-1))) >> 23) | |
182 | 251 |
183 /* Complex multiplication */ | 252 /* Complex multiplication */ |
184 static INLINE void ComplexMult(real_t *y1, real_t *y2, | 253 static INLINE void ComplexMult(real_t *y1, real_t *y2, |
185 real_t x1, real_t x2, real_t c1, real_t c2) | 254 real_t x1, real_t x2, real_t c1, real_t c2) |
186 { | 255 { |