10725
|
1 /*
|
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
|
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
|
|
4 **
|
|
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.
|
|
9 **
|
|
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.
|
|
14 **
|
|
15 ** You should have received a copy of the GNU General Public License
|
|
16 ** along with this program; if not, write to the Free Software
|
|
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 **
|
10989
|
25 ** $Id: fixed.h,v 1.1 2003/08/30 22:30:21 arpi Exp $
|
10725
|
26 **/
|
|
27
|
|
28 #ifndef __FIXED_H__
|
|
29 #define __FIXED_H__
|
|
30
|
|
31 #ifdef __cplusplus
|
|
32 extern "C" {
|
|
33 #endif
|
|
34
|
|
35
|
|
36 #define COEF_BITS 28
|
|
37 #define COEF_PRECISION (1 << COEF_BITS)
|
10989
|
38 #define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR
|
10725
|
39 #define REAL_PRECISION (1 << REAL_BITS)
|
|
40
|
|
41
|
|
42 typedef int32_t real_t;
|
|
43
|
|
44
|
10989
|
45 #define REAL_CONST(A) ((real_t)((A)*(REAL_PRECISION)))
|
|
46 #define COEF_CONST(A) ((real_t)((A)*(COEF_PRECISION)))
|
10725
|
47
|
|
48 #if defined(_WIN32) && !defined(_WIN32_WCE)
|
|
49
|
|
50 /* multiply real with real */
|
|
51 static INLINE MUL(real_t A, real_t B)
|
|
52 {
|
|
53 _asm {
|
|
54 mov eax,A
|
|
55 imul B
|
|
56 #if 0
|
|
57 shrd eax,edx,REAL_BITS
|
|
58 #else
|
|
59 shr eax,REAL_BITS
|
|
60 shl edx,(32-REAL_BITS)
|
|
61 or eax,edx
|
|
62 #endif
|
|
63 }
|
|
64 }
|
|
65
|
|
66 /* multiply coef with coef */
|
|
67 static INLINE MUL_C_C(real_t A, real_t B)
|
|
68 {
|
|
69 _asm {
|
|
70 mov eax,A
|
|
71 imul B
|
|
72 #if 0
|
|
73 shrd eax,edx,COEF_BITS
|
|
74 #else
|
|
75 shr eax,COEF_BITS
|
|
76 shl edx,(32-COEF_BITS)
|
|
77 or eax,edx
|
|
78 #endif
|
|
79 }
|
|
80 }
|
|
81
|
|
82 /* multiply real with coef */
|
|
83 static INLINE MUL_R_C(real_t A, real_t B)
|
|
84 {
|
|
85 _asm {
|
|
86 mov eax,A
|
|
87 imul B
|
|
88 #if 0
|
|
89 shrd eax,edx,COEF_BITS
|
|
90 #else
|
|
91 shr eax,COEF_BITS
|
|
92 shl edx,(32-COEF_BITS)
|
|
93 or eax,edx
|
|
94 #endif
|
|
95 }
|
|
96 }
|
|
97
|
|
98 #elif defined(__GNUC__) && defined (__arm__)
|
|
99
|
|
100 /* taken from MAD */
|
|
101 #define arm_mul(x, y, SCALEBITS) \
|
|
102 ({ uint32_t __hi; \
|
|
103 uint32_t __lo; \
|
|
104 uint32_t __result; \
|
|
105 asm ("smull %0, %1, %3, %4\n\t" \
|
|
106 "movs %0, %0, lsr %5\n\t" \
|
|
107 "adc %2, %0, %1, lsl %6" \
|
|
108 : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \
|
|
109 : "%r" (x), "r" (y), \
|
|
110 "M" (SCALEBITS), "M" (32 - (SCALEBITS)) \
|
|
111 : "cc"); \
|
|
112 __result; \
|
|
113 })
|
|
114
|
|
115 static INLINE real_t MUL(real_t A, real_t B)
|
|
116 {
|
|
117 return arm_mul( A, B, REAL_BITS);
|
|
118 }
|
|
119
|
|
120 static INLINE real_t MUL_C_C(real_t A, real_t B)
|
|
121 {
|
|
122 return arm_mul( A, B, COEF_BITS);
|
|
123 }
|
|
124
|
|
125 static INLINE real_t MUL_R_C(real_t A, real_t B)
|
|
126 {
|
|
127 return arm_mul( A, B, COEF_BITS);
|
|
128 }
|
|
129
|
|
130 #else
|
|
131
|
|
132 /* multiply real with real */
|
|
133 #define MUL(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (REAL_BITS-1))) >> REAL_BITS)
|
|
134 /* multiply coef with coef */
|
|
135 #define MUL_C_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
|
|
136 /* multiply real with coef */
|
|
137 #define MUL_R_C(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (COEF_BITS-1))) >> COEF_BITS)
|
|
138
|
|
139 #endif
|
|
140
|
|
141
|
|
142 #ifdef __cplusplus
|
|
143 }
|
|
144 #endif
|
|
145 #endif
|