annotate libfaad2/fixed.h @ 14190:856ec42684b1

Sync with 1.154
author jheryan
date Mon, 20 Dec 2004 06:32:01 +0000
parents 6d50ef45a058
children 2ae5ab4331ca
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
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
10725
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 **
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
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
26 ** $Id: fixed.h,v 1.4 2004/06/23 13:50:50 diego Exp $
12625
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #ifndef __FIXED_H__
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #define __FIXED_H__
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #ifdef __cplusplus
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 extern "C" {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
37 #if defined(_WIN32_WCE) && defined(_ARM_)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
38 #include <cmnintrin.h>
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
39 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #define COEF_BITS 28
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #define COEF_PRECISION (1 << COEF_BITS)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
43 #define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #define REAL_PRECISION (1 << REAL_BITS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
46 /* FRAC is the fractional only part of the fixed point number [0.0..1.0) */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
47 #define FRAC_SIZE 32 /* frac is a 32 bit integer */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
48 #define FRAC_BITS 31
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
49 #define FRAC_PRECISION ((uint32_t)(1 << FRAC_BITS))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
50 #define FRAC_MAX 0x7FFFFFFF
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 typedef int32_t real_t;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
55 #define REAL_CONST(A) (((A) >= 0) ? ((real_t)((A)*(REAL_PRECISION)+0.5)) : ((real_t)((A)*(REAL_PRECISION)-0.5)))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
56 #define COEF_CONST(A) (((A) >= 0) ? ((real_t)((A)*(COEF_PRECISION)+0.5)) : ((real_t)((A)*(COEF_PRECISION)-0.5)))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
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))))
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
58 //#define FRAC_CONST(A) (((A) >= 0) ? ((real_t)((A)*(FRAC_PRECISION)+0.5)) : ((real_t)((A)*(FRAC_PRECISION)-0.5)))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
59
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
60 #define Q2_BITS 22
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
61 #define Q2_PRECISION (1 << Q2_BITS)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
62 #define Q2_CONST(A) (((A) >= 0) ? ((real_t)((A)*(Q2_PRECISION)+0.5)) : ((real_t)((A)*(Q2_PRECISION)-0.5)))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 #if defined(_WIN32) && !defined(_WIN32_WCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
66 /* multiply with real shift */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
67 static INLINE real_t MUL_R(real_t A, real_t B)
10725
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 shrd eax,edx,REAL_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
76 /* multiply with coef shift */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
77 static INLINE real_t MUL_C(real_t A, real_t B)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 _asm {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 mov eax,A
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 imul B
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 shrd eax,edx,COEF_BITS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
86 static INLINE real_t MUL_Q2(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
87 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
88 _asm {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
89 mov eax,A
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
90 imul B
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
91 shrd eax,edx,Q2_BITS
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
92 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
93 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
94
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
95 static INLINE real_t MUL_SHIFT6(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
96 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
97 _asm {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
98 mov eax,A
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
99 imul B
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
100 shrd eax,edx,6
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
101 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
102 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
103
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
104 static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
105 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
106 _asm {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
107 mov eax,A
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
108 imul B
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
109 shrd eax,edx,23
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
110 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
111 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
112
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
113 #if 1
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
114 static INLINE real_t _MulHigh(real_t A, real_t B)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 _asm {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 mov eax,A
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 imul B
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
119 mov eax,edx
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
123 /* multiply with fractional shift */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
124 static INLINE real_t MUL_F(real_t A, real_t B)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
125 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
126 return _MulHigh(A,B) << (FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
127 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
128
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
129 /* Complex multiplication */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
130 static INLINE void ComplexMult(real_t *y1, real_t *y2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
131 real_t x1, real_t x2, real_t c1, real_t c2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
132 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
133 *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
134 *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
135 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
136 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
137 static INLINE real_t MUL_F(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
138 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
139 _asm {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
140 mov eax,A
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
141 imul B
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
142 shrd eax,edx,FRAC_BITS
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
143 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
144 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
145
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
146 /* Complex multiplication */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
147 static INLINE void ComplexMult(real_t *y1, real_t *y2,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
148 real_t x1, real_t x2, real_t c1, real_t c2)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
149 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
150 *y1 = MUL_F(x1, c1) + MUL_F(x2, c2);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
151 *y2 = MUL_F(x2, c1) - MUL_F(x1, c2);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
152 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
153 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
154
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 #elif defined(__GNUC__) && defined (__arm__)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 /* taken from MAD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 #define arm_mul(x, y, SCALEBITS) \
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
159 ({ \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
160 uint32_t __hi; \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
161 uint32_t __lo; \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
162 uint32_t __result; \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
163 asm("smull %0, %1, %3, %4\n\t" \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
164 "movs %0, %0, lsr %5\n\t" \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
165 "adc %2, %0, %1, lsl %6" \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
166 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
167 : "%r" (x), "r" (y), \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
168 "M" (SCALEBITS), "M" (32 - (SCALEBITS)) \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
169 : "cc"); \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
170 __result; \
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
171 })
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173 static INLINE real_t MUL_R(real_t A, real_t B)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175 return arm_mul(A, B, REAL_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
176 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
177
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 static INLINE real_t MUL_C(real_t A, real_t B)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
179 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
180 return arm_mul(A, B, COEF_BITS);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
183 static INLINE real_t MUL_Q2(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
184 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
185 return arm_mul(A, B, Q2_BITS);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
186 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
187
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
188 static INLINE real_t MUL_SHIFT6(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
189 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
190 return arm_mul(A, B, 6);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
191 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
192
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
193 static INLINE real_t MUL_SHIFT23(real_t A, real_t B)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
194 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
195 return arm_mul(A, B, 23);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
196 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
197
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
198 static INLINE real_t _MulHigh(real_t x, real_t y)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
200 uint32_t __lo;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
201 uint32_t __hi;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
202 asm("smull\t%0, %1, %2, %3"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
203 : "=&r"(__lo),"=&r"(__hi)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
204 : "%r"(x),"r"(y)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
205 : "cc");
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
206 return __hi;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
207 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
208
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
209 static INLINE real_t MUL_F(real_t A, real_t B)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
210 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
211 return _MulHigh(A, B) << (FRAC_SIZE-FRAC_BITS);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
214 /* Complex multiplication */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
215 static INLINE void ComplexMult(real_t *y1, real_t *y2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
216 real_t x1, real_t x2, real_t c1, real_t c2)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
218 int32_t tmp, yt1, yt2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
219 asm("smull %0, %1, %4, %6\n\t"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
220 "smlal %0, %1, %5, %7\n\t"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
221 "rsb %3, %4, #0\n\t"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
222 "smull %0, %2, %5, %6\n\t"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
223 "smlal %0, %2, %3, %7"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
224 : "=&r" (tmp), "=&r" (yt1), "=&r" (yt2), "=r" (x1)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
225 : "3" (x1), "r" (x2), "r" (c1), "r" (c2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
226 : "cc" );
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
227 *y1 = yt1 << (FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
228 *y2 = yt2 << (FRAC_SIZE-FRAC_BITS);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
233 /* multiply with real shift */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
234 #define MUL_R(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
235 /* multiply with coef shift */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
236 #define MUL_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
237 /* multiply with fractional shift */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
238 #if defined(_WIN32_WCE) && defined(_ARM_)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
239 /* eVC for PocketPC has an intrinsic function that returns only the high 32 bits of a 32x32 bit multiply */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
240 static INLINE real_t MUL_F(real_t A, real_t B)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
241 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
242 return _MulHigh(A,B) << (32-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
243 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
244 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
245 #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
246 #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
247 #endif
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
248 #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
249 #define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
250 #define MUL_SHIFT23(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (23-1))) >> 23)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
251
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
252 /* Complex multiplication */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
253 static INLINE void ComplexMult(real_t *y1, real_t *y2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
254 real_t x1, real_t x2, real_t c1, real_t c2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
255 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
256 *y1 = (_MulHigh(x1, c1) + _MulHigh(x2, c2))<<(FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
257 *y2 = (_MulHigh(x2, c1) - _MulHigh(x1, c2))<<(FRAC_SIZE-FRAC_BITS);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
258 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
263
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 #ifdef __cplusplus
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 #endif