1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the code that performs Analysis of the input audio
22  *  stream.
23  *
24  ******************************************************************************/
25 #include "common/bt_target.h"
26 #include <string.h>
27 #include "sbc_encoder.h"
28 #include "sbc_enc_func_declare.h"
29 #include "osi/allocator.h"
30 /*#include <math.h>*/
31 #if (defined(SBC_ENC_INCLUDED) && SBC_ENC_INCLUDED == TRUE)
32 
33 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
34 #define WIND_4_SUBBANDS_0_1 (SINT32)0x01659F45  /* gas32CoeffFor4SBs[8] = -gas32CoeffFor4SBs[32] = 0x01659F45 */
35 #define WIND_4_SUBBANDS_0_2 (SINT32)0x115B1ED2  /* gas32CoeffFor4SBs[16] = -gas32CoeffFor4SBs[24] = 0x115B1ED2 */
36 #define WIND_4_SUBBANDS_1_0 (SINT32)0x001194E6  /* gas32CoeffFor4SBs[1 et 39] = 0x001194E6 */
37 #define WIND_4_SUBBANDS_1_1 (SINT32)0x029DBAA3  /* gas32CoeffFor4SBs[9 et 31] = 0x029DBAA3 */
38 #define WIND_4_SUBBANDS_1_2 (SINT32)0x18F55C90  /* gas32CoeffFor4SBs[17 et 23] = 0x18F55C90 */
39 #define WIND_4_SUBBANDS_1_3 (SINT32)0xF60FAF37  /* gas32CoeffFor4SBs[15 et 25] = 0xF60FAF37 */
40 #define WIND_4_SUBBANDS_1_4 (SINT32)0xFF9BB9D5  /* gas32CoeffFor4SBs[7 et 33] = 0xFF9BB9D5 */
41 #define WIND_4_SUBBANDS_2_0 (SINT32)0x0030E2D3  /* gas32CoeffFor4SBs[2 et 38] = 0x0030E2D3 */
42 #define WIND_4_SUBBANDS_2_1 (SINT32)0x03B23341  /* gas32CoeffFor4SBs[10 et 30] = 0x03B23341 */
43 #define WIND_4_SUBBANDS_2_2 (SINT32)0x1F91CA46  /* gas32CoeffFor4SBs[18 et 22] = 0x1F91CA46 */
44 #define WIND_4_SUBBANDS_2_3 (SINT32)0xFC4F91D4  /* gas32CoeffFor4SBs[14 et 26] = 0xFC4F91D4 */
45 #define WIND_4_SUBBANDS_2_4 (SINT32)0x003D239B  /* gas32CoeffFor4SBs[6 et 34] = 0x003D239B */
46 #define WIND_4_SUBBANDS_3_0 (SINT32)0x00599403  /* gas32CoeffFor4SBs[3 et 37] = 0x00599403 */
47 #define WIND_4_SUBBANDS_3_1 (SINT32)0x041EEE40  /* gas32CoeffFor4SBs[11 et 29] = 0x041EEE40 */
48 #define WIND_4_SUBBANDS_3_2 (SINT32)0x2412F251  /* gas32CoeffFor4SBs[19 et 21] = 0x2412F251 */
49 #define WIND_4_SUBBANDS_3_3 (SINT32)0x00C8F2BC  /* gas32CoeffFor4SBs[13 et 27] = 0x00C8F2BC */
50 #define WIND_4_SUBBANDS_3_4 (SINT32)0x007F88E4  /* gas32CoeffFor4SBs[5 et 35] = 0x007F88E4 */
51 #define WIND_4_SUBBANDS_4_0 (SINT32)0x007DBCC8  /* gas32CoeffFor4SBs[4 et 36] = 0x007DBCC8 */
52 #define WIND_4_SUBBANDS_4_1 (SINT32)0x034FEE2C  /* gas32CoeffFor4SBs[12 et 28] = 0x034FEE2C */
53 #define WIND_4_SUBBANDS_4_2 (SINT32)0x25AC1FF2  /* gas32CoeffFor4SBs[20] = 0x25AC1FF2 */
54 
55 #define WIND_8_SUBBANDS_0_1 (SINT32)0x00B97348  /* 16 0x00B97348 */
56 #define WIND_8_SUBBANDS_0_2 (SINT32)0x08B4307A  /* 32 0x08B4307A */
57 #define WIND_8_SUBBANDS_1_0 (SINT32)0x00052173  /* 1 et 79 = 0x00052173 */
58 #define WIND_8_SUBBANDS_1_1 (SINT32)0x01071B96  /* 17 et 63 = 0x01071B96 */
59 #define WIND_8_SUBBANDS_1_2 (SINT32)0x0A9F3E9A  /* 33 et 47 = 0x0A9F3E9A*/
60 #define WIND_8_SUBBANDS_1_3 (SINT32)0xF9312891  /* 31 et 49 = 0xF9312891 */
61 #define WIND_8_SUBBANDS_1_4 (SINT32)0xFF8D6793  /* 15 et 65 = 0xFF8D6793 */
62 #define WIND_8_SUBBANDS_2_0 (SINT32)0x000B3F71  /* 2 et 78 = 0x000B3F71 */
63 #define WIND_8_SUBBANDS_2_1 (SINT32)0x0156B3CA  /* 18 et 62 = 0x0156B3CA */
64 #define WIND_8_SUBBANDS_2_2 (SINT32)0x0C7D59B6  /* 34 et 46 = 0x0C7D59B6 */
65 #define WIND_8_SUBBANDS_2_3 (SINT32)0xFAFF95FC  /* 30 et 50 = 0xFAFF95FC */
66 #define WIND_8_SUBBANDS_2_4 (SINT32)0xFFC9F10E  /* 14 et 66 = 0xFFC9F10E */
67 #define WIND_8_SUBBANDS_3_0 (SINT32)0x00122C7D  /* 3 et 77 = 0x00122C7D*/
68 #define WIND_8_SUBBANDS_3_1 (SINT32)0x01A1B38B  /* 19 et 61 = 0x01A1B38B */
69 #define WIND_8_SUBBANDS_3_2 (SINT32)0x0E3BB16F  /* 35 et 45 = 0x0E3BB16F */
70 #define WIND_8_SUBBANDS_3_3 (SINT32)0xFCA86E7E  /* 29 et 51 = 0xFCA86E7E */
71 #define WIND_8_SUBBANDS_3_4 (SINT32)0xFFFA2413  /* 13 et 67 = 0xFFFA2413 */
72 #define WIND_8_SUBBANDS_4_0 (SINT32)0x001AFF89  /* 4 et 66 = 0x001AFF89 */
73 #define WIND_8_SUBBANDS_4_1 (SINT32)0x01E0224C  /* 20 et 60 = 0x01E0224C */
74 #define WIND_8_SUBBANDS_4_2 (SINT32)0x0FC721F9  /* 36 et 44 = 0x0FC721F9 */
75 #define WIND_8_SUBBANDS_4_3 (SINT32)0xFE20435D  /* 28 et 52 = 0xFE20435D */
76 #define WIND_8_SUBBANDS_4_4 (SINT32)0x001D8FD2  /* 12 et 68 = 0x001D8FD2 */
77 #define WIND_8_SUBBANDS_5_0 (SINT32)0x00255A62  /* 5 et 75 = 0x00255A62 */
78 #define WIND_8_SUBBANDS_5_1 (SINT32)0x0209291F  /* 21 et 59 = 0x0209291F */
79 #define WIND_8_SUBBANDS_5_2 (SINT32)0x110ECEF0  /* 37 et 43 = 0x110ECEF0 */
80 #define WIND_8_SUBBANDS_5_3 (SINT32)0xFF5EEB73  /* 27 et  53 = 0xFF5EEB73 */
81 #define WIND_8_SUBBANDS_5_4 (SINT32)0x0034F8B6  /* 11 et 69 = 0x0034F8B6 */
82 #define WIND_8_SUBBANDS_6_0 (SINT32)0x003060F4  /* 6 et 74 = 0x003060F4 */
83 #define WIND_8_SUBBANDS_6_1 (SINT32)0x02138653  /* 22 et 58 = 0x02138653 */
84 #define WIND_8_SUBBANDS_6_2 (SINT32)0x120435FA  /* 38 et 42 = 0x120435FA */
85 #define WIND_8_SUBBANDS_6_3 (SINT32)0x005FD0FF  /* 26 et 54 = 0x005FD0FF */
86 #define WIND_8_SUBBANDS_6_4 (SINT32)0x00415B75  /* 10 et 70 = 0x00415B75 */
87 #define WIND_8_SUBBANDS_7_0 (SINT32)0x003A72E7  /* 7 et 73 = 0x003A72E7 */
88 #define WIND_8_SUBBANDS_7_1 (SINT32)0x01F5F424  /* 23 et 57 = 0x01F5F424 */
89 #define WIND_8_SUBBANDS_7_2 (SINT32)0x129C226F  /* 39 et 41 = 0x129C226F */
90 #define WIND_8_SUBBANDS_7_3 (SINT32)0x01223EBA  /* 25 et 55 = 0x01223EBA */
91 #define WIND_8_SUBBANDS_7_4 (SINT32)0x0044EF48  /* 9 et 71 = 0x0044EF48 */
92 #define WIND_8_SUBBANDS_8_0 (SINT32)0x0041EC6A  /* 8 et 72 = 0x0041EC6A */
93 #define WIND_8_SUBBANDS_8_1 (SINT32)0x01A7ECEF  /* 24 et 56 = 0x01A7ECEF */
94 #define WIND_8_SUBBANDS_8_2 (SINT32)0x12CF6C75  /* 40 = 0x12CF6C75 */
95 #else
96 #define WIND_4_SUBBANDS_0_1 (SINT16)0x0166  /* gas32CoeffFor4SBs[8] = -gas32CoeffFor4SBs[32] = 0x01659F45 */
97 #define WIND_4_SUBBANDS_0_2 (SINT16)0x115B  /* gas32CoeffFor4SBs[16] = -gas32CoeffFor4SBs[24] = 0x115B1ED2 */
98 #define WIND_4_SUBBANDS_1_0 (SINT16)0x0012  /* gas32CoeffFor4SBs[1 et 39] = 0x001194E6 */
99 #define WIND_4_SUBBANDS_1_1 (SINT16)0x029E  /* gas32CoeffFor4SBs[9 et 31] = 0x029DBAA3 */
100 #define WIND_4_SUBBANDS_1_2 (SINT16)0x18F5  /* gas32CoeffFor4SBs[17 et 23] = 0x18F55C90 */
101 #define WIND_4_SUBBANDS_1_3 (SINT16)0xF610  /* gas32CoeffFor4SBs[15 et 25] = 0xF60FAF37 */
102 #define WIND_4_SUBBANDS_1_4 (SINT16)0xFF9C  /* gas32CoeffFor4SBs[7 et 33] = 0xFF9BB9D5 */
103 #define WIND_4_SUBBANDS_2_0 (SINT16)0x0031  /* gas32CoeffFor4SBs[2 et 38] = 0x0030E2D3 */
104 #define WIND_4_SUBBANDS_2_1 (SINT16)0x03B2  /* gas32CoeffFor4SBs[10 et 30] = 0x03B23341 */
105 #define WIND_4_SUBBANDS_2_2 (SINT16)0x1F91  /* gas32CoeffFor4SBs[18 et 22] = 0x1F91CA46 */
106 #define WIND_4_SUBBANDS_2_3 (SINT16)0xFC50  /* gas32CoeffFor4SBs[14 et 26] = 0xFC4F91D4 */
107 #define WIND_4_SUBBANDS_2_4 (SINT16)0x003D  /* gas32CoeffFor4SBs[6 et 34] = 0x003D239B */
108 #define WIND_4_SUBBANDS_3_0 (SINT16)0x005A  /* gas32CoeffFor4SBs[3 et 37] = 0x00599403 */
109 #define WIND_4_SUBBANDS_3_1 (SINT16)0x041F  /* gas32CoeffFor4SBs[11 et 29] = 0x041EEE40 */
110 #define WIND_4_SUBBANDS_3_2 (SINT16)0x2413  /* gas32CoeffFor4SBs[19 et 21] = 0x2412F251 */
111 #define WIND_4_SUBBANDS_3_3 (SINT16)0x00C9  /* gas32CoeffFor4SBs[13 et 27] = 0x00C8F2BC */
112 #define WIND_4_SUBBANDS_3_4 (SINT16)0x0080  /* gas32CoeffFor4SBs[5 et 35] = 0x007F88E4 */
113 #define WIND_4_SUBBANDS_4_0 (SINT16)0x007E  /* gas32CoeffFor4SBs[4 et 36] = 0x007DBCC8 */
114 #define WIND_4_SUBBANDS_4_1 (SINT16)0x0350  /* gas32CoeffFor4SBs[12 et 28] = 0x034FEE2C */
115 #define WIND_4_SUBBANDS_4_2 (SINT16)0x25AC  /* gas32CoeffFor4SBs[20] = 25AC1FF2 */
116 
117 #define WIND_8_SUBBANDS_0_1 (SINT16)0x00B9  /* 16 0x12CF6C75 */
118 #define WIND_8_SUBBANDS_0_2 (SINT16)0x08B4  /* 32 0x08B4307A */
119 #define WIND_8_SUBBANDS_1_0 (SINT16)0x0005  /* 1 et 79 = 0x00052173 */
120 #define WIND_8_SUBBANDS_1_1 (SINT16)0x0107  /* 17 et 63 = 0x01071B96 */
121 #define WIND_8_SUBBANDS_1_2 (SINT16)0x0A9F  /* 33 et 47 = 0x0A9F3E9A*/
122 #define WIND_8_SUBBANDS_1_3 (SINT16)0xF931  /* 31 et 49 = 0xF9312891 */
123 #define WIND_8_SUBBANDS_1_4 (SINT16)0xFF8D  /* 15 et 65 = 0xFF8D6793 */
124 #define WIND_8_SUBBANDS_2_0 (SINT16)0x000B  /* 2 et 78 = 0x000B3F71 */
125 #define WIND_8_SUBBANDS_2_1 (SINT16)0x0157  /* 18 et 62 = 0x0156B3CA */
126 #define WIND_8_SUBBANDS_2_2 (SINT16)0x0C7D  /* 34 et 46 = 0x0C7D59B6 */
127 #define WIND_8_SUBBANDS_2_3 (SINT16)0xFB00  /* 30 et 50 = 0xFAFF95FC */
128 #define WIND_8_SUBBANDS_2_4 (SINT16)0xFFCA  /* 14 et 66 = 0xFFC9F10E */
129 #define WIND_8_SUBBANDS_3_0 (SINT16)0x0012  /* 3 et 77 = 0x00122C7D*/
130 #define WIND_8_SUBBANDS_3_1 (SINT16)0x01A2  /* 19 et 61 = 0x01A1B38B */
131 #define WIND_8_SUBBANDS_3_2 (SINT16)0x0E3C  /* 35 et 45 = 0x0E3BB16F */
132 #define WIND_8_SUBBANDS_3_3 (SINT16)0xFCA8  /* 29 et 51 = 0xFCA86E7E */
133 #define WIND_8_SUBBANDS_3_4 (SINT16)0xFFFA  /* 13 et 67 = 0xFFFA2413 */
134 #define WIND_8_SUBBANDS_4_0 (SINT16)0x001B  /* 4 et 66 = 0x001AFF89 */
135 #define WIND_8_SUBBANDS_4_1 (SINT16)0x01E0  /* 20 et 60 = 0x01E0224C */
136 #define WIND_8_SUBBANDS_4_2 (SINT16)0x0FC7  /* 36 et 44 = 0x0FC721F9 */
137 #define WIND_8_SUBBANDS_4_3 (SINT16)0xFE20  /* 28 et 52 = 0xFE20435D */
138 #define WIND_8_SUBBANDS_4_4 (SINT16)0x001E  /* 12 et 68 = 0x001D8FD2 */
139 #define WIND_8_SUBBANDS_5_0 (SINT16)0x0025  /* 5 et 75 = 0x00255A62 */
140 #define WIND_8_SUBBANDS_5_1 (SINT16)0x0209  /* 21 et 59 = 0x0209291F */
141 #define WIND_8_SUBBANDS_5_2 (SINT16)0x110F  /* 37 et 43 = 0x110ECEF0 */
142 #define WIND_8_SUBBANDS_5_3 (SINT16)0xFF5F  /* 27 et  53 = 0xFF5EEB73 */
143 #define WIND_8_SUBBANDS_5_4 (SINT16)0x0035  /* 11 et 69 = 0x0034F8B6 */
144 #define WIND_8_SUBBANDS_6_0 (SINT16)0x0030  /* 6 et 74 = 0x003060F4 */
145 #define WIND_8_SUBBANDS_6_1 (SINT16)0x0214  /* 22 et 58 = 0x02138653 */
146 #define WIND_8_SUBBANDS_6_2 (SINT16)0x1204  /* 38 et 42 = 0x120435FA */
147 #define WIND_8_SUBBANDS_6_3 (SINT16)0x0060  /* 26 et 54 = 0x005FD0FF */
148 #define WIND_8_SUBBANDS_6_4 (SINT16)0x0041  /* 10 et 70 = 0x00415B75 */
149 #define WIND_8_SUBBANDS_7_0 (SINT16)0x003A  /* 7 et 73 = 0x003A72E7 */
150 #define WIND_8_SUBBANDS_7_1 (SINT16)0x01F6  /* 23 et 57 = 0x01F5F424 */
151 #define WIND_8_SUBBANDS_7_2 (SINT16)0x129C  /* 39 et 41 = 0x129C226F */
152 #define WIND_8_SUBBANDS_7_3 (SINT16)0x0122  /* 25 et 55 = 0x01223EBA */
153 #define WIND_8_SUBBANDS_7_4 (SINT16)0x0045  /* 9 et 71 = 0x0044EF48 */
154 #define WIND_8_SUBBANDS_8_0 (SINT16)0x0042  /* 8 et 72 = 0x0041EC6A */
155 #define WIND_8_SUBBANDS_8_1 (SINT16)0x01A8  /* 24 et 56 = 0x01A7ECEF */
156 #define WIND_8_SUBBANDS_8_2 (SINT16)0x12CF  /* 40 = 0x12CF6C75 */
157 #endif
158 
159 #if (SBC_USE_ARM_PRAGMA==TRUE)
160 #pragma arm section zidata = "sbc_s32_analysis_section"
161 #endif
162 #if BT_BLE_DYNAMIC_ENV_MEMORY == FALSE
163 static SINT32   s32DCTY[16]  = {0};
164 static SINT32   s32X[ENC_VX_BUFFER_SIZE / 2];
165 static SINT16   *s16X = (SINT16 *) s32X;   /* s16X must be 32 bits aligned cf  SHIFTUP_X8_2*/
166 #else
167 static SINT32   *s32DCTY;
168 static SINT32   *s32X;
169 static SINT16   *s16X;   /* s16X must be 32 bits aligned cf  SHIFTUP_X8_2*/
170 #endif //BT_BLE_DYNAMIC_ENV_MEMORY == FALSE
171 
172 #if (SBC_USE_ARM_PRAGMA==TRUE)
173 #pragma arm section zidata
174 #endif
175 
176 /* This macro is for 4 subbands */
177 #define SHIFTUP_X4                                                               \
178 {                                                                                   \
179     ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+38);                                 \
180     for (i=0;i<9;i++)                                                               \
181     {                                                                               \
182         *ps32X=*(ps32X-2-(ShiftCounter>>1));  ps32X--;                                 \
183         *ps32X=*(ps32X-2-(ShiftCounter>>1));  ps32X--;                                 \
184     }                                                                               \
185 }
186 #define SHIFTUP_X4_2                                                              \
187 {                                                                                   \
188     ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+38);                                   \
189     ps32X2=(SINT32 *)(s16X+(EncMaxShiftCounter<<1)+78);                             \
190     for (i=0;i<9;i++)                                                               \
191     {                                                                               \
192         *ps32X=*(ps32X-2-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-2-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
193         *ps32X=*(ps32X-2-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-2-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
194     }                                                                               \
195 }
196 
197 /* This macro is for 8 subbands */
198 #define SHIFTUP_X8                                                               \
199 {                                                                                   \
200     ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+78);                                 \
201     for (i=0;i<9;i++)                                                               \
202     {                                                                               \
203         *ps32X=*(ps32X-4-(ShiftCounter>>1));  ps32X--;                                 \
204         *ps32X=*(ps32X-4-(ShiftCounter>>1));  ps32X--;                                 \
205         *ps32X=*(ps32X-4-(ShiftCounter>>1));  ps32X--;                                 \
206         *ps32X=*(ps32X-4-(ShiftCounter>>1));  ps32X--;                                 \
207     }                                                                               \
208 }
209 #define SHIFTUP_X8_2                                                               \
210 {                                                                                   \
211     ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+78);                                   \
212     ps32X2=(SINT32 *)(s16X+(EncMaxShiftCounter<<1)+158);                             \
213     for (i=0;i<9;i++)                                                               \
214     {                                                                               \
215         *ps32X=*(ps32X-4-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
216         *ps32X=*(ps32X-4-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
217         *ps32X=*(ps32X-4-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
218         *ps32X=*(ps32X-4-(ShiftCounter>>1));  *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--;  ps32X2--;                     \
219     }                                                                               \
220 }
221 
222 #if (SBC_ARM_ASM_OPT==TRUE)
223 #define WINDOW_ACCU_8_0 \
224 {\
225     __asm\
226     {\
227         MUL s32Hi,WIND_8_SUBBANDS_0_1,(s16X[ChOffset+16]-s16X[ChOffset+64]);\
228         MLA s32Hi,WIND_8_SUBBANDS_0_2,(s16X[ChOffset+32]-s16X[ChOffset+48]),s32Hi;\
229         MOV s32DCTY[0],s32Hi;\
230     }\
231 }
232 #define WINDOW_ACCU_8_1_15 \
233 {\
234     __asm\
235     {\
236         MUL s32Hi,WIND_8_SUBBANDS_1_0,s16X[ChOffset+1];\
237         MUL s32Hi2,WIND_8_SUBBANDS_1_0,s16X[ChOffset+64+15];\
238         MLA s32Hi,WIND_8_SUBBANDS_1_1,s16X[ChOffset+16+1],s32Hi;\
239         MLA s32Hi2,WIND_8_SUBBANDS_1_1,s16X[ChOffset+48+15],s32Hi2;\
240         MLA s32Hi,WIND_8_SUBBANDS_1_2,s16X[ChOffset+32+1],s32Hi;\
241         MLA s32Hi2,WIND_8_SUBBANDS_1_2,s16X[ChOffset+32+15],s32Hi2;\
242         MLA s32Hi,WIND_8_SUBBANDS_1_3,s16X[ChOffset+48+1],s32Hi;\
243         MLA s32Hi2,WIND_8_SUBBANDS_1_3,s16X[ChOffset+16+15],s32Hi2;\
244         MLA s32Hi,WIND_8_SUBBANDS_1_4,s16X[ChOffset+64+1],s32Hi;\
245         MLA s32Hi2,WIND_8_SUBBANDS_1_4,s16X[ChOffset+15],s32Hi2;\
246         MOV s32DCTY[1],s32Hi;\
247         MOV s32DCTY[15],s32Hi2;\
248     }\
249 }
250 #define WINDOW_ACCU_8_2_14 \
251 {\
252     __asm\
253     {\
254         MUL s32Hi,WIND_8_SUBBANDS_2_0,s16X[ChOffset+2];\
255         MUL s32Hi2,WIND_8_SUBBANDS_2_0,s16X[ChOffset+64+14];\
256         MLA s32Hi,WIND_8_SUBBANDS_2_1,s16X[ChOffset+16+2],s32Hi;\
257         MLA s32Hi2,WIND_8_SUBBANDS_2_1,s16X[ChOffset+48+14],s32Hi2;\
258         MLA s32Hi,WIND_8_SUBBANDS_2_2,s16X[ChOffset+32+2],s32Hi;\
259         MLA s32Hi2,WIND_8_SUBBANDS_2_2,s16X[ChOffset+32+14],s32Hi2;\
260         MLA s32Hi,WIND_8_SUBBANDS_2_3,s16X[ChOffset+48+2],s32Hi;\
261         MLA s32Hi2,WIND_8_SUBBANDS_2_3,s16X[ChOffset+16+14],s32Hi2;\
262         MLA s32Hi,WIND_8_SUBBANDS_2_4,s16X[ChOffset+64+2],s32Hi;\
263         MLA s32Hi2,WIND_8_SUBBANDS_2_4,s16X[ChOffset+14],s32Hi2;\
264         MOV s32DCTY[2],s32Hi;\
265         MOV s32DCTY[14],s32Hi2;\
266     }\
267 }
268 #define WINDOW_ACCU_8_3_13 \
269 {\
270     __asm\
271     {\
272         MUL s32Hi,WIND_8_SUBBANDS_3_0,s16X[ChOffset+3];\
273         MUL s32Hi2,WIND_8_SUBBANDS_3_0,s16X[ChOffset+64+13];\
274         MLA s32Hi,WIND_8_SUBBANDS_3_1,s16X[ChOffset+16+3],s32Hi;\
275         MLA s32Hi2,WIND_8_SUBBANDS_3_1,s16X[ChOffset+48+13],s32Hi2;\
276         MLA s32Hi,WIND_8_SUBBANDS_3_2,s16X[ChOffset+32+3],s32Hi;\
277         MLA s32Hi2,WIND_8_SUBBANDS_3_2,s16X[ChOffset+32+13],s32Hi2;\
278         MLA s32Hi,WIND_8_SUBBANDS_3_3,s16X[ChOffset+48+3],s32Hi;\
279         MLA s32Hi2,WIND_8_SUBBANDS_3_3,s16X[ChOffset+16+13],s32Hi2;\
280         MLA s32Hi,WIND_8_SUBBANDS_3_4,s16X[ChOffset+64+3],s32Hi;\
281         MLA s32Hi2,WIND_8_SUBBANDS_3_4,s16X[ChOffset+13],s32Hi2;\
282         MOV s32DCTY[3],s32Hi;\
283         MOV s32DCTY[13],s32Hi2;\
284     }\
285 }
286 #define WINDOW_ACCU_8_4_12 \
287 {\
288     __asm\
289     {\
290         MUL s32Hi,WIND_8_SUBBANDS_4_0,s16X[ChOffset+4];\
291         MUL s32Hi2,WIND_8_SUBBANDS_4_0,s16X[ChOffset+64+12];\
292         MLA s32Hi,WIND_8_SUBBANDS_4_1,s16X[ChOffset+16+4],s32Hi;\
293         MLA s32Hi2,WIND_8_SUBBANDS_4_1,s16X[ChOffset+48+12],s32Hi2;\
294         MLA s32Hi,WIND_8_SUBBANDS_4_2,s16X[ChOffset+32+4],s32Hi;\
295         MLA s32Hi2,WIND_8_SUBBANDS_4_2,s16X[ChOffset+32+12],s32Hi2;\
296         MLA s32Hi,WIND_8_SUBBANDS_4_3,s16X[ChOffset+48+4],s32Hi;\
297         MLA s32Hi2,WIND_8_SUBBANDS_4_3,s16X[ChOffset+16+12],s32Hi2;\
298         MLA s32Hi,WIND_8_SUBBANDS_4_4,s16X[ChOffset+64+4],s32Hi;\
299         MLA s32Hi2,WIND_8_SUBBANDS_4_4,s16X[ChOffset+12],s32Hi2;\
300         MOV s32DCTY[4],s32Hi;\
301         MOV s32DCTY[12],s32Hi2;\
302     }\
303 }
304 #define WINDOW_ACCU_8_5_11 \
305 {\
306     __asm\
307     {\
308         MUL s32Hi,WIND_8_SUBBANDS_5_0,s16X[ChOffset+5];\
309         MUL s32Hi2,WIND_8_SUBBANDS_5_0,s16X[ChOffset+64+11];\
310         MLA s32Hi,WIND_8_SUBBANDS_5_1,s16X[ChOffset+16+5],s32Hi;\
311         MLA s32Hi2,WIND_8_SUBBANDS_5_1,s16X[ChOffset+48+11],s32Hi2;\
312         MLA s32Hi,WIND_8_SUBBANDS_5_2,s16X[ChOffset+32+5],s32Hi;\
313         MLA s32Hi2,WIND_8_SUBBANDS_5_2,s16X[ChOffset+32+11],s32Hi2;\
314         MLA s32Hi,WIND_8_SUBBANDS_5_3,s16X[ChOffset+48+5],s32Hi;\
315         MLA s32Hi2,WIND_8_SUBBANDS_5_3,s16X[ChOffset+16+11],s32Hi2;\
316         MLA s32Hi,WIND_8_SUBBANDS_5_4,s16X[ChOffset+64+5],s32Hi;\
317         MLA s32Hi2,WIND_8_SUBBANDS_5_4,s16X[ChOffset+11],s32Hi2;\
318         MOV s32DCTY[5],s32Hi;\
319         MOV s32DCTY[11],s32Hi2;\
320     }\
321 }
322 #define WINDOW_ACCU_8_6_10 \
323 {\
324     __asm\
325     {\
326         MUL s32Hi,WIND_8_SUBBANDS_6_0,s16X[ChOffset+6];\
327         MUL s32Hi2,WIND_8_SUBBANDS_6_0,s16X[ChOffset+64+10];\
328         MLA s32Hi,WIND_8_SUBBANDS_6_1,s16X[ChOffset+16+6],s32Hi;\
329         MLA s32Hi2,WIND_8_SUBBANDS_6_1,s16X[ChOffset+48+10],s32Hi2;\
330         MLA s32Hi,WIND_8_SUBBANDS_6_2,s16X[ChOffset+32+6],s32Hi;\
331         MLA s32Hi2,WIND_8_SUBBANDS_6_2,s16X[ChOffset+32+10],s32Hi2;\
332         MLA s32Hi,WIND_8_SUBBANDS_6_3,s16X[ChOffset+48+6],s32Hi;\
333         MLA s32Hi2,WIND_8_SUBBANDS_6_3,s16X[ChOffset+16+10],s32Hi2;\
334         MLA s32Hi,WIND_8_SUBBANDS_6_4,s16X[ChOffset+64+6],s32Hi;\
335         MLA s32Hi2,WIND_8_SUBBANDS_6_4,s16X[ChOffset+10],s32Hi2;\
336         MOV s32DCTY[6],s32Hi;\
337         MOV s32DCTY[10],s32Hi2;\
338     }\
339 }
340 #define WINDOW_ACCU_8_7_9 \
341 {\
342     __asm\
343     {\
344         MUL s32Hi,WIND_8_SUBBANDS_7_0,s16X[ChOffset+7];\
345         MUL s32Hi2,WIND_8_SUBBANDS_7_0,s16X[ChOffset+64+9];\
346         MLA s32Hi,WIND_8_SUBBANDS_7_1,s16X[ChOffset+16+7],s32Hi;\
347         MLA s32Hi2,WIND_8_SUBBANDS_7_1,s16X[ChOffset+48+9],s32Hi2;\
348         MLA s32Hi,WIND_8_SUBBANDS_7_2,s16X[ChOffset+32+7],s32Hi;\
349         MLA s32Hi2,WIND_8_SUBBANDS_7_2,s16X[ChOffset+32+9],s32Hi2;\
350         MLA s32Hi,WIND_8_SUBBANDS_7_3,s16X[ChOffset+48+7],s32Hi;\
351         MLA s32Hi2,WIND_8_SUBBANDS_7_3,s16X[ChOffset+16+9],s32Hi2;\
352         MLA s32Hi,WIND_8_SUBBANDS_7_4,s16X[ChOffset+64+7],s32Hi;\
353         MLA s32Hi2,WIND_8_SUBBANDS_7_4,s16X[ChOffset+9],s32Hi2;\
354         MOV s32DCTY[7],s32Hi;\
355         MOV s32DCTY[9],s32Hi2;\
356     }\
357 }
358 #define WINDOW_ACCU_8_8 \
359 {\
360     __asm\
361     {\
362         MUL s32Hi,WIND_8_SUBBANDS_8_0,(s16X[ChOffset+8]+s16X[ChOffset+8+64]);\
363         MLA s32Hi,WIND_8_SUBBANDS_8_1,(s16X[ChOffset+8+16]+s16X[ChOffset+8+64]),s32Hi;\
364         MLA s32Hi,WIND_8_SUBBANDS_8_2,s16X[ChOffset+8+32],s32Hi;\
365         MOV s32DCTY[8],s32Hi;\
366     }\
367 }
368 #define WINDOW_ACCU_4_0 \
369 {\
370     __asm\
371     {\
372         MUL s32Hi,WIND_4_SUBBANDS_0_1,(s16X[ChOffset+8]-s16X[ChOffset+32]);\
373         MLA s32Hi,WIND_4_SUBBANDS_0_2,(s16X[ChOffset+16]-s16X[ChOffset+24]),s32Hi;\
374         MOV s32DCTY[0],s32Hi;\
375     }\
376 }
377 #define WINDOW_ACCU_4_1_7 \
378 {\
379     __asm\
380     {\
381         MUL s32Hi,WIND_4_SUBBANDS_1_0,s16X[ChOffset+1];\
382         MUL s32Hi2,WIND_4_SUBBANDS_1_0,s16X[ChOffset+32+7];\
383         MLA s32Hi,WIND_4_SUBBANDS_1_1,s16X[ChOffset+8+1],s32Hi;\
384         MLA s32Hi2,WIND_4_SUBBANDS_1_1,s16X[ChOffset+24+7],s32Hi2;\
385         MLA s32Hi,WIND_4_SUBBANDS_1_2,s16X[ChOffset+16+1],s32Hi;\
386         MLA s32Hi2,WIND_4_SUBBANDS_1_2,s16X[ChOffset+16+7],s32Hi2;\
387         MLA s32Hi,WIND_4_SUBBANDS_1_3,s16X[ChOffset+24+1],s32Hi;\
388         MLA s32Hi2,WIND_4_SUBBANDS_1_3,s16X[ChOffset+8+7],s32Hi2;\
389         MLA s32Hi,WIND_4_SUBBANDS_1_4,s16X[ChOffset+32+1],s32Hi;\
390         MLA s32Hi2,WIND_4_SUBBANDS_1_4,s16X[ChOffset+7],s32Hi2;\
391         MOV s32DCTY[1],s32Hi;\
392         MOV s32DCTY[7],s32Hi2;\
393     }\
394 }
395 #define WINDOW_ACCU_4_2_6 \
396 {\
397     __asm\
398     {\
399         MUL s32Hi,WIND_4_SUBBANDS_2_0,s16X[ChOffset+2];\
400         MUL s32Hi2,WIND_4_SUBBANDS_2_0,s16X[ChOffset+32+6];\
401         MLA s32Hi,WIND_4_SUBBANDS_2_1,s16X[ChOffset+8+2],s32Hi;\
402         MLA s32Hi2,WIND_4_SUBBANDS_2_1,s16X[ChOffset+24+6],s32Hi2;\
403         MLA s32Hi,WIND_4_SUBBANDS_2_2,s16X[ChOffset+16+2],s32Hi;\
404         MLA s32Hi2,WIND_4_SUBBANDS_2_2,s16X[ChOffset+16+6],s32Hi2;\
405         MLA s32Hi,WIND_4_SUBBANDS_2_3,s16X[ChOffset+24+2],s32Hi;\
406         MLA s32Hi2,WIND_4_SUBBANDS_2_3,s16X[ChOffset+8+6],s32Hi2;\
407         MLA s32Hi,WIND_4_SUBBANDS_2_4,s16X[ChOffset+32+2],s32Hi;\
408         MLA s32Hi2,WIND_4_SUBBANDS_2_4,s16X[ChOffset+6],s32Hi2;\
409         MOV s32DCTY[2],s32Hi;\
410         MOV s32DCTY[6],s32Hi2;\
411     }\
412 }
413 #define WINDOW_ACCU_4_3_5 \
414 {\
415     __asm\
416     {\
417         MUL s32Hi,WIND_4_SUBBANDS_3_0,s16X[ChOffset+3];\
418         MUL s32Hi2,WIND_4_SUBBANDS_3_0,s16X[ChOffset+32+5];\
419         MLA s32Hi,WIND_4_SUBBANDS_3_1,s16X[ChOffset+8+3],s32Hi;\
420         MLA s32Hi2,WIND_4_SUBBANDS_3_1,s16X[ChOffset+24+5],s32Hi2;\
421         MLA s32Hi,WIND_4_SUBBANDS_3_2,s16X[ChOffset+16+3],s32Hi;\
422         MLA s32Hi2,WIND_4_SUBBANDS_3_2,s16X[ChOffset+16+5],s32Hi2;\
423         MLA s32Hi,WIND_4_SUBBANDS_3_3,s16X[ChOffset+24+3],s32Hi;\
424         MLA s32Hi2,WIND_4_SUBBANDS_3_3,s16X[ChOffset+8+5],s32Hi2;\
425         MLA s32Hi,WIND_4_SUBBANDS_3_4,s16X[ChOffset+32+3],s32Hi;\
426         MLA s32Hi2,WIND_4_SUBBANDS_3_4,s16X[ChOffset+5],s32Hi2;\
427         MOV s32DCTY[3],s32Hi;\
428         MOV s32DCTY[5],s32Hi2;\
429     }\
430 }
431 #define WINDOW_ACCU_4_4 \
432 {\
433     __asm\
434     {\
435         MUL s32Hi,WIND_4_SUBBANDS_4_0,(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
436         MLA s32Hi,WIND_4_SUBBANDS_4_1,(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]),s32Hi;\
437         MLA s32Hi,WIND_4_SUBBANDS_4_2,s16X[ChOffset+4+16],s32Hi;\
438         MOV s32DCTY[4],s32Hi;\
439     }\
440 }
441 
442 #define WINDOW_PARTIAL_4 \
443 {\
444     WINDOW_ACCU_4_0;     WINDOW_ACCU_4_1_7;\
445     WINDOW_ACCU_4_2_6;   WINDOW_ACCU_4_3_5;\
446     WINDOW_ACCU_4_4;\
447 }
448 
449 #define WINDOW_PARTIAL_8 \
450 {\
451     WINDOW_ACCU_8_0;     WINDOW_ACCU_8_1_15;\
452     WINDOW_ACCU_8_2_14;  WINDOW_ACCU_8_3_13;\
453     WINDOW_ACCU_8_4_12;  WINDOW_ACCU_8_5_11;\
454     WINDOW_ACCU_8_6_10;  WINDOW_ACCU_8_7_9;\
455     WINDOW_ACCU_8_8;\
456 }
457 
458 #else
459 #if (SBC_IPAQ_OPT==TRUE)
460 
461 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
462 #define WINDOW_ACCU_8_0 \
463 {\
464     s64Temp=(SINT64)WIND_8_SUBBANDS_0_1*(SINT64)(s16X[ChOffset+16]-s16X[ChOffset+64]);\
465     s64Temp+=(SINT64)WIND_8_SUBBANDS_0_2*(SINT64)(s16X[ChOffset+32]-s16X[ChOffset+48]);\
466     s32DCTY[0]=(SINT32)(s64Temp>>16);\
467 }
468 #define WINDOW_ACCU_8_1_15 \
469 {\
470     s64Temp=(SINT64)WIND_8_SUBBANDS_1_0*(SINT64)s16X[ChOffset+1];\
471     s64Temp2=(SINT64)WIND_8_SUBBANDS_1_0*(SINT64)s16X[ChOffset+64+15];\
472     s64Temp+=(SINT64)WIND_8_SUBBANDS_1_1*(SINT64)s16X[ChOffset+16+1];\
473     s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_1*(SINT64)s16X[ChOffset+48+15];\
474     s64Temp+=(SINT64)WIND_8_SUBBANDS_1_2*(SINT64)s16X[ChOffset+32+1];\
475     s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_2*(SINT64)s16X[ChOffset+32+15];\
476     s64Temp+=(SINT64)WIND_8_SUBBANDS_1_3*(SINT64)s16X[ChOffset+48+1];\
477     s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_3*(SINT64)s16X[ChOffset+16+15];\
478     s64Temp+=(SINT64)WIND_8_SUBBANDS_1_4*(SINT64)s16X[ChOffset+64+1];\
479     s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_4*(SINT64)s16X[ChOffset+15];\
480     s32DCTY[1]=(SINT32)(s64Temp>>16);\
481     s32DCTY[15]=(SINT32)(s64Temp2>>16);\
482 }
483 #define WINDOW_ACCU_8_2_14 \
484 {\
485     s64Temp=(SINT64)WIND_8_SUBBANDS_2_0*(SINT64)s16X[ChOffset+2];\
486     s64Temp2=(SINT64)WIND_8_SUBBANDS_2_0*(SINT64)s16X[ChOffset+64+14];\
487     s64Temp+=(SINT64)WIND_8_SUBBANDS_2_1*(SINT64)s16X[ChOffset+16+2];\
488     s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_1*(SINT64)s16X[ChOffset+48+14];\
489     s64Temp+=(SINT64)WIND_8_SUBBANDS_2_2*(SINT64)s16X[ChOffset+32+2];\
490     s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_2*(SINT64)s16X[ChOffset+32+14];\
491     s64Temp+=(SINT64)WIND_8_SUBBANDS_2_3*(SINT64)s16X[ChOffset+48+2];\
492     s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_3*(SINT64)s16X[ChOffset+16+14];\
493     s64Temp+=(SINT64)WIND_8_SUBBANDS_2_4*(SINT64)s16X[ChOffset+64+2];\
494     s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_4*(SINT64)s16X[ChOffset+14];\
495     s32DCTY[2]=(SINT32)(s64Temp>>16);\
496     s32DCTY[14]=(SINT32)(s64Temp2>>16);\
497 }
498 #define WINDOW_ACCU_8_3_13 \
499 {\
500     s64Temp=(SINT64)WIND_8_SUBBANDS_3_0*(SINT64)s16X[ChOffset+3];\
501     s64Temp2=(SINT64)WIND_8_SUBBANDS_3_0*(SINT64)s16X[ChOffset+64+13];\
502     s64Temp+=(SINT64)WIND_8_SUBBANDS_3_1*(SINT64)s16X[ChOffset+16+3];\
503     s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_1*(SINT64)s16X[ChOffset+48+13];\
504     s64Temp+=(SINT64)WIND_8_SUBBANDS_3_2*(SINT64)s16X[ChOffset+32+3];\
505     s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_2*(SINT64)s16X[ChOffset+32+13];\
506     s64Temp+=(SINT64)WIND_8_SUBBANDS_3_3*(SINT64)s16X[ChOffset+48+3];\
507     s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_3*(SINT64)s16X[ChOffset+16+13];\
508     s64Temp+=(SINT64)WIND_8_SUBBANDS_3_4*(SINT64)s16X[ChOffset+64+3];\
509     s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_4*(SINT64)s16X[ChOffset+13];\
510     s32DCTY[3]=(SINT32)(s64Temp>>16);\
511     s32DCTY[13]=(SINT32)(s64Temp2>>16);\
512 }
513 #define WINDOW_ACCU_8_4_12 \
514 {\
515     s64Temp=(SINT64)WIND_8_SUBBANDS_4_0*(SINT64)s16X[ChOffset+4];\
516     s64Temp2=(SINT64)WIND_8_SUBBANDS_4_0*(SINT64)s16X[ChOffset+64+12];\
517     s64Temp+=(SINT64)WIND_8_SUBBANDS_4_1*(SINT64)s16X[ChOffset+16+4];\
518     s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_1*(SINT64)s16X[ChOffset+48+12];\
519     s64Temp+=(SINT64)WIND_8_SUBBANDS_4_2*(SINT64)s16X[ChOffset+32+4];\
520     s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_2*(SINT64)s16X[ChOffset+32+12];\
521     s64Temp+=(SINT64)WIND_8_SUBBANDS_4_3*(SINT64)s16X[ChOffset+48+4];\
522     s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_3*(SINT64)s16X[ChOffset+16+12];\
523     s64Temp+=(SINT64)WIND_8_SUBBANDS_4_4*(SINT64)s16X[ChOffset+64+4];\
524     s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_4*(SINT64)s16X[ChOffset+12];\
525     s32DCTY[4]=(SINT32)(s64Temp>>16);\
526     s32DCTY[12]=(SINT32)(s64Temp2>>16);\
527 }
528 #define WINDOW_ACCU_8_5_11 \
529 {\
530     s64Temp=(SINT64)WIND_8_SUBBANDS_5_0*(SINT64)s16X[ChOffset+5];\
531     s64Temp2=(SINT64)WIND_8_SUBBANDS_5_0*(SINT64)s16X[ChOffset+64+11];\
532     s64Temp+=(SINT64)WIND_8_SUBBANDS_5_1*(SINT64)s16X[ChOffset+16+5];\
533     s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_1*(SINT64)s16X[ChOffset+48+11];\
534     s64Temp+=(SINT64)WIND_8_SUBBANDS_5_2*(SINT64)s16X[ChOffset+32+5];\
535     s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_2*(SINT64)s16X[ChOffset+32+11];\
536     s64Temp+=(SINT64)WIND_8_SUBBANDS_5_3*(SINT64)s16X[ChOffset+48+5];\
537     s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_3*(SINT64)s16X[ChOffset+16+11];\
538     s64Temp+=(SINT64)WIND_8_SUBBANDS_5_4*(SINT64)s16X[ChOffset+64+5];\
539     s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_4*(SINT64)s16X[ChOffset+11];\
540     s32DCTY[5]=(SINT32)(s64Temp>>16);\
541     s32DCTY[11]=(SINT32)(s64Temp2>>16);\
542 }
543 #define WINDOW_ACCU_8_6_10 \
544 {\
545     s64Temp=(SINT64)WIND_8_SUBBANDS_6_0*(SINT64)s16X[ChOffset+6];\
546     s64Temp2=(SINT64)WIND_8_SUBBANDS_6_0*(SINT64)s16X[ChOffset+64+10];\
547     s64Temp+=(SINT64)WIND_8_SUBBANDS_6_1*(SINT64)s16X[ChOffset+16+6];\
548     s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_1*(SINT64)s16X[ChOffset+48+10];\
549     s64Temp+=(SINT64)WIND_8_SUBBANDS_6_2*(SINT64)s16X[ChOffset+32+6];\
550     s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_2*(SINT64)s16X[ChOffset+32+10];\
551     s64Temp+=(SINT64)WIND_8_SUBBANDS_6_3*(SINT64)s16X[ChOffset+48+6];\
552     s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_3*(SINT64)s16X[ChOffset+16+10];\
553     s64Temp+=(SINT64)WIND_8_SUBBANDS_6_4*(SINT64)s16X[ChOffset+64+6];\
554     s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_4*(SINT64)s16X[ChOffset+10];\
555     s32DCTY[6]=(SINT32)(s64Temp>>16);\
556     s32DCTY[10]=(SINT32)(s64Temp2>>16);\
557 }
558 #define WINDOW_ACCU_8_7_9 \
559 {\
560     s64Temp=(SINT64)WIND_8_SUBBANDS_7_0*(SINT64)s16X[ChOffset+7];\
561     s64Temp2=(SINT64)WIND_8_SUBBANDS_7_0*(SINT64)s16X[ChOffset+64+9];\
562     s64Temp+=(SINT64)WIND_8_SUBBANDS_7_1*(SINT64)s16X[ChOffset+16+7];\
563     s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_1*(SINT64)s16X[ChOffset+48+9];\
564     s64Temp+=(SINT64)WIND_8_SUBBANDS_7_2*(SINT64)s16X[ChOffset+32+7];\
565     s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_2*(SINT64)s16X[ChOffset+32+9];\
566     s64Temp+=(SINT64)WIND_8_SUBBANDS_7_3*(SINT64)s16X[ChOffset+48+7];\
567     s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_3*(SINT64)s16X[ChOffset+16+9];\
568     s64Temp+=(SINT64)WIND_8_SUBBANDS_7_4*(SINT64)s16X[ChOffset+64+7];\
569     s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_4*(SINT64)s16X[ChOffset+9];\
570     s32DCTY[7]=(SINT32)(s64Temp>>16);\
571     s32DCTY[9]=(SINT32)(s64Temp2>>16);\
572 }
573 #define WINDOW_ACCU_8_8 \
574 {\
575     s64Temp=(SINT64)WIND_8_SUBBANDS_8_0*(SINT64)(s16X[ChOffset+8]+s16X[ChOffset+64+8]);\
576     s64Temp+=(SINT64)WIND_8_SUBBANDS_8_1*(SINT64)(s16X[ChOffset+16+8]+s16X[ChOffset+48+8]);\
577     s64Temp+=(SINT64)WIND_8_SUBBANDS_8_2*(SINT64)s16X[ChOffset+32+8];\
578     s32DCTY[8]=(SINT32)(s64Temp>>16);\
579 }
580 #define WINDOW_ACCU_4_0 \
581 {\
582     s64Temp=(SINT64)WIND_4_SUBBANDS_0_1*(SINT64)(s16X[ChOffset+8]-s16X[ChOffset+32]);\
583     s64Temp+=(SINT64)WIND_4_SUBBANDS_0_2*(SINT64)(s16X[ChOffset+16]-s16X[ChOffset+24]);\
584     s32DCTY[0]=(SINT32)(s64Temp>>16);\
585 }
586 #define WINDOW_ACCU_4_1_7 \
587 {\
588     s64Temp=(SINT64)WIND_4_SUBBANDS_1_0*(SINT64)s16X[ChOffset+1];\
589     s64Temp2=(SINT64)WIND_4_SUBBANDS_1_0*(SINT64)s16X[ChOffset+32+7];\
590     s64Temp+=(SINT64)WIND_4_SUBBANDS_1_1*(SINT64)s16X[ChOffset+8+1];\
591     s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_1*(SINT64)s16X[ChOffset+24+7];\
592     s64Temp+=(SINT64)WIND_4_SUBBANDS_1_2*(SINT64)s16X[ChOffset+16+1];\
593     s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_2*(SINT64)s16X[ChOffset+16+7];\
594     s64Temp+=(SINT64)WIND_4_SUBBANDS_1_3*(SINT64)s16X[ChOffset+24+1];\
595     s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_3*(SINT64)s16X[ChOffset+8+7];\
596     s64Temp+=(SINT64)WIND_4_SUBBANDS_1_4*(SINT64)s16X[ChOffset+32+1];\
597     s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_4*(SINT64)s16X[ChOffset+7];\
598     s32DCTY[1]=(SINT32)(s64Temp>>16);\
599     s32DCTY[7]=(SINT32)(s64Temp2>>16);\
600 }
601 #define WINDOW_ACCU_4_2_6 \
602 {\
603     s64Temp=(SINT64)WIND_4_SUBBANDS_2_0*(SINT64)s16X[ChOffset+2];\
604     s64Temp2=(SINT64)WIND_4_SUBBANDS_2_0*(SINT64)s16X[ChOffset+32+6];\
605     s64Temp+=(SINT64)WIND_4_SUBBANDS_2_1*(SINT64)s16X[ChOffset+8+2];\
606     s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_1*(SINT64)s16X[ChOffset+24+6];\
607     s64Temp+=(SINT64)WIND_4_SUBBANDS_2_2*(SINT64)s16X[ChOffset+16+2];\
608     s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_2*(SINT64)s16X[ChOffset+16+6];\
609     s64Temp+=(SINT64)WIND_4_SUBBANDS_2_3*(SINT64)s16X[ChOffset+24+2];\
610     s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_3*(SINT64)s16X[ChOffset+8+6];\
611     s64Temp+=(SINT64)WIND_4_SUBBANDS_2_4*(SINT64)s16X[ChOffset+32+2];\
612     s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_4*(SINT64)s16X[ChOffset+6];\
613     s32DCTY[2]=(SINT32)(s64Temp>>16);\
614     s32DCTY[6]=(SINT32)(s64Temp2>>16);\
615 }
616 #define WINDOW_ACCU_4_3_5 \
617 {\
618     s64Temp=(SINT64)WIND_4_SUBBANDS_3_0*(SINT64)s16X[ChOffset+3];\
619     s64Temp2=(SINT64)WIND_4_SUBBANDS_3_0*(SINT64)s16X[ChOffset+32+5];\
620     s64Temp+=(SINT64)WIND_4_SUBBANDS_3_1*(SINT64)s16X[ChOffset+8+3];\
621     s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_1*(SINT64)s16X[ChOffset+24+5];\
622     s64Temp+=(SINT64)WIND_4_SUBBANDS_3_2*(SINT64)s16X[ChOffset+16+3];\
623     s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_2*(SINT64)s16X[ChOffset+16+5];\
624     s64Temp+=(SINT64)WIND_4_SUBBANDS_3_3*(SINT64)s16X[ChOffset+24+3];\
625     s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_3*(SINT64)s16X[ChOffset+8+5];\
626     s64Temp+=(SINT64)WIND_4_SUBBANDS_3_4*(SINT64)s16X[ChOffset+32+3];\
627     s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_4*(SINT64)s16X[ChOffset+5];\
628     s32DCTY[3]=(SINT32)(s64Temp>>16);\
629     s32DCTY[5]=(SINT32)(s64Temp2>>16);\
630 }
631 
632 #define WINDOW_ACCU_4_4 \
633 {\
634     s64Temp=(SINT64)WIND_4_SUBBANDS_4_0*(SINT64)(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
635     s64Temp+=(SINT64)WIND_4_SUBBANDS_4_1*(SINT64)(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]);\
636     s64Temp+=(SINT64)WIND_4_SUBBANDS_4_2*(SINT64)s16X[ChOffset+4+16];\
637     s32DCTY[4]=(SINT32)(s64Temp>>16);\
638 }
639 #else /* SBC_IS_64_MULT_IN_WINDOW_ACCU == FALSE */
640 #define WINDOW_ACCU_8_0 \
641 {\
642     s32Temp=(SINT32)WIND_8_SUBBANDS_0_1*(SINT32)(s16X[ChOffset+16]-s16X[ChOffset+64]);\
643     s32Temp+=(SINT32)WIND_8_SUBBANDS_0_2*(SINT32)(s16X[ChOffset+32]-s16X[ChOffset+48]);\
644     s32DCTY[0]=(SINT32)s32Temp;\
645 }
646 #define WINDOW_ACCU_8_1_15 \
647 {\
648     s32Temp=(SINT32)WIND_8_SUBBANDS_1_0*(SINT32)s16X[ChOffset+1];\
649     s32Temp2=(SINT32)WIND_8_SUBBANDS_1_0*(SINT32)s16X[ChOffset+64+15];\
650     s32Temp+=(SINT32)WIND_8_SUBBANDS_1_1*(SINT32)s16X[ChOffset+16+1];\
651     s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_1*(SINT32)s16X[ChOffset+48+15];\
652     s32Temp+=(SINT32)WIND_8_SUBBANDS_1_2*(SINT32)s16X[ChOffset+32+1];\
653     s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_2*(SINT32)s16X[ChOffset+32+15];\
654     s32Temp+=(SINT32)WIND_8_SUBBANDS_1_3*(SINT32)s16X[ChOffset+48+1];\
655     s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_3*(SINT32)s16X[ChOffset+16+15];\
656     s32Temp+=(SINT32)WIND_8_SUBBANDS_1_4*(SINT32)s16X[ChOffset+64+1];\
657     s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_4*(SINT32)s16X[ChOffset+15];\
658     s32DCTY[1]=(SINT32)s32Temp;\
659     s32DCTY[15]=(SINT32)s32Temp2;\
660 }
661 #define WINDOW_ACCU_8_2_14 \
662 {\
663     s32Temp=(SINT32)WIND_8_SUBBANDS_2_0*(SINT32)s16X[ChOffset+2];\
664     s32Temp2=(SINT32)WIND_8_SUBBANDS_2_0*(SINT32)s16X[ChOffset+64+14];\
665     s32Temp+=(SINT32)WIND_8_SUBBANDS_2_1*(SINT32)s16X[ChOffset+16+2];\
666     s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_1*(SINT32)s16X[ChOffset+48+14];\
667     s32Temp+=(SINT32)WIND_8_SUBBANDS_2_2*(SINT32)s16X[ChOffset+32+2];\
668     s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_2*(SINT32)s16X[ChOffset+32+14];\
669     s32Temp+=(SINT32)WIND_8_SUBBANDS_2_3*(SINT32)s16X[ChOffset+48+2];\
670     s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_3*(SINT32)s16X[ChOffset+16+14];\
671     s32Temp+=(SINT32)WIND_8_SUBBANDS_2_4*(SINT32)s16X[ChOffset+64+2];\
672     s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_4*(SINT32)s16X[ChOffset+14];\
673     s32DCTY[2]=(SINT32)s32Temp;\
674     s32DCTY[14]=(SINT32)s32Temp2;\
675 }
676 #define WINDOW_ACCU_8_3_13 \
677 {\
678     s32Temp=(SINT32)WIND_8_SUBBANDS_3_0*(SINT32)s16X[ChOffset+3];\
679     s32Temp2=(SINT32)WIND_8_SUBBANDS_3_0*(SINT32)s16X[ChOffset+64+13];\
680     s32Temp+=(SINT32)WIND_8_SUBBANDS_3_1*(SINT32)s16X[ChOffset+16+3];\
681     s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_1*(SINT32)s16X[ChOffset+48+13];\
682     s32Temp+=(SINT32)WIND_8_SUBBANDS_3_2*(SINT32)s16X[ChOffset+32+3];\
683     s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_2*(SINT32)s16X[ChOffset+32+13];\
684     s32Temp+=(SINT32)WIND_8_SUBBANDS_3_3*(SINT32)s16X[ChOffset+48+3];\
685     s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_3*(SINT32)s16X[ChOffset+16+13];\
686     s32Temp+=(SINT32)WIND_8_SUBBANDS_3_4*(SINT32)s16X[ChOffset+64+3];\
687     s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_4*(SINT32)s16X[ChOffset+13];\
688     s32DCTY[3]=(SINT32)s32Temp;\
689     s32DCTY[13]=(SINT32)s32Temp2;\
690 }
691 #define WINDOW_ACCU_8_4_12 \
692 {\
693     s32Temp=(SINT32)WIND_8_SUBBANDS_4_0*(SINT32)s16X[ChOffset+4];\
694     s32Temp2=(SINT32)WIND_8_SUBBANDS_4_0*(SINT32)s16X[ChOffset+64+12];\
695     s32Temp+=(SINT32)WIND_8_SUBBANDS_4_1*(SINT32)s16X[ChOffset+16+4];\
696     s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_1*(SINT32)s16X[ChOffset+48+12];\
697     s32Temp+=(SINT32)WIND_8_SUBBANDS_4_2*(SINT32)s16X[ChOffset+32+4];\
698     s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_2*(SINT32)s16X[ChOffset+32+12];\
699     s32Temp+=(SINT32)WIND_8_SUBBANDS_4_3*(SINT32)s16X[ChOffset+48+4];\
700     s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_3*(SINT32)s16X[ChOffset+16+12];\
701     s32Temp+=(SINT32)WIND_8_SUBBANDS_4_4*(SINT32)s16X[ChOffset+64+4];\
702     s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_4*(SINT32)s16X[ChOffset+12];\
703     s32DCTY[4]=(SINT32)s32Temp;\
704     s32DCTY[12]=(SINT32)s32Temp2;\
705 }
706 #define WINDOW_ACCU_8_5_11 \
707 {\
708     s32Temp=(SINT32)WIND_8_SUBBANDS_5_0*(SINT32)s16X[ChOffset+5];\
709     s32Temp2=(SINT32)WIND_8_SUBBANDS_5_0*(SINT32)s16X[ChOffset+64+11];\
710     s32Temp+=(SINT32)WIND_8_SUBBANDS_5_1*(SINT32)s16X[ChOffset+16+5];\
711     s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_1*(SINT32)s16X[ChOffset+48+11];\
712     s32Temp+=(SINT32)WIND_8_SUBBANDS_5_2*(SINT32)s16X[ChOffset+32+5];\
713     s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_2*(SINT32)s16X[ChOffset+32+11];\
714     s32Temp+=(SINT32)WIND_8_SUBBANDS_5_3*(SINT32)s16X[ChOffset+48+5];\
715     s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_3*(SINT32)s16X[ChOffset+16+11];\
716     s32Temp+=(SINT32)WIND_8_SUBBANDS_5_4*(SINT32)s16X[ChOffset+64+5];\
717     s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_4*(SINT32)s16X[ChOffset+11];\
718     s32DCTY[5]=(SINT32)s32Temp;\
719     s32DCTY[11]=(SINT32)s32Temp2;\
720 }
721 #define WINDOW_ACCU_8_6_10 \
722 {\
723     s32Temp=(SINT32)WIND_8_SUBBANDS_6_0*(SINT32)s16X[ChOffset+6];\
724     s32Temp2=(SINT32)WIND_8_SUBBANDS_6_0*(SINT32)s16X[ChOffset+64+10];\
725     s32Temp+=(SINT32)WIND_8_SUBBANDS_6_1*(SINT32)s16X[ChOffset+16+6];\
726     s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_1*(SINT32)s16X[ChOffset+48+10];\
727     s32Temp+=(SINT32)WIND_8_SUBBANDS_6_2*(SINT32)s16X[ChOffset+32+6];\
728     s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_2*(SINT32)s16X[ChOffset+32+10];\
729     s32Temp+=(SINT32)WIND_8_SUBBANDS_6_3*(SINT32)s16X[ChOffset+48+6];\
730     s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_3*(SINT32)s16X[ChOffset+16+10];\
731     s32Temp+=(SINT32)WIND_8_SUBBANDS_6_4*(SINT32)s16X[ChOffset+64+6];\
732     s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_4*(SINT32)s16X[ChOffset+10];\
733     s32DCTY[6]=(SINT32)s32Temp;\
734     s32DCTY[10]=(SINT32)s32Temp2;\
735 }
736 #define WINDOW_ACCU_8_7_9 \
737 {\
738     s32Temp=(SINT32)WIND_8_SUBBANDS_7_0*(SINT32)s16X[ChOffset+7];\
739     s32Temp2=(SINT32)WIND_8_SUBBANDS_7_0*(SINT32)s16X[ChOffset+64+9];\
740     s32Temp+=(SINT32)WIND_8_SUBBANDS_7_1*(SINT32)s16X[ChOffset+16+7];\
741     s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_1*(SINT32)s16X[ChOffset+48+9];\
742     s32Temp+=(SINT32)WIND_8_SUBBANDS_7_2*(SINT32)s16X[ChOffset+32+7];\
743     s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_2*(SINT32)s16X[ChOffset+32+9];\
744     s32Temp+=(SINT32)WIND_8_SUBBANDS_7_3*(SINT32)s16X[ChOffset+48+7];\
745     s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_3*(SINT32)s16X[ChOffset+16+9];\
746     s32Temp+=(SINT32)WIND_8_SUBBANDS_7_4*(SINT32)s16X[ChOffset+64+7];\
747     s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_4*(SINT32)s16X[ChOffset+9];\
748     s32DCTY[7]=(SINT32)s32Temp;\
749     s32DCTY[9]=(SINT32)s32Temp2;\
750 }
751 #define WINDOW_ACCU_8_8 \
752 {\
753     s32Temp=(SINT32)WIND_8_SUBBANDS_8_0*(SINT32)(s16X[ChOffset+8]+s16X[ChOffset+64+8]);\
754     s32Temp+=(SINT32)WIND_8_SUBBANDS_8_1*(SINT32)(s16X[ChOffset+16+8]+s16X[ChOffset+48+8]);\
755     s32Temp+=(SINT32)WIND_8_SUBBANDS_8_2*(SINT32)s16X[ChOffset+32+8];\
756     s32DCTY[8]=(SINT32)s32Temp;\
757 }
758 #define WINDOW_ACCU_4_0 \
759 {\
760     s32Temp=(SINT32)WIND_4_SUBBANDS_0_1*(SINT32)(s16X[ChOffset+8]-s16X[ChOffset+32]);\
761     s32Temp+=(SINT32)WIND_4_SUBBANDS_0_2*(SINT32)(s16X[ChOffset+16]-s16X[ChOffset+24]);\
762     s32DCTY[0]=(SINT32)(s32Temp);\
763 }
764 #define WINDOW_ACCU_4_1_7 \
765 {\
766     s32Temp=(SINT32)WIND_4_SUBBANDS_1_0*(SINT32)s16X[ChOffset+1];\
767     s32Temp2=(SINT32)WIND_4_SUBBANDS_1_0*(SINT32)s16X[ChOffset+32+7];\
768     s32Temp+=(SINT32)WIND_4_SUBBANDS_1_1*(SINT32)s16X[ChOffset+8+1];\
769     s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_1*(SINT32)s16X[ChOffset+24+7];\
770     s32Temp+=(SINT32)WIND_4_SUBBANDS_1_2*(SINT32)s16X[ChOffset+16+1];\
771     s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_2*(SINT32)s16X[ChOffset+16+7];\
772     s32Temp+=(SINT32)WIND_4_SUBBANDS_1_3*(SINT32)s16X[ChOffset+24+1];\
773     s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_3*(SINT32)s16X[ChOffset+8+7];\
774     s32Temp+=(SINT32)WIND_4_SUBBANDS_1_4*(SINT32)s16X[ChOffset+32+1];\
775     s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_4*(SINT32)s16X[ChOffset+7];\
776     s32DCTY[1]=(SINT32)(s32Temp);\
777     s32DCTY[7]=(SINT32)(s32Temp2);\
778 }
779 #define WINDOW_ACCU_4_2_6 \
780 {\
781     s32Temp=(SINT32)WIND_4_SUBBANDS_2_0*(SINT32)s16X[ChOffset+2];\
782     s32Temp2=(SINT32)WIND_4_SUBBANDS_2_0*(SINT32)s16X[ChOffset+32+6];\
783     s32Temp+=(SINT32)WIND_4_SUBBANDS_2_1*(SINT32)s16X[ChOffset+8+2];\
784     s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_1*(SINT32)s16X[ChOffset+24+6];\
785     s32Temp+=(SINT32)WIND_4_SUBBANDS_2_2*(SINT32)s16X[ChOffset+16+2];\
786     s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_2*(SINT32)s16X[ChOffset+16+6];\
787     s32Temp+=(SINT32)WIND_4_SUBBANDS_2_3*(SINT32)s16X[ChOffset+24+2];\
788     s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_3*(SINT32)s16X[ChOffset+8+6];\
789     s32Temp+=(SINT32)WIND_4_SUBBANDS_2_4*(SINT32)s16X[ChOffset+32+2];\
790     s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_4*(SINT32)s16X[ChOffset+6];\
791     s32DCTY[2]=(SINT32)(s32Temp);\
792     s32DCTY[6]=(SINT32)(s32Temp2);\
793 }
794 #define WINDOW_ACCU_4_3_5 \
795 {\
796     s32Temp=(SINT32)WIND_4_SUBBANDS_3_0*(SINT32)s16X[ChOffset+3];\
797     s32Temp2=(SINT32)WIND_4_SUBBANDS_3_0*(SINT32)s16X[ChOffset+32+5];\
798     s32Temp+=(SINT32)WIND_4_SUBBANDS_3_1*(SINT32)s16X[ChOffset+8+3];\
799     s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_1*(SINT32)s16X[ChOffset+24+5];\
800     s32Temp+=(SINT32)WIND_4_SUBBANDS_3_2*(SINT32)s16X[ChOffset+16+3];\
801     s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_2*(SINT32)s16X[ChOffset+16+5];\
802     s32Temp+=(SINT32)WIND_4_SUBBANDS_3_3*(SINT32)s16X[ChOffset+24+3];\
803     s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_3*(SINT32)s16X[ChOffset+8+5];\
804     s32Temp+=(SINT32)WIND_4_SUBBANDS_3_4*(SINT32)s16X[ChOffset+32+3];\
805     s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_4*(SINT32)s16X[ChOffset+5];\
806     s32DCTY[3]=(SINT32)(s32Temp);\
807     s32DCTY[5]=(SINT32)(s32Temp2);\
808 }
809 
810 #define WINDOW_ACCU_4_4 \
811 {\
812     s32Temp=(SINT32)WIND_4_SUBBANDS_4_0*(SINT32)(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
813     s32Temp+=(SINT32)WIND_4_SUBBANDS_4_1*(SINT32)(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]);\
814     s32Temp+=(SINT32)WIND_4_SUBBANDS_4_2*(SINT32)s16X[ChOffset+4+16];\
815     s32DCTY[4]=(SINT32)(s32Temp);\
816 }
817 #endif
818 #define WINDOW_PARTIAL_4 \
819 {\
820     WINDOW_ACCU_4_0;     WINDOW_ACCU_4_1_7;\
821     WINDOW_ACCU_4_2_6;   WINDOW_ACCU_4_3_5;\
822     WINDOW_ACCU_4_4;\
823 }
824 
825 #define WINDOW_PARTIAL_8 \
826 {\
827     WINDOW_ACCU_8_0;         WINDOW_ACCU_8_1_15;\
828     WINDOW_ACCU_8_2_14;      WINDOW_ACCU_8_3_13;\
829     WINDOW_ACCU_8_4_12;      WINDOW_ACCU_8_5_11;\
830     WINDOW_ACCU_8_6_10;      WINDOW_ACCU_8_7_9;\
831     WINDOW_ACCU_8_8;\
832 }
833 #else
834 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
835 #define WINDOW_ACCU_4(i) \
836 {\
837     s64Temp=((SINT64)gas32CoeffFor4SBs[i] * (SINT64)s16X[ChOffset+i]);                                    \
838     s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+8)] * (SINT64)s16X[ChOffset+i+8]);                                    \
839     s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+16)] * (SINT64)s16X[ChOffset+i+16]);                                    \
840     s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+24)] * (SINT64)s16X[ChOffset+i+24]);                                    \
841     s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+32)] * (SINT64)s16X[ChOffset+i+32]);                                    \
842     s32DCTY[i]=(SINT32)(s64Temp>>16);\
843     /*printf("s32DCTY4: 0x%x \n", s32DCTY[i]);*/\
844 }
845 #else
846 #define WINDOW_ACCU_4(i) \
847 {\
848     s32DCTY[i]=(gas32CoeffFor4SBs[i * 2] * s16X[ChOffset+i])                                    \
849             +  (((SINT32)(UINT16)(gas32CoeffFor4SBs[(i * 2) + 1]) * s16X[ChOffset+i]) >> 16);   \
850     s32DCTY[i]+=(gas32CoeffFor4SBs[(i+8) * 2] * s16X[ChOffset+i+8])                                    \
851             +  (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+8) * 2) + 1]) * s16X[ChOffset+i+8]) >> 16);   \
852     s32DCTY[i]+=(gas32CoeffFor4SBs[(i+16) * 2] * s16X[ChOffset+i+16])                                    \
853             +  (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+16) * 2) + 1]) * s16X[ChOffset+i+16]) >> 16);   \
854     s32DCTY[i]+=(gas32CoeffFor4SBs[(i+24) * 2] * s16X[ChOffset+i+24])                                    \
855             +  (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+24) * 2) + 1]) * s16X[ChOffset+i+24]) >> 16);   \
856     s32DCTY[i]+=(gas32CoeffFor4SBs[(i+32) * 2] * s16X[ChOffset+i+32])                                    \
857             +  (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+32) * 2) + 1]) * s16X[ChOffset+i+32]) >> 16);   \
858 }
859 #endif
860 #define WINDOW_PARTIAL_4 \
861 {\
862     WINDOW_ACCU_4(0);      WINDOW_ACCU_4(1);\
863     WINDOW_ACCU_4(2);      WINDOW_ACCU_4(3);\
864     WINDOW_ACCU_4(4);      WINDOW_ACCU_4(5);\
865     WINDOW_ACCU_4(6);      WINDOW_ACCU_4(7);\
866 }
867 
868 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
869 #define WINDOW_ACCU_8(i) \
870 {\
871     s64Temp = ((((SINT64)gas32CoeffFor8SBs[i]      * (SINT64)s16X[ChOffset+i]   )));                 \
872     s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+16)] * (SINT64)s16X[ChOffset+i+16])));                 \
873     s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+32)] * (SINT64)s16X[ChOffset+i+32])));                 \
874     s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+48)] * (SINT64)s16X[ChOffset+i+48])));                 \
875     s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+64)] * (SINT64)s16X[ChOffset+i+64])));                 \
876     /*printf("s32DCTY8: %d= 0x%x * %d\n", s32DCTY[i], gas32CoeffFor8SBs[i], s16X[ChOffset+i]);*/     \
877     s32DCTY[i]=(SINT32)(s64Temp>>16);\
878 }
879 #else
880 #define WINDOW_ACCU_8(i) \
881 {\
882     s32DCTY[i]=(gas32CoeffFor8SBs[i * 2] * s16X[ChOffset+i])                                    \
883             +  (((SINT32)(UINT16)(gas32CoeffFor8SBs[(i * 2) + 1]) * s16X[ChOffset+i]) >> 16);   \
884     s32DCTY[i]+=(gas32CoeffFor8SBs[(i+16) * 2] * s16X[ChOffset+i+16])                                    \
885             +  (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+16) * 2) + 1]) * s16X[ChOffset+i+16]) >> 16);   \
886     s32DCTY[i]+=(gas32CoeffFor8SBs[(i+32) * 2] * s16X[ChOffset+i+32])                                    \
887             +  (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+32) * 2) + 1]) * s16X[ChOffset+i+32]) >> 16);   \
888     s32DCTY[i]+=(gas32CoeffFor8SBs[(i+48) * 2] * s16X[ChOffset+i+48])                                    \
889             +  (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+48) * 2) + 1]) * s16X[ChOffset+i+48]) >> 16);   \
890     s32DCTY[i]+=(gas32CoeffFor8SBs[(i+64) * 2] * s16X[ChOffset+i+64])                                    \
891             +  (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+64) * 2) + 1]) * s16X[ChOffset+i+64]) >> 16);   \
892     /*printf("s32DCTY8: %d = 0x%4x%4x * %d\n", s32DCTY[i], gas32CoeffFor8SBs[i * 2], (gas32CoeffFor8SBs[(i * 2) + 1]), s16X[ChOffset+i]);*/\
893     /*s32DCTY[i]=(SINT32)(s64Temp>>16);*/\
894 }
895 #endif
896 #define WINDOW_PARTIAL_8 \
897 {\
898     WINDOW_ACCU_8(0);      WINDOW_ACCU_8(1);\
899     WINDOW_ACCU_8(2);      WINDOW_ACCU_8(3);\
900     WINDOW_ACCU_8(4);      WINDOW_ACCU_8(5);\
901     WINDOW_ACCU_8(6);      WINDOW_ACCU_8(7);\
902     WINDOW_ACCU_8(8);      WINDOW_ACCU_8(9);\
903     WINDOW_ACCU_8(10);     WINDOW_ACCU_8(11);\
904     WINDOW_ACCU_8(12);     WINDOW_ACCU_8(13);\
905     WINDOW_ACCU_8(14);     WINDOW_ACCU_8(15);\
906 }
907 #endif
908 #endif
909 
910 static SINT16 ShiftCounter = 0;
911 extern SINT16 EncMaxShiftCounter;
912 /****************************************************************************
913 * SbcAnalysisFilter - performs Analysis of the input audio stream
914 *
915 * RETURNS : N/A
916 */
SbcAnalysisFilter4(SBC_ENC_PARAMS * pstrEncParams)917 void SbcAnalysisFilter4(SBC_ENC_PARAMS *pstrEncParams)
918 {
919     SINT16 *ps16PcmBuf;
920     SINT32 *ps32SbBuf;
921     SINT32  s32Blk, s32Ch;
922     SINT32  s32NumOfChannels, s32NumOfBlocks;
923     SINT32 i, *ps32X, *ps32X2;
924     SINT32 Offset, Offset2, ChOffset;
925 #if (SBC_ARM_ASM_OPT==TRUE)
926     register SINT32 s32Hi, s32Hi2;
927 #else
928 #if (SBC_IPAQ_OPT==TRUE)
929 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
930     register SINT64 s64Temp, s64Temp2;
931 #else
932     register SINT32 s32Temp, s32Temp2;
933 #endif
934 #else
935 
936 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
937     SINT64 s64Temp;
938 #endif
939 
940 #endif
941 #endif
942 
943     s32NumOfChannels = pstrEncParams->s16NumOfChannels;
944     s32NumOfBlocks   = pstrEncParams->s16NumOfBlocks;
945 
946     ps16PcmBuf = pstrEncParams->ps16NextPcmBuffer;
947 
948     ps32SbBuf  = pstrEncParams->s32SbBuffer;
949     Offset2 = (SINT32)(EncMaxShiftCounter + 40);
950     for (s32Blk = 0; s32Blk < s32NumOfBlocks; s32Blk++) {
951         Offset = (SINT32)(EncMaxShiftCounter - ShiftCounter);
952         /* Store new samples */
953         if (s32NumOfChannels == 1) {
954             s16X[3 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
955             s16X[2 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
956             s16X[1 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
957             s16X[0 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
958         } else {
959             s16X[3 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
960             s16X[Offset2 + 3 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
961             s16X[2 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
962             s16X[Offset2 + 2 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
963             s16X[1 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
964             s16X[Offset2 + 1 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
965             s16X[0 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
966             s16X[Offset2 + 0 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
967         }
968         for (s32Ch = 0; s32Ch < s32NumOfChannels; s32Ch++) {
969             ChOffset = s32Ch * Offset2 + Offset;
970 
971             WINDOW_PARTIAL_4
972 
973             SBC_FastIDCT4(s32DCTY, ps32SbBuf);
974 
975             ps32SbBuf += SUB_BANDS_4;
976         }
977         if (s32NumOfChannels == 1) {
978             if (ShiftCounter >= EncMaxShiftCounter) {
979                 SHIFTUP_X4;
980                 ShiftCounter = 0;
981             } else {
982                 ShiftCounter += SUB_BANDS_4;
983             }
984         } else {
985             if (ShiftCounter >= EncMaxShiftCounter) {
986                 SHIFTUP_X4_2;
987                 ShiftCounter = 0;
988             } else {
989                 ShiftCounter += SUB_BANDS_4;
990             }
991         }
992     }
993 }
994 
995 /* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */
SbcAnalysisFilter8(SBC_ENC_PARAMS * pstrEncParams)996 void SbcAnalysisFilter8 (SBC_ENC_PARAMS *pstrEncParams)
997 {
998     SINT16 *ps16PcmBuf;
999     SINT32 *ps32SbBuf;
1000     SINT32  s32Blk, s32Ch;                                    /* counter for block*/
1001     SINT32 Offset, Offset2;
1002     SINT32  s32NumOfChannels, s32NumOfBlocks;
1003     SINT32 i, *ps32X, *ps32X2;
1004     SINT32 ChOffset;
1005 #if (SBC_ARM_ASM_OPT==TRUE)
1006     register SINT32 s32Hi, s32Hi2;
1007 #else
1008 #if (SBC_IPAQ_OPT==TRUE)
1009 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
1010     register SINT64 s64Temp, s64Temp2;
1011 #else
1012     register SINT32 s32Temp, s32Temp2;
1013 #endif
1014 #else
1015 #if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
1016     SINT64 s64Temp;
1017 #endif
1018 #endif
1019 #endif
1020 
1021     s32NumOfChannels = pstrEncParams->s16NumOfChannels;
1022     s32NumOfBlocks   = pstrEncParams->s16NumOfBlocks;
1023 
1024     ps16PcmBuf = pstrEncParams->ps16NextPcmBuffer;
1025 
1026     ps32SbBuf  = pstrEncParams->s32SbBuffer;
1027     Offset2 = (SINT32)(EncMaxShiftCounter + 80);
1028     for (s32Blk = 0; s32Blk < s32NumOfBlocks; s32Blk++) {
1029         Offset = (SINT32)(EncMaxShiftCounter - ShiftCounter);
1030         /* Store new samples */
1031         if (s32NumOfChannels == 1) {
1032             s16X[7 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1033             s16X[6 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1034             s16X[5 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1035             s16X[4 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1036             s16X[3 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1037             s16X[2 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1038             s16X[1 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1039             s16X[0 + Offset] = *ps16PcmBuf;   ps16PcmBuf++;
1040         } else {
1041             s16X[7 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1042             s16X[Offset2 + 7 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1043             s16X[6 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1044             s16X[Offset2 + 6 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1045             s16X[5 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1046             s16X[Offset2 + 5 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1047             s16X[4 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1048             s16X[Offset2 + 4 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1049             s16X[3 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1050             s16X[Offset2 + 3 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1051             s16X[2 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1052             s16X[Offset2 + 2 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1053             s16X[1 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1054             s16X[Offset2 + 1 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1055             s16X[0 + Offset] = *ps16PcmBuf;        ps16PcmBuf++;
1056             s16X[Offset2 + 0 + Offset] = *ps16PcmBuf;     ps16PcmBuf++;
1057         }
1058         for (s32Ch = 0; s32Ch < s32NumOfChannels; s32Ch++) {
1059             ChOffset = s32Ch * Offset2 + Offset;
1060 
1061             WINDOW_PARTIAL_8
1062 
1063             SBC_FastIDCT8 (s32DCTY, ps32SbBuf);
1064 
1065             ps32SbBuf += SUB_BANDS_8;
1066         }
1067         if (s32NumOfChannels == 1) {
1068             if (ShiftCounter >= EncMaxShiftCounter) {
1069                 SHIFTUP_X8;
1070                 ShiftCounter = 0;
1071             } else {
1072                 ShiftCounter += SUB_BANDS_8;
1073             }
1074         } else {
1075             if (ShiftCounter >= EncMaxShiftCounter) {
1076                 SHIFTUP_X8_2;
1077                 ShiftCounter = 0;
1078             } else {
1079                 ShiftCounter += SUB_BANDS_8;
1080             }
1081         }
1082     }
1083 }
1084 
SbcAnalysisInit(void)1085 void SbcAnalysisInit (void)
1086 {
1087     static bool loaded = false;
1088     if (!loaded) {
1089         loaded = true;
1090 #if BT_BLE_DYNAMIC_ENV_MEMORY == TRUE
1091         s32X = (SINT32 *)osi_malloc(sizeof(SINT32) * (ENC_VX_BUFFER_SIZE / 2));
1092         s32DCTY = (SINT32 *)osi_malloc(sizeof(SINT32) * 16);
1093         assert(s32X);
1094         assert(s32DCTY);
1095         memset(s32X, 0, sizeof(SINT16) * ENC_VX_BUFFER_SIZE);
1096         memset(s32DCTY, 0, sizeof(SINT32) * 16);
1097         s16X = (SINT16 *) s32X;
1098 #endif
1099     }
1100     memset(s16X, 0, ENC_VX_BUFFER_SIZE * sizeof(SINT16));
1101     ShiftCounter = 0;
1102 }
1103 
1104 #endif /* #if (defined(SBC_ENC_INCLUDED) && SBC_ENC_INCLUDED == TRUE) */
1105