OSDN Git Service

sbc: Use plain C primitive if doing msbc on neon
[android-x86/external-bluetooth-sbc.git] / sbc / sbc_tables.h
1 /*
2  *
3  *  Bluetooth low-complexity, subband codec (SBC) library
4  *
5  *  Copyright (C) 2008-2010  Nokia Corporation
6  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
7  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk@ploetzli.ch>
8  *  Copyright (C) 2005-2006  Brad Midgley <bmidgley@xmission.com>
9  *
10  *
11  *  This library is free software; you can redistribute it and/or
12  *  modify it under the terms of the GNU Lesser General Public
13  *  License as published by the Free Software Foundation; either
14  *  version 2.1 of the License, or (at your option) any later version.
15  *
16  *  This library is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  Lesser General Public License for more details.
20  *
21  *  You should have received a copy of the GNU Lesser General Public
22  *  License along with this library; if not, write to the Free Software
23  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  */
26
27 /* A2DP specification: Appendix B, page 69 */
28 static const int sbc_offset4[4][4] = {
29         { -1, 0, 0, 0 },
30         { -2, 0, 0, 1 },
31         { -2, 0, 0, 1 },
32         { -2, 0, 0, 1 }
33 };
34
35 /* A2DP specification: Appendix B, page 69 */
36 static const int sbc_offset8[4][8] = {
37         { -2, 0, 0, 0, 0, 0, 0, 1 },
38         { -3, 0, 0, 0, 0, 0, 1, 2 },
39         { -4, 0, 0, 0, 0, 0, 1, 2 },
40         { -4, 0, 0, 0, 0, 0, 1, 2 }
41 };
42
43 /* extra bits of precision for the synthesis filter input data */
44 #define SBCDEC_FIXED_EXTRA_BITS 2
45
46 #define SS4(val) ASR(val, SCALE_SPROTO4_TBL)
47 #define SS8(val) ASR(val, SCALE_SPROTO8_TBL)
48 #define SN4(val) ASR(val, SCALE_NPROTO4_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)
49 #define SN8(val) ASR(val, SCALE_NPROTO8_TBL + 1 + SBCDEC_FIXED_EXTRA_BITS)
50
51 static const int32_t sbc_proto_4_40m0[] = {
52         SS4(0x00000000), SS4(0xffa6982f), SS4(0xfba93848), SS4(0x0456c7b8),
53         SS4(0x005967d1), SS4(0xfffb9ac7), SS4(0xff589157), SS4(0xf9c2a8d8),
54         SS4(0x027c1434), SS4(0x0019118b), SS4(0xfff3c74c), SS4(0xff137330),
55         SS4(0xf81b8d70), SS4(0x00ec1b8b), SS4(0xfff0b71a), SS4(0xffe99b00),
56         SS4(0xfef84470), SS4(0xf6fb4370), SS4(0xffcdc351), SS4(0xffe01dc7)
57 };
58
59 static const int32_t sbc_proto_4_40m1[] = {
60         SS4(0xffe090ce), SS4(0xff2c0475), SS4(0xf694f800), SS4(0xff2c0475),
61         SS4(0xffe090ce), SS4(0xffe01dc7), SS4(0xffcdc351), SS4(0xf6fb4370),
62         SS4(0xfef84470), SS4(0xffe99b00), SS4(0xfff0b71a), SS4(0x00ec1b8b),
63         SS4(0xf81b8d70), SS4(0xff137330), SS4(0xfff3c74c), SS4(0x0019118b),
64         SS4(0x027c1434), SS4(0xf9c2a8d8), SS4(0xff589157), SS4(0xfffb9ac7)
65 };
66
67 static const int32_t sbc_proto_8_80m0[] = {
68         SS8(0x00000000), SS8(0xfe8d1970), SS8(0xee979f00), SS8(0x11686100),
69         SS8(0x0172e690), SS8(0xfff5bd1a), SS8(0xfdf1c8d4), SS8(0xeac182c0),
70         SS8(0x0d9daee0), SS8(0x00e530da), SS8(0xffe9811d), SS8(0xfd52986c),
71         SS8(0xe7054ca0), SS8(0x0a00d410), SS8(0x006c1de4), SS8(0xffdba705),
72         SS8(0xfcbc98e8), SS8(0xe3889d20), SS8(0x06af2308), SS8(0x000bb7db),
73         SS8(0xffca00ed), SS8(0xfc3fbb68), SS8(0xe071bc00), SS8(0x03bf7948),
74         SS8(0xffc4e05c), SS8(0xffb54b3b), SS8(0xfbedadc0), SS8(0xdde26200),
75         SS8(0x0142291c), SS8(0xff960e94), SS8(0xff9f3e17), SS8(0xfbd8f358),
76         SS8(0xdbf79400), SS8(0xff405e01), SS8(0xff7d4914), SS8(0xff8b1a31),
77         SS8(0xfc1417b8), SS8(0xdac7bb40), SS8(0xfdbb828c), SS8(0xff762170)
78 };
79
80 static const int32_t sbc_proto_8_80m1[] = {
81         SS8(0xff7c272c), SS8(0xfcb02620), SS8(0xda612700), SS8(0xfcb02620),
82         SS8(0xff7c272c), SS8(0xff762170), SS8(0xfdbb828c), SS8(0xdac7bb40),
83         SS8(0xfc1417b8), SS8(0xff8b1a31), SS8(0xff7d4914), SS8(0xff405e01),
84         SS8(0xdbf79400), SS8(0xfbd8f358), SS8(0xff9f3e17), SS8(0xff960e94),
85         SS8(0x0142291c), SS8(0xdde26200), SS8(0xfbedadc0), SS8(0xffb54b3b),
86         SS8(0xffc4e05c), SS8(0x03bf7948), SS8(0xe071bc00), SS8(0xfc3fbb68),
87         SS8(0xffca00ed), SS8(0x000bb7db), SS8(0x06af2308), SS8(0xe3889d20),
88         SS8(0xfcbc98e8), SS8(0xffdba705), SS8(0x006c1de4), SS8(0x0a00d410),
89         SS8(0xe7054ca0), SS8(0xfd52986c), SS8(0xffe9811d), SS8(0x00e530da),
90         SS8(0x0d9daee0), SS8(0xeac182c0), SS8(0xfdf1c8d4), SS8(0xfff5bd1a)
91 };
92
93 static const int32_t synmatrix4[8][4] = {
94         { SN4(0x05a82798), SN4(0xfa57d868), SN4(0xfa57d868), SN4(0x05a82798) },
95         { SN4(0x030fbc54), SN4(0xf89be510), SN4(0x07641af0), SN4(0xfcf043ac) },
96         { SN4(0x00000000), SN4(0x00000000), SN4(0x00000000), SN4(0x00000000) },
97         { SN4(0xfcf043ac), SN4(0x07641af0), SN4(0xf89be510), SN4(0x030fbc54) },
98         { SN4(0xfa57d868), SN4(0x05a82798), SN4(0x05a82798), SN4(0xfa57d868) },
99         { SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) },
100         { SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000), SN4(0xf8000000) },
101         { SN4(0xf89be510), SN4(0xfcf043ac), SN4(0x030fbc54), SN4(0x07641af0) }
102 };
103
104 static const int32_t synmatrix8[16][8] = {
105         { SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798),
106           SN8(0x05a82798), SN8(0xfa57d868), SN8(0xfa57d868), SN8(0x05a82798) },
107         { SN8(0x0471ced0), SN8(0xf8275a10), SN8(0x018f8b84), SN8(0x06a6d988),
108           SN8(0xf9592678), SN8(0xfe70747c), SN8(0x07d8a5f0), SN8(0xfb8e3130) },
109         { SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac),
110           SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54) },
111         { SN8(0x018f8b84), SN8(0xfb8e3130), SN8(0x06a6d988), SN8(0xf8275a10),
112           SN8(0x07d8a5f0), SN8(0xf9592678), SN8(0x0471ced0), SN8(0xfe70747c) },
113         { SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000),
114           SN8(0x00000000), SN8(0x00000000), SN8(0x00000000), SN8(0x00000000) },
115         { SN8(0xfe70747c), SN8(0x0471ced0), SN8(0xf9592678), SN8(0x07d8a5f0),
116           SN8(0xf8275a10), SN8(0x06a6d988), SN8(0xfb8e3130), SN8(0x018f8b84) },
117         { SN8(0xfcf043ac), SN8(0x07641af0), SN8(0xf89be510), SN8(0x030fbc54),
118           SN8(0x030fbc54), SN8(0xf89be510), SN8(0x07641af0), SN8(0xfcf043ac) },
119         { SN8(0xfb8e3130), SN8(0x07d8a5f0), SN8(0xfe70747c), SN8(0xf9592678),
120           SN8(0x06a6d988), SN8(0x018f8b84), SN8(0xf8275a10), SN8(0x0471ced0) },
121         { SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868),
122           SN8(0xfa57d868), SN8(0x05a82798), SN8(0x05a82798), SN8(0xfa57d868) },
123         { SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
124           SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) },
125         { SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
126           SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
127         { SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
128           SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
129         { SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000),
130           SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000), SN8(0xf8000000) },
131         { SN8(0xf8275a10), SN8(0xf9592678), SN8(0xfb8e3130), SN8(0xfe70747c),
132           SN8(0x018f8b84), SN8(0x0471ced0), SN8(0x06a6d988), SN8(0x07d8a5f0) },
133         { SN8(0xf89be510), SN8(0xfcf043ac), SN8(0x030fbc54), SN8(0x07641af0),
134           SN8(0x07641af0), SN8(0x030fbc54), SN8(0xfcf043ac), SN8(0xf89be510) },
135         { SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
136           SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
137 };
138
139 /* Uncomment the following line to enable high precision build of SBC encoder */
140
141 /* #define SBC_HIGH_PRECISION */
142
143 #ifdef SBC_HIGH_PRECISION
144 #define FIXED_A int64_t /* data type for fixed point accumulator */
145 #define FIXED_T int32_t /* data type for fixed point constants */
146 #define SBC_FIXED_EXTRA_BITS 16
147 #else
148 #define FIXED_A int32_t /* data type for fixed point accumulator */
149 #define FIXED_T int16_t /* data type for fixed point constants */
150 #define SBC_FIXED_EXTRA_BITS 0
151 #endif
152
153 /* A2DP specification: Section 12.8 Tables
154  *
155  * Original values are premultiplied by 2 for better precision (that is the
156  * maximum which is possible without overflows)
157  *
158  * Note: in each block of 8 numbers sign was changed for elements 2 and 7
159  * in order to compensate the same change applied to cos_table_fixed_4
160  */
161 #define SBC_PROTO_FIXED4_SCALE \
162         ((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
163 #define F_PROTO4(x) (FIXED_A) ((x * 2) * \
164         ((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
165 #define F(x) F_PROTO4(x)
166 static const FIXED_T _sbc_proto_fixed4[40] = {
167         F(0.00000000E+00),  F(5.36548976E-04),
168         -F(1.49188357E-03),  F(2.73370904E-03),
169         F(3.83720193E-03),  F(3.89205149E-03),
170         F(1.86581691E-03),  F(3.06012286E-03),
171
172         F(1.09137620E-02),  F(2.04385087E-02),
173         -F(2.88757392E-02),  F(3.21939290E-02),
174         F(2.58767811E-02),  F(6.13245186E-03),
175         -F(2.88217274E-02),  F(7.76463494E-02),
176
177         F(1.35593274E-01),  F(1.94987841E-01),
178         -F(2.46636662E-01),  F(2.81828203E-01),
179         F(2.94315332E-01),  F(2.81828203E-01),
180         F(2.46636662E-01), -F(1.94987841E-01),
181
182         -F(1.35593274E-01), -F(7.76463494E-02),
183         F(2.88217274E-02),  F(6.13245186E-03),
184         F(2.58767811E-02),  F(3.21939290E-02),
185         F(2.88757392E-02), -F(2.04385087E-02),
186
187         -F(1.09137620E-02), -F(3.06012286E-03),
188         -F(1.86581691E-03),  F(3.89205149E-03),
189         F(3.83720193E-03),  F(2.73370904E-03),
190         F(1.49188357E-03), -F(5.36548976E-04),
191 };
192 #undef F
193
194 /*
195  * To produce this cosine matrix in Octave:
196  *
197  * b = zeros(4, 8);
198  * for i = 0:3
199  * for j = 0:7 b(i+1, j+1) = cos((i + 0.5) * (j - 2) * (pi/4))
200  * endfor
201  * endfor;
202  * printf("%.10f, ", b');
203  *
204  * Note: in each block of 8 numbers sign was changed for elements 2 and 7
205  *
206  * Change of sign for element 2 allows to replace constant 1.0 (not
207  * representable in Q15 format) with -1.0 (fine with Q15).
208  * Changed sign for element 7 allows to have more similar constants
209  * and simplify subband filter function code.
210  */
211 #define SBC_COS_TABLE_FIXED4_SCALE \
212         ((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
213 #define F_COS4(x) (FIXED_A) ((x) * \
214         ((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
215 #define F(x) F_COS4(x)
216 static const FIXED_T cos_table_fixed_4[32] = {
217         F(0.7071067812),  F(0.9238795325), -F(1.0000000000),  F(0.9238795325),
218         F(0.7071067812),  F(0.3826834324),  F(0.0000000000),  F(0.3826834324),
219
220         -F(0.7071067812),  F(0.3826834324), -F(1.0000000000),  F(0.3826834324),
221         -F(0.7071067812), -F(0.9238795325), -F(0.0000000000), -F(0.9238795325),
222
223         -F(0.7071067812), -F(0.3826834324), -F(1.0000000000), -F(0.3826834324),
224         -F(0.7071067812),  F(0.9238795325),  F(0.0000000000),  F(0.9238795325),
225
226         F(0.7071067812), -F(0.9238795325), -F(1.0000000000), -F(0.9238795325),
227         F(0.7071067812), -F(0.3826834324), -F(0.0000000000), -F(0.3826834324),
228 };
229 #undef F
230
231 /* A2DP specification: Section 12.8 Tables
232  *
233  * Original values are premultiplied by 4 for better precision (that is the
234  * maximum which is possible without overflows)
235  *
236  * Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
237  * in order to compensate the same change applied to cos_table_fixed_8
238  */
239 #define SBC_PROTO_FIXED8_SCALE \
240         ((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
241 #define F_PROTO8(x) (FIXED_A) ((x * 2) * \
242         ((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
243 #define F(x) F_PROTO8(x)
244 static const FIXED_T _sbc_proto_fixed8[80] = {
245         F(0.00000000E+00),  F(1.56575398E-04),
246         F(3.43256425E-04),  F(5.54620202E-04),
247         -F(8.23919506E-04),  F(1.13992507E-03),
248         F(1.47640169E-03),  F(1.78371725E-03),
249         F(2.01182542E-03),  F(2.10371989E-03),
250         F(1.99454554E-03),  F(1.61656283E-03),
251         F(9.02154502E-04),  F(1.78805361E-04),
252         F(1.64973098E-03),  F(3.49717454E-03),
253
254         F(5.65949473E-03),  F(8.02941163E-03),
255         F(1.04584443E-02),  F(1.27472335E-02),
256         -F(1.46525263E-02),  F(1.59045603E-02),
257         F(1.62208471E-02),  F(1.53184106E-02),
258         F(1.29371806E-02),  F(8.85757540E-03),
259         F(2.92408442E-03), -F(4.91578024E-03),
260         -F(1.46404076E-02),  F(2.61098752E-02),
261         F(3.90751381E-02),  F(5.31873032E-02),
262
263         F(6.79989431E-02),  F(8.29847578E-02),
264         F(9.75753918E-02),  F(1.11196689E-01),
265         -F(1.23264548E-01),  F(1.33264415E-01),
266         F(1.40753505E-01),  F(1.45389847E-01),
267         F(1.46955068E-01),  F(1.45389847E-01),
268         F(1.40753505E-01),  F(1.33264415E-01),
269         F(1.23264548E-01), -F(1.11196689E-01),
270         -F(9.75753918E-02), -F(8.29847578E-02),
271
272         -F(6.79989431E-02), -F(5.31873032E-02),
273         -F(3.90751381E-02), -F(2.61098752E-02),
274         F(1.46404076E-02), -F(4.91578024E-03),
275         F(2.92408442E-03),  F(8.85757540E-03),
276         F(1.29371806E-02),  F(1.53184106E-02),
277         F(1.62208471E-02),  F(1.59045603E-02),
278         F(1.46525263E-02), -F(1.27472335E-02),
279         -F(1.04584443E-02), -F(8.02941163E-03),
280
281         -F(5.65949473E-03), -F(3.49717454E-03),
282         -F(1.64973098E-03), -F(1.78805361E-04),
283         -F(9.02154502E-04),  F(1.61656283E-03),
284         F(1.99454554E-03),  F(2.10371989E-03),
285         F(2.01182542E-03),  F(1.78371725E-03),
286         F(1.47640169E-03),  F(1.13992507E-03),
287         F(8.23919506E-04), -F(5.54620202E-04),
288         -F(3.43256425E-04), -F(1.56575398E-04),
289 };
290 #undef F
291
292 /*
293  * To produce this cosine matrix in Octave:
294  *
295  * b = zeros(8, 16);
296  * for i = 0:7
297  * for j = 0:15 b(i+1, j+1) = cos((i + 0.5) * (j - 4) * (pi/8))
298  * endfor endfor;
299  * printf("%.10f, ", b');
300  *
301  * Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
302  *
303  * Change of sign for element 4 allows to replace constant 1.0 (not
304  * representable in Q15 format) with -1.0 (fine with Q15).
305  * Changed signs for elements 13, 14, 15 allow to have more similar constants
306  * and simplify subband filter function code.
307  */
308 #define SBC_COS_TABLE_FIXED8_SCALE \
309         ((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
310 #define F_COS8(x) (FIXED_A) ((x) * \
311         ((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
312 #define F(x) F_COS8(x)
313 static const FIXED_T cos_table_fixed_8[128] = {
314         F(0.7071067812),  F(0.8314696123),  F(0.9238795325),  F(0.9807852804),
315         -F(1.0000000000),  F(0.9807852804),  F(0.9238795325),  F(0.8314696123),
316         F(0.7071067812),  F(0.5555702330),  F(0.3826834324),  F(0.1950903220),
317         F(0.0000000000),  F(0.1950903220),  F(0.3826834324),  F(0.5555702330),
318
319         -F(0.7071067812), -F(0.1950903220),  F(0.3826834324),  F(0.8314696123),
320         -F(1.0000000000),  F(0.8314696123),  F(0.3826834324), -F(0.1950903220),
321         -F(0.7071067812), -F(0.9807852804), -F(0.9238795325), -F(0.5555702330),
322         -F(0.0000000000), -F(0.5555702330), -F(0.9238795325), -F(0.9807852804),
323
324         -F(0.7071067812), -F(0.9807852804), -F(0.3826834324),  F(0.5555702330),
325         -F(1.0000000000),  F(0.5555702330), -F(0.3826834324), -F(0.9807852804),
326         -F(0.7071067812),  F(0.1950903220),  F(0.9238795325),  F(0.8314696123),
327         F(0.0000000000),  F(0.8314696123),  F(0.9238795325),  F(0.1950903220),
328
329         F(0.7071067812), -F(0.5555702330), -F(0.9238795325),  F(0.1950903220),
330         -F(1.0000000000),  F(0.1950903220), -F(0.9238795325), -F(0.5555702330),
331         F(0.7071067812),  F(0.8314696123), -F(0.3826834324), -F(0.9807852804),
332         -F(0.0000000000), -F(0.9807852804), -F(0.3826834324),  F(0.8314696123),
333
334         F(0.7071067812),  F(0.5555702330), -F(0.9238795325), -F(0.1950903220),
335         -F(1.0000000000), -F(0.1950903220), -F(0.9238795325),  F(0.5555702330),
336         F(0.7071067812), -F(0.8314696123), -F(0.3826834324),  F(0.9807852804),
337         F(0.0000000000),  F(0.9807852804), -F(0.3826834324), -F(0.8314696123),
338
339         -F(0.7071067812),  F(0.9807852804), -F(0.3826834324), -F(0.5555702330),
340         -F(1.0000000000), -F(0.5555702330), -F(0.3826834324),  F(0.9807852804),
341         -F(0.7071067812), -F(0.1950903220),  F(0.9238795325), -F(0.8314696123),
342         -F(0.0000000000), -F(0.8314696123),  F(0.9238795325), -F(0.1950903220),
343
344         -F(0.7071067812),  F(0.1950903220),  F(0.3826834324), -F(0.8314696123),
345         -F(1.0000000000), -F(0.8314696123),  F(0.3826834324),  F(0.1950903220),
346         -F(0.7071067812),  F(0.9807852804), -F(0.9238795325),  F(0.5555702330),
347         -F(0.0000000000),  F(0.5555702330), -F(0.9238795325),  F(0.9807852804),
348
349         F(0.7071067812), -F(0.8314696123),  F(0.9238795325), -F(0.9807852804),
350         -F(1.0000000000), -F(0.9807852804),  F(0.9238795325), -F(0.8314696123),
351         F(0.7071067812), -F(0.5555702330),  F(0.3826834324), -F(0.1950903220),
352         -F(0.0000000000), -F(0.1950903220),  F(0.3826834324), -F(0.5555702330),
353 };
354 #undef F
355
356 /*
357  * Enforce 16 byte alignment for the data, which is supposed to be used
358  * with SIMD optimized code.
359  */
360
361 #define SBC_ALIGN_BITS 4
362 #define SBC_ALIGN_MASK ((1 << (SBC_ALIGN_BITS)) - 1)
363
364 #ifdef __GNUC__
365 #define SBC_ALIGNED __attribute__((aligned(1 << (SBC_ALIGN_BITS))))
366 #else
367 #define SBC_ALIGNED
368 #endif
369
370 /*
371  * Constant tables for the use in SIMD optimized analysis filters
372  * Each table consists of two parts:
373  * 1. reordered "proto" table
374  * 2. reordered "cos" table
375  *
376  * Due to non-symmetrical reordering, separate tables for "even"
377  * and "odd" cases are needed
378  */
379
380 static const FIXED_T SBC_ALIGNED analysis_consts_fixed4_simd_even[40 + 16] = {
381 #define C0 1.0932568993
382 #define C1 1.3056875580
383 #define C2 1.3056875580
384 #define C3 1.6772280856
385
386 #define F(x) F_PROTO4(x)
387          F(0.00000000E+00 * C0),  F(3.83720193E-03 * C0),
388          F(5.36548976E-04 * C1),  F(2.73370904E-03 * C1),
389          F(3.06012286E-03 * C2),  F(3.89205149E-03 * C2),
390          F(0.00000000E+00 * C3), -F(1.49188357E-03 * C3),
391          F(1.09137620E-02 * C0),  F(2.58767811E-02 * C0),
392          F(2.04385087E-02 * C1),  F(3.21939290E-02 * C1),
393          F(7.76463494E-02 * C2),  F(6.13245186E-03 * C2),
394          F(0.00000000E+00 * C3), -F(2.88757392E-02 * C3),
395          F(1.35593274E-01 * C0),  F(2.94315332E-01 * C0),
396          F(1.94987841E-01 * C1),  F(2.81828203E-01 * C1),
397         -F(1.94987841E-01 * C2),  F(2.81828203E-01 * C2),
398          F(0.00000000E+00 * C3), -F(2.46636662E-01 * C3),
399         -F(1.35593274E-01 * C0),  F(2.58767811E-02 * C0),
400         -F(7.76463494E-02 * C1),  F(6.13245186E-03 * C1),
401         -F(2.04385087E-02 * C2),  F(3.21939290E-02 * C2),
402          F(0.00000000E+00 * C3),  F(2.88217274E-02 * C3),
403         -F(1.09137620E-02 * C0),  F(3.83720193E-03 * C0),
404         -F(3.06012286E-03 * C1),  F(3.89205149E-03 * C1),
405         -F(5.36548976E-04 * C2),  F(2.73370904E-03 * C2),
406          F(0.00000000E+00 * C3), -F(1.86581691E-03 * C3),
407 #undef F
408 #define F(x) F_COS4(x)
409          F(0.7071067812 / C0),  F(0.9238795325 / C1),
410         -F(0.7071067812 / C0),  F(0.3826834324 / C1),
411         -F(0.7071067812 / C0), -F(0.3826834324 / C1),
412          F(0.7071067812 / C0), -F(0.9238795325 / C1),
413          F(0.3826834324 / C2), -F(1.0000000000 / C3),
414         -F(0.9238795325 / C2), -F(1.0000000000 / C3),
415          F(0.9238795325 / C2), -F(1.0000000000 / C3),
416         -F(0.3826834324 / C2), -F(1.0000000000 / C3),
417 #undef F
418
419 #undef C0
420 #undef C1
421 #undef C2
422 #undef C3
423 };
424
425 static const FIXED_T SBC_ALIGNED analysis_consts_fixed4_simd_odd[40 + 16] = {
426 #define C0 1.3056875580
427 #define C1 1.6772280856
428 #define C2 1.0932568993
429 #define C3 1.3056875580
430
431 #define F(x) F_PROTO4(x)
432          F(2.73370904E-03 * C0),  F(5.36548976E-04 * C0),
433         -F(1.49188357E-03 * C1),  F(0.00000000E+00 * C1),
434          F(3.83720193E-03 * C2),  F(1.09137620E-02 * C2),
435          F(3.89205149E-03 * C3),  F(3.06012286E-03 * C3),
436          F(3.21939290E-02 * C0),  F(2.04385087E-02 * C0),
437         -F(2.88757392E-02 * C1),  F(0.00000000E+00 * C1),
438          F(2.58767811E-02 * C2),  F(1.35593274E-01 * C2),
439          F(6.13245186E-03 * C3),  F(7.76463494E-02 * C3),
440          F(2.81828203E-01 * C0),  F(1.94987841E-01 * C0),
441         -F(2.46636662E-01 * C1),  F(0.00000000E+00 * C1),
442          F(2.94315332E-01 * C2), -F(1.35593274E-01 * C2),
443          F(2.81828203E-01 * C3), -F(1.94987841E-01 * C3),
444          F(6.13245186E-03 * C0), -F(7.76463494E-02 * C0),
445          F(2.88217274E-02 * C1),  F(0.00000000E+00 * C1),
446          F(2.58767811E-02 * C2), -F(1.09137620E-02 * C2),
447          F(3.21939290E-02 * C3), -F(2.04385087E-02 * C3),
448          F(3.89205149E-03 * C0), -F(3.06012286E-03 * C0),
449         -F(1.86581691E-03 * C1),  F(0.00000000E+00 * C1),
450          F(3.83720193E-03 * C2),  F(0.00000000E+00 * C2),
451          F(2.73370904E-03 * C3), -F(5.36548976E-04 * C3),
452 #undef F
453 #define F(x) F_COS4(x)
454          F(0.9238795325 / C0), -F(1.0000000000 / C1),
455          F(0.3826834324 / C0), -F(1.0000000000 / C1),
456         -F(0.3826834324 / C0), -F(1.0000000000 / C1),
457         -F(0.9238795325 / C0), -F(1.0000000000 / C1),
458          F(0.7071067812 / C2),  F(0.3826834324 / C3),
459         -F(0.7071067812 / C2), -F(0.9238795325 / C3),
460         -F(0.7071067812 / C2),  F(0.9238795325 / C3),
461          F(0.7071067812 / C2), -F(0.3826834324 / C3),
462 #undef F
463
464 #undef C0
465 #undef C1
466 #undef C2
467 #undef C3
468 };
469
470 static const FIXED_T SBC_ALIGNED analysis_consts_fixed8_simd_even[80 + 64] = {
471 #define C0 2.7906148894
472 #define C1 2.4270044280
473 #define C2 2.8015616024
474 #define C3 3.1710363741
475 #define C4 2.5377944043
476 #define C5 2.4270044280
477 #define C6 2.8015616024
478 #define C7 3.1710363741
479
480 #define F(x) F_PROTO8(x)
481          F(0.00000000E+00 * C0),  F(2.01182542E-03 * C0),
482          F(1.56575398E-04 * C1),  F(1.78371725E-03 * C1),
483          F(3.43256425E-04 * C2),  F(1.47640169E-03 * C2),
484          F(5.54620202E-04 * C3),  F(1.13992507E-03 * C3),
485         -F(8.23919506E-04 * C4),  F(0.00000000E+00 * C4),
486          F(2.10371989E-03 * C5),  F(3.49717454E-03 * C5),
487          F(1.99454554E-03 * C6),  F(1.64973098E-03 * C6),
488          F(1.61656283E-03 * C7),  F(1.78805361E-04 * C7),
489          F(5.65949473E-03 * C0),  F(1.29371806E-02 * C0),
490          F(8.02941163E-03 * C1),  F(1.53184106E-02 * C1),
491          F(1.04584443E-02 * C2),  F(1.62208471E-02 * C2),
492          F(1.27472335E-02 * C3),  F(1.59045603E-02 * C3),
493         -F(1.46525263E-02 * C4),  F(0.00000000E+00 * C4),
494          F(8.85757540E-03 * C5),  F(5.31873032E-02 * C5),
495          F(2.92408442E-03 * C6),  F(3.90751381E-02 * C6),
496         -F(4.91578024E-03 * C7),  F(2.61098752E-02 * C7),
497          F(6.79989431E-02 * C0),  F(1.46955068E-01 * C0),
498          F(8.29847578E-02 * C1),  F(1.45389847E-01 * C1),
499          F(9.75753918E-02 * C2),  F(1.40753505E-01 * C2),
500          F(1.11196689E-01 * C3),  F(1.33264415E-01 * C3),
501         -F(1.23264548E-01 * C4),  F(0.00000000E+00 * C4),
502          F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
503          F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
504          F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
505         -F(6.79989431E-02 * C0),  F(1.29371806E-02 * C0),
506         -F(5.31873032E-02 * C1),  F(8.85757540E-03 * C1),
507         -F(3.90751381E-02 * C2),  F(2.92408442E-03 * C2),
508         -F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
509          F(1.46404076E-02 * C4),  F(0.00000000E+00 * C4),
510          F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
511          F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
512          F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
513         -F(5.65949473E-03 * C0),  F(2.01182542E-03 * C0),
514         -F(3.49717454E-03 * C1),  F(2.10371989E-03 * C1),
515         -F(1.64973098E-03 * C2),  F(1.99454554E-03 * C2),
516         -F(1.78805361E-04 * C3),  F(1.61656283E-03 * C3),
517         -F(9.02154502E-04 * C4),  F(0.00000000E+00 * C4),
518          F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
519          F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
520          F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
521 #undef F
522 #define F(x) F_COS8(x)
523          F(0.7071067812 / C0),  F(0.8314696123 / C1),
524         -F(0.7071067812 / C0), -F(0.1950903220 / C1),
525         -F(0.7071067812 / C0), -F(0.9807852804 / C1),
526          F(0.7071067812 / C0), -F(0.5555702330 / C1),
527          F(0.7071067812 / C0),  F(0.5555702330 / C1),
528         -F(0.7071067812 / C0),  F(0.9807852804 / C1),
529         -F(0.7071067812 / C0),  F(0.1950903220 / C1),
530          F(0.7071067812 / C0), -F(0.8314696123 / C1),
531          F(0.9238795325 / C2),  F(0.9807852804 / C3),
532          F(0.3826834324 / C2),  F(0.8314696123 / C3),
533         -F(0.3826834324 / C2),  F(0.5555702330 / C3),
534         -F(0.9238795325 / C2),  F(0.1950903220 / C3),
535         -F(0.9238795325 / C2), -F(0.1950903220 / C3),
536         -F(0.3826834324 / C2), -F(0.5555702330 / C3),
537          F(0.3826834324 / C2), -F(0.8314696123 / C3),
538          F(0.9238795325 / C2), -F(0.9807852804 / C3),
539         -F(1.0000000000 / C4),  F(0.5555702330 / C5),
540         -F(1.0000000000 / C4), -F(0.9807852804 / C5),
541         -F(1.0000000000 / C4),  F(0.1950903220 / C5),
542         -F(1.0000000000 / C4),  F(0.8314696123 / C5),
543         -F(1.0000000000 / C4), -F(0.8314696123 / C5),
544         -F(1.0000000000 / C4), -F(0.1950903220 / C5),
545         -F(1.0000000000 / C4),  F(0.9807852804 / C5),
546         -F(1.0000000000 / C4), -F(0.5555702330 / C5),
547          F(0.3826834324 / C6),  F(0.1950903220 / C7),
548         -F(0.9238795325 / C6), -F(0.5555702330 / C7),
549          F(0.9238795325 / C6),  F(0.8314696123 / C7),
550         -F(0.3826834324 / C6), -F(0.9807852804 / C7),
551         -F(0.3826834324 / C6),  F(0.9807852804 / C7),
552          F(0.9238795325 / C6), -F(0.8314696123 / C7),
553         -F(0.9238795325 / C6),  F(0.5555702330 / C7),
554          F(0.3826834324 / C6), -F(0.1950903220 / C7),
555 #undef F
556
557 #undef C0
558 #undef C1
559 #undef C2
560 #undef C3
561 #undef C4
562 #undef C5
563 #undef C6
564 #undef C7
565 };
566
567 static const FIXED_T SBC_ALIGNED analysis_consts_fixed8_simd_odd[80 + 64] = {
568 #define C0 2.5377944043
569 #define C1 2.4270044280
570 #define C2 2.8015616024
571 #define C3 3.1710363741
572 #define C4 2.7906148894
573 #define C5 2.4270044280
574 #define C6 2.8015616024
575 #define C7 3.1710363741
576
577 #define F(x) F_PROTO8(x)
578          F(0.00000000E+00 * C0), -F(8.23919506E-04 * C0),
579          F(1.56575398E-04 * C1),  F(1.78371725E-03 * C1),
580          F(3.43256425E-04 * C2),  F(1.47640169E-03 * C2),
581          F(5.54620202E-04 * C3),  F(1.13992507E-03 * C3),
582          F(2.01182542E-03 * C4),  F(5.65949473E-03 * C4),
583          F(2.10371989E-03 * C5),  F(3.49717454E-03 * C5),
584          F(1.99454554E-03 * C6),  F(1.64973098E-03 * C6),
585          F(1.61656283E-03 * C7),  F(1.78805361E-04 * C7),
586          F(0.00000000E+00 * C0), -F(1.46525263E-02 * C0),
587          F(8.02941163E-03 * C1),  F(1.53184106E-02 * C1),
588          F(1.04584443E-02 * C2),  F(1.62208471E-02 * C2),
589          F(1.27472335E-02 * C3),  F(1.59045603E-02 * C3),
590          F(1.29371806E-02 * C4),  F(6.79989431E-02 * C4),
591          F(8.85757540E-03 * C5),  F(5.31873032E-02 * C5),
592          F(2.92408442E-03 * C6),  F(3.90751381E-02 * C6),
593         -F(4.91578024E-03 * C7),  F(2.61098752E-02 * C7),
594          F(0.00000000E+00 * C0), -F(1.23264548E-01 * C0),
595          F(8.29847578E-02 * C1),  F(1.45389847E-01 * C1),
596          F(9.75753918E-02 * C2),  F(1.40753505E-01 * C2),
597          F(1.11196689E-01 * C3),  F(1.33264415E-01 * C3),
598          F(1.46955068E-01 * C4), -F(6.79989431E-02 * C4),
599          F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
600          F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
601          F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
602          F(0.00000000E+00 * C0),  F(1.46404076E-02 * C0),
603         -F(5.31873032E-02 * C1),  F(8.85757540E-03 * C1),
604         -F(3.90751381E-02 * C2),  F(2.92408442E-03 * C2),
605         -F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
606          F(1.29371806E-02 * C4), -F(5.65949473E-03 * C4),
607          F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
608          F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
609          F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
610          F(0.00000000E+00 * C0), -F(9.02154502E-04 * C0),
611         -F(3.49717454E-03 * C1),  F(2.10371989E-03 * C1),
612         -F(1.64973098E-03 * C2),  F(1.99454554E-03 * C2),
613         -F(1.78805361E-04 * C3),  F(1.61656283E-03 * C3),
614          F(2.01182542E-03 * C4),  F(0.00000000E+00 * C4),
615          F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
616          F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
617          F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
618 #undef F
619 #define F(x) F_COS8(x)
620         -F(1.0000000000 / C0),  F(0.8314696123 / C1),
621         -F(1.0000000000 / C0), -F(0.1950903220 / C1),
622         -F(1.0000000000 / C0), -F(0.9807852804 / C1),
623         -F(1.0000000000 / C0), -F(0.5555702330 / C1),
624         -F(1.0000000000 / C0),  F(0.5555702330 / C1),
625         -F(1.0000000000 / C0),  F(0.9807852804 / C1),
626         -F(1.0000000000 / C0),  F(0.1950903220 / C1),
627         -F(1.0000000000 / C0), -F(0.8314696123 / C1),
628          F(0.9238795325 / C2),  F(0.9807852804 / C3),
629          F(0.3826834324 / C2),  F(0.8314696123 / C3),
630         -F(0.3826834324 / C2),  F(0.5555702330 / C3),
631         -F(0.9238795325 / C2),  F(0.1950903220 / C3),
632         -F(0.9238795325 / C2), -F(0.1950903220 / C3),
633         -F(0.3826834324 / C2), -F(0.5555702330 / C3),
634          F(0.3826834324 / C2), -F(0.8314696123 / C3),
635          F(0.9238795325 / C2), -F(0.9807852804 / C3),
636          F(0.7071067812 / C4),  F(0.5555702330 / C5),
637         -F(0.7071067812 / C4), -F(0.9807852804 / C5),
638         -F(0.7071067812 / C4),  F(0.1950903220 / C5),
639          F(0.7071067812 / C4),  F(0.8314696123 / C5),
640          F(0.7071067812 / C4), -F(0.8314696123 / C5),
641         -F(0.7071067812 / C4), -F(0.1950903220 / C5),
642         -F(0.7071067812 / C4),  F(0.9807852804 / C5),
643          F(0.7071067812 / C4), -F(0.5555702330 / C5),
644          F(0.3826834324 / C6),  F(0.1950903220 / C7),
645         -F(0.9238795325 / C6), -F(0.5555702330 / C7),
646          F(0.9238795325 / C6),  F(0.8314696123 / C7),
647         -F(0.3826834324 / C6), -F(0.9807852804 / C7),
648         -F(0.3826834324 / C6),  F(0.9807852804 / C7),
649          F(0.9238795325 / C6), -F(0.8314696123 / C7),
650         -F(0.9238795325 / C6),  F(0.5555702330 / C7),
651          F(0.3826834324 / C6), -F(0.1950903220 / C7),
652 #undef F
653
654 #undef C0
655 #undef C1
656 #undef C2
657 #undef C3
658 #undef C4
659 #undef C5
660 #undef C6
661 #undef C7
662 };