1 /*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef SBC_TABLES_H
17 #define SBC_TABLES_H
18
19 #include <cstddef>
20 #include <cstdint>
21 #include <limits.h>
22 #include "sbc_math.h"
23
24 static const int SBC_OFFSET_4[4][4] = {
25 { -1, 0, 0, 0 },
26 { -2, 0, 0, 1 },
27 { -2, 0, 0, 1 },
28 { -2, 0, 0, 1 }
29 };
30
31 static const int SBC_OFFSET_8[4][8] = {
32 { -2, 0, 0, 0, 0, 0, 0, 1 },
33 { -3, 0, 0, 0, 0, 0, 1, 2 },
34 { -4, 0, 0, 0, 0, 0, 1, 2 },
35 { -4, 0, 0, 0, 0, 0, 1, 2 }
36 };
37
38 #define SBCDEC_FIXED_EXTRA_BITS 2
39
SS4(int32_t val)40 static inline int32_t SS4(int32_t val)
41 {
42 return ((-2 >> 1 == -1) ? (static_cast<int32_t>(val)) >> (SCALE_SPROTO4_TBL) :
43 (static_cast<int32_t>(val)) / (1 << (SCALE_SPROTO4_TBL)));
44 }
SS8(int32_t val)45 static inline int32_t SS8(int32_t val)
46 {
47 return ((-2 >> 1 == -1) ? (static_cast<int32_t>(val)) >> (SCALE_SPROTO8_TBL) :
48 (static_cast<int32_t>(val)) / (1 << (SCALE_SPROTO8_TBL)));
49 }
SN4(int32_t val)50 static inline int32_t SN4(int32_t val)
51 {
52 return ((-2 >> 1 == -1) ? (static_cast<int32_t>(val)) >> (SCALE_NPROTO4_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS) :
53 (static_cast<int32_t>(val)) / (1 << (SCALE_NPROTO4_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)));
54 }
SN8(int32_t val)55 static inline int32_t SN8(int32_t val)
56 {
57 return ((-2 >> 1 == -1) ? (static_cast<int32_t>(val)) >> (SCALE_NPROTO8_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS) :
58 (static_cast<int32_t>(val)) / (1 << (SCALE_NPROTO8_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)));
59 }
60
61 static const int32_t PROTO_4_40M0[] = {
62 SS4(0x00000000), SS4(0xffa6982f), SS4(0xfba93848), SS4(0x0456c7b8),
63 SS4(0x005967d1), SS4(0xfffb9ac7), SS4(0xff589157), SS4(0xf9c2a8d8),
64 SS4(0x027c1434), SS4(0x0019118b), SS4(0xfff3c74c), SS4(0xff137330),
65 SS4(0xf81b8d70), SS4(0x00ec1b8b), SS4(0xfff0b71a), SS4(0xffe99b00),
66 SS4(0xfef84470), SS4(0xf6fb4370), SS4(0xffcdc351), SS4(0xffe01dc7)
67 };
68
69 static const int32_t PROTO_4_40M1[] = {
70 SS4(0xffe090ce), SS4(0xff2c0475), SS4(0xf694f800), SS4(0xff2c0475),
71 SS4(0xffe090ce), SS4(0xffe01dc7), SS4(0xffcdc351), SS4(0xf6fb4370),
72 SS4(0xfef84470), SS4(0xffe99b00), SS4(0xfff0b71a), SS4(0x00ec1b8b),
73 SS4(0xf81b8d70), SS4(0xff137330), SS4(0xfff3c74c), SS4(0x0019118b),
74 SS4(0x027c1434), SS4(0xf9c2a8d8), SS4(0xff589157), SS4(0xfffb9ac7)
75 };
76
77 static const int32_t PROTO_8_80M0[] = {
78 SS8(0x00000000), SS8(0xfe8d1970), SS8(0xee979f00), SS8(0x11686100),
79 SS8(0x0172e690), SS8(0xfff5bd1a), SS8(0xfdf1c8d4), SS8(0xeac182c0),
80 SS8(0x0d9daee0), SS8(0x00e530da), SS8(0xffe9811d), SS8(0xfd52986c),
81 SS8(0xe7054ca0), SS8(0x0a00d410), SS8(0x006c1de4), SS8(0xffdba705),
82 SS8(0xfcbc98e8), SS8(0xe3889d20), SS8(0x06af2308), SS8(0x000bb7db),
83 SS8(0xffca00ed), SS8(0xfc3fbb68), SS8(0xe071bc00), SS8(0x03bf7948),
84 SS8(0xffc4e05c), SS8(0xffb54b3b), SS8(0xfbedadc0), SS8(0xdde26200),
85 SS8(0x0142291c), SS8(0xff960e94), SS8(0xff9f3e17), SS8(0xfbd8f358),
86 SS8(0xdbf79400), SS8(0xff405e01), SS8(0xff7d4914), SS8(0xff8b1a31),
87 SS8(0xfc1417b8), SS8(0xdac7bb40), SS8(0xfdbb828c), SS8(0xff762170)
88 };
89
90 static const int32_t PROTO_8_80M1[] = {
91 SS8(0xff7c272c), SS8(0xfcb02620), SS8(0xda612700), SS8(0xfcb02620),
92 SS8(0xff7c272c), SS8(0xff762170), SS8(0xfdbb828c), SS8(0xdac7bb40),
93 SS8(0xfc1417b8), SS8(0xff8b1a31), SS8(0xff7d4914), SS8(0xff405e01),
94 SS8(0xdbf79400), SS8(0xfbd8f358), SS8(0xff9f3e17), SS8(0xff960e94),
95 SS8(0x0142291c), SS8(0xdde26200), SS8(0xfbedadc0), SS8(0xffb54b3b),
96 SS8(0xffc4e05c), SS8(0x03bf7948), SS8(0xe071bc00), SS8(0xfc3fbb68),
97 SS8(0xffca00ed), SS8(0x000bb7db), SS8(0x06af2308), SS8(0xe3889d20),
98 SS8(0xfcbc98e8), SS8(0xffdba705), SS8(0x006c1de4), SS8(0x0a00d410),
99 SS8(0xe7054ca0), SS8(0xfd52986c), SS8(0xffe9811d), SS8(0x00e530da),
100 SS8(0x0d9daee0), SS8(0xeac182c0), SS8(0xfdf1c8d4), SS8(0xfff5bd1a)
101 };
102
103 static const int32_t SYNMATRIX4[8][4] = {
104 { SN4(0x05a82798), SN4(0xfa57d868), SN4(0xfa57d868), SN4(0x05a82798) },
105 { SN4(0x030fbc54), SN4(0xf89be510), SN4(0x07641af0), SN4(0xfcf043ac) },
106 { SN4(0x00000000), SN4(0x00000000), SN4(0x00000000), SN4(0x00000000) },
107 { SN4(0xfcf043ac), SN4(0x07641af0), SN4(0xf89be510), SN4(0x030fbc54) },
108 { SN4(0xfa57d868), SN4(0x05a82798), SN4(0x05a82798), SN4(0xfa57d868) },
109 { SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) },
110 { SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000) },
111 { SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) }
112 };
113
114 static const int32_t SYNMATRIX8[16][8] = {
115 { SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798),
116 SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798) },
117 { SN8(0x0471ced0), SN8(0xf8275a10), SN8(0x018f8b84), SN8(0x06a6d988),
118 SN8(0xf9592678), SN8(0xfe70747c), SN8(0x07d8a5f0), SN8(0xfb8e3130) },
119 { SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac),
120 SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54) },
121 { SN8(0x018f8b84), SN8(0xfb8e3130), SN8(0x06a6d988), SN8(0xf8275a10),
122 SN8(0x07d8a5f0), SN8(0xf9592678), SN8(0x0471ced0), SN8(0xfe70747c) },
123 { SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000),
124 SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000) },
125 { SN8(0xfe70747c), SN8(0x0471ced0), SN8(0xf9592678), SN8(0x07d8a5f0),
126 SN8(0xf8275a10), SN8(0x06a6d988), SN8(0xfb8e3130), SN8(0x018f8b84) },
127 { SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54),
128 SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac) },
129 { SN8(0xfb8e3130), SN8(0x07d8a5f0), SN8(0xfe70747c), SN8(0xf9592678),
130 SN8(0x06a6d988), SN8(0x018f8b84), SN8(0xf8275a10), SN8(0x0471ced0) },
131 { SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868),
132 SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868) },
133 { SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
134 SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) },
135 { SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
136 SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
137 { SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
138 SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
139 { SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000),
140 SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000) },
141 { SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
142 SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
143 { SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
144 SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
145 { SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
146 SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
147 };
148
149 #define SBC_FIXED_EXTRA_BITS 0
150
151 #define PROTO_BAND4_SCALE \
152 ((sizeof(int16_t) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
FProto4(double x)153 static int16_t FProto4(double x) {
154 return static_cast<int32_t>((x * 2) * \
155 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
156 }
FProto4N(double x)157 static int16_t FProto4N(double x) {
158 return -static_cast<int32_t>((x * 2) * \
159 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
160 }
161
162 static const int16_t PROTO_BAND4[40] = {
163 FProto4(0.00000000E+00), FProto4(5.36548976E-04),
164 FProto4N(1.49188357E-03), FProto4(2.73370904E-03),
165 FProto4(3.83720193E-03), FProto4(3.89205149E-03),
166 FProto4(1.86581691E-03), FProto4(3.06012286E-03),
167
168 FProto4(1.09137620E-02), FProto4(2.04385087E-02),
169 FProto4N(2.88757392E-02), FProto4(3.21939290E-02),
170 FProto4(2.58767811E-02), FProto4(6.13245186E-03),
171 FProto4N(2.88217274E-02), FProto4(7.76463494E-02),
172
173 FProto4(1.35593274E-01), FProto4(1.94987841E-01),
174 FProto4N(2.46636662E-01), FProto4(2.81828203E-01),
175 FProto4(2.94315332E-01), FProto4(2.81828203E-01),
176 FProto4(2.46636662E-01), FProto4N(1.94987841E-01),
177
178 FProto4N(1.35593274E-01), FProto4N(7.76463494E-02),
179 FProto4(2.88217274E-02), FProto4(6.13245186E-03),
180 FProto4(2.58767811E-02), FProto4(3.21939290E-02),
181 FProto4(2.88757392E-02), FProto4N(2.04385087E-02),
182
183 FProto4N(1.09137620E-02), FProto4N(3.06012286E-03),
184 FProto4N(1.86581691E-03), FProto4(3.89205149E-03),
185 FProto4(3.83720193E-03), FProto4(2.73370904E-03),
186 FProto4(1.49188357E-03), FProto4N(5.36548976E-04),
187 };
188
189 #define COS_TABLE_BAND4_SCALE \
190 ((sizeof(int16_t) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
FCos4(double x)191 static int16_t FCos4(double x) {
192 return static_cast<int32_t>((x) * \
193 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
194 }
FCos4N(double x)195 static int16_t FCos4N(double x) {
196 return -static_cast<int32_t>((x) * \
197 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
198 }
199
200 static const int16_t COS_TABLE_BAND_4[32] = {
201 FCos4(0.7071067812), FCos4(0.9238795325), FCos4N(1.0000000000), FCos4(0.9238795325),
202 FCos4(0.7071067812), FCos4(0.3826834324), FCos4(0.0000000000), FCos4(0.3826834324),
203
204 FCos4N(0.7071067812), FCos4(0.3826834324), FCos4N(1.0000000000), FCos4(0.3826834324),
205 FCos4N(0.7071067812), FCos4N(0.9238795325), FCos4N(0.0000000000), FCos4N(0.9238795325),
206
207 FCos4N(0.7071067812), FCos4N(0.3826834324), FCos4N(1.0000000000), FCos4N(0.3826834324),
208 FCos4N(0.7071067812), FCos4(0.9238795325), FCos4(0.0000000000), FCos4(0.9238795325),
209
210 FCos4(0.7071067812), FCos4N(0.9238795325), FCos4N(1.0000000000), FCos4N(0.9238795325),
211 FCos4(0.7071067812), FCos4N(0.3826834324), FCos4N(0.0000000000), FCos4N(0.3826834324),
212 };
213
214 #define PROTO_BAND8_SCALE \
215 ((sizeof(int16_t) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
FProto8(double x)216 static int16_t FProto8(double x) {
217 return static_cast<int32_t>((x * 2) * \
218 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
219 }
FProto8N(double x)220 static int16_t FProto8N(double x) {
221 return -static_cast<int32_t>((x * 2) * \
222 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
223 }
224
225 static const int16_t PROTO_BAND8[80] = {
226 FProto8(0.00000000E+00), FProto8(1.56575398E-04),
227 FProto8(3.43256425E-04), FProto8(5.54620202E-04),
228 FProto8N(8.23919506E-04), FProto8(1.13992507E-03),
229 FProto8(1.47640169E-03), FProto8(1.78371725E-03),
230 FProto8(2.01182542E-03), FProto8(2.10371989E-03),
231 FProto8(1.99454554E-03), FProto8(1.61656283E-03),
232 FProto8(9.02154502E-04), FProto8(1.78805361E-04),
233 FProto8(1.64973098E-03), FProto8(3.49717454E-03),
234
235 FProto8(5.65949473E-03), FProto8(8.02941163E-03),
236 FProto8(1.04584443E-02), FProto8(1.27472335E-02),
237 FProto8N(1.46525263E-02), FProto8(1.59045603E-02),
238 FProto8(1.62208471E-02), FProto8(1.53184106E-02),
239 FProto8(1.29371806E-02), FProto8(8.85757540E-03),
240 FProto8(2.92408442E-03), FProto8N(4.91578024E-03),
241 FProto8N(1.46404076E-02), FProto8(2.61098752E-02),
242 FProto8(3.90751381E-02), FProto8(5.31873032E-02),
243
244 FProto8(6.79989431E-02), FProto8(8.29847578E-02),
245 FProto8(9.75753918E-02), FProto8(1.11196689E-01),
246 FProto8N(1.23264548E-01), FProto8(1.33264415E-01),
247 FProto8(1.40753505E-01), FProto8(1.45389847E-01),
248 FProto8(1.46955068E-01), FProto8(1.45389847E-01),
249 FProto8(1.40753505E-01), FProto8(1.33264415E-01),
250 FProto8(1.23264548E-01), FProto8N(1.11196689E-01),
251 FProto8N(9.75753918E-02), FProto8N(8.29847578E-02),
252
253 FProto8N(6.79989431E-02), FProto8N(5.31873032E-02),
254 FProto8N(3.90751381E-02), FProto8N(2.61098752E-02),
255 FProto8(1.46404076E-02), FProto8N(4.91578024E-03),
256 FProto8(2.92408442E-03), FProto8(8.85757540E-03),
257 FProto8(1.29371806E-02), FProto8(1.53184106E-02),
258 FProto8(1.62208471E-02), FProto8(1.59045603E-02),
259 FProto8(1.46525263E-02), FProto8N(1.27472335E-02),
260 FProto8N(1.04584443E-02), FProto8N(8.02941163E-03),
261
262 FProto8N(5.65949473E-03), FProto8N(3.49717454E-03),
263 FProto8N(1.64973098E-03), FProto8N(1.78805361E-04),
264 FProto8N(9.02154502E-04), FProto8(1.61656283E-03),
265 FProto8(1.99454554E-03), FProto8(2.10371989E-03),
266 FProto8(2.01182542E-03), FProto8(1.78371725E-03),
267 FProto8(1.47640169E-03), FProto8(1.13992507E-03),
268 FProto8(8.23919506E-04), FProto8N(5.54620202E-04),
269 FProto8N(3.43256425E-04), FProto8N(1.56575398E-04),
270 };
271
272 #define COS_TABLE_BAND8_SCALE \
273 ((sizeof(int16_t) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
FCos8(double x)274 static int16_t FCos8(double x) {
275 return static_cast<int32_t>((x) * \
276 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
277 }
FCos8N(double x)278 static int16_t FCos8N(double x) {
279 return -static_cast<int32_t>((x) * \
280 (static_cast<int32_t>(1) << (sizeof(int16_t) * CHAR_BIT - 1)) + 0.5);
281 }
282
283 static const int16_t COS_TABLE_BAND_8[128] = {
284 FCos8(0.7071067812), FCos8(0.8314696123), FCos8(0.9238795325), FCos8(0.9807852804),
285 FCos8N(1.0000000000), FCos8(0.9807852804), FCos8(0.9238795325), FCos8(0.8314696123),
286 FCos8(0.7071067812), FCos8(0.5555702330), FCos8(0.3826834324), FCos8(0.1950903220),
287 FCos8(0.0000000000), FCos8(0.1950903220), FCos8(0.3826834324), FCos8(0.5555702330),
288
289 FCos8N(0.7071067812), FCos8N(0.1950903220), FCos8(0.3826834324), FCos8(0.8314696123),
290 FCos8N(1.0000000000), FCos8(0.8314696123), FCos8(0.3826834324), FCos8N(0.1950903220),
291 FCos8N(0.7071067812), FCos8N(0.9807852804), FCos8N(0.9238795325), FCos8N(0.5555702330),
292 FCos8N(0.0000000000), FCos8N(0.5555702330), FCos8N(0.9238795325), FCos8N(0.9807852804),
293
294 FCos8N(0.7071067812), FCos8N(0.9807852804), FCos8N(0.3826834324), FCos8(0.5555702330),
295 FCos8N(1.0000000000), FCos8(0.5555702330), FCos8N(0.3826834324), FCos8N(0.9807852804),
296 FCos8N(0.7071067812), FCos8(0.1950903220), FCos8(0.9238795325), FCos8(0.8314696123),
297 FCos8(0.0000000000), FCos8(0.8314696123), FCos8(0.9238795325), FCos8(0.1950903220),
298
299 FCos8(0.7071067812), FCos8N(0.5555702330), FCos8N(0.9238795325), FCos8(0.1950903220),
300 FCos8N(1.0000000000), FCos8(0.1950903220), FCos8N(0.9238795325), FCos8N(0.5555702330),
301 FCos8(0.7071067812), FCos8(0.8314696123), FCos8N(0.3826834324), FCos8N(0.9807852804),
302 FCos8N(0.0000000000), FCos8N(0.9807852804), FCos8N(0.3826834324), FCos8(0.8314696123),
303
304 FCos8(0.7071067812), FCos8(0.5555702330), FCos8N(0.9238795325), FCos8N(0.1950903220),
305 FCos8N(1.0000000000), FCos8N(0.1950903220), FCos8N(0.9238795325), FCos8(0.5555702330),
306 FCos8(0.7071067812), FCos8N(0.8314696123), FCos8N(0.3826834324), FCos8(0.9807852804),
307 FCos8(0.0000000000), FCos8(0.9807852804), FCos8N(0.3826834324), FCos8N(0.8314696123),
308
309 FCos8N(0.7071067812), FCos8(0.9807852804), FCos8N(0.3826834324), FCos8N(0.5555702330),
310 FCos8N(1.0000000000), FCos8N(0.5555702330), FCos8N(0.3826834324), FCos8(0.9807852804),
311 FCos8N(0.7071067812), FCos8N(0.1950903220), FCos8(0.9238795325), FCos8N(0.8314696123),
312 FCos8N(0.0000000000), FCos8N(0.8314696123), FCos8(0.9238795325), FCos8N(0.1950903220),
313
314 FCos8N(0.7071067812), FCos8(0.1950903220), FCos8(0.3826834324), FCos8N(0.8314696123),
315 FCos8N(1.0000000000), FCos8N(0.8314696123), FCos8(0.3826834324), FCos8(0.1950903220),
316 FCos8N(0.7071067812), FCos8(0.9807852804), FCos8N(0.9238795325), FCos8(0.5555702330),
317 FCos8N(0.0000000000), FCos8(0.5555702330), FCos8N(0.9238795325), FCos8(0.9807852804),
318
319 FCos8(0.7071067812), FCos8N(0.8314696123), FCos8(0.9238795325), FCos8N(0.9807852804),
320 FCos8N(1.0000000000), FCos8N(0.9807852804), FCos8(0.9238795325), FCos8N(0.8314696123),
321 FCos8(0.7071067812), FCos8N(0.5555702330), FCos8(0.3826834324), FCos8N(0.1950903220),
322 FCos8N(0.0000000000), FCos8N(0.1950903220), FCos8(0.3826834324), FCos8N(0.5555702330),
323 };
324
325 #define SBC_ALIGN_BITS 4
326 #define SBC_ALIGN_MASK ((1 << (SBC_ALIGN_BITS)) - 1)
327
328 static const int16_t ANALYSIS_CONSTS_BAND4_EVEN_MODE[40 + 16] = {
329 #define C0 1.0932568993
330 #define C1 1.3056875580
331 #define C2 1.3056875580
332 #define C3 1.6772280856
333
334 FProto4(0.00000000E+00 * C0), FProto4(3.83720193E-03 * C0),
335 FProto4(5.36548976E-04 * C1), FProto4(2.73370904E-03 * C1),
336 FProto4(3.06012286E-03 * C2), FProto4(3.89205149E-03 * C2),
337 FProto4(0.00000000E+00 * C3), FProto4N(1.49188357E-03 * C3),
338 FProto4(1.09137620E-02 * C0), FProto4(2.58767811E-02 * C0),
339 FProto4(2.04385087E-02 * C1), FProto4(3.21939290E-02 * C1),
340 FProto4(7.76463494E-02 * C2), FProto4(6.13245186E-03 * C2),
341 FProto4(0.00000000E+00 * C3), FProto4N(2.88757392E-02 * C3),
342 FProto4(1.35593274E-01 * C0), FProto4(2.94315332E-01 * C0),
343 FProto4(1.94987841E-01 * C1), FProto4(2.81828203E-01 * C1),
344 FProto4N(1.94987841E-01 * C2), FProto4(2.81828203E-01 * C2),
345 FProto4(0.00000000E+00 * C3), FProto4N(2.46636662E-01 * C3),
346 FProto4N(1.35593274E-01 * C0), FProto4(2.58767811E-02 * C0),
347 FProto4N(7.76463494E-02 * C1), FProto4(6.13245186E-03 * C1),
348 FProto4N(2.04385087E-02 * C2), FProto4(3.21939290E-02 * C2),
349 FProto4(0.00000000E+00 * C3), FProto4(2.88217274E-02 * C3),
350 FProto4N(1.09137620E-02 * C0), FProto4(3.83720193E-03 * C0),
351 FProto4N(3.06012286E-03 * C1), FProto4(3.89205149E-03 * C1),
352 FProto4N(5.36548976E-04 * C2), FProto4(2.73370904E-03 * C2),
353 FProto4(0.00000000E+00 * C3), FProto4N(1.86581691E-03 * C3),
354
355 FCos4(0.7071067812 / C0), FCos4(0.9238795325 / C1),
356 FCos4N(0.7071067812 / C0), FCos4(0.3826834324 / C1),
357 FCos4N(0.7071067812 / C0), FCos4N(0.3826834324 / C1),
358 FCos4(0.7071067812 / C0), FCos4N(0.9238795325 / C1),
359 FCos4(0.3826834324 / C2), FCos4N(1.0000000000 / C3),
360 FCos4N(0.9238795325 / C2), FCos4N(1.0000000000 / C3),
361 FCos4(0.9238795325 / C2), FCos4N(1.0000000000 / C3),
362 FCos4N(0.3826834324 / C2), FCos4N(1.0000000000 / C3),
363
364 #undef C0
365 #undef C1
366 #undef C2
367 #undef C3
368 };
369
370 static const int16_t ANALYSIS_CONSTS_BAND4_ODD_MODE[40 + 16] = {
371 #define C0 1.3056875580
372 #define C1 1.6772280856
373 #define C2 1.0932568993
374 #define C3 1.3056875580
375
376 FProto4(2.73370904E-03 * C0), FProto4(5.36548976E-04 * C0),
377 FProto4N(1.49188357E-03 * C1), FProto4(0.00000000E+00 * C1),
378 FProto4(3.83720193E-03 * C2), FProto4(1.09137620E-02 * C2),
379 FProto4(3.89205149E-03 * C3), FProto4(3.06012286E-03 * C3),
380 FProto4(3.21939290E-02 * C0), FProto4(2.04385087E-02 * C0),
381 FProto4N(2.88757392E-02 * C1), FProto4(0.00000000E+00 * C1),
382 FProto4(2.58767811E-02 * C2), FProto4(1.35593274E-01 * C2),
383 FProto4(6.13245186E-03 * C3), FProto4(7.76463494E-02 * C3),
384 FProto4(2.81828203E-01 * C0), FProto4(1.94987841E-01 * C0),
385 FProto4N(2.46636662E-01 * C1), FProto4(0.00000000E+00 * C1),
386 FProto4(2.94315332E-01 * C2), FProto4N(1.35593274E-01 * C2),
387 FProto4(2.81828203E-01 * C3), FProto4N(1.94987841E-01 * C3),
388 FProto4(6.13245186E-03 * C0), FProto4N(7.76463494E-02 * C0),
389 FProto4(2.88217274E-02 * C1), FProto4(0.00000000E+00 * C1),
390 FProto4(2.58767811E-02 * C2), FProto4N(1.09137620E-02 * C2),
391 FProto4(3.21939290E-02 * C3), FProto4N(2.04385087E-02 * C3),
392 FProto4(3.89205149E-03 * C0), FProto4N(3.06012286E-03 * C0),
393 FProto4N(1.86581691E-03 * C1), FProto4(0.00000000E+00 * C1),
394 FProto4(3.83720193E-03 * C2), FProto4(0.00000000E+00 * C2),
395 FProto4(2.73370904E-03 * C3), FProto4N(5.36548976E-04 * C3),
396
397 FCos4(0.9238795325 / C0), FCos4N(1.0000000000 / C1),
398 FCos4(0.3826834324 / C0), FCos4N(1.0000000000 / C1),
399 FCos4N(0.3826834324 / C0), FCos4N(1.0000000000 / C1),
400 FCos4N(0.9238795325 / C0), FCos4N(1.0000000000 / C1),
401 FCos4(0.7071067812 / C2), FCos4(0.3826834324 / C3),
402 FCos4N(0.7071067812 / C2), FCos4N(0.9238795325 / C3),
403 FCos4N(0.7071067812 / C2), FCos4(0.9238795325 / C3),
404 FCos4(0.7071067812 / C2), FCos4N(0.3826834324 / C3),
405
406 #undef C0
407 #undef C1
408 #undef C2
409 #undef C3
410 };
411
412 static const int16_t ANALYSIS_CONSTS_BAND8_EVEN_MODE[80 + 64] = {
413 #define C0 2.7906148894
414 #define C1 2.4270044280
415 #define C2 2.8015616024
416 #define C3 3.1710363741
417 #define C4 2.5377944043
418 #define C5 2.4270044280
419 #define C6 2.8015616024
420 #define C7 3.1710363741
421
422 FProto8(0.00000000E+00 * C0), FProto8(2.01182542E-03 * C0),
423 FProto8(1.56575398E-04 * C1), FProto8(1.78371725E-03 * C1),
424 FProto8(3.43256425E-04 * C2), FProto8(1.47640169E-03 * C2),
425 FProto8(5.54620202E-04 * C3), FProto8(1.13992507E-03 * C3),
426 FProto8N(8.23919506E-04 * C4), FProto8(0.00000000E+00 * C4),
427 FProto8(2.10371989E-03 * C5), FProto8(3.49717454E-03 * C5),
428 FProto8(1.99454554E-03 * C6), FProto8(1.64973098E-03 * C6),
429 FProto8(1.61656283E-03 * C7), FProto8(1.78805361E-04 * C7),
430 FProto8(5.65949473E-03 * C0), FProto8(1.29371806E-02 * C0),
431 FProto8(8.02941163E-03 * C1), FProto8(1.53184106E-02 * C1),
432 FProto8(1.04584443E-02 * C2), FProto8(1.62208471E-02 * C2),
433 FProto8(1.27472335E-02 * C3), FProto8(1.59045603E-02 * C3),
434 FProto8N(1.46525263E-02 * C4), FProto8(0.00000000E+00 * C4),
435 FProto8(8.85757540E-03 * C5), FProto8(5.31873032E-02 * C5),
436 FProto8(2.92408442E-03 * C6), FProto8(3.90751381E-02 * C6),
437 FProto8N(4.91578024E-03 * C7), FProto8(2.61098752E-02 * C7),
438 FProto8(6.79989431E-02 * C0), FProto8(1.46955068E-01 * C0),
439 FProto8(8.29847578E-02 * C1), FProto8(1.45389847E-01 * C1),
440 FProto8(9.75753918E-02 * C2), FProto8(1.40753505E-01 * C2),
441 FProto8(1.11196689E-01 * C3), FProto8(1.33264415E-01 * C3),
442 FProto8N(1.23264548E-01 * C4), FProto8(0.00000000E+00 * C4),
443 FProto8(1.45389847E-01 * C5), FProto8N(8.29847578E-02 * C5),
444 FProto8(1.40753505E-01 * C6), FProto8N(9.75753918E-02 * C6),
445 FProto8(1.33264415E-01 * C7), FProto8N(1.11196689E-01 * C7),
446 FProto8N(6.79989431E-02 * C0), FProto8(1.29371806E-02 * C0),
447 FProto8N(5.31873032E-02 * C1), FProto8(8.85757540E-03 * C1),
448 FProto8N(3.90751381E-02 * C2), FProto8(2.92408442E-03 * C2),
449 FProto8N(2.61098752E-02 * C3), FProto8N(4.91578024E-03 * C3),
450 FProto8(1.46404076E-02 * C4), FProto8(0.00000000E+00 * C4),
451 FProto8(1.53184106E-02 * C5), FProto8N(8.02941163E-03 * C5),
452 FProto8(1.62208471E-02 * C6), FProto8N(1.04584443E-02 * C6),
453 FProto8(1.59045603E-02 * C7), FProto8N(1.27472335E-02 * C7),
454 FProto8N(5.65949473E-03 * C0), FProto8(2.01182542E-03 * C0),
455 FProto8N(3.49717454E-03 * C1), FProto8(2.10371989E-03 * C1),
456 FProto8N(1.64973098E-03 * C2), FProto8(1.99454554E-03 * C2),
457 FProto8N(1.78805361E-04 * C3), FProto8(1.61656283E-03 * C3),
458 FProto8N(9.02154502E-04 * C4), FProto8(0.00000000E+00 * C4),
459 FProto8(1.78371725E-03 * C5), FProto8N(1.56575398E-04 * C5),
460 FProto8(1.47640169E-03 * C6), FProto8N(3.43256425E-04 * C6),
461 FProto8(1.13992507E-03 * C7), FProto8N(5.54620202E-04 * C7),
462
463 FCos8(0.7071067812 / C0), FCos8(0.8314696123 / C1),
464 FCos8N(0.7071067812 / C0), FCos8N(0.1950903220 / C1),
465 FCos8N(0.7071067812 / C0), FCos8N(0.9807852804 / C1),
466 FCos8(0.7071067812 / C0), FCos8N(0.5555702330 / C1),
467 FCos8(0.7071067812 / C0), FCos8(0.5555702330 / C1),
468 FCos8N(0.7071067812 / C0), FCos8(0.9807852804 / C1),
469 FCos8N(0.7071067812 / C0), FCos8(0.1950903220 / C1),
470 FCos8(0.7071067812 / C0), FCos8N(0.8314696123 / C1),
471 FCos8(0.9238795325 / C2), FCos8(0.9807852804 / C3),
472 FCos8(0.3826834324 / C2), FCos8(0.8314696123 / C3),
473 FCos8N(0.3826834324 / C2), FCos8(0.5555702330 / C3),
474 FCos8N(0.9238795325 / C2), FCos8(0.1950903220 / C3),
475 FCos8N(0.9238795325 / C2), FCos8N(0.1950903220 / C3),
476 FCos8N(0.3826834324 / C2), FCos8N(0.5555702330 / C3),
477 FCos8(0.3826834324 / C2), FCos8N(0.8314696123 / C3),
478 FCos8(0.9238795325 / C2), FCos8N(0.9807852804 / C3),
479 FCos8N(1.0000000000 / C4), FCos8(0.5555702330 / C5),
480 FCos8N(1.0000000000 / C4), FCos8N(0.9807852804 / C5),
481 FCos8N(1.0000000000 / C4), FCos8(0.1950903220 / C5),
482 FCos8N(1.0000000000 / C4), FCos8(0.8314696123 / C5),
483 FCos8N(1.0000000000 / C4), FCos8N(0.8314696123 / C5),
484 FCos8N(1.0000000000 / C4), FCos8N(0.1950903220 / C5),
485 FCos8N(1.0000000000 / C4), FCos8(0.9807852804 / C5),
486 FCos8N(1.0000000000 / C4), FCos8N(0.5555702330 / C5),
487 FCos8(0.3826834324 / C6), FCos8(0.1950903220 / C7),
488 FCos8N(0.9238795325 / C6), FCos8N(0.5555702330 / C7),
489 FCos8(0.9238795325 / C6), FCos8(0.8314696123 / C7),
490 FCos8N(0.3826834324 / C6), FCos8N(0.9807852804 / C7),
491 FCos8N(0.3826834324 / C6), FCos8(0.9807852804 / C7),
492 FCos8(0.9238795325 / C6), FCos8N(0.8314696123 / C7),
493 FCos8N(0.9238795325 / C6), FCos8(0.5555702330 / C7),
494 FCos8(0.3826834324 / C6), FCos8N(0.1950903220 / C7),
495
496 #undef C0
497 #undef C1
498 #undef C2
499 #undef C3
500 #undef C4
501 #undef C5
502 #undef C6
503 #undef C7
504 };
505
506 static const int16_t ANALYSIS_CONSTS_BAND8_ODD_MODE[80 + 64] = {
507 #define C0 2.5377944043
508 #define C1 2.4270044280
509 #define C2 2.8015616024
510 #define C3 3.1710363741
511 #define C4 2.7906148894
512 #define C5 2.4270044280
513 #define C6 2.8015616024
514 #define C7 3.1710363741
515
516 FProto8(0.00000000E+00 * C0), FProto8N(8.23919506E-04 * C0),
517 FProto8(1.56575398E-04 * C1), FProto8(1.78371725E-03 * C1),
518 FProto8(3.43256425E-04 * C2), FProto8(1.47640169E-03 * C2),
519 FProto8(5.54620202E-04 * C3), FProto8(1.13992507E-03 * C3),
520 FProto8(2.01182542E-03 * C4), FProto8(5.65949473E-03 * C4),
521 FProto8(2.10371989E-03 * C5), FProto8(3.49717454E-03 * C5),
522 FProto8(1.99454554E-03 * C6), FProto8(1.64973098E-03 * C6),
523 FProto8(1.61656283E-03 * C7), FProto8(1.78805361E-04 * C7),
524 FProto8(0.00000000E+00 * C0), FProto8N(1.46525263E-02 * C0),
525 FProto8(8.02941163E-03 * C1), FProto8(1.53184106E-02 * C1),
526 FProto8(1.04584443E-02 * C2), FProto8(1.62208471E-02 * C2),
527 FProto8(1.27472335E-02 * C3), FProto8(1.59045603E-02 * C3),
528 FProto8(1.29371806E-02 * C4), FProto8(6.79989431E-02 * C4),
529 FProto8(8.85757540E-03 * C5), FProto8(5.31873032E-02 * C5),
530 FProto8(2.92408442E-03 * C6), FProto8(3.90751381E-02 * C6),
531 FProto8N(4.91578024E-03 * C7), FProto8(2.61098752E-02 * C7),
532 FProto8(0.00000000E+00 * C0), FProto8N(1.23264548E-01 * C0),
533 FProto8(8.29847578E-02 * C1), FProto8(1.45389847E-01 * C1),
534 FProto8(9.75753918E-02 * C2), FProto8(1.40753505E-01 * C2),
535 FProto8(1.11196689E-01 * C3), FProto8(1.33264415E-01 * C3),
536 FProto8(1.46955068E-01 * C4), FProto8N(6.79989431E-02 * C4),
537 FProto8(1.45389847E-01 * C5), FProto8N(8.29847578E-02 * C5),
538 FProto8(1.40753505E-01 * C6), FProto8N(9.75753918E-02 * C6),
539 FProto8(1.33264415E-01 * C7), FProto8N(1.11196689E-01 * C7),
540 FProto8(0.00000000E+00 * C0), FProto8(1.46404076E-02 * C0),
541 FProto8N(5.31873032E-02 * C1), FProto8(8.85757540E-03 * C1),
542 FProto8N(3.90751381E-02 * C2), FProto8(2.92408442E-03 * C2),
543 FProto8N(2.61098752E-02 * C3), FProto8N(4.91578024E-03 * C3),
544 FProto8(1.29371806E-02 * C4), FProto8N(5.65949473E-03 * C4),
545 FProto8(1.53184106E-02 * C5), FProto8N(8.02941163E-03 * C5),
546 FProto8(1.62208471E-02 * C6), FProto8N(1.04584443E-02 * C6),
547 FProto8(1.59045603E-02 * C7), FProto8N(1.27472335E-02 * C7),
548 FProto8(0.00000000E+00 * C0), FProto8N(9.02154502E-04 * C0),
549 FProto8N(3.49717454E-03 * C1), FProto8(2.10371989E-03 * C1),
550 FProto8N(1.64973098E-03 * C2), FProto8(1.99454554E-03 * C2),
551 FProto8N(1.78805361E-04 * C3), FProto8(1.61656283E-03 * C3),
552 FProto8(2.01182542E-03 * C4), FProto8(0.00000000E+00 * C4),
553 FProto8(1.78371725E-03 * C5), FProto8N(1.56575398E-04 * C5),
554 FProto8(1.47640169E-03 * C6), FProto8N(3.43256425E-04 * C6),
555 FProto8(1.13992507E-03 * C7), FProto8N(5.54620202E-04 * C7),
556
557 FCos8N(1.0000000000 / C0), FCos8(0.8314696123 / C1),
558 FCos8N(1.0000000000 / C0), FCos8N(0.1950903220 / C1),
559 FCos8N(1.0000000000 / C0), FCos8N(0.9807852804 / C1),
560 FCos8N(1.0000000000 / C0), FCos8N(0.5555702330 / C1),
561 FCos8N(1.0000000000 / C0), FCos8(0.5555702330 / C1),
562 FCos8N(1.0000000000 / C0), FCos8(0.9807852804 / C1),
563 FCos8N(1.0000000000 / C0), FCos8(0.1950903220 / C1),
564 FCos8N(1.0000000000 / C0), FCos8N(0.8314696123 / C1),
565 FCos8(0.9238795325 / C2), FCos8(0.9807852804 / C3),
566 FCos8(0.3826834324 / C2), FCos8(0.8314696123 / C3),
567 FCos8N(0.3826834324 / C2), FCos8(0.5555702330 / C3),
568 FCos8N(0.9238795325 / C2), FCos8(0.1950903220 / C3),
569 FCos8N(0.9238795325 / C2), FCos8N(0.1950903220 / C3),
570 FCos8N(0.3826834324 / C2), FCos8N(0.5555702330 / C3),
571 FCos8(0.3826834324 / C2), FCos8N(0.8314696123 / C3),
572 FCos8(0.9238795325 / C2), FCos8N(0.9807852804 / C3),
573 FCos8(0.7071067812 / C4), FCos8(0.5555702330 / C5),
574 FCos8N(0.7071067812 / C4), FCos8N(0.9807852804 / C5),
575 FCos8N(0.7071067812 / C4), FCos8(0.1950903220 / C5),
576 FCos8(0.7071067812 / C4), FCos8(0.8314696123 / C5),
577 FCos8(0.7071067812 / C4), FCos8N(0.8314696123 / C5),
578 FCos8N(0.7071067812 / C4), FCos8N(0.1950903220 / C5),
579 FCos8N(0.7071067812 / C4), FCos8(0.9807852804 / C5),
580 FCos8(0.7071067812 / C4), FCos8N(0.5555702330 / C5),
581 FCos8(0.3826834324 / C6), FCos8(0.1950903220 / C7),
582 FCos8N(0.9238795325 / C6), FCos8N(0.5555702330 / C7),
583 FCos8(0.9238795325 / C6), FCos8(0.8314696123 / C7),
584 FCos8N(0.3826834324 / C6), FCos8N(0.9807852804 / C7),
585 FCos8N(0.3826834324 / C6), FCos8(0.9807852804 / C7),
586 FCos8(0.9238795325 / C6), FCos8N(0.8314696123 / C7),
587 FCos8N(0.9238795325 / C6), FCos8(0.5555702330 / C7),
588 FCos8(0.3826834324 / C6), FCos8N(0.1950903220 / C7),
589
590 #undef C0
591 #undef C1
592 #undef C2
593 #undef C3
594 #undef C4
595 #undef C5
596 #undef C6
597 #undef C7
598 };
599 #endif // SBC_TABLES_H
600