• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2023 The Android Open Source Project
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  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #include <string.h>
21 #include "ixheaac_type_def.h"
22 #include "ixheaacd_mps_struct_def.h"
23 #include "ixheaacd_error_codes.h"
24 #include "ixheaacd_mps_res_rom.h"
25 #include "ixheaacd_mps_aac_struct.h"
26 #include "ixheaac_constants.h"
27 #include "ixheaac_basic_ops32.h"
28 #include "ixheaac_basic_ops40.h"
29 #include "ixheaacd_bitbuffer.h"
30 #include "ixheaacd_common_rom.h"
31 #include "ixheaacd_sbrdecsettings.h"
32 #include "ixheaacd_sbr_scale.h"
33 #include "ixheaacd_env_extr_part.h"
34 #include "ixheaacd_sbr_rom.h"
35 #include "ixheaacd_hybrid.h"
36 #include "ixheaacd_ps_dec.h"
37 #include "ixheaacd_mps_polyphase.h"
38 #include "ixheaacd_config.h"
39 #include "ixheaacd_qmf_dec.h"
40 #include "ixheaacd_mps_dec.h"
41 #include "ixheaacd_mps_defines.h"
42 #include "ixheaacd_mps_macro_def.h"
43 #include "ixheaacd_mps_basic_op.h"
44 #include "ixheaac_error_standards.h"
45 
ixheaacd_fft32(WORD32 * vec,const WORD16 * fft_c)46 static VOID ixheaacd_fft32(WORD32 *vec, const WORD16 *fft_c) {
47   WORD32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11, tmp12, tmp13,
48       tmp14, tmp15;
49   WORD32 temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18, temp19, temp110,
50       temp111, temp112, temp113, temp114, temp115;
51   WORD32 temp20, temp21, temp22, temp23, temp24, temp25, temp26, temp27, temp28, temp29, temp210,
52       temp211, temp212, temp213, temp214, temp215;
53   WORD32 temp30, temp31, temp32, temp33, temp34, temp35, temp36, temp37, temp38, temp39, temp310,
54       temp311, temp312, temp313, temp314, temp315;
55   WORD32 temp316, temp317, temp318, temp319, temp320, temp321, temp322, temp323, temp324, temp325,
56       temp326, temp327, temp328, temp329, temp330, temp331;
57   WORD32 temp40, temp41, temp42, temp43, temp44, temp45, temp46, temp47, temp48, temp49, temp410,
58       temp411, temp412, temp413, temp414, temp415;
59 
60   temp20 = ixheaac_sub32_sat(vec[2], vec[34]);
61   temp21 = ixheaac_sub32_sat(vec[3], vec[35]);
62   temp30 = ixheaac_add32_sat(vec[0], vec[32]);
63   temp31 = ixheaac_add32_sat(vec[1], vec[33]);
64   temp32 = ixheaac_add32_sat(vec[2], vec[34]);
65   temp33 = ixheaac_add32_sat(vec[3], vec[35]);
66 
67   temp22 = ixheaac_sub32_sat(vec[6], vec[38]);
68   temp23 = ixheaac_sub32_sat(vec[7], vec[39]);
69   temp34 = ixheaac_add32_sat(vec[4], vec[36]);
70   temp35 = ixheaac_add32_sat(vec[5], vec[37]);
71   temp36 = ixheaac_add32_sat(vec[6], vec[38]);
72   temp37 = ixheaac_add32_sat(vec[7], vec[39]);
73 
74   temp24 = ixheaac_sub32_sat(vec[10], vec[42]);
75   temp25 = ixheaac_sub32_sat(vec[11], vec[43]);
76   temp38 = ixheaac_add32_sat(vec[8], vec[40]);
77   temp39 = ixheaac_add32_sat(vec[9], vec[41]);
78   temp310 = ixheaac_add32_sat(vec[10], vec[42]);
79   temp311 = ixheaac_add32_sat(vec[11], vec[43]);
80 
81   temp26 = ixheaac_sub32_sat(vec[14], vec[46]);
82   temp27 = ixheaac_sub32_sat(vec[15], vec[47]);
83   temp312 = ixheaac_add32_sat(vec[12], vec[44]);
84   temp313 = ixheaac_add32_sat(vec[13], vec[45]);
85   temp314 = ixheaac_add32_sat(vec[14], vec[46]);
86   temp315 = ixheaac_add32_sat(vec[15], vec[47]);
87 
88   temp28 = ixheaac_sub32_sat(vec[18], vec[50]);
89   temp29 = ixheaac_sub32_sat(vec[19], vec[51]);
90   temp316 = ixheaac_add32_sat(vec[16], vec[48]);
91   temp317 = ixheaac_add32_sat(vec[17], vec[49]);
92   temp318 = ixheaac_add32_sat(vec[18], vec[50]);
93   temp319 = ixheaac_add32_sat(vec[19], vec[51]);
94 
95   temp210 = ixheaac_sub32_sat(vec[22], vec[54]);
96   temp211 = ixheaac_sub32_sat(vec[23], vec[55]);
97   temp320 = ixheaac_add32_sat(vec[20], vec[52]);
98   temp321 = ixheaac_add32_sat(vec[21], vec[53]);
99   temp322 = ixheaac_add32_sat(vec[22], vec[54]);
100   temp323 = ixheaac_add32_sat(vec[23], vec[55]);
101 
102   temp212 = ixheaac_sub32_sat(vec[26], vec[58]);
103   temp213 = ixheaac_sub32_sat(vec[27], vec[59]);
104   temp324 = ixheaac_add32_sat(vec[24], vec[56]);
105   temp325 = ixheaac_add32_sat(vec[25], vec[57]);
106   temp326 = ixheaac_add32_sat(vec[26], vec[58]);
107   temp327 = ixheaac_add32_sat(vec[27], vec[59]);
108 
109   temp214 = ixheaac_sub32_sat(vec[30], vec[62]);
110   temp215 = ixheaac_sub32_sat(vec[31], vec[63]);
111   temp328 = ixheaac_add32_sat(vec[28], vec[60]);
112   temp329 = ixheaac_add32_sat(vec[29], vec[61]);
113   temp330 = ixheaac_add32_sat(vec[30], vec[62]);
114   temp331 = ixheaac_add32_sat(vec[31], vec[63]);
115 
116   temp41 = -ixheaac_add32_sat(temp20, temp214);
117   temp42 = ixheaac_sub32_sat(temp20, temp214);
118   temp40 = ixheaac_add32_sat(temp21, temp215);
119   temp43 = ixheaac_sub32_sat(temp21, temp215);
120   temp45 = -ixheaac_add32_sat(temp22, temp212);
121   temp46 = ixheaac_sub32_sat(temp22, temp212);
122   temp44 = ixheaac_add32_sat(temp23, temp213);
123   temp47 = ixheaac_sub32_sat(temp23, temp213);
124   temp49 = -ixheaac_add32_sat(temp24, temp210);
125   temp410 = ixheaac_sub32_sat(temp24, temp210);
126   temp48 = ixheaac_add32_sat(temp25, temp211);
127   temp411 = ixheaac_sub32_sat(temp25, temp211);
128   temp413 = -ixheaac_add32_sat(temp26, temp28);
129   temp414 = ixheaac_sub32_sat(temp26, temp28);
130   temp412 = ixheaac_add32_sat(temp27, temp29);
131   temp415 = ixheaac_sub32_sat(temp27, temp29);
132 
133   temp20 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
134            ixheaac_mult32x16in32_shl(temp40, fft_c[3]),
135            ixheaac_mult32x16in32_shl(temp44, fft_c[2])),
136            ixheaac_mult32x16in32_shl(temp48, fft_c[1])),
137            ixheaac_mult32x16in32_shl(temp412, fft_c[0]));
138 
139   temp24 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
140            ixheaac_mult32x16in32_shl(temp40, fft_c[2]),
141            ixheaac_mult32x16in32_shl(temp44, fft_c[0])),
142            ixheaac_mult32x16in32_shl(temp48, fft_c[3])),
143            ixheaac_mult32x16in32_shl(temp412, fft_c[1]));
144 
145   temp28 = ixheaac_add32_sat(ixheaac_sub32_sat(ixheaac_add32_sat(
146            ixheaac_mult32x16in32_shl(temp40, fft_c[1]),
147            ixheaac_mult32x16in32_shl(temp44, fft_c[3])),
148            ixheaac_mult32x16in32_shl(temp48, fft_c[0])),
149            ixheaac_mult32x16in32_shl(temp412, fft_c[2]));
150 
151   temp212 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
152             ixheaac_mult32x16in32_shl(temp40, fft_c[0]),
153             ixheaac_mult32x16in32_shl(temp44, fft_c[1])),
154             ixheaac_mult32x16in32_shl(temp48, fft_c[2])),
155             ixheaac_mult32x16in32_shl(temp412, fft_c[3]));
156 
157   temp21 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
158            ixheaac_mult32x16in32_shl(temp41, fft_c[3]),
159            ixheaac_mult32x16in32_shl(temp45, fft_c[2])),
160            ixheaac_mult32x16in32_shl(temp49, fft_c[1])),
161            ixheaac_mult32x16in32_shl(temp413, fft_c[0]));
162 
163   temp25 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
164            ixheaac_mult32x16in32_shl(temp41, fft_c[2]),
165            ixheaac_mult32x16in32_shl(temp45, fft_c[0])),
166            ixheaac_mult32x16in32_shl(temp49, fft_c[3])),
167            ixheaac_mult32x16in32_shl(temp413, fft_c[1]));
168 
169   temp29 = ixheaac_add32_sat(ixheaac_sub32_sat(ixheaac_add32_sat(
170            ixheaac_mult32x16in32_shl(temp41, fft_c[1]),
171            ixheaac_mult32x16in32_shl(temp45, fft_c[3])),
172            ixheaac_mult32x16in32_shl(temp49, fft_c[0])),
173            ixheaac_mult32x16in32_shl(temp413, fft_c[2]));
174 
175   temp213 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
176             ixheaac_mult32x16in32_shl(temp41, fft_c[0]),
177             ixheaac_mult32x16in32_shl(temp45, fft_c[1])),
178             ixheaac_mult32x16in32_shl(temp49, fft_c[2])),
179             ixheaac_mult32x16in32_shl(temp413, fft_c[3]));
180 
181   temp22 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
182            ixheaac_mult32x16in32_shl(temp42, fft_c[0]),
183            ixheaac_mult32x16in32_shl(temp46, fft_c[1])),
184            ixheaac_mult32x16in32_shl(temp410, fft_c[2])),
185            ixheaac_mult32x16in32_shl(temp414, fft_c[3]));
186 
187   temp26 = ixheaac_sub32_sat(ixheaac_sub32_sat(ixheaac_sub32_sat(
188            ixheaac_mult32x16in32_shl(temp42, fft_c[1]),
189            ixheaac_mult32x16in32_shl(temp46, fft_c[3])),
190            ixheaac_mult32x16in32_shl(temp410, fft_c[0])),
191            ixheaac_mult32x16in32_shl(temp414, fft_c[2]));
192 
193   temp210 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
194             ixheaac_mult32x16in32_shl(temp42, fft_c[2]),
195             ixheaac_mult32x16in32_shl(temp46, fft_c[0])),
196             ixheaac_mult32x16in32_shl(temp410, fft_c[3])),
197             ixheaac_mult32x16in32_shl(temp414, fft_c[1]));
198 
199   temp214 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
200             ixheaac_mult32x16in32_shl(temp42, fft_c[3]),
201             ixheaac_mult32x16in32_shl(temp46, fft_c[2])),
202             ixheaac_mult32x16in32_shl(temp410, fft_c[1])),
203             ixheaac_mult32x16in32_shl(temp414, fft_c[0]));
204 
205   temp23 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_add32_sat(
206            ixheaac_mult32x16in32_shl(temp43, fft_c[0]),
207            ixheaac_mult32x16in32_shl(temp47, fft_c[1])),
208            ixheaac_mult32x16in32_shl(temp411, fft_c[2])),
209            ixheaac_mult32x16in32_shl(temp415, fft_c[3]));
210 
211   temp27 = ixheaac_sub32_sat(ixheaac_sub32_sat(ixheaac_sub32_sat(
212            ixheaac_mult32x16in32_shl(temp43, fft_c[1]),
213            ixheaac_mult32x16in32_shl(temp47, fft_c[3])),
214            ixheaac_mult32x16in32_shl(temp411, fft_c[0])),
215            ixheaac_mult32x16in32_shl(temp415, fft_c[2]));
216 
217   temp211 = ixheaac_add32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
218             ixheaac_mult32x16in32_shl(temp43, fft_c[2]),
219             ixheaac_mult32x16in32_shl(temp47, fft_c[0])),
220             ixheaac_mult32x16in32_shl(temp411, fft_c[3])),
221             ixheaac_mult32x16in32_shl(temp415, fft_c[1]));
222 
223   temp215 = ixheaac_sub32_sat(ixheaac_add32_sat(ixheaac_sub32_sat(
224             ixheaac_mult32x16in32_shl(temp43, fft_c[3]),
225             ixheaac_mult32x16in32_shl(temp47, fft_c[2])),
226             ixheaac_mult32x16in32_shl(temp411, fft_c[1])),
227             ixheaac_mult32x16in32_shl(temp415, fft_c[0]));
228 
229   temp40 = ixheaac_add32_sat(temp20, temp22);
230   temp414 = ixheaac_sub32_sat(temp20, temp22);
231   temp41 = ixheaac_add32_sat(temp21, temp23);
232   temp415 = ixheaac_sub32_sat(temp21, temp23);
233   temp42 = ixheaac_add32_sat(temp24, temp26);
234   temp412 = ixheaac_sub32_sat(temp24, temp26);
235   temp43 = ixheaac_add32_sat(temp25, temp27);
236   temp413 = ixheaac_sub32_sat(temp25, temp27);
237   temp44 = ixheaac_add32_sat(temp28, temp210);
238   temp410 = ixheaac_sub32_sat(temp28, temp210);
239   temp45 = ixheaac_add32_sat(temp29, temp211);
240   temp411 = ixheaac_sub32_sat(temp29, temp211);
241   temp46 = ixheaac_add32_sat(temp212, temp214);
242   temp48 = ixheaac_sub32_sat(temp212, temp214);
243   temp47 = ixheaac_add32_sat(temp213, temp215);
244   temp49 = ixheaac_sub32_sat(temp213, temp215);
245 
246   temp10 = ixheaac_add32_sat(temp30, temp316);
247   temp11 = ixheaac_add32_sat(temp31, temp317);
248   temp12 = ixheaac_add32_sat(temp32, temp318);
249   temp13 = ixheaac_add32_sat(temp33, temp319);
250   temp14 = ixheaac_add32_sat(temp34, temp320);
251   temp15 = ixheaac_add32_sat(temp35, temp321);
252   temp16 = ixheaac_add32_sat(temp36, temp322);
253   temp17 = ixheaac_add32_sat(temp37, temp323);
254   temp18 = ixheaac_add32_sat(temp38, temp324);
255   temp19 = ixheaac_add32_sat(temp39, temp325);
256   temp110 = ixheaac_add32_sat(temp310, temp326);
257   temp111 = ixheaac_add32_sat(temp311, temp327);
258   temp112 = ixheaac_add32_sat(temp312, temp328);
259   temp113 = ixheaac_add32_sat(temp313, temp329);
260   temp114 = ixheaac_add32_sat(temp314, temp330);
261   temp115 = ixheaac_add32_sat(temp315, temp331);
262 
263   tmp0 = ixheaac_add32_sat(temp10, temp18);
264   tmp2 = ixheaac_sub32_sat(temp10, temp18);
265   tmp1 = ixheaac_add32_sat(temp11, temp19);
266   tmp3 = ixheaac_sub32_sat(temp11, temp19);
267   tmp4 = ixheaac_add32_sat(temp12, temp110);
268   tmp6 = ixheaac_sub32_sat(temp12, temp110);
269   tmp5 = ixheaac_add32_sat(temp13, temp111);
270   tmp7 = ixheaac_sub32_sat(temp13, temp111);
271   tmp8 = ixheaac_add32_sat(temp14, temp112);
272   tmp10 = ixheaac_sub32_sat(temp14, temp112);
273   tmp9 = ixheaac_add32_sat(temp15, temp113);
274   tmp11 = ixheaac_sub32_sat(temp15, temp113);
275   tmp12 = ixheaac_add32_sat(temp16, temp114);
276   tmp14 = ixheaac_sub32_sat(temp16, temp114);
277   tmp13 = ixheaac_add32_sat(temp17, temp115);
278   tmp15 = ixheaac_sub32_sat(temp17, temp115);
279 
280   temp20 = ixheaac_add32_sat(tmp0, tmp8);
281   temp24 = ixheaac_sub32_sat(tmp0, tmp8);
282   temp21 = ixheaac_add32_sat(tmp1, tmp9);
283   temp25 = ixheaac_sub32_sat(tmp1, tmp9);
284   temp28 = ixheaac_sub32_sat(tmp2, tmp11);
285   temp210 = ixheaac_add32_sat(tmp2, tmp11);
286   temp29 = ixheaac_add32_sat(tmp3, tmp10);
287   temp211 = ixheaac_sub32_sat(tmp3, tmp10);
288   temp22 = ixheaac_add32_sat(tmp4, tmp12);
289   temp27 = ixheaac_sub32_sat(tmp4, tmp12);
290   temp23 = ixheaac_add32_sat(tmp5, tmp13);
291   temp26 = ixheaac_sub32_sat(tmp13, tmp5);
292 
293   tmp1 = ixheaac_add32_sat(tmp6, tmp14);
294   tmp2 = ixheaac_sub32_sat(tmp6, tmp14);
295   tmp0 = ixheaac_add32_sat(tmp7, tmp15);
296   tmp3 = ixheaac_sub32_sat(tmp7, tmp15);
297 
298   temp212 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(tmp0, tmp2), INV_SQRT2_Q15);
299   temp214 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(tmp0, tmp2), INV_SQRT2_Q15);
300   temp213 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(tmp3, tmp1), INV_SQRT2_Q15);
301   temp215 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(tmp1, tmp3), -INV_SQRT2_Q15);
302 
303   temp10 = ixheaac_sub32_sat(temp30, temp316);
304   temp11 = ixheaac_sub32_sat(temp31, temp317);
305   temp12 = ixheaac_sub32_sat(temp32, temp318);
306   temp13 = ixheaac_sub32_sat(temp33, temp319);
307   temp14 = ixheaac_sub32_sat(temp34, temp320);
308   temp15 = ixheaac_sub32_sat(temp35, temp321);
309   temp16 = ixheaac_sub32_sat(temp36, temp322);
310   temp17 = ixheaac_sub32_sat(temp37, temp323);
311   temp18 = ixheaac_sub32_sat(temp38, temp324);
312   temp19 = ixheaac_sub32_sat(temp39, temp325);
313   temp110 = ixheaac_sub32_sat(temp310, temp326);
314   temp111 = ixheaac_sub32_sat(temp311, temp327);
315   temp112 = ixheaac_sub32_sat(temp312, temp328);
316   temp113 = ixheaac_sub32_sat(temp313, temp329);
317   temp114 = ixheaac_sub32_sat(temp314, temp330);
318   temp115 = ixheaac_sub32_sat(temp315, temp331);
319 
320   temp30 = ixheaac_add32_sat(temp20, temp22);
321   temp316 = ixheaac_sub32_sat(temp20, temp22);
322   temp31 = ixheaac_add32_sat(temp21, temp23);
323   temp317 = ixheaac_sub32_sat(temp21, temp23);
324   temp38 = ixheaac_sub32_sat(temp24, temp26);
325   temp324 = ixheaac_add32_sat(temp24, temp26);
326   temp39 = ixheaac_sub32_sat(temp25, temp27);
327   temp325 = ixheaac_add32_sat(temp25, temp27);
328   temp312 = ixheaac_add32_sat(temp28, temp214);
329   temp328 = ixheaac_sub32_sat(temp28, temp214);
330   temp313 = ixheaac_add32_sat(temp29, temp215);
331   temp329 = ixheaac_sub32_sat(temp29, temp215);
332   temp34 = ixheaac_add32_sat(temp210, temp212);
333   temp320 = ixheaac_sub32_sat(temp210, temp212);
334   temp35 = ixheaac_add32_sat(temp211, temp213);
335   temp321 = ixheaac_sub32_sat(temp211, temp213);
336 
337   tmp9 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp12, temp114), -COS_3PI_BY_8_Q15);
338   tmp10 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp12, temp114), COS_PI_BY_8_Q15);
339   tmp8 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp13, temp115), COS_3PI_BY_8_Q15);
340   tmp11 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp13, temp115), COS_PI_BY_8_Q15);
341   tmp5 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp14, temp112), -INV_SQRT2_Q15);
342   tmp6 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp14, temp112), INV_SQRT2_Q15);
343   tmp4 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp15, temp113), INV_SQRT2_Q15);
344   tmp7 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp15, temp113), INV_SQRT2_Q15);
345   tmp13 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp16, temp110), -COS_PI_BY_8_Q15);
346   tmp14 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp16, temp110), COS_3PI_BY_8_Q15);
347   tmp12 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp17, temp111), COS_PI_BY_8_Q15);
348   tmp15 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp17, temp111), COS_3PI_BY_8_Q15);
349 
350   temp12 = ixheaac_sub32_sat(ixheaac_shl32(ixheaac_mult32x16in32(tmp8, SQRT2PLUS1_Q13), 3),
351            ixheaac_mult32x16in32_shl(tmp12, SQRT2MINUS1_Q15));
352   temp13 = ixheaac_sub32_sat(ixheaac_shl32(ixheaac_mult32x16in32(tmp9, SQRT2PLUS1_Q13), 3),
353            ixheaac_mult32x16in32_shl(tmp13, SQRT2MINUS1_Q15));
354   temp14 = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(tmp10, SQRT2MINUS1_Q15),
355            ixheaac_shl32(ixheaac_mult32x16in32(tmp14, SQRT2PLUS1_Q13), 3));
356   temp15 = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(tmp11, SQRT2MINUS1_Q15),
357            ixheaac_shl32(ixheaac_mult32x16in32(tmp15, SQRT2PLUS1_Q13), 3));
358 
359   tmp8 = ixheaac_add32_sat(tmp8, tmp12);
360   tmp9 = ixheaac_add32_sat(tmp9, tmp13);
361   tmp10 = ixheaac_add32_sat(tmp10, tmp14);
362   tmp11 = ixheaac_add32_sat(tmp11, tmp15);
363   temp16 = ixheaac_add32_sat(temp10, tmp4);
364   temp110 = ixheaac_sub32_sat(temp10, tmp4);
365   temp17 = ixheaac_add32_sat(temp11, tmp5);
366   temp111 = ixheaac_sub32_sat(temp11, tmp5);
367 
368   temp112 = ixheaac_sub32_sat(tmp6, temp19);
369   temp114 = ixheaac_add32_sat(tmp6, temp19);
370   temp113 = ixheaac_add32_sat(temp18, tmp7);
371   temp115 = ixheaac_sub32_sat(temp18, tmp7);
372 
373   tmp0 = ixheaac_sub32_sat(temp16, temp114);
374   tmp2 = ixheaac_add32_sat(temp16, temp114);
375   tmp1 = ixheaac_add32_sat(temp17, temp115);
376   tmp3 = ixheaac_sub32_sat(temp17, temp115);
377   tmp4 = ixheaac_add32_sat(temp110, temp112);
378   tmp6 = ixheaac_sub32_sat(temp110, temp112);
379   tmp5 = ixheaac_add32_sat(temp111, temp113);
380   tmp7 = ixheaac_sub32_sat(temp111, temp113);
381 
382   temp110 = ixheaac_add32_sat(tmp8, tmp10);
383   tmp10 = ixheaac_sub32_sat(tmp8, tmp10);
384   temp111 = ixheaac_add32_sat(tmp9, tmp11);
385   tmp11 = ixheaac_sub32_sat(tmp9, tmp11);
386 
387   tmp12 = ixheaac_add32_sat(temp12, temp14);
388   tmp14 = ixheaac_sub32_sat(temp12, temp14);
389   tmp13 = ixheaac_add32_sat(temp13, temp15);
390   tmp15 = ixheaac_sub32_sat(temp13, temp15);
391 
392   temp32 = ixheaac_add32_sat(tmp2, temp110);
393   temp318 = ixheaac_sub32_sat(tmp2, temp110);
394   temp33 = ixheaac_add32_sat(tmp3, temp111);
395   temp319 = ixheaac_sub32_sat(tmp3, temp111);
396   temp36 = ixheaac_add32_sat(tmp0, tmp12);
397   temp322 = ixheaac_sub32_sat(tmp0, tmp12);
398   temp37 = ixheaac_add32_sat(tmp1, tmp13);
399   temp323 = ixheaac_sub32_sat(tmp1, tmp13);
400   temp314 = ixheaac_add32_sat(tmp4, tmp10);
401   temp330 = ixheaac_sub32_sat(tmp4, tmp10);
402   temp315 = ixheaac_add32_sat(tmp5, tmp11);
403   temp331 = ixheaac_sub32_sat(tmp5, tmp11);
404   temp310 = ixheaac_add32_sat(tmp6, tmp14);
405   temp326 = ixheaac_sub32_sat(tmp6, tmp14);
406   temp311 = ixheaac_add32_sat(tmp7, tmp15);
407   temp327 = ixheaac_sub32_sat(tmp7, tmp15);
408 
409   temp10 = ixheaac_sub32_sat(vec[0], vec[32]);
410   temp11 = ixheaac_sub32_sat(vec[1], vec[33]);
411   temp12 = ixheaac_sub32_sat(vec[4], vec[36]);
412   temp13 = ixheaac_sub32_sat(vec[5], vec[37]);
413   temp14 = ixheaac_sub32_sat(vec[8], vec[40]);
414   temp15 = ixheaac_sub32_sat(vec[9], vec[41]);
415   temp16 = ixheaac_sub32_sat(vec[12], vec[44]);
416   temp17 = ixheaac_sub32_sat(vec[13], vec[45]);
417   temp18 = ixheaac_sub32_sat(vec[16], vec[48]);
418   temp19 = ixheaac_sub32_sat(vec[17], vec[49]);
419   temp110 = ixheaac_sub32_sat(vec[20], vec[52]);
420   temp111 = ixheaac_sub32_sat(vec[21], vec[53]);
421   temp112 = ixheaac_sub32_sat(vec[24], vec[56]);
422   temp113 = ixheaac_sub32_sat(vec[25], vec[57]);
423   temp114 = ixheaac_sub32_sat(vec[28], vec[60]);
424   temp115 = ixheaac_sub32_sat(vec[29], vec[61]);
425 
426   tmp9 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp12, temp114), -COS_3PI_BY_8_Q15);
427   tmp10 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp12, temp114), COS_PI_BY_8_Q15);
428   tmp8 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp13, temp115), COS_3PI_BY_8_Q15);
429   tmp11 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp13, temp115), COS_PI_BY_8_Q15);
430   tmp5 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp14, temp112), -INV_SQRT2_Q15);
431   tmp6 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp14, temp112), INV_SQRT2_Q15);
432   tmp4 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp15, temp113), INV_SQRT2_Q15);
433   tmp7 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp15, temp113), INV_SQRT2_Q15);
434   tmp13 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp16, temp110), -COS_PI_BY_8_Q15);
435   tmp14 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp16, temp110), COS_3PI_BY_8_Q15);
436   tmp12 = ixheaac_mult32x16in32_shl(ixheaac_add32_sat(temp17, temp111), COS_PI_BY_8_Q15);
437   tmp15 = ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(temp17, temp111), COS_3PI_BY_8_Q15);
438 
439   temp12 = ixheaac_sub32_sat(ixheaac_shl32(ixheaac_mult32x16in32(tmp8, SQRT2PLUS1_Q13), 3),
440            ixheaac_mult32x16in32_shl(tmp12, SQRT2MINUS1_Q15));
441   temp13 = ixheaac_sub32_sat(ixheaac_shl32(ixheaac_mult32x16in32(tmp9, SQRT2PLUS1_Q13), 3),
442            ixheaac_mult32x16in32_shl(tmp13, SQRT2MINUS1_Q15));
443   temp14 = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(tmp10, SQRT2MINUS1_Q15),
444            ixheaac_shl32(ixheaac_mult32x16in32(tmp14, SQRT2PLUS1_Q13), 3));
445   temp15 = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(tmp11, SQRT2MINUS1_Q15),
446            ixheaac_shl32(ixheaac_mult32x16in32(tmp15, SQRT2PLUS1_Q13), 3));
447 
448   tmp8 = ixheaac_add32_sat(tmp8, tmp12);
449   tmp9 = ixheaac_add32_sat(tmp9, tmp13);
450   tmp10 = ixheaac_add32_sat(tmp10, tmp14);
451   tmp11 = ixheaac_add32_sat(tmp11, tmp15);
452   temp16 = ixheaac_add32_sat(temp10, tmp4);
453   temp110 = ixheaac_sub32_sat(temp10, tmp4);
454   temp17 = ixheaac_add32_sat(temp11, tmp5);
455   temp111 = ixheaac_sub32_sat(temp11, tmp5);
456 
457   temp112 = ixheaac_sub32_sat(tmp6, temp19);
458   temp114 = ixheaac_add32_sat(tmp6, temp19);
459   temp113 = ixheaac_add32_sat(temp18, tmp7);
460   temp115 = ixheaac_sub32_sat(temp18, tmp7);
461 
462   tmp0 = ixheaac_sub32_sat(temp16, temp114);
463   tmp2 = ixheaac_add32_sat(temp16, temp114);
464   tmp1 = ixheaac_add32_sat(temp17, temp115);
465   tmp3 = ixheaac_sub32_sat(temp17, temp115);
466   tmp4 = ixheaac_add32_sat(temp110, temp112);
467   tmp6 = ixheaac_sub32_sat(temp110, temp112);
468   tmp5 = ixheaac_add32_sat(temp111, temp113);
469   tmp7 = ixheaac_sub32_sat(temp111, temp113);
470 
471   temp110 = ixheaac_add32_sat(tmp8, tmp10);
472   tmp10 = ixheaac_sub32_sat(tmp8, tmp10);
473   temp111 = ixheaac_add32_sat(tmp9, tmp11);
474   tmp11 = ixheaac_sub32_sat(tmp9, tmp11);
475 
476   tmp12 = ixheaac_add32_sat(temp12, temp14);
477   tmp14 = ixheaac_sub32_sat(temp12, temp14);
478   tmp13 = ixheaac_add32_sat(temp13, temp15);
479   tmp15 = ixheaac_sub32_sat(temp13, temp15);
480 
481   temp10 = ixheaac_add32_sat(tmp2, temp110);
482   temp18 = ixheaac_sub32_sat(tmp2, temp110);
483   temp11 = ixheaac_add32_sat(tmp3, temp111);
484   temp19 = ixheaac_sub32_sat(tmp3, temp111);
485   temp12 = ixheaac_add32_sat(tmp0, tmp12);
486   temp110 = ixheaac_sub32_sat(tmp0, tmp12);
487   temp13 = ixheaac_add32_sat(tmp1, tmp13);
488   temp111 = ixheaac_sub32_sat(tmp1, tmp13);
489   temp16 = ixheaac_add32_sat(tmp4, tmp10);
490   temp114 = ixheaac_sub32_sat(tmp4, tmp10);
491   temp17 = ixheaac_add32_sat(tmp5, tmp11);
492   temp115 = ixheaac_sub32_sat(tmp5, tmp11);
493   temp14 = ixheaac_add32_sat(tmp6, tmp14);
494   temp112 = ixheaac_sub32_sat(tmp6, tmp14);
495   temp15 = ixheaac_add32_sat(tmp7, tmp15);
496   temp113 = ixheaac_sub32_sat(tmp7, tmp15);
497 
498   *vec++ = temp30;
499   *vec++ = temp31;
500   *vec++ = ixheaac_add32_sat(temp10, temp40);
501   *vec++ = ixheaac_add32_sat(temp11, temp41);
502   *vec++ = temp32;
503   *vec++ = temp33;
504   *vec++ = ixheaac_add32_sat(temp12, temp42);
505   *vec++ = ixheaac_add32_sat(temp13, temp43);
506   *vec++ = temp34;
507   *vec++ = temp35;
508   *vec++ = ixheaac_add32_sat(temp14, temp44);
509   *vec++ = ixheaac_add32_sat(temp15, temp45);
510   *vec++ = temp36;
511   *vec++ = temp37;
512   *vec++ = ixheaac_add32_sat(temp16, temp46);
513   *vec++ = ixheaac_add32_sat(temp17, temp47);
514   *vec++ = temp38;
515   *vec++ = temp39;
516   *vec++ = ixheaac_add32_sat(temp18, temp48);
517   *vec++ = ixheaac_add32_sat(temp19, temp49);
518   *vec++ = temp310;
519   *vec++ = temp311;
520   *vec++ = ixheaac_add32_sat(temp110, temp410);
521   *vec++ = ixheaac_add32_sat(temp111, temp411);
522   *vec++ = temp312;
523   *vec++ = temp313;
524   *vec++ = ixheaac_add32_sat(temp112, temp412);
525   *vec++ = ixheaac_add32_sat(temp113, temp413);
526   *vec++ = temp314;
527   *vec++ = temp315;
528   *vec++ = ixheaac_add32_sat(temp114, temp414);
529   *vec++ = ixheaac_add32_sat(temp115, temp415);
530   *vec++ = temp316;
531   *vec++ = temp317;
532   *vec++ = ixheaac_sub32_sat(temp10, temp40);
533   *vec++ = ixheaac_sub32_sat(temp11, temp41);
534   *vec++ = temp318;
535   *vec++ = temp319;
536   *vec++ = ixheaac_sub32_sat(temp12, temp42);
537   *vec++ = ixheaac_sub32_sat(temp13, temp43);
538   *vec++ = temp320;
539   *vec++ = temp321;
540   *vec++ = ixheaac_sub32_sat(temp14, temp44);
541   *vec++ = ixheaac_sub32_sat(temp15, temp45);
542   *vec++ = temp322;
543   *vec++ = temp323;
544   *vec++ = ixheaac_sub32_sat(temp16, temp46);
545   *vec++ = ixheaac_sub32_sat(temp17, temp47);
546   *vec++ = temp324;
547   *vec++ = temp325;
548   *vec++ = ixheaac_sub32_sat(temp18, temp48);
549   *vec++ = ixheaac_sub32_sat(temp19, temp49);
550   *vec++ = temp326;
551   *vec++ = temp327;
552   *vec++ = ixheaac_sub32_sat(temp110, temp410);
553   *vec++ = ixheaac_sub32_sat(temp111, temp411);
554   *vec++ = temp328;
555   *vec++ = temp329;
556   *vec++ = ixheaac_sub32_sat(temp112, temp412);
557   *vec++ = ixheaac_sub32_sat(temp113, temp413);
558   *vec++ = temp330;
559   *vec++ = temp331;
560   *vec++ = ixheaac_sub32_sat(temp114, temp414);
561   *vec++ = ixheaac_sub32_sat(temp115, temp415);
562 }
563 
ixheaacd_cos_mod(WORD32 * subband,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)564 static VOID ixheaacd_cos_mod(WORD32 *subband, ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
565   WORD32 i, m;
566   WORD16 wim, wre;
567   WORD32 temp_1;
568   const WORD16 *ptr1, *ptr2, *ptr3, *ptr4;
569   WORD32 re1, im1, re2, im2;
570 
571   m = WORD_LENGTH;
572   ptr1 = qmf_table_ptr->sbr_sin_twiddle;
573   ptr2 = qmf_table_ptr->sbr_cos_twiddle;
574   ptr3 = qmf_table_ptr->sbr_sin_twiddle + 31;
575   ptr4 = qmf_table_ptr->sbr_cos_twiddle + 31;
576   for (i = 0; i < 16; i++) {
577     temp_1 = (i << 1);
578     re1 = subband[temp_1];
579     im2 = subband[temp_1 + 1];
580     re2 = subband[62 - temp_1];
581     im1 = subband[63 - temp_1];
582 
583     wim = *ptr1++;
584     wre = *ptr2++;
585 
586     subband[temp_1] = ixheaac_add32_sat(
587         ixheaac_mult32x16in32_shl(im1, wim), ixheaac_mult32x16in32_shl(re1, wre));
588     subband[temp_1 + 1] = ixheaac_sub32_sat(
589         ixheaac_mult32x16in32_shl(im1, wre), ixheaac_mult32x16in32_shl(re1, wim));
590 
591     wim = *ptr3--;
592     wre = *ptr4--;
593 
594     subband[62 - temp_1] = ixheaac_add32_sat(
595         ixheaac_mult32x16in32_shl(im2, wim), ixheaac_mult32x16in32_shl(re2, wre));
596     subband[63 - temp_1] = ixheaac_sub32_sat(
597         ixheaac_mult32x16in32_shl(im2, wre), ixheaac_mult32x16in32_shl(re2, wim));
598   }
599 
600   ixheaacd_fft32(subband, qmf_table_ptr->fft_c);
601 
602   ptr1 = qmf_table_ptr->sbr_alt_sin_twiddle;
603   ptr2 = qmf_table_ptr->sbr_alt_sin_twiddle + m;
604   wim = *ptr1++;
605   wre = *ptr2--;
606 
607   for (i = 0; i < 16; i++) {
608     temp_1 = (i << 1);
609     re1 = subband[temp_1];
610     im1 = subband[temp_1 + 1];
611     re2 = subband[62 - temp_1];
612     im2 = subband[63 - temp_1];
613 
614     subband[temp_1] = ixheaac_add32_sat(
615         ixheaac_mult32x16in32_shl(re1, wre), ixheaac_mult32x16in32_shl(im1, wim));
616     subband[63 - temp_1] = ixheaac_sub32_sat(
617         ixheaac_mult32x16in32_shl(re1, wim), ixheaac_mult32x16in32_shl(im1, wre));
618 
619     wim = *ptr1++;
620     wre = *ptr2--;
621 
622     subband[62 - temp_1] = ixheaac_add32_sat(
623         ixheaac_mult32x16in32_shl(re2, wim), ixheaac_mult32x16in32_shl(im2, wre));
624     subband[temp_1 + 1] = ixheaac_sub32_sat(
625         ixheaac_mult32x16in32_shl(re2, wre), ixheaac_mult32x16in32_shl(im2, wim));
626   }
627 }
628 
ixheaacd_sin_mod(WORD32 * subband,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)629 static VOID ixheaacd_sin_mod(WORD32 *subband, ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
630   WORD32 i, m;
631   WORD16 wre, wim;
632   WORD32 temp_1;
633   WORD32 re1, im1, re2, im2;
634   const WORD16 *ptr1, *ptr2, *ptr3, *ptr4;
635 
636   ptr1 = qmf_table_ptr->sbr_sin_twiddle;
637   ptr2 = qmf_table_ptr->sbr_cos_twiddle;
638   ptr3 = qmf_table_ptr->sbr_sin_twiddle + 31;
639   ptr4 = qmf_table_ptr->sbr_cos_twiddle + 31;
640 
641   m = WORD_LENGTH;
642 
643   for (i = 0; i < 16; i++) {
644     temp_1 = (i << 1);
645 
646     re1 = subband[temp_1];
647     im2 = subband[temp_1 + 1];
648     re2 = subband[62 - temp_1];
649     im1 = subband[63 - temp_1];
650 
651     wre = *ptr1++;
652     wim = *ptr2++;
653 
654     subband[temp_1 + 1] = ixheaac_add32_sat(
655         ixheaac_mult32x16in32_shl(im1, wim), ixheaac_mult32x16in32_shl(re1, wre));
656     subband[temp_1] = ixheaac_sub32_sat(
657         ixheaac_mult32x16in32_shl(im1, wre), ixheaac_mult32x16in32_shl(re1, wim));
658 
659     wre = *ptr3--;
660     wim = *ptr4--;
661 
662     subband[63 - temp_1] = ixheaac_add32_sat(
663         ixheaac_mult32x16in32_shl(im2, wim), ixheaac_mult32x16in32_shl(re2, wre));
664     subband[62 - temp_1] = ixheaac_sub32_sat(
665         ixheaac_mult32x16in32_shl(im2, wre), ixheaac_mult32x16in32_shl(re2, wim));
666   }
667 
668   ixheaacd_fft32(subband, qmf_table_ptr->fft_c);
669 
670   ptr1 = qmf_table_ptr->sbr_alt_sin_twiddle;
671   ptr2 = qmf_table_ptr->sbr_alt_sin_twiddle + m;
672 
673   wim = *ptr1++;
674   wre = *ptr2--;
675 
676   for (i = 0; i < 16; i++) {
677     temp_1 = (i << 1);
678     re1 = subband[temp_1];
679     im1 = subband[temp_1 + 1];
680     re2 = subband[62 - temp_1];
681     im2 = subband[63 - temp_1];
682 
683     subband[63 - temp_1] = -ixheaac_add32_sat(
684         ixheaac_mult32x16in32_shl(re1, wre), ixheaac_mult32x16in32_shl(im1, wim));
685     subband[temp_1] = -ixheaac_sub32_sat(
686         ixheaac_mult32x16in32_shl(re1, wim), ixheaac_mult32x16in32_shl(im1, wre));
687 
688     wim = *ptr1++;
689     wre = *ptr2--;
690 
691     subband[temp_1 + 1] = -ixheaac_add32_sat(
692         ixheaac_mult32x16in32_shl(re2, wim), ixheaac_mult32x16in32_shl(im2, wre));
693     subband[62 - temp_1] = -ixheaac_sub32_sat(
694         ixheaac_mult32x16in32_shl(re2, wre), ixheaac_mult32x16in32_shl(im2, wim));
695   }
696 }
697 
ixheaacd_inverse_modulation(WORD32 * qmf_real,WORD32 * qmf_imag,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)698 static VOID ixheaacd_inverse_modulation(WORD32 *qmf_real, WORD32 *qmf_imag,
699                                         ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
700   WORD32 i;
701 
702   const WORD16 *ptr1, *ptr2, *ptr3, *ptr4;
703   const WORD16 *fft = qmf_table_ptr->fft_c;
704   WORD16 wre, wim;
705   WORD32 re1, im1, re2, im2;
706   WORD32 re12, im12, re22, im22;
707   WORD32 temp_1;
708 
709   ptr1 = qmf_table_ptr->sbr_sin_twiddle;
710   ptr2 = qmf_table_ptr->sbr_cos_twiddle;
711   ptr3 = ptr1 + 31;
712   ptr4 = ptr2 + 31;
713 
714   for (i = 0; i < 16; i++) {
715     temp_1 = (i << 1);
716 
717     re1 = qmf_real[temp_1];
718     im1 = qmf_real[63 - temp_1];
719 
720     wim = *ptr1++;
721     wre = *ptr2++;
722 
723     qmf_real[temp_1] = ixheaac_add32_sat(
724         ixheaac_mult32x16in32_shl(im1, wim), ixheaac_mult32x16in32_shl(re1, wre));
725 
726     re12 = qmf_imag[temp_1];
727     im12 = qmf_imag[63 - temp_1];
728 
729     qmf_imag[temp_1] = ixheaac_sub32_sat(
730         ixheaac_mult32x16in32_shl(im12, wim), ixheaac_mult32x16in32_shl(re12, wre));
731 
732     im2 = qmf_real[temp_1 + 1];
733 
734     qmf_real[temp_1 + 1] = ixheaac_sub32_sat(
735         ixheaac_mult32x16in32_shl(im1, wre), ixheaac_mult32x16in32_shl(re1, wim));
736 
737     im22 = qmf_imag[temp_1 + 1];
738 
739     qmf_imag[temp_1 + 1] = ixheaac_add32_sat(
740         ixheaac_mult32x16in32_shl(im12, wre), ixheaac_mult32x16in32_shl(re12, wim));
741 
742     wim = *ptr3--;
743     wre = *ptr4--;
744 
745     re2 = qmf_real[62 - temp_1];
746 
747     qmf_real[62 - temp_1] = ixheaac_add32_sat(
748         ixheaac_mult32x16in32_shl(im2, wim), ixheaac_mult32x16in32_shl(re2, wre));
749 
750     re22 = qmf_imag[62 - temp_1];
751 
752     qmf_imag[62 - temp_1] = ixheaac_sub32_sat(
753         ixheaac_mult32x16in32_shl(im22, wim), ixheaac_mult32x16in32_shl(re22, wre));
754 
755     qmf_real[63 - temp_1] = ixheaac_sub32_sat(
756         ixheaac_mult32x16in32_shl(im2, wre), ixheaac_mult32x16in32_shl(re2, wim));
757     qmf_imag[63 - temp_1] = ixheaac_add32_sat(
758         ixheaac_mult32x16in32_shl(im22, wre), ixheaac_mult32x16in32_shl(re22, wim));
759   }
760 
761   ixheaacd_fft32(qmf_real, fft);
762   ixheaacd_fft32(qmf_imag, fft);
763 
764   ptr1 = qmf_table_ptr->sbr_alt_sin_twiddle;
765   ptr2 = ptr1 + 32;
766 
767   wim = *ptr1++;
768   wre = *ptr2--;
769   for (i = 0; i < 16; i++) {
770     temp_1 = (i << 1);
771     re1 = qmf_real[temp_1];
772     im1 = qmf_real[temp_1 + 1];
773     re12 = qmf_imag[temp_1];
774     im12 = qmf_imag[temp_1 + 1];
775 
776     qmf_real[temp_1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
777         im12, re1), wre), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im1, re12), wim));
778     qmf_imag[temp_1] = ixheaac_add32_sat(ixheaac_mult32x16in32_shl((ixheaac_add32_sat(
779         im12, re1)), wre), ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(im1, re12), wim));
780 
781     im2 = qmf_real[63 - temp_1];
782     im22 = qmf_imag[63 - temp_1];
783 
784     qmf_real[63 - temp_1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
785         im1, re12), wre), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im12, re1), wim));
786     qmf_imag[63 - temp_1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
787         re1, im12), wim), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im1, re12), wre));
788 
789     wim = *ptr1++;
790     wre = *ptr2--;
791     re2 = qmf_real[62 - temp_1];
792     re22 = qmf_imag[62 - temp_1];
793 
794     qmf_real[temp_1 + 1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
795         im2, re22), wim), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im22, re2), wre));
796     qmf_imag[temp_1 + 1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
797         re2, im22), wre), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im2, re22), wim));
798 
799     qmf_real[62 - temp_1] = ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(
800         im22, re2), wim), ixheaac_mult32x16in32_shl(ixheaac_add32_sat(im2, re22), wre));
801     qmf_imag[62 - temp_1] = ixheaac_add32_sat(ixheaac_mult32x16in32_shl(ixheaac_add32_sat(
802         re2, im22), wim), ixheaac_mult32x16in32_shl(ixheaac_sub32_sat(im2, re22), wre));
803   }
804 }
805 
ixheaacd_calculate_syn_filt_bank_res64(ia_mps_dec_qmf_syn_filter_bank * syn,WORD32 * sr,WORD32 * si,WORD32 * time_sig,WORD32 channel,WORD32 resolution,WORD32 nr_samples,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)806 VOID ixheaacd_calculate_syn_filt_bank_res64(ia_mps_dec_qmf_syn_filter_bank *syn, WORD32 *sr,
807                                             WORD32 *si, WORD32 *time_sig, WORD32 channel,
808                                             WORD32 resolution, WORD32 nr_samples,
809                                             ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
810   WORD32 j, k;
811   WORD32 *synth_buf;
812   WORD32 *syn_buf_p1, *syn_buf_p2, *syn_buf_p3;
813   WORD32 val;
814   const WORD32 *p_filter_1, *p_filter_6;
815   const WORD32 *p_filter_2, *p_filter_7;
816   const WORD32 *p_filter_3, *p_filter_8;
817   const WORD32 *p_filter_4, *p_filter_9;
818   const WORD32 *p_filter_5, *p_filter_10;
819 
820   WORD32 *p_sr, *p_si;
821 
822   WORD32 *sbr_qmf_states_synthesis = syn->sbr_qmf_states_synthesis;
823   synth_buf = &(sbr_qmf_states_synthesis[channel * QMF_FILTER_STATE_SYN_SIZE_MPS]);
824 
825   p_sr = sr;
826   p_si = si;
827   for (k = 0; k < nr_samples; k++) {
828     WORD32 *new_samp = p_si;
829     WORD32 *new_samp2;
830 
831     ixheaacd_inverse_modulation(p_sr, p_si, qmf_table_ptr);
832 
833     p_filter_1 = syn->p_filter_syn;
834     p_filter_2 = p_filter_1 + 64;
835     p_filter_3 = p_filter_2 + 65;
836     p_filter_4 = p_filter_3 + 65;
837     p_filter_5 = p_filter_4 + 65;
838 
839     syn_buf_p1 = &synth_buf[63];
840     val = *(p_sr);
841 
842     {
843       WORD32 val1 = *(p_si + 63);
844       syn_buf_p2 = &synth_buf[63];
845 
846       *time_sig++ = ixheaac_add32_sat(syn_buf_p1[512],
847                         ixheaacd_mps_mult32_shr_30(*(p_filter_5 + 65), val));
848       syn_buf_p1[512] = ixheaac_add32_sat(syn_buf_p2[448],
849                             ixheaacd_mps_mult32_shr_30(*(p_filter_5 + 64), val1));
850       syn_buf_p2[448] = ixheaac_add32_sat(syn_buf_p1[384],
851                             ixheaacd_mps_mult32_shr_30(*p_filter_5++, val));
852       syn_buf_p1[384] = ixheaac_add32_sat(syn_buf_p2[320],
853                             ixheaacd_mps_mult32_shr_30(*(p_filter_4 + 64), val1));
854       syn_buf_p2[320] = ixheaac_add32_sat(syn_buf_p1[256],
855                             ixheaacd_mps_mult32_shr_30(*p_filter_4++, val));
856       syn_buf_p1[256] = ixheaac_add32_sat(syn_buf_p2[192],
857                             ixheaacd_mps_mult32_shr_30(*(p_filter_3 + 64), val1));
858       syn_buf_p2[192] = ixheaac_add32_sat(syn_buf_p1[128],
859                             ixheaacd_mps_mult32_shr_30(*p_filter_3++, val));
860       syn_buf_p1[128] = ixheaac_add32_sat(syn_buf_p2[64],
861                             ixheaacd_mps_mult32_shr_30(*(p_filter_2 + 64), val1));
862       syn_buf_p2[64] = ixheaac_add32_sat(syn_buf_p1[0],
863                             ixheaacd_mps_mult32_shr_30(*p_filter_2++, val));
864       syn_buf_p1[0] = ixheaacd_mps_mult32_shr_30(*(p_filter_1 + 63), val1);
865     }
866     p_filter_6 = p_filter_1 + 62;
867     p_filter_7 = p_filter_2 + 62;
868     p_filter_8 = p_filter_3 + 62;
869     p_filter_9 = p_filter_4 + 62;
870     p_filter_10 = p_filter_5 + 62;
871     time_sig += 62;
872 
873     syn_buf_p2 = synth_buf;
874     syn_buf_p3 = syn_buf_p2;
875     new_samp2 = p_sr + 63;
876     for (j = 0; j < resolution - 1; j++) {
877       *time_sig-- = ixheaac_add32_sat(syn_buf_p3[512],
878                         ixheaacd_mps_mult32_shr_30(*p_filter_6--, (*new_samp2)));
879       syn_buf_p3[512] = ixheaac_add32_sat(syn_buf_p2[448],
880                             ixheaacd_mps_mult32_shr_30(*p_filter_5++, (*new_samp)));
881       syn_buf_p2[448] = ixheaac_add32_sat(syn_buf_p3[384],
882                             ixheaacd_mps_mult32_shr_30(*p_filter_7--, (*new_samp2)));
883       syn_buf_p3[384] = ixheaac_add32_sat(syn_buf_p2[320],
884                             ixheaacd_mps_mult32_shr_30(*p_filter_4++, (*new_samp)));
885       syn_buf_p2[320] = ixheaac_add32_sat(syn_buf_p3[256],
886                             ixheaacd_mps_mult32_shr_30(*p_filter_8--, (*new_samp2)));
887       syn_buf_p3[256] = ixheaac_add32_sat(syn_buf_p2[192],
888                             ixheaacd_mps_mult32_shr_30(*p_filter_3++, (*new_samp)));
889       syn_buf_p2[192] = ixheaac_add32_sat(syn_buf_p3[128],
890                             ixheaacd_mps_mult32_shr_30(*p_filter_9--, (*new_samp2)));
891       syn_buf_p3[128] = ixheaac_add32_sat(syn_buf_p2[64],
892                             ixheaacd_mps_mult32_shr_30(*p_filter_2++, (*new_samp)));
893       syn_buf_p2[64] = ixheaac_add32_sat(syn_buf_p3[0],
894                            ixheaacd_mps_mult32_shr_30(*p_filter_10--, (*new_samp2)));
895       syn_buf_p3[0] = ixheaacd_mps_mult32_shr_30(*p_filter_1++, (*new_samp));
896 
897       new_samp++;
898       syn_buf_p2++;
899 
900       new_samp2--;
901       syn_buf_p3++;
902     }
903 
904     time_sig += 64;
905 
906     p_sr += MAX_HYBRID_BANDS;
907     p_si += MAX_HYBRID_BANDS;
908   }
909 }
910 
ixheaacd_calculate_syn_filt_bank(ia_mps_dec_qmf_syn_filter_bank * syn,WORD32 * sr,WORD32 * si,WORD32 * time_sig,WORD32 channel,WORD32 resolution,WORD32 nr_samples,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)911 VOID ixheaacd_calculate_syn_filt_bank(ia_mps_dec_qmf_syn_filter_bank *syn, WORD32 *sr, WORD32 *si,
912                                       WORD32 *time_sig, WORD32 channel, WORD32 resolution,
913                                       WORD32 nr_samples,
914                                       ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
915   WORD32 j, k;
916   WORD32 *synth_buf;
917   WORD32 *p_sr, *p_si;
918   WORD32 *buf_ptr;
919   WORD32 resx2 = resolution << 1;
920   WORD32 *sbr_qmf_states_synthesis = syn->sbr_qmf_states_synthesis;
921 
922   synth_buf = &(sbr_qmf_states_synthesis[channel * QMF_FILTER_STATE_SYN_SIZE_MPS]);
923 
924   p_sr = sr;
925   p_si = si;
926   for (k = 0; k < nr_samples; k++) {
927     WORD32 *new_samp = p_si + 63;
928 
929     const WORD32 *p_filter_1 = syn->p_filter_syn;
930     const WORD32 *p_filter_2 = p_filter_1 + 65;
931     const WORD32 *p_filter_3 = p_filter_2 + 65;
932     const WORD32 *p_filter_4 = p_filter_3 + 65;
933     const WORD32 *p_filter_5 = p_filter_4 + 65;
934 
935     ixheaacd_inverse_modulation(p_sr, p_si, qmf_table_ptr);
936 
937     for (j = 0; j < resolution; j++) {
938       synth_buf[j] = ixheaacd_mps_mult32_shr_30(*p_filter_1++, (*new_samp));
939       synth_buf[resx2 + j] = ixheaac_add32_sat(synth_buf[resx2 + j],
940                                  ixheaacd_mps_mult32_shr_30(*p_filter_2++, (*new_samp)));
941       synth_buf[resx2 * 2 + j] = ixheaac_add32_sat(synth_buf[resx2 * 2 + j],
942                                      ixheaacd_mps_mult32_shr_30(*p_filter_3++, (*new_samp)));
943       synth_buf[resx2 * 3 + j] = ixheaac_add32_sat(synth_buf[resx2 * 3 + j],
944                                      ixheaacd_mps_mult32_shr_30(*p_filter_4++, (*new_samp)));
945       synth_buf[resx2 * 4 + j] = ixheaac_add32_sat(synth_buf[resx2 * 4 + j],
946                                      ixheaacd_mps_mult32_shr_30(*p_filter_5++, (*new_samp)));
947 
948       new_samp--;
949     }
950 
951     synth_buf[resx2 - 1] = ixheaac_add32_sat(synth_buf[resx2 - 1],
952                                ixheaacd_mps_mult32_shr_30(*p_filter_1++, *p_sr));
953     synth_buf[resx2 * 2 - 1] = ixheaac_add32_sat(synth_buf[resx2 * 2 - 1],
954                                    ixheaacd_mps_mult32_shr_30(*p_filter_2++, *p_sr));
955     synth_buf[3 * resx2 - 1] = ixheaac_add32_sat(synth_buf[3 * resx2 - 1],
956                                    ixheaacd_mps_mult32_shr_30(*p_filter_3++, *p_sr));
957     synth_buf[4 * resx2 - 1] = ixheaac_add32_sat(synth_buf[4 * resx2 - 1],
958                                    ixheaacd_mps_mult32_shr_30(*p_filter_4++, *p_sr));
959     *time_sig++ = ixheaac_add32_sat(synth_buf[5 * resx2 - 1],
960                       ixheaacd_mps_mult32_shr_30(*p_filter_5++, *p_sr));
961 
962     p_filter_1 -= 2;
963     p_filter_2 -= 2;
964     p_filter_3 -= 2;
965     p_filter_4 -= 2;
966     p_filter_5 -= 2;
967 
968     new_samp = p_sr + resolution - 1;
969 
970     for (j = 0; j < resolution - 1; j++) {
971       synth_buf[resolution + j] = ixheaac_add32_sat(synth_buf[resolution + j],
972                                       ixheaacd_mps_mult32_shr_30(*--p_filter_5, (*new_samp)));
973       synth_buf[resolution * (3) + j] =
974           ixheaac_add32_sat(synth_buf[resolution * (3) + j],
975               ixheaacd_mps_mult32_shr_30(*--p_filter_4, (*new_samp)));
976       synth_buf[resolution * (5) + j] =
977           ixheaac_add32_sat(synth_buf[resolution * (5) + j],
978               ixheaacd_mps_mult32_shr_30(*--p_filter_3, (*new_samp)));
979       synth_buf[resolution * (7) + j] =
980           ixheaac_add32_sat(synth_buf[resolution * (7) + j],
981               ixheaacd_mps_mult32_shr_30(*--p_filter_2, (*new_samp)));
982       synth_buf[resolution * (9) + j] =
983           ixheaac_add32_sat(synth_buf[resolution * (9) + j],
984               ixheaacd_mps_mult32_shr_30(*--p_filter_1, (*new_samp)));
985       new_samp--;
986     }
987 
988     buf_ptr = synth_buf + 9 * resolution + resolution - 2;
989     for (j = 0; j < resolution - 1; j++) {
990       *time_sig++ = *buf_ptr--;
991     }
992 
993     memmove((synth_buf + resolution), synth_buf, (9 * resolution) * sizeof(WORD32));
994 
995     p_sr += MAX_HYBRID_BANDS;
996     p_si += MAX_HYBRID_BANDS;
997   }
998 }
999 
1000 IA_ERRORCODE
ixheaacd_syn_filt_bank_init(ia_mps_dec_synthesis_interface_handle self,WORD32 resolution)1001 ixheaacd_syn_filt_bank_init(ia_mps_dec_synthesis_interface_handle self, WORD32 resolution) {
1002   switch (resolution) {
1003     case QMF_BANDS_32:
1004       self->syn_filter_bank = ixheaacd_calculate_syn_filt_bank;
1005       break;
1006     case QMF_BANDS_64:
1007       self->syn_filter_bank = ixheaacd_calculate_syn_filt_bank_res64;
1008       break;
1009     case QMF_BANDS_128:
1010       self->syn_filter_bank = ixheaacd_calculate_syn_filt_bank;
1011       break;
1012     default:
1013       return IA_XHEAAC_MPS_DEC_INIT_NONFATAL_INVALID_QMF_BAND;
1014       break;
1015   }
1016   return IA_NO_ERROR;
1017 }
1018 
ia_mps_enc_fwd_mod(WORD32 * time_in,WORD32 * r_subband,WORD32 * i_subband,ia_mps_dec_qmf_tables_struct * qmf_table_ptr)1019 static VOID ia_mps_enc_fwd_mod(WORD32 *time_in, WORD32 *r_subband, WORD32 *i_subband,
1020                                ia_mps_dec_qmf_tables_struct *qmf_table_ptr) {
1021   WORD32 i;
1022 
1023   for (i = 0; i < 64; i++) {
1024     r_subband[i] = time_in[i] - time_in[127 - i];
1025     i_subband[i] = time_in[i] + time_in[127 - i];
1026   }
1027   ixheaacd_cos_mod(r_subband, qmf_table_ptr);
1028   ixheaacd_sin_mod(i_subband, qmf_table_ptr);
1029 }
1030 
ixheaacd_calc_ana_filt_bank(ia_heaac_mps_state_struct * pstr_mps_state,WORD16 * time_in,WORD32 * r_analysis,WORD32 * i_analysis,WORD32 channel)1031 VOID ixheaacd_calc_ana_filt_bank(ia_heaac_mps_state_struct *pstr_mps_state, WORD16 *time_in,
1032                                  WORD32 *r_analysis, WORD32 *i_analysis, WORD32 channel) {
1033   ia_mps_dec_qmf_ana_filter_bank *qmf_bank = &pstr_mps_state->qmf_bank[channel];
1034   ia_mps_dec_qmf_tables_struct *qmf_table_ptr =
1035       pstr_mps_state->ia_mps_dec_mps_table.qmf_table_ptr;
1036   WORD32 i, k, m;
1037 
1038   WORD32 *syn_buffer = pstr_mps_state->mps_scratch_mem_v;
1039   WORD64 accu1 = 0, accu2 = 0;
1040   WORD16 flag;
1041   WORD32 *fp1;
1042   WORD32 *fp2;
1043   WORD32 *temp;
1044   const WORD32 *start_co_eff_ptr_l;
1045   const WORD32 *start_co_eff_ptr_r;
1046   const WORD32 *ptr_pf_l, *ptr_pf_r;
1047   WORD32 *qmf_states_curr_pos;
1048   WORD32 offset = 0;
1049   WORD32 n_channels = pstr_mps_state->num_input_channels;
1050   WORD32 nr_samples = pstr_mps_state->time_slots;
1051   WORD32 qmf_bands = pstr_mps_state->qmf_bands;
1052   WORD32 shift = pstr_mps_state->bits_per_sample - 16;
1053   WORD32 gain = pstr_mps_state->clip_protect_gain;
1054 
1055   WORD32 *p_ana_real = r_analysis;
1056   WORD32 *p_ana_imag = i_analysis;
1057 
1058   WORD32 *p_ana_re, *p_ana_im;
1059 
1060   flag = qmf_bank->flag;
1061   if (!flag) {
1062     fp1 = qmf_bank->qmf_states_buffer;
1063     fp2 = qmf_bank->qmf_states_buffer + qmf_bands;
1064   } else {
1065     fp2 = qmf_bank->qmf_states_buffer;
1066     fp1 = qmf_bank->qmf_states_buffer + qmf_bands;
1067   }
1068 
1069   qmf_bank->qmf_states_curr_pos =
1070       ((WORD32 *)(qmf_bank->qmf_states_buffer) + (qmf_bank->offset * qmf_bands));
1071 
1072   offset = qmf_bank->offset;
1073   start_co_eff_ptr_l = qmf_bank->ref_co_eff_ptr_l + qmf_bank->offset_l;
1074   start_co_eff_ptr_r = qmf_bank->ref_co_eff_ptr_r - qmf_bank->offset_r;
1075 
1076   for (i = 0; i < nr_samples; i++) {
1077     const WORD16 *pcoz = qmf_table_ptr->ia_qmf_anl_addt_cos,
1078                  *psin = qmf_table_ptr->ia_qmf_anl_addt_sin;
1079     qmf_states_curr_pos = qmf_bank->qmf_states_curr_pos;
1080 
1081     p_ana_re = p_ana_real;
1082     p_ana_im = p_ana_imag;
1083 
1084     temp = fp1;
1085     fp1 = fp2;
1086     fp2 = temp;
1087 
1088     if (flag) {
1089       start_co_eff_ptr_l--;
1090 
1091       if (start_co_eff_ptr_l == qmf_bank->ref_co_eff_ptr_l) start_co_eff_ptr_l += 5;
1092     } else {
1093       start_co_eff_ptr_r++;
1094       if (start_co_eff_ptr_r == qmf_bank->ref_co_eff_ptr_r) start_co_eff_ptr_r -= 5;
1095     }
1096 
1097     flag++;
1098     if ((flag & ONE_BIT_MASK) == 0) flag = 0;
1099 
1100     if (shift == 0) {
1101       for (k = 0; k < qmf_bands; k++) {
1102         qmf_states_curr_pos[k] = ixheaacd_mps_mult32_shr_15(
1103             (WORD32)time_in[n_channels * (i * qmf_bands + k) + channel], gain);
1104       }
1105     } else {
1106       for (k = 0; k < qmf_bands; k++) {
1107         WORD32 temp;
1108         temp = ixheaacd_mps_mult32_shr_15(
1109             (WORD32)time_in[n_channels * (i * qmf_bands + k) + channel], gain);
1110 
1111         qmf_states_curr_pos[k] = temp >> shift;
1112       }
1113     }
1114 
1115     ptr_pf_l = start_co_eff_ptr_l;
1116     ptr_pf_r = start_co_eff_ptr_r;
1117 
1118     for (k = 0; k < qmf_bands; k++) {
1119       {
1120         accu1 = (WORD64)((WORD64)ptr_pf_l[0] * (WORD64)fp1[k]);
1121         accu1 += (WORD64)((WORD64)ptr_pf_l[1] * (WORD64)fp1[128 + k]);
1122         accu1 += (WORD64)((WORD64)ptr_pf_l[2] * (WORD64)fp1[256 + k]);
1123         accu1 += (WORD64)((WORD64)ptr_pf_l[3] * (WORD64)fp1[384 + k]);
1124         accu1 += (WORD64)((WORD64)ptr_pf_l[4] * (WORD64)fp1[512 + k]);
1125 
1126         accu2 = (WORD64)((WORD64)ptr_pf_r[-1] * (WORD64)fp2[k]);
1127         accu2 += (WORD64)((WORD64)ptr_pf_r[-2] * (WORD64)fp2[128 + k]);
1128         accu2 += (WORD64)((WORD64)ptr_pf_r[-3] * (WORD64)fp2[256 + k]);
1129         accu2 += (WORD64)((WORD64)ptr_pf_r[-4] * (WORD64)fp2[384 + k]);
1130         accu2 += (WORD64)((WORD64)ptr_pf_r[-5] * (WORD64)fp2[512 + k]);
1131       }
1132       syn_buffer[(qmf_bands << 1) - 1 - k] = (WORD32)((WORD64)accu1 >> 21);
1133       syn_buffer[qmf_bands - 1 - k] = (WORD32)((WORD64)accu2 >> 21);
1134       ptr_pf_l += 10;
1135       ptr_pf_r -= 10;
1136     }
1137 
1138     ia_mps_enc_fwd_mod(syn_buffer, p_ana_re, p_ana_im, qmf_table_ptr);
1139 
1140     for (m = 0; m < (qmf_bands >> 1); m++) {
1141       WORD32 a_cos, b_cos, a_sin, b_sin;
1142       WORD32 a_cos1, b_cos1, a_sin1, b_sin1;
1143 
1144       WORD16 coz = *pcoz++, sin = *psin++;
1145 
1146       a_cos = ixheaac_mult32x16in32(p_ana_re[m], coz);
1147       b_sin = ixheaac_mult32x16in32(p_ana_im[m], sin);
1148       b_cos = ixheaac_mult32x16in32(p_ana_im[m], coz);
1149       a_sin = ixheaac_mult32x16in32(p_ana_re[m], sin);
1150 
1151       p_ana_re[m] = ((a_cos + b_sin) << 1);
1152       p_ana_im[m] = ((b_cos - a_sin) << 1);
1153 
1154       a_cos1 = ixheaac_mult32x16in32(p_ana_re[qmf_bands - 1 - m], coz);
1155       b_sin1 = ixheaac_mult32x16in32(p_ana_im[qmf_bands - 1 - m], sin);
1156 
1157       a_sin1 = ixheaac_mult32x16in32(p_ana_re[qmf_bands - 1 - m], sin);
1158       p_ana_re[qmf_bands - 1 - m] = ((-a_cos1 + b_sin1) << 1);
1159       b_cos1 = ixheaac_mult32x16in32(p_ana_im[qmf_bands - 1 - m], coz);
1160 
1161       p_ana_im[qmf_bands - 1 - m] = ((-b_cos1 - a_sin1) << 1);
1162     }
1163 
1164     qmf_bank->qmf_states_curr_pos = qmf_bank->qmf_states_curr_pos + qmf_bands;
1165     offset++;
1166     if (offset == 10) {
1167       offset = 0;
1168       qmf_bank->qmf_states_curr_pos = qmf_bank->qmf_states_buffer;
1169     }
1170 
1171     p_ana_real += MAX_NUM_QMF_BANDS;
1172     p_ana_imag += MAX_NUM_QMF_BANDS;
1173   }
1174 
1175   qmf_bank->offset_l = (WORD32)(start_co_eff_ptr_l - qmf_bank->ref_co_eff_ptr_l);
1176   qmf_bank->offset_r = (WORD32)(qmf_bank->ref_co_eff_ptr_r - start_co_eff_ptr_r);
1177 
1178   qmf_bank->flag = flag;
1179   qmf_bank->offset = offset;
1180 }
1181