xref: /aosp_15_r20/external/libxaac/decoder/generic/ixheaacd_qmf_dec_generic.c (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2018 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 
22 #include "ixheaacd_sbr_common.h"
23 #include "ixheaac_type_def.h"
24 
25 #include "ixheaac_constants.h"
26 #include "ixheaac_basic_ops32.h"
27 #include "ixheaac_basic_ops16.h"
28 #include "ixheaac_basic_ops40.h"
29 #include "ixheaac_basic_ops.h"
30 
31 #include "ixheaacd_intrinsics.h"
32 #include "ixheaacd_common_rom.h"
33 #include "ixheaacd_bitbuffer.h"
34 #include "ixheaacd_sbrdecsettings.h"
35 #include "ixheaacd_sbr_scale.h"
36 #include "ixheaacd_lpp_tran.h"
37 #include "ixheaacd_env_extr_part.h"
38 #include "ixheaacd_sbr_rom.h"
39 #include "ixheaacd_hybrid.h"
40 #include "ixheaacd_ps_dec.h"
41 #include "ixheaacd_env_extr.h"
42 #include "ixheaacd_qmf_dec.h"
43 
44 #include "ixheaac_basic_op.h"
45 #include "ixheaacd_env_calc.h"
46 
47 #include "ixheaacd_interface.h"
48 
49 #include "ixheaacd_function_selector.h"
50 #include "ixheaacd_audioobjtypes.h"
51 #if !__ARM_NEON__
52 
53 #define DCT3_LEN (32)
54 #define DCT2_LEN (64)
55 
56 #define LP_SHIFT_VAL 7
57 #define HQ_SHIFT_64 4
58 #define RADIXSHIFT 1
59 #define HQ_SHIFT_VAL 4
60 
61 extern const WORD32 ixheaacd_ldmps_polyphase_filter_coeff_fix[1280];
62 
ixheaacd_dct3_32(WORD32 * input,WORD32 * output,const WORD16 * main_twidle_fwd,const WORD16 * post_tbl,const WORD16 * w_16,const WORD32 * p_table)63 VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output,
64                       const WORD16 *main_twidle_fwd, const WORD16 *post_tbl,
65                       const WORD16 *w_16, const WORD32 *p_table) {
66   WORD32 n, k;
67 
68   WORD32 temp1[6];
69   WORD32 temp2[4];
70   WORD16 twid_re, twid_im;
71   WORD32 *ptr_reverse, *ptr_forward, *p_out, *ptr_out1;
72   const WORD16 *twidle_fwd, *twidle_rev;
73 
74   ptr_forward = &input[49];
75   ptr_reverse = &input[47];
76 
77   p_out = output;
78   twidle_fwd = main_twidle_fwd;
79   twidle_fwd += 4;
80 
81   *p_out++ = input[48] >> LP_SHIFT_VAL;
82   *p_out++ = 0;
83 
84   for (n = 1; n < DCT3_LEN / 2; n++) {
85     temp1[0] = *ptr_forward++;
86     temp1[1] = *ptr_reverse--;
87     temp1[0] = ixheaac_add32_sat(ixheaac_shr32(temp1[0], LP_SHIFT_VAL),
88                                   ixheaac_shr32(temp1[1], LP_SHIFT_VAL));
89 
90     temp1[2] = *(ptr_forward - 33);
91     temp1[3] = *(ptr_reverse - 31);
92     temp1[1] = ixheaac_sub32_sat(ixheaac_shr32(temp1[2], LP_SHIFT_VAL),
93                                   ixheaac_shr32(temp1[3], LP_SHIFT_VAL));
94     twid_re = *twidle_fwd++;
95 
96     twid_im = *twidle_fwd;
97     twidle_fwd += 3;
98 
99     *p_out++ = ixheaac_mult32x16in32(temp1[0], twid_re) +
100                ixheaac_mult32x16in32(temp1[1], twid_im);
101     *p_out++ = -ixheaac_mult32x16in32(temp1[1], twid_re) +
102                ixheaac_mult32x16in32(temp1[0], twid_im);
103   }
104 
105   twid_re = *twidle_fwd++;
106 
107   twid_im = *twidle_fwd;
108   twidle_fwd += 3;
109 
110   temp1[1] = *ptr_reverse--;
111   temp1[0] = *(ptr_reverse - 31);
112   temp1[1] = ixheaac_sub32_sat(ixheaac_shr32(temp1[1], LP_SHIFT_VAL),
113                                 ixheaac_shr32(temp1[0], LP_SHIFT_VAL));
114 
115   temp1[0] = temp1[1];
116 
117   temp2[2] = ixheaac_mult32x16in32(temp1[0], twid_re) +
118              ixheaac_mult32x16in32(temp1[1], twid_im);
119   temp2[3] = -ixheaac_mult32x16in32(temp1[1], twid_re) +
120              ixheaac_mult32x16in32(temp1[0], twid_im);
121 
122   ptr_forward = output;
123   ptr_reverse = &output[DCT3_LEN - 1];
124 
125   temp2[0] = *ptr_forward++;
126   temp2[1] = *ptr_forward--;
127 
128   temp1[0] = -temp2[1] - temp2[3];
129   temp1[1] = temp2[0] - temp2[2];
130   temp2[0] = (temp2[0] + temp2[2] + temp1[0]);
131   temp2[1] = (temp2[1] - temp2[3] + temp1[1]);
132 
133   temp2[0] >>= 1;
134   temp2[1] >>= 1;
135 
136   *ptr_forward++ = temp2[0];
137   *ptr_forward++ = temp2[1];
138 
139   twidle_fwd = post_tbl + 2;
140   twidle_rev = post_tbl + 14;
141 
142   for (n = 1; n < DCT3_LEN / 4; n++) {
143     temp2[0] = *ptr_forward++;
144     temp2[1] = *ptr_forward--;
145     temp2[3] = *ptr_reverse--;
146     temp2[2] = *ptr_reverse++;
147 
148     twid_re = *twidle_rev;
149     twidle_rev -= 2;
150     twid_im = *twidle_fwd;
151     twidle_fwd += 2;
152 
153     temp1[0] = temp2[0] - temp2[2];
154     temp1[1] = (temp2[0] + temp2[2]);
155 
156     temp1[2] = temp2[1] + temp2[3];
157     temp1[3] = (temp2[1] - temp2[3]);
158 
159     temp1[4] = ixheaac_mult32x16in32(temp1[0], twid_re) +
160                ixheaac_mult32x16in32(temp1[2], twid_im);
161     temp1[5] = -ixheaac_mult32x16in32(temp1[2], twid_re) +
162                ixheaac_mult32x16in32(temp1[0], twid_im);
163 
164     temp1[1] >>= 1;
165     temp1[3] >>= 1;
166 
167     *ptr_forward++ = temp1[1] - temp1[4];
168     *ptr_forward++ = temp1[3] + temp1[5];
169 
170     *ptr_reverse-- = -temp1[3] + temp1[5];
171     *ptr_reverse-- = temp1[1] + temp1[4];
172   }
173   temp2[0] = *ptr_forward++;
174   temp2[1] = *ptr_forward--;
175   temp2[3] = *ptr_reverse--;
176   temp2[2] = *ptr_reverse++;
177 
178   twid_re = -*twidle_rev;
179   twidle_rev -= 2;
180   twid_im = *twidle_fwd;
181   twidle_fwd += 2;
182 
183   temp1[0] = temp2[0] - temp2[2];
184   temp1[1] = (temp2[0] + temp2[2]);
185 
186   temp1[2] = temp2[1] + temp2[3];
187   temp1[3] = (temp2[1] - temp2[3]);
188 
189   temp1[4] = ixheaac_mult32x16in32(temp1[0], twid_re) -
190              ixheaac_mult32x16in32(temp1[2], twid_im);
191   temp1[5] = ixheaac_mult32x16in32(temp1[2], twid_re) +
192              ixheaac_mult32x16in32(temp1[0], twid_im);
193 
194   temp1[1] >>= 1;
195   temp1[3] >>= 1;
196   *ptr_forward++ = temp1[1] + temp1[4];
197   *ptr_forward++ = temp1[3] + temp1[5];
198 
199   ixheaacd_radix4bfly(w_16, output, 1, 4);
200   ixheaacd_postradixcompute4(input, output, p_table, 16);
201 
202   output[0] = input[0];
203   output[2] = input[1];
204 
205   p_out = input + 2;
206   ptr_forward = output + 1;
207   ptr_reverse = output + 30;
208   ptr_out1 = input + 18;
209 
210   for (k = (DCT3_LEN / 4) - 1; k != 0; k--) {
211     WORD32 tempre, tempim;
212 
213     tempre = *p_out++;
214     tempim = *p_out++;
215     *ptr_forward = (tempim);
216     ptr_forward += 2;
217     *ptr_forward = (tempre);
218     ptr_forward += 2;
219 
220     tempre = *ptr_out1++;
221     tempim = *ptr_out1++;
222     *ptr_reverse = (tempim);
223     ptr_reverse -= 2;
224     *ptr_reverse = (tempre);
225     ptr_reverse -= 2;
226   }
227 
228   {
229     WORD32 tempre, tempim;
230     tempre = *p_out++;
231     tempim = *p_out++;
232     *ptr_forward = (tempim);
233     ptr_forward += 2;
234     *ptr_forward = (tempre);
235     ptr_forward += 2;
236   }
237 
238   return;
239 }
240 
ixheaacd_dct2_64(WORD32 * x,WORD32 * X,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr,WORD16 * filter_states)241 VOID ixheaacd_dct2_64(WORD32 *x, WORD32 *X,
242                       ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
243                       WORD16 *filter_states) {
244   ixheaacd_pretwdct2(x, X);
245 
246   ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_32, X, 1, 8);
247 
248   ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_32 + 48, X, 4, 2);
249 
250   ixheaacd_postradixcompute2(x, X, qmf_dec_tables_ptr->dig_rev_table2_32, 32);
251 
252   ixheaacd_fftposttw(x, qmf_dec_tables_ptr);
253 
254   ixheaacd_posttwdct2(x, filter_states, qmf_dec_tables_ptr);
255 
256   return;
257 }
258 
ixheaacd_cos_sin_mod(WORD32 * subband,ia_sbr_qmf_filter_bank_struct * qmf_bank,WORD16 * p_twiddle,WORD32 * p_dig_rev_tbl)259 VOID ixheaacd_cos_sin_mod(WORD32 *subband,
260                           ia_sbr_qmf_filter_bank_struct *qmf_bank,
261                           WORD16 *p_twiddle, WORD32 *p_dig_rev_tbl) {
262   WORD32 re2, re3;
263   WORD16 wim, wre;
264 
265   WORD32 i, M_2;
266   WORD32 M = ixheaac_shr32(qmf_bank->no_channels, 1);
267 
268   const WORD16 *p_sin;
269   const WORD16 *p_sin_cos = &qmf_bank->cos_twiddle[0];
270   WORD32 subband_tmp[128];
271   WORD32 re;
272   WORD32 im;
273   WORD32 *psubband, *psubband1;
274   WORD32 *psubband_t, *psubband1_t;
275   WORD32 *psubband2, *psubband12;
276   WORD32 *psubband_t2, *psubband1_t2;
277 
278   M_2 = ixheaac_shr32(M, 1);
279 
280   psubband = &subband[0];
281   psubband1 = &subband[2 * M - 1];
282   psubband_t = subband_tmp;
283   psubband1_t = &subband_tmp[2 * M - 1];
284 
285   psubband2 = &subband[64];
286   psubband12 = &subband[2 * M - 1 + 64];
287   psubband_t2 = &subband_tmp[64];
288   psubband1_t2 = &subband_tmp[2 * M - 1 + 64];
289 
290   for (i = (M_2 >> 1) - 1; i >= 0; i--) {
291     re = *psubband++;
292     im = *psubband1--;
293 
294     wim = *p_sin_cos++;
295     wre = *p_sin_cos++;
296 
297     *psubband_t++ = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wre),
298                                        ixheaac_mult32x16in32(im, wim));
299     *psubband_t++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
300                                        ixheaac_mult32x16in32(re, wim));
301 
302     re = *psubband2++;
303     im = *psubband12--;
304 
305     *psubband_t2++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wim),
306                                         ixheaac_mult32x16in32(re, wre));
307     *psubband_t2++ = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wim),
308                                         ixheaac_mult32x16in32(im, wre));
309 
310     re = *psubband1--;
311     im = *psubband++;
312 
313     wim = *p_sin_cos++;
314     wre = *p_sin_cos++;
315 
316     *psubband1_t-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
317                                         ixheaac_mult32x16in32(re, wim));
318     *psubband1_t-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wre),
319                                         ixheaac_mult32x16in32(im, wim));
320 
321     re = *psubband12--;
322     im = *psubband2++;
323 
324     *psubband1_t2-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wim),
325                                          ixheaac_mult32x16in32(im, wre));
326     *psubband1_t2-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wim),
327                                          ixheaac_mult32x16in32(re, wre));
328 
329     re = *psubband++;
330     im = *psubband1--;
331 
332     wim = *p_sin_cos++;
333     wre = *p_sin_cos++;
334 
335     *psubband_t++ = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wre),
336                                        ixheaac_mult32x16in32(im, wim));
337     *psubband_t++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
338                                        ixheaac_mult32x16in32(re, wim));
339 
340     re = *psubband2++;
341     im = *psubband12--;
342 
343     *psubband_t2++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wim),
344                                         ixheaac_mult32x16in32(re, wre));
345     *psubband_t2++ = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wim),
346                                         ixheaac_mult32x16in32(im, wre));
347 
348     re = *psubband1--;
349     im = *psubband++;
350 
351     wim = *p_sin_cos++;
352     wre = *p_sin_cos++;
353 
354     *psubband1_t-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
355                                         ixheaac_mult32x16in32(re, wim));
356     *psubband1_t-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wre),
357                                         ixheaac_mult32x16in32(im, wim));
358 
359     re = *psubband12--;
360     im = *psubband2++;
361     ;
362 
363     *psubband1_t2-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wim),
364                                          ixheaac_mult32x16in32(im, wre));
365     *psubband1_t2-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wim),
366                                          ixheaac_mult32x16in32(re, wre));
367   }
368 
369   if (M == 32) {
370     ixheaacd_radix4bfly(p_twiddle, subband_tmp, 1, 8);
371     ixheaacd_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2);
372     ixheaacd_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32);
373 
374     ixheaacd_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8);
375     ixheaacd_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2);
376     ixheaacd_postradixcompute2(&subband[64], &subband_tmp[64], p_dig_rev_tbl,
377                                32);
378 
379   } else {
380     ixheaacd_radix4bfly(p_twiddle, subband_tmp, 1, 4);
381     ixheaacd_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16);
382 
383     ixheaacd_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4);
384     ixheaacd_postradixcompute4(&subband[64], &subband_tmp[64], p_dig_rev_tbl,
385                                16);
386   }
387 
388   psubband = &subband[0];
389   psubband1 = &subband[2 * M - 1];
390 
391   re = *psubband1;
392 
393   *psubband = *psubband >> 1;
394   psubband++;
395   *psubband1 = ixheaac_negate32_sat(*psubband >> 1);
396   psubband1--;
397 
398   p_sin = &qmf_bank->alt_sin_twiddle[0];
399   wim = *p_sin++;
400   wre = *p_sin++;
401 
402   im = *psubband1;
403 
404   *psubband1-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wre),
405                                     ixheaac_mult32x16in32(im, wim));
406   *psubband++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
407                                    ixheaac_mult32x16in32(re, wim));
408 
409   psubband2 = &subband[64];
410   psubband12 = &subband[2 * M - 1 + 64];
411 
412   re = *psubband12;
413 
414   *psubband12-- = ixheaac_negate32_sat(*psubband2 >> 1);
415 
416   *psubband2 = psubband2[1] >> 1;
417 
418   psubband2++;
419 
420   im = *psubband12;
421 
422   *psubband2++ = ixheaac_negate32_sat(ixheaac_add32_sat(
423       ixheaac_mult32x16in32(re, wre), ixheaac_mult32x16in32(im, wim)));
424   *psubband12-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(re, wim),
425                                      ixheaac_mult32x16in32(im, wre));
426 
427   for (i = (M_2 - 2); i >= 0; i--) {
428     im = psubband[0];
429 
430     re = psubband[1];
431 
432     re2 = *psubband1;
433 
434     *psubband++ = ixheaac_add32_sat(ixheaac_mult32x16in32(re, wim),
435                                      ixheaac_mult32x16in32(im, wre));
436     *psubband1-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wim),
437                                       ixheaac_mult32x16in32(re, wre));
438 
439     im = psubband2[0];
440 
441     re = psubband2[1];
442 
443     re3 = *psubband12;
444 
445     *psubband12-- = ixheaac_negate32_sat(ixheaac_add32_sat(
446         ixheaac_mult32x16in32(re, wim), ixheaac_mult32x16in32(im, wre)));
447     *psubband2++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(re, wre),
448                                       ixheaac_mult32x16in32(im, wim));
449 
450     wim = *p_sin++;
451     wre = *p_sin++;
452     im = psubband1[0];
453 
454     *psubband1-- = ixheaac_add32_sat(ixheaac_mult32x16in32(re2, wre),
455                                       ixheaac_mult32x16in32(im, wim));
456     *psubband++ = ixheaac_sub32_sat(ixheaac_mult32x16in32(im, wre),
457                                      ixheaac_mult32x16in32(re2, wim));
458 
459     im = psubband12[0];
460 
461     *psubband2++ = ixheaac_negate32_sat(ixheaac_add32_sat(
462         ixheaac_mult32x16in32(re3, wre), ixheaac_mult32x16in32(im, wim)));
463     *psubband12-- = ixheaac_sub32_sat(ixheaac_mult32x16in32(re3, wim),
464                                        ixheaac_mult32x16in32(im, wre));
465   }
466 }
467 
ixheaacd_fwd_modulation(const WORD32 * p_time_in1,WORD32 * real_subband,WORD32 * imag_subband,ia_sbr_qmf_filter_bank_struct * qmf_bank,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr,WORD32 ld_mps_flag)468 VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband,
469                              WORD32 *imag_subband,
470                              ia_sbr_qmf_filter_bank_struct *qmf_bank,
471                              ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
472                              WORD32 ld_mps_flag) {
473   WORD32 i;
474   const WORD32 *p_time_in2 = &p_time_in1[2 * qmf_bank->no_channels - 1];
475   WORD32 temp1, temp2;
476   WORD32 *t_real_subband = real_subband;
477   WORD32 *t_imag_subband = imag_subband;
478   const WORD16 *tcos;
479 
480   for (i = qmf_bank->no_channels - 1; i >= 0; i--) {
481     temp1 = ixheaac_shr32(*p_time_in1++, HQ_SHIFT_VAL);
482     temp2 = ixheaac_shr32(*p_time_in2--, HQ_SHIFT_VAL);
483 
484     *t_real_subband++ = ixheaac_sub32_sat(temp1, temp2);
485 
486     *t_imag_subband++ = ixheaac_add32_sat(temp1, temp2);
487   }
488 
489   if (qmf_bank->no_channels != 64)
490     ixheaacd_cos_sin_mod(real_subband, qmf_bank, qmf_dec_tables_ptr->w_16,
491                          qmf_dec_tables_ptr->dig_rev_table4_16);
492   else
493     ixheaacd_cos_sin_mod(real_subband, qmf_bank, qmf_dec_tables_ptr->w_32,
494                          qmf_dec_tables_ptr->dig_rev_table2_32);
495 
496   if (ld_mps_flag == 0) {
497     tcos = qmf_bank->t_cos;
498 
499     for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) {
500       WORD16 cosh, sinh;
501       WORD32 re, im;
502 
503       re = *real_subband;
504       im = *imag_subband;
505       cosh = *tcos++;
506       sinh = *tcos++;
507       *real_subband++ =
508           ixheaac_add32_sat(ixheaac_mult32x16in32_shl(re, cosh),
509                              ixheaac_mult32x16in32_shl(im, sinh));
510       *imag_subband++ =
511           ixheaac_sub32_sat(ixheaac_mult32x16in32_shl(im, cosh),
512                              ixheaac_mult32x16in32_shl(re, sinh));
513     }
514   } else {
515     WORD32 i_band;
516     for (i = 0; i < min(64, qmf_bank->no_channels); i += 2) {
517       i_band = real_subband[i];
518       real_subband[i] = -imag_subband[i];
519       imag_subband[i] = i_band;
520 
521       i_band = -real_subband[i + 1];
522       real_subband[i + 1] = imag_subband[i + 1];
523       imag_subband[i + 1] = i_band;
524     }
525   }
526 }
527 
ixheaacd_sbr_qmfanal32_winadd(WORD16 * inp1,WORD16 * inp2,const WORD16 * p_qmf1,const WORD16 * p_qmf2,WORD32 * p_out)528 VOID ixheaacd_sbr_qmfanal32_winadd(WORD16 *inp1, WORD16 *inp2,
529                                    const WORD16 *p_qmf1, const WORD16 *p_qmf2,
530                                    WORD32 *p_out) {
531   WORD32 n;
532 
533   for (n = 0; n < 32; n += 2) {
534     WORD32 accu;
535 
536     accu = ixheaac_mult16x16in32(inp1[n + 0], p_qmf1[2 * (n + 0)]);
537     accu = ixheaac_add32_sat(
538         accu, ixheaac_mult16x16in32(inp1[n + 64], p_qmf1[2 * (n + 64)]));
539     accu = ixheaac_add32_sat(
540         accu, ixheaac_mult16x16in32(inp1[n + 128], p_qmf1[2 * (n + 128)]));
541     accu = ixheaac_add32_sat(
542         accu, ixheaac_mult16x16in32(inp1[n + 192], p_qmf1[2 * (n + 192)]));
543     accu = ixheaac_add32_sat(
544         accu, ixheaac_mult16x16in32(inp1[n + 256], p_qmf1[2 * (n + 256)]));
545     p_out[n] = accu;
546 
547     accu = ixheaac_mult16x16in32(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]);
548     accu = ixheaac_add32_sat(
549         accu,
550         ixheaac_mult16x16in32(inp1[n + 1 + 64], p_qmf1[2 * (n + 1 + 64)]));
551     accu = ixheaac_add32_sat(
552         accu,
553         ixheaac_mult16x16in32(inp1[n + 1 + 128], p_qmf1[2 * (n + 1 + 128)]));
554     accu = ixheaac_add32_sat(
555         accu,
556         ixheaac_mult16x16in32(inp1[n + 1 + 192], p_qmf1[2 * (n + 1 + 192)]));
557     accu = ixheaac_add32_sat(
558         accu,
559         ixheaac_mult16x16in32(inp1[n + 1 + 256], p_qmf1[2 * (n + 1 + 256)]));
560     p_out[n + 1] = accu;
561 
562     accu = ixheaac_mult16x16in32(inp2[n + 0], p_qmf2[2 * (n + 0)]);
563     accu = ixheaac_add32_sat(
564         accu, ixheaac_mult16x16in32(inp2[n + 64], p_qmf2[2 * (n + 64)]));
565     accu = ixheaac_add32_sat(
566         accu, ixheaac_mult16x16in32(inp2[n + 128], p_qmf2[2 * (n + 128)]));
567     accu = ixheaac_add32_sat(
568         accu, ixheaac_mult16x16in32(inp2[n + 192], p_qmf2[2 * (n + 192)]));
569     accu = ixheaac_add32_sat(
570         accu, ixheaac_mult16x16in32(inp2[n + 256], p_qmf2[2 * (n + 256)]));
571     p_out[n + 32] = accu;
572 
573     accu = ixheaac_mult16x16in32(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]);
574     accu = ixheaac_add32_sat(
575         accu,
576         ixheaac_mult16x16in32(inp2[n + 1 + 64], p_qmf2[2 * (n + 1 + 64)]));
577     accu = ixheaac_add32_sat(
578         accu,
579         ixheaac_mult16x16in32(inp2[n + 1 + 128], p_qmf2[2 * (n + 1 + 128)]));
580     accu = ixheaac_add32_sat(
581         accu,
582         ixheaac_mult16x16in32(inp2[n + 1 + 192], p_qmf2[2 * (n + 1 + 192)]));
583     accu = ixheaac_add32_sat(
584         accu,
585         ixheaac_mult16x16in32(inp2[n + 1 + 256], p_qmf2[2 * (n + 1 + 256)]));
586     p_out[n + 1 + 32] = accu;
587   }
588 }
589 
ixheaacd_cplx_anal_qmffilt(const WORD16 * time_sample_buf,ia_sbr_scale_fact_struct * sbr_scale_factor,WORD32 ** qmf_real,WORD32 ** qmf_imag,ia_sbr_qmf_filter_bank_struct * qmf_bank,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr,WORD32 ch_fac,WORD32 low_pow_flag,WORD audio_object_type)590 VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_sample_buf,
591                                 ia_sbr_scale_fact_struct *sbr_scale_factor,
592                                 WORD32 **qmf_real, WORD32 **qmf_imag,
593                                 ia_sbr_qmf_filter_bank_struct *qmf_bank,
594                                 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
595                                 WORD32 ch_fac, WORD32 low_pow_flag,
596                                 WORD audio_object_type) {
597   WORD32 i, k;
598   WORD32 num_time_slots = qmf_bank->num_time_slots;
599 
600   WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS] = { 0 };
601   WORD16 *filter_states = qmf_bank->core_samples_buffer;
602 
603   WORD16 *fp1, *fp2, *tmp;
604 
605   WORD16 *filter_1;
606   WORD16 *filter_2;
607   WORD16 *filt_ptr;
608   WORD32 start_slot = 0;
609 
610   if (audio_object_type != AOT_ER_AAC_ELD &&
611       audio_object_type != AOT_ER_AAC_LD) {
612     qmf_bank->filter_pos +=
613         (qmf_dec_tables_ptr->qmf_c - qmf_bank->analy_win_coeff);
614     qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c;
615   } else {
616     qmf_bank->filter_pos +=
617         (qmf_dec_tables_ptr->qmf_c_eld3 - qmf_bank->analy_win_coeff);
618     qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3;
619   }
620 
621   filter_1 = qmf_bank->filter_pos;
622 
623   if (audio_object_type != AOT_ER_AAC_ELD &&
624       audio_object_type != AOT_ER_AAC_LD) {
625     filter_2 = filter_1 + 64;
626   } else {
627     filter_2 = filter_1 + qmf_bank->no_channels;
628   }
629 
630   sbr_scale_factor->st_lb_scale = 0;
631   sbr_scale_factor->lb_scale = -10;
632   if (!low_pow_flag) {
633     if (audio_object_type != AOT_ER_AAC_ELD &&
634         audio_object_type != AOT_ER_AAC_LD) {
635       sbr_scale_factor->lb_scale = -8;
636     } else {
637       sbr_scale_factor->lb_scale = -9;
638     }
639     if (qmf_bank->no_channels != 64) {
640       qmf_bank->cos_twiddle =
641           (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32;
642       qmf_bank->alt_sin_twiddle =
643           (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32;
644     } else {
645       qmf_bank->cos_twiddle =
646           (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64;
647       qmf_bank->alt_sin_twiddle =
648           (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64;
649     }
650     if (audio_object_type != AOT_ER_AAC_ELD &&
651         audio_object_type != AOT_ER_AAC_LD) {
652       qmf_bank->t_cos = (WORD16 *)qmf_dec_tables_ptr->sbr_t_cos_sin_l32;
653     } else {
654       qmf_bank->t_cos =
655           (WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld;
656     }
657   }
658 
659   fp1 = qmf_bank->anal_filter_states;
660   fp2 = qmf_bank->anal_filter_states + qmf_bank->no_channels;
661 
662   if (audio_object_type == AOT_ER_AAC_ELD ||
663       audio_object_type == AOT_ER_AAC_LD) {
664     filter_2 = qmf_bank->filter_2;
665     fp1 = qmf_bank->fp1_anal;
666     fp2 = qmf_bank->fp2_anal;
667   }
668 
669   for (i = start_slot; i < num_time_slots + start_slot; i++) {
670     for (k = 0; k < qmf_bank->no_channels; k++)
671       filter_states[qmf_bank->no_channels - 1 - k] =
672           time_sample_buf[ch_fac * k];
673 
674     if (audio_object_type != AOT_ER_AAC_ELD &&
675         audio_object_type != AOT_ER_AAC_LD) {
676       ixheaacd_sbr_qmfanal32_winadd(fp1, fp2, filter_1, filter_2,
677                                     analysis_buffer);
678     } else {
679       ixheaacd_sbr_qmfanal32_winadd_eld(fp1, fp2, filter_1, filter_2,
680                                         analysis_buffer);
681     }
682 
683     time_sample_buf += qmf_bank->no_channels * ch_fac;
684 
685     filter_states -= qmf_bank->no_channels;
686     if (filter_states < qmf_bank->anal_filter_states) {
687       filter_states = qmf_bank->anal_filter_states +
688                       ((qmf_bank->no_channels * 10) - qmf_bank->no_channels);
689     }
690 
691     tmp = fp1;
692     fp1 = fp2;
693     fp2 = tmp;
694     if (audio_object_type != AOT_ER_AAC_ELD &&
695         audio_object_type != AOT_ER_AAC_LD) {
696       filter_1 += 64;
697       filter_2 += 64;
698     } else {
699       filter_1 += qmf_bank->no_channels;
700       filter_2 += qmf_bank->no_channels;
701     }
702 
703     filt_ptr = filter_1;
704     filter_1 = filter_2;
705     filter_2 = filt_ptr;
706     if (audio_object_type != AOT_ER_AAC_ELD &&
707         audio_object_type != AOT_ER_AAC_LD) {
708       if (filter_2 > (qmf_bank->analy_win_coeff + 640)) {
709         filter_1 = (WORD16 *)qmf_bank->analy_win_coeff;
710         filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 64;
711       }
712     } else {
713       if (filter_2 >
714           (qmf_bank->analy_win_coeff + (qmf_bank->no_channels * 10))) {
715         filter_1 = (WORD16 *)qmf_bank->analy_win_coeff;
716         filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + qmf_bank->no_channels;
717       }
718     }
719 
720     if (!low_pow_flag) {
721       ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i],
722                               qmf_bank, qmf_dec_tables_ptr, 0);
723     } else {
724       ixheaacd_dct3_32(
725           (WORD32 *)analysis_buffer, qmf_real[i], qmf_dec_tables_ptr->dct23_tw,
726           qmf_dec_tables_ptr->post_fft_tbl, qmf_dec_tables_ptr->w_16,
727           qmf_dec_tables_ptr->dig_rev_table4_16);
728     }
729   }
730 
731   qmf_bank->filter_pos = filter_1;
732   qmf_bank->core_samples_buffer = filter_states;
733 
734   if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD)
735 
736   {
737     qmf_bank->fp1_anal = fp1;
738     qmf_bank->fp2_anal = fp2;
739     qmf_bank->filter_2 = filter_2;
740   }
741 }
742 
ixheaacd_cplx_anal_qmffilt_32(const WORD32 * time_sample_buf,ia_sbr_scale_fact_struct * sbr_scale_factor,WORD32 ** qmf_real,WORD32 ** qmf_imag,ia_sbr_qmf_filter_bank_struct * qmf_bank,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr,WORD32 ch_fac,WORD32 ldsbr_present)743 VOID ixheaacd_cplx_anal_qmffilt_32(const WORD32 *time_sample_buf,
744                                    ia_sbr_scale_fact_struct *sbr_scale_factor,
745                                    WORD32 **qmf_real, WORD32 **qmf_imag,
746                                    ia_sbr_qmf_filter_bank_struct *qmf_bank,
747                                    ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
748                                    WORD32 ch_fac, WORD32 ldsbr_present) {
749   WORD32 i, k;
750   WORD32 num_time_slots = qmf_bank->num_time_slots;
751 
752   WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS];
753   WORD32 *filter_states = qmf_bank->core_samples_buffer_32;
754 
755   WORD32 *fp1, *fp2, *tmp;
756 
757   WORD32 *filter_1;
758   WORD32 *filter_2;
759   WORD32 *filt_ptr;
760   WORD32 start_slot = 2;
761 
762   if (ldsbr_present) {
763     qmf_bank->filter_pos_32 +=
764         (qmf_dec_tables_ptr->qmf_c_ldsbr_mps - qmf_bank->analy_win_coeff_32);
765     qmf_bank->analy_win_coeff_32 = qmf_dec_tables_ptr->qmf_c_ldsbr_mps;
766   } else {
767     qmf_bank->filter_pos_32 += (ixheaacd_ldmps_polyphase_filter_coeff_fix -
768                                 qmf_bank->analy_win_coeff_32);
769     qmf_bank->analy_win_coeff_32 =
770         (WORD32 *)ixheaacd_ldmps_polyphase_filter_coeff_fix;
771   }
772 
773   filter_1 = qmf_bank->filter_pos_32;
774   filter_2 = filter_1 + qmf_bank->no_channels;
775 
776   sbr_scale_factor->st_lb_scale = 0;
777   sbr_scale_factor->lb_scale = -10;
778 
779   sbr_scale_factor->lb_scale = -9;
780   if (qmf_bank->no_channels != 64) {
781     qmf_bank->cos_twiddle =
782         (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32;
783     qmf_bank->alt_sin_twiddle =
784         (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32;
785   } else {
786     qmf_bank->cos_twiddle =
787         (WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64;
788     qmf_bank->alt_sin_twiddle =
789         (WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64;
790   }
791   qmf_bank->t_cos =
792       (WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld;
793 
794   fp1 = qmf_bank->anal_filter_states_32;
795   fp2 = qmf_bank->anal_filter_states_32 + qmf_bank->no_channels;
796 
797   filter_2 = qmf_bank->filter_2_32;
798   fp1 = qmf_bank->fp1_anal_32;
799   fp2 = qmf_bank->fp2_anal_32;
800 
801   for (i = start_slot; i < num_time_slots + start_slot; i++) {
802     for (k = 0; k < qmf_bank->no_channels; k++)
803       filter_states[qmf_bank->no_channels - 1 - k] =
804           time_sample_buf[ch_fac * k];
805 
806     if (ldsbr_present) {
807       ixheaacd_sbr_qmfanal32_winadd_eld_32(fp1, fp2, filter_1, filter_2,
808                                            analysis_buffer);
809     } else {
810       ixheaacd_sbr_qmfanal32_winadd_eld_mps(fp1, fp2, filter_1, filter_2,
811                                             analysis_buffer);
812     }
813 
814     time_sample_buf += qmf_bank->no_channels * ch_fac;
815 
816     filter_states -= qmf_bank->no_channels;
817 
818     if (filter_states < qmf_bank->anal_filter_states_32) {
819       filter_states = qmf_bank->anal_filter_states_32 +
820                       ((qmf_bank->no_channels * 10) - qmf_bank->no_channels);
821     }
822 
823     tmp = fp1;
824     fp1 = fp2;
825     fp2 = tmp;
826 
827     filter_1 += qmf_bank->no_channels;
828     filter_2 += qmf_bank->no_channels;
829 
830     filt_ptr = filter_1;
831     filter_1 = filter_2;
832     filter_2 = filt_ptr;
833 
834     if (filter_2 >
835         (qmf_bank->analy_win_coeff_32 + (qmf_bank->no_channels * 10))) {
836       filter_1 = (WORD32 *)qmf_bank->analy_win_coeff_32;
837       filter_2 = (WORD32 *)qmf_bank->analy_win_coeff_32 + qmf_bank->no_channels;
838     }
839 
840     ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i], qmf_bank,
841                             qmf_dec_tables_ptr, 1);
842   }
843 
844   qmf_bank->filter_pos_32 = filter_1;
845   qmf_bank->core_samples_buffer_32 = filter_states;
846 
847   qmf_bank->fp1_anal_32 = fp1;
848   qmf_bank->fp2_anal_32 = fp2;
849   qmf_bank->filter_2_32 = filter_2;
850 }
ixheaacd_inv_modulation_lp(WORD32 * qmf_real,WORD16 * filter_states,ia_sbr_qmf_filter_bank_struct * syn_qmf,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)851 VOID ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states,
852                                 ia_sbr_qmf_filter_bank_struct *syn_qmf,
853                                 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
854   WORD32 L = syn_qmf->no_channels;
855   const WORD32 M = (L >> 1);
856   WORD32 *dct_in = qmf_real;
857   WORD32 time_out[2 * NO_SYNTHESIS_CHANNELS];
858 
859   WORD32 *ptime_out = &time_out[0];
860 
861   if (L == 64)
862     ixheaacd_dct2_64(dct_in, ptime_out, qmf_dec_tables_ptr, filter_states + M);
863   else
864     ixheaacd_dct2_32(dct_in, time_out, qmf_dec_tables_ptr, filter_states);
865 
866   filter_states[3 * M] = 0;
867 }
868 
ixheaacd_inv_emodulation(WORD32 * qmf_real,ia_sbr_qmf_filter_bank_struct * syn_qmf,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)869 VOID ixheaacd_inv_emodulation(WORD32 *qmf_real,
870                               ia_sbr_qmf_filter_bank_struct *syn_qmf,
871                               ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
872   if (syn_qmf->no_channels == 64)
873     ixheaacd_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->w_32,
874                          qmf_dec_tables_ptr->dig_rev_table2_32);
875   else
876     ixheaacd_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->w_16,
877                          qmf_dec_tables_ptr->dig_rev_table4_16);
878 }
879 
ixheaacd_esbr_radix4bfly(const WORD32 * w,WORD32 * x,WORD32 index1,WORD32 index)880 VOID ixheaacd_esbr_radix4bfly(const WORD32 *w, WORD32 *x, WORD32 index1,
881                               WORD32 index) {
882   int i;
883   WORD32 l1, l2, h2, fft_jmp;
884   WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0;
885   WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0;
886   WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1;
887   WORD32 x_h2_0, x_h2_1;
888   WORD32 si10, si20, si30, co10, co20, co30;
889 
890   WORD64 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6;
891   WORD64 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12;
892   const WORD32 *w_ptr = w;
893   WORD32 i1;
894 
895   h2 = index << 1;
896   l1 = index << 2;
897   l2 = (index << 2) + (index << 1);
898 
899   fft_jmp = 6 * (index);
900 
901   for (i1 = 0; i1 < index1; i1++) {
902     for (i = 0; i < index; i++) {
903       si10 = (*w_ptr++);
904       co10 = (*w_ptr++);
905       si20 = (*w_ptr++);
906       co20 = (*w_ptr++);
907       si30 = (*w_ptr++);
908       co30 = (*w_ptr++);
909 
910       x_0 = x[0];
911       x_h2_0 = x[h2];
912       x_l1_0 = x[l1];
913       x_l2_0 = x[l2];
914 
915       xh0_0 = ixheaac_add32_sat(x_0, x_l1_0);
916       xl0_0 = ixheaac_sub32_sat(x_0, x_l1_0);
917 
918       xh20_0 = ixheaac_add32_sat(x_h2_0, x_l2_0);
919       xl20_0 = ixheaac_sub32_sat(x_h2_0, x_l2_0);
920 
921       x[0] = ixheaac_add32_sat(xh0_0, xh20_0);
922       xt0_0 = ixheaac_sub32_sat(xh0_0, xh20_0);
923 
924       x_1 = x[1];
925       x_h2_1 = x[h2 + 1];
926       x_l1_1 = x[l1 + 1];
927       x_l2_1 = x[l2 + 1];
928 
929       xh1_0 = ixheaac_add32_sat(x_1, x_l1_1);
930       xl1_0 = ixheaac_sub32_sat(x_1, x_l1_1);
931 
932       xh21_0 = ixheaac_add32_sat(x_h2_1, x_l2_1);
933       xl21_0 = ixheaac_sub32_sat(x_h2_1, x_l2_1);
934 
935       x[1] = ixheaac_add32_sat(xh1_0, xh21_0);
936       yt0_0 = ixheaac_sub32_sat(xh1_0, xh21_0);
937 
938       xt1_0 = ixheaac_add32_sat(xl0_0, xl21_0);
939       xt2_0 = ixheaac_sub32_sat(xl0_0, xl21_0);
940 
941       yt2_0 = ixheaac_add32_sat(xl1_0, xl20_0);
942       yt1_0 = ixheaac_sub32_sat(xl1_0, xl20_0);
943 
944       mul_11 = ixheaac_mult64(xt2_0, co30);
945       mul_3 = ixheaac_mult64(yt2_0, si30);
946       x[l2] = (WORD32)((mul_3 + mul_11) >> 32) << RADIXSHIFT;
947 
948       mul_5 = ixheaac_mult64(xt2_0, si30);
949       mul_9 = ixheaac_mult64(yt2_0, co30);
950       x[l2 + 1] = (WORD32)((mul_9 - mul_5) >> 32) << RADIXSHIFT;
951 
952       mul_12 = ixheaac_mult64(xt0_0, co20);
953       mul_2 = ixheaac_mult64(yt0_0, si20);
954       x[l1] = (WORD32)((mul_2 + mul_12) >> 32) << RADIXSHIFT;
955 
956       mul_6 = ixheaac_mult64(xt0_0, si20);
957       mul_8 = ixheaac_mult64(yt0_0, co20);
958       x[l1 + 1] = (WORD32)((mul_8 - mul_6) >> 32) << RADIXSHIFT;
959 
960       mul_4 = ixheaac_mult64(xt1_0, co10);
961       mul_1 = ixheaac_mult64(yt1_0, si10);
962       x[h2] = (WORD32)((mul_1 + mul_4) >> 32) << RADIXSHIFT;
963 
964       mul_10 = ixheaac_mult64(xt1_0, si10);
965       mul_7 = ixheaac_mult64(yt1_0, co10);
966       x[h2 + 1] = (WORD32)((mul_7 - mul_10) >> 32) << RADIXSHIFT;
967 
968       x += 2;
969     }
970     x += fft_jmp;
971     w_ptr = w_ptr - fft_jmp;
972   }
973 }
974 
ixheaacd_esbr_postradixcompute2(WORD32 * ptr_y,WORD32 * ptr_x,const WORD32 * pdig_rev_tbl,WORD32 npoints)975 VOID ixheaacd_esbr_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x,
976                                      const WORD32 *pdig_rev_tbl,
977                                      WORD32 npoints) {
978   WORD32 i, k;
979   WORD32 h2;
980   WORD32 x_0, x_1, x_2, x_3;
981   WORD32 x_4, x_5, x_6, x_7;
982   WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f;
983   WORD32 n00, n10, n20, n30, n01, n11, n21, n31;
984   WORD32 n02, n12, n22, n32, n03, n13, n23, n33;
985   WORD32 *x2, *x0;
986   WORD32 *y0, *y1, *y2, *y3;
987 
988   y0 = ptr_y;
989   y2 = ptr_y + (WORD32)npoints;
990   x0 = ptr_x;
991   x2 = ptr_x + (WORD32)(npoints >> 1);
992 
993   y1 = y0 + (WORD32)(npoints >> 2);
994   y3 = y2 + (WORD32)(npoints >> 2);
995 
996   for (k = 0; k < 2; k++) {
997     for (i = 0; i<npoints>> 1; i += 8) {
998       h2 = *pdig_rev_tbl++ >> 2;
999 
1000       x_0 = *x0++;
1001       x_1 = *x0++;
1002       x_2 = *x0++;
1003       x_3 = *x0++;
1004       x_4 = *x0++;
1005       x_5 = *x0++;
1006       x_6 = *x0++;
1007       x_7 = *x0++;
1008 
1009       n00 = ixheaac_add32_sat(x_0, x_2);
1010       n01 = ixheaac_add32_sat(x_1, x_3);
1011       n20 = ixheaac_sub32_sat(x_0, x_2);
1012       n21 = ixheaac_sub32_sat(x_1, x_3);
1013       n10 = ixheaac_add32_sat(x_4, x_6);
1014       n11 = ixheaac_add32_sat(x_5, x_7);
1015       n30 = ixheaac_sub32_sat(x_4, x_6);
1016       n31 = ixheaac_sub32_sat(x_5, x_7);
1017 
1018       y0[h2] = n00;
1019       y0[h2 + 1] = n01;
1020       y1[h2] = n10;
1021       y1[h2 + 1] = n11;
1022       y2[h2] = n20;
1023       y2[h2 + 1] = n21;
1024       y3[h2] = n30;
1025       y3[h2 + 1] = n31;
1026 
1027       x_8 = *x2++;
1028       x_9 = *x2++;
1029       x_a = *x2++;
1030       x_b = *x2++;
1031       x_c = *x2++;
1032       x_d = *x2++;
1033       x_e = *x2++;
1034       x_f = *x2++;
1035 
1036       n02 = ixheaac_add32_sat(x_8, x_a);
1037       n03 = ixheaac_add32_sat(x_9, x_b);
1038       n22 = ixheaac_sub32_sat(x_8, x_a);
1039       n23 = ixheaac_sub32_sat(x_9, x_b);
1040       n12 = ixheaac_add32_sat(x_c, x_e);
1041       n13 = ixheaac_add32_sat(x_d, x_f);
1042       n32 = ixheaac_sub32_sat(x_c, x_e);
1043       n33 = ixheaac_sub32_sat(x_d, x_f);
1044 
1045       y0[h2 + 2] = n02;
1046       y0[h2 + 3] = n03;
1047       y1[h2 + 2] = n12;
1048       y1[h2 + 3] = n13;
1049       y2[h2 + 2] = n22;
1050       y2[h2 + 3] = n23;
1051       y3[h2 + 2] = n32;
1052       y3[h2 + 3] = n33;
1053     }
1054     x0 += (WORD32)npoints >> 1;
1055     x2 += (WORD32)npoints >> 1;
1056   }
1057 }
1058 
ixheaacd_esbr_postradixcompute4(WORD32 * ptr_y,WORD32 * ptr_x,const WORD32 * p_dig_rev_tbl,WORD32 npoints)1059 VOID ixheaacd_esbr_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x,
1060                                      const WORD32 *p_dig_rev_tbl,
1061                                      WORD32 npoints) {
1062   WORD32 i, k;
1063   WORD32 h2;
1064   WORD32 xh0_0, xh1_0, xl0_0, xl1_0;
1065   WORD32 xh0_1, xh1_1, xl0_1, xl1_1;
1066   WORD32 x_0, x_1, x_2, x_3;
1067   WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3;
1068   WORD32 x_4, x_5, x_6, x_7;
1069   WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f;
1070   WORD32 n00, n10, n20, n30, n01, n11, n21, n31;
1071   WORD32 n02, n12, n22, n32, n03, n13, n23, n33;
1072   WORD32 *x2, *x0;
1073   WORD32 *y0, *y1, *y2, *y3;
1074 
1075   y0 = ptr_y;
1076   y2 = ptr_y + (WORD32)npoints;
1077   x0 = ptr_x;
1078   x2 = ptr_x + (WORD32)(npoints >> 1);
1079 
1080   y1 = y0 + (WORD32)(npoints >> 1);
1081   y3 = y2 + (WORD32)(npoints >> 1);
1082 
1083   for (k = 0; k < 2; k++) {
1084     for (i = 0; i<npoints>> 1; i += 8) {
1085       h2 = *p_dig_rev_tbl++ >> 2;
1086       x_0 = *x0++;
1087       x_1 = *x0++;
1088       x_2 = *x0++;
1089       x_3 = *x0++;
1090       x_4 = *x0++;
1091       x_5 = *x0++;
1092       x_6 = *x0++;
1093       x_7 = *x0++;
1094 
1095       xh0_0 = ixheaac_add32_sat(x_0, x_4);
1096       xh1_0 = ixheaac_add32_sat(x_1, x_5);
1097       xl0_0 = ixheaac_sub32_sat(x_0, x_4);
1098       xl1_0 = ixheaac_sub32_sat(x_1, x_5);
1099       xh0_1 = ixheaac_add32_sat(x_2, x_6);
1100       xh1_1 = ixheaac_add32_sat(x_3, x_7);
1101       xl0_1 = ixheaac_sub32_sat(x_2, x_6);
1102       xl1_1 = ixheaac_sub32_sat(x_3, x_7);
1103 
1104       n00 = ixheaac_add32_sat(xh0_0, xh0_1);
1105       n01 = ixheaac_add32_sat(xh1_0, xh1_1);
1106       n10 = ixheaac_add32_sat(xl0_0, xl1_1);
1107       n11 = ixheaac_sub32_sat(xl1_0, xl0_1);
1108       n20 = ixheaac_sub32_sat(xh0_0, xh0_1);
1109       n21 = ixheaac_sub32_sat(xh1_0, xh1_1);
1110       n30 = ixheaac_sub32_sat(xl0_0, xl1_1);
1111       n31 = ixheaac_add32_sat(xl1_0, xl0_1);
1112 
1113       y0[h2] = n00;
1114       y0[h2 + 1] = n01;
1115       y1[h2] = n10;
1116       y1[h2 + 1] = n11;
1117       y2[h2] = n20;
1118       y2[h2 + 1] = n21;
1119       y3[h2] = n30;
1120       y3[h2 + 1] = n31;
1121 
1122       x_8 = *x2++;
1123       x_9 = *x2++;
1124       x_a = *x2++;
1125       x_b = *x2++;
1126       x_c = *x2++;
1127       x_d = *x2++;
1128       x_e = *x2++;
1129       x_f = *x2++;
1130 
1131       xh0_2 = ixheaac_add32_sat(x_8, x_c);
1132       xh1_2 = ixheaac_add32_sat(x_9, x_d);
1133       xl0_2 = ixheaac_sub32_sat(x_8, x_c);
1134       xl1_2 = ixheaac_sub32_sat(x_9, x_d);
1135       xh0_3 = ixheaac_add32_sat(x_a, x_e);
1136       xh1_3 = ixheaac_add32_sat(x_b, x_f);
1137       xl0_3 = ixheaac_sub32_sat(x_a, x_e);
1138       xl1_3 = ixheaac_sub32_sat(x_b, x_f);
1139 
1140       n02 = ixheaac_add32_sat(xh0_2, xh0_3);
1141       n03 = ixheaac_add32_sat(xh1_2, xh1_3);
1142       n12 = ixheaac_add32_sat(xl0_2, xl1_3);
1143       n13 = ixheaac_sub32_sat(xl1_2, xl0_3);
1144       n22 = ixheaac_sub32_sat(xh0_2, xh0_3);
1145       n23 = ixheaac_sub32_sat(xh1_2, xh1_3);
1146       n32 = ixheaac_sub32_sat(xl0_2, xl1_3);
1147       n33 = ixheaac_add32_sat(xl1_2, xl0_3);
1148 
1149       y0[h2 + 2] = n02;
1150       y0[h2 + 3] = n03;
1151       y1[h2 + 2] = n12;
1152       y1[h2 + 3] = n13;
1153       y2[h2 + 2] = n22;
1154       y2[h2 + 3] = n23;
1155       y3[h2 + 2] = n32;
1156       y3[h2 + 3] = n33;
1157     }
1158     x0 += (WORD32)npoints >> 1;
1159     x2 += (WORD32)npoints >> 1;
1160   }
1161 }
1162 
ixheaacd_esbr_cos_sin_mod(WORD32 * subband,ia_sbr_qmf_filter_bank_struct * qmf_bank,WORD32 * p_twiddle,WORD32 * p_dig_rev_tbl)1163 VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband,
1164                                ia_sbr_qmf_filter_bank_struct *qmf_bank,
1165                                WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl) {
1166   WORD32 z;
1167   WORD32 temp[128];
1168   WORD32 scaleshift = 0;
1169 
1170   WORD32 re2, re3;
1171   WORD32 wim, wre;
1172 
1173   WORD32 i, M_2;
1174   WORD32 M = ixheaac_shr32(qmf_bank->no_channels, 1);
1175 
1176   const WORD32 *p_sin;
1177   const WORD32 *p_sin_cos;
1178 
1179   WORD32 subband_tmp[128];
1180   WORD32 re;
1181   WORD32 im;
1182   WORD32 *psubband, *psubband1;
1183   WORD32 *psubband_t, *psubband1_t;
1184   WORD32 *psubband2, *psubband12;
1185   WORD32 *psubband_t2, *psubband1_t2;
1186 
1187   M_2 = ixheaac_shr32(M, 1);
1188 
1189   p_sin_cos = qmf_bank->esbr_cos_twiddle;
1190 
1191   psubband = &subband[0];
1192   psubband1 = &subband[2 * M - 1];
1193   psubband_t = subband_tmp;
1194   psubband1_t = &subband_tmp[2 * M - 1];
1195 
1196   psubband2 = &subband[64];
1197   psubband12 = &subband[2 * M - 1 + 64];
1198   psubband_t2 = &subband_tmp[64];
1199   psubband1_t2 = &subband_tmp[2 * M - 1 + 64];
1200 
1201   for (i = (M_2 >> 1) - 1; i >= 0; i--) {
1202     re = *psubband++;
1203     im = *psubband1--;
1204 
1205     wim = *p_sin_cos++;
1206     wre = *p_sin_cos++;
1207 
1208     *psubband_t++ = (WORD32)(
1209         (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1210         32);
1211     *psubband_t++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1212                                                  ixheaac_mult64(re, wim))) >>
1213                              32);
1214 
1215     re = *psubband2++;
1216     im = *psubband12--;
1217 
1218     *psubband_t2++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wim),
1219                                                   ixheaac_mult64(re, wre))) >>
1220                               32);
1221     *psubband_t2++ = (WORD32)(
1222         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1223         32);
1224 
1225     re = *psubband1--;
1226     im = *psubband++;
1227 
1228     wim = *p_sin_cos++;
1229     wre = *p_sin_cos++;
1230 
1231     *psubband1_t-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1232                                                   ixheaac_mult64(re, wim))) >>
1233                               32);
1234     *psubband1_t-- = (WORD32)(
1235         (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1236         32);
1237 
1238     re = *psubband12--;
1239     im = *psubband2++;
1240 
1241     *psubband1_t2-- = (WORD32)(
1242         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1243         32);
1244     *psubband1_t2-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wim),
1245                                                    ixheaac_mult64(re, wre))) >>
1246                                32);
1247 
1248     re = *psubband++;
1249     im = *psubband1--;
1250 
1251     wim = *p_sin_cos++;
1252     wre = *p_sin_cos++;
1253 
1254     *psubband_t++ = (WORD32)(
1255         (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1256         32);
1257     *psubband_t++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1258                                                  ixheaac_mult64(re, wim))) >>
1259                              32);
1260 
1261     re = *psubband2++;
1262     im = *psubband12--;
1263 
1264     *psubband_t2++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wim),
1265                                                   ixheaac_mult64(re, wre))) >>
1266                               32);
1267     *psubband_t2++ = (WORD32)(
1268         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1269         32);
1270 
1271     re = *psubband1--;
1272     im = *psubband++;
1273 
1274     wim = *p_sin_cos++;
1275     wre = *p_sin_cos++;
1276 
1277     *psubband1_t-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1278                                                   ixheaac_mult64(re, wim))) >>
1279                               32);
1280     *psubband1_t-- = (WORD32)(
1281         (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1282         32);
1283 
1284     re = *psubband12--;
1285     im = *psubband2++;
1286 
1287     *psubband1_t2-- = (WORD32)(
1288         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1289         32);
1290     *psubband1_t2-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wim),
1291                                                    ixheaac_mult64(re, wre))) >>
1292                                32);
1293   }
1294 
1295   if (M == 32) {
1296     ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 8);
1297     ixheaacd_esbr_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2);
1298     ixheaacd_esbr_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32);
1299 
1300     ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8);
1301     ixheaacd_esbr_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2);
1302     ixheaacd_esbr_postradixcompute2(&subband[64], &subband_tmp[64],
1303                                     p_dig_rev_tbl, 32);
1304 
1305   }
1306 
1307   else if (M == 16) {
1308     ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 4);
1309     ixheaacd_esbr_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16);
1310 
1311     ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4);
1312     ixheaacd_esbr_postradixcompute4(&subband[64], &subband_tmp[64],
1313                                     p_dig_rev_tbl, 16);
1314 
1315   }
1316 
1317   else if (M == 12) {
1318     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1319       temp[z] = subband_tmp[2 * z];
1320       temp[12 + z] = subband_tmp[2 * z + 1];
1321     }
1322 
1323     ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift);
1324 
1325     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1326       subband[2 * z] = temp[z];
1327       subband[2 * z + 1] = temp[z + 12];
1328     }
1329     scaleshift = 0;
1330     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1331       temp[z] = subband_tmp[64 + 2 * z];
1332       temp[12 + z] = subband_tmp[64 + 2 * z + 1];
1333     }
1334 
1335     ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift);
1336 
1337     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1338       subband[64 + 2 * z] = temp[z];
1339       subband[64 + 2 * z + 1] = temp[z + 12];
1340     }
1341 
1342   }
1343 
1344   else {
1345     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1346       temp[z] = subband_tmp[2 * z];
1347       temp[8 + z] = subband_tmp[2 * z + 1];
1348     }
1349 
1350     (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift);
1351 
1352     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1353       subband[2 * z] = temp[z] << scaleshift;
1354       subband[2 * z + 1] = temp[z + 8] << scaleshift;
1355     }
1356     scaleshift = 0;
1357     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1358       temp[z] = subband_tmp[64 + 2 * z];
1359       temp[8 + z] = subband_tmp[64 + 2 * z + 1];
1360     }
1361 
1362     (*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift);
1363 
1364     for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
1365       subband[64 + 2 * z] = temp[z] << scaleshift;
1366       subband[64 + 2 * z + 1] = temp[8 + z] << scaleshift;
1367     }
1368   }
1369 
1370   psubband = &subband[0];
1371   psubband1 = &subband[2 * M - 1];
1372 
1373   re = *psubband1;
1374 
1375   *psubband = *psubband >> 1;
1376   psubband++;
1377   *psubband1 = ixheaac_negate32_sat(*psubband >> 1);
1378   psubband1--;
1379 
1380   p_sin = qmf_bank->esbr_alt_sin_twiddle;
1381 
1382   wim = *p_sin++;
1383   wre = *p_sin++;
1384 
1385   im = *psubband1;
1386 
1387   *psubband1-- = (WORD32)(
1388       (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1389       32);
1390   *psubband++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1391                                              ixheaac_mult64(re, wim))) >>
1392                          32);
1393 
1394   psubband2 = &subband[64];
1395   psubband12 = &subband[2 * M - 1 + 64];
1396 
1397   re = *psubband12;
1398 
1399   *psubband12-- = ixheaac_negate32_sat(*psubband2 >> 1);
1400 
1401   *psubband2 = psubband2[1] >> 1;
1402 
1403   psubband2++;
1404 
1405   im = *psubband12;
1406 
1407   *psubband2++ = ixheaac_negate32_sat((WORD32)(
1408       (ixheaac_add64(ixheaac_mult64(re, wre), ixheaac_mult64(im, wim))) >>
1409       32));
1410   *psubband12-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(re, wim),
1411                                                ixheaac_mult64(im, wre))) >>
1412                            32);
1413 
1414   for (i = (M_2 - 2); i >= 0; i--) {
1415     im = psubband[0];
1416 
1417     re = psubband[1];
1418 
1419     re2 = *psubband1;
1420 
1421     *psubband++ = (WORD32)(
1422         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1423         32);
1424     *psubband1-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wim),
1425                                                 ixheaac_mult64(re, wre))) >>
1426                             32);
1427 
1428     im = psubband2[0];
1429 
1430     re = psubband2[1];
1431 
1432     re3 = *psubband12;
1433 
1434     *psubband12-- = ixheaac_negate32_sat((WORD32)(
1435         (ixheaac_add64(ixheaac_mult64(re, wim), ixheaac_mult64(im, wre))) >>
1436         32));
1437     *psubband2++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(re, wre),
1438                                                 ixheaac_mult64(im, wim))) >>
1439                             32);
1440 
1441     wim = *p_sin++;
1442     wre = *p_sin++;
1443     im = psubband1[0];
1444 
1445     *psubband1-- = (WORD32)(
1446         (ixheaac_add64(ixheaac_mult64(re2, wre), ixheaac_mult64(im, wim))) >>
1447         32);
1448     *psubband++ = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, wre),
1449                                                ixheaac_mult64(re2, wim))) >>
1450                            32);
1451 
1452     im = psubband12[0];
1453 
1454     *psubband2++ = ixheaac_negate32_sat((WORD32)(
1455         (ixheaac_add64(ixheaac_mult64(re3, wre), ixheaac_mult64(im, wim))) >>
1456         32));
1457     *psubband12-- = (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(re3, wim),
1458                                                  ixheaac_mult64(im, wre))) >>
1459                              32);
1460   }
1461 }
1462 
ixheaacd_esbr_fwd_modulation(const WORD32 * time_sample_buf,WORD32 * real_subband,WORD32 * imag_subband,ia_sbr_qmf_filter_bank_struct * qmf_bank,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)1463 VOID ixheaacd_esbr_fwd_modulation(
1464     const WORD32 *time_sample_buf, WORD32 *real_subband, WORD32 *imag_subband,
1465     ia_sbr_qmf_filter_bank_struct *qmf_bank,
1466     ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
1467   WORD32 i;
1468   const WORD32 *time_sample_buf1 =
1469       &time_sample_buf[2 * qmf_bank->no_channels - 1];
1470   WORD32 temp1, temp2;
1471   WORD32 *t_real_subband = real_subband;
1472   WORD32 *t_imag_subband = imag_subband;
1473   const WORD32 *tcos;
1474 
1475   for (i = qmf_bank->no_channels - 1; i >= 0; i--) {
1476     temp1 = ixheaac_shr32(*time_sample_buf++, HQ_SHIFT_64);
1477     temp2 = ixheaac_shr32(*time_sample_buf1--, HQ_SHIFT_64);
1478 
1479     *t_real_subband++ = ixheaac_sub32_sat(temp1, temp2);
1480 
1481     *t_imag_subband++ = ixheaac_add32_sat(temp1, temp2);
1482   }
1483 
1484   ixheaacd_esbr_cos_sin_mod(real_subband, qmf_bank,
1485                             qmf_dec_tables_ptr->esbr_w_16,
1486                             qmf_dec_tables_ptr->dig_rev_table4_16);
1487 
1488   tcos = qmf_bank->esbr_t_cos;
1489 
1490   for (i = (qmf_bank->usb - qmf_bank->lsb - 1); i >= 0; i--) {
1491     WORD32 cosh, sinh;
1492     WORD32 re, im;
1493 
1494     re = *real_subband;
1495     im = *imag_subband;
1496     cosh = *tcos++;
1497     sinh = *tcos++;
1498     *real_subband++ = (WORD32)((ixheaac_add64(ixheaac_mult64(re, cosh),
1499                                                ixheaac_mult64(im, sinh))) >>
1500                                31);
1501     *imag_subband++ =
1502         (WORD32)((ixheaac_sub64_sat(ixheaac_mult64(im, cosh),
1503                                      ixheaac_mult64(re, sinh))) >>
1504                  31);
1505   }
1506 }
1507 
ixheaacd_sbr_qmfsyn64_winadd(WORD16 * tmp1,WORD16 * tmp2,WORD16 * inp1,WORD16 * sample_buffer,FLAG shift,WORD32 ch_fac)1508 VOID ixheaacd_sbr_qmfsyn64_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1,
1509                                   WORD16 *sample_buffer, FLAG shift,
1510                                   WORD32 ch_fac) {
1511   WORD32 k;
1512   WORD32 rounding_fac = 0x8000;
1513   rounding_fac = rounding_fac >> shift;
1514 
1515   for (k = 0; k < 64; k++) {
1516     WORD32 syn_out = rounding_fac;
1517 
1518     syn_out = ixheaac_add32_sat(
1519         syn_out, ixheaac_mult16x16in32(tmp1[0 + k], inp1[k + 0]));
1520     syn_out = ixheaac_add32_sat(
1521         syn_out, ixheaac_mult16x16in32(tmp1[256 + k], inp1[k + 128]));
1522     syn_out = ixheaac_add32_sat(
1523         syn_out, ixheaac_mult16x16in32(tmp1[512 + k], inp1[k + 256]));
1524     syn_out = ixheaac_add32_sat(
1525         syn_out, ixheaac_mult16x16in32(tmp1[768 + k], inp1[k + 384]));
1526     syn_out = ixheaac_add32_sat(
1527         syn_out, ixheaac_mult16x16in32(tmp1[1024 + k], inp1[k + 512]));
1528 
1529     syn_out = ixheaac_add32_sat(
1530         syn_out, ixheaac_mult16x16in32(tmp2[128 + k], inp1[k + 64]));
1531     syn_out = ixheaac_add32_sat(
1532         syn_out, ixheaac_mult16x16in32(tmp2[384 + k], inp1[k + 192]));
1533     syn_out = ixheaac_add32_sat(
1534         syn_out, ixheaac_mult16x16in32(tmp2[640 + k], inp1[k + 320]));
1535     syn_out = ixheaac_add32_sat(
1536         syn_out, ixheaac_mult16x16in32(tmp2[896 + k], inp1[k + 448]));
1537     syn_out = ixheaac_add32_sat(
1538         syn_out, ixheaac_mult16x16in32(tmp2[1152 + k], inp1[k + 576]));
1539 
1540     sample_buffer[ch_fac * k] = (ixheaac_shl32_sat(syn_out, shift) >> 16);
1541   }
1542 }
1543 
ixheaacd_esbr_qmfsyn64_winadd(WORD32 * tmp1,WORD32 * tmp2,WORD32 * inp1,WORD32 * sample_buffer,WORD32 ch_fac)1544 VOID ixheaacd_esbr_qmfsyn64_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *inp1,
1545                                    WORD32 *sample_buffer, WORD32 ch_fac) {
1546   WORD32 k;
1547 
1548   for (k = 0; k < 64; k++) {
1549     WORD64 syn_out = 0;
1550 
1551     syn_out =
1552         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[0 + k], inp1[k + 0]));
1553     syn_out =
1554         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[256 + k], inp1[k + 128]));
1555     syn_out =
1556         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[512 + k], inp1[k + 256]));
1557     syn_out =
1558         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[768 + k], inp1[k + 384]));
1559     syn_out =
1560         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[1024 + k], inp1[k + 512]));
1561 
1562     syn_out =
1563         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[128 + k], inp1[k + 64]));
1564     syn_out =
1565         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[384 + k], inp1[k + 192]));
1566     syn_out =
1567         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[640 + k], inp1[k + 320]));
1568     syn_out =
1569         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[896 + k], inp1[k + 448]));
1570     syn_out =
1571         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[1152 + k], inp1[k + 576]));
1572 
1573     sample_buffer[ch_fac * k] = (WORD32)(syn_out >> 31);
1574   }
1575 }
1576 
ixheaacd_esbr_qmfsyn32_winadd(WORD32 * tmp1,WORD32 * tmp2,WORD32 * inp1,WORD32 * sample_buffer,WORD32 ch_fac)1577 VOID ixheaacd_esbr_qmfsyn32_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *inp1,
1578                                    WORD32 *sample_buffer, WORD32 ch_fac) {
1579   WORD32 k;
1580 
1581   for (k = 0; k < 32; k++) {
1582     WORD64 syn_out = 0;
1583 
1584     syn_out =
1585         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[0 + k], inp1[2 * (k + 0)]));
1586     syn_out =
1587         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[128 + k], inp1[2 * (k + 64)]));
1588     syn_out =
1589         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[256 + k], inp1[2 * (k + 128)]));
1590     syn_out =
1591         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[384 + k], inp1[2 * (k + 192)]));
1592     syn_out =
1593         ixheaac_add64(syn_out, ixheaac_mult64(tmp1[512 + k], inp1[2 * (k + 256)]));
1594 
1595     syn_out =
1596         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[64 + k], inp1[2 * (k + 32)]));
1597     syn_out =
1598         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[192 + k], inp1[2 * (k + 96)]));
1599     syn_out =
1600         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[320 + k], inp1[2 * (k + 160)]));
1601     syn_out =
1602         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[448 + k], inp1[2 * (k + 224)]));
1603     syn_out =
1604         ixheaac_add64(syn_out, ixheaac_mult64(tmp2[576 + k], inp1[2 * (k + 288)]));
1605 
1606     sample_buffer[ch_fac * k] = (WORD32)(syn_out >> 31);
1607   }
1608 }
1609 
ixheaacd_shiftrountine(WORD32 * qmf_real,WORD32 * qmf_imag,WORD32 len,WORD32 common_shift)1610 VOID ixheaacd_shiftrountine(WORD32 *qmf_real, WORD32 *qmf_imag, WORD32 len,
1611                             WORD32 common_shift) {
1612   WORD32 treal, timag;
1613   WORD32 j;
1614 
1615   if (common_shift < 0) {
1616     WORD32 cshift = -common_shift;
1617     cshift = ixheaac_min32(cshift, 31);
1618     for (j = len - 1; j >= 0; j--) {
1619       treal = *qmf_real;
1620       timag = *qmf_imag;
1621 
1622       treal = (ixheaac_shr32(treal, cshift));
1623       timag = (ixheaac_shr32(timag, cshift));
1624 
1625       *qmf_real++ = treal;
1626       *qmf_imag++ = timag;
1627     }
1628   } else {
1629     for (j = len - 1; j >= 0; j--) {
1630       treal = (ixheaac_shl32_sat(*qmf_real, common_shift));
1631       timag = (ixheaac_shl32_sat(*qmf_imag, common_shift));
1632       *qmf_real++ = treal;
1633       *qmf_imag++ = timag;
1634     }
1635   }
1636 }
1637 
ixheaacd_shiftrountine_with_rnd(WORD32 * qmf_real,WORD32 * qmf_imag,WORD16 * filter_states,WORD32 len,WORD32 shift)1638 VOID ixheaacd_shiftrountine_with_rnd(WORD32 *qmf_real, WORD32 *qmf_imag,
1639                                      WORD16 *filter_states, WORD32 len,
1640                                      WORD32 shift) {
1641   WORD16 *filter_states_rev = filter_states + len;
1642   WORD32 treal, timag;
1643   WORD32 j;
1644 
1645   for (j = (len - 1); j >= 0; j -= 2) {
1646     WORD32 r1, r2, i1, i2;
1647     i2 = qmf_imag[j];
1648     r2 = qmf_real[j];
1649 
1650     r1 = *qmf_real++;
1651     i1 = *qmf_imag++;
1652 
1653     timag = ixheaac_add32_sat(i1, r1);
1654     timag = (ixheaac_shl32_sat(timag, shift));
1655     filter_states_rev[j] = ixheaac_round16(timag);
1656 
1657     treal = ixheaac_sub32_sat(i2, r2);
1658     treal = (ixheaac_shl32_sat(treal, shift));
1659     filter_states[j] = ixheaac_round16(treal);
1660 
1661     treal = ixheaac_sub32_sat(i1, r1);
1662     treal = (ixheaac_shl32_sat(treal, shift));
1663     *filter_states++ = ixheaac_round16(treal);
1664 
1665     timag = ixheaac_add32_sat(i2, r2);
1666     ;
1667     timag = (ixheaac_shl32_sat(timag, shift));
1668     *filter_states_rev++ = ixheaac_round16(timag);
1669   }
1670 }
1671 
ixheaacd_shiftrountine_with_rnd_eld(WORD32 * qmf_real,WORD32 * qmf_imag,WORD16 * filter_states,WORD32 len,WORD32 shift)1672 VOID ixheaacd_shiftrountine_with_rnd_eld(WORD32 *qmf_real, WORD32 *qmf_imag,
1673                                          WORD16 *filter_states, WORD32 len,
1674                                          WORD32 shift) {
1675   WORD16 *filter_states_rev = filter_states + len;
1676   WORD32 treal, timag;
1677   WORD32 j;
1678 
1679   for (j = (len - 1); j >= 0; j -= 2) {
1680     WORD32 r1, r2, i1, i2;
1681     i2 = qmf_imag[j];
1682     r2 = qmf_real[j];
1683     r1 = *qmf_real++;
1684     i1 = *qmf_imag++;
1685 
1686     timag = ixheaac_negate32_sat(ixheaac_add32_sat(i1, r1));
1687     timag = (ixheaac_shl32_sat(timag, shift));
1688     filter_states_rev[j] = ixheaac_round16(timag);
1689 
1690     treal = ixheaac_sub32_sat(r2, i2);
1691     treal = (ixheaac_shl32_sat(treal, shift));
1692     filter_states[j] = ixheaac_round16(treal);
1693 
1694     treal = ixheaac_sub32_sat(r1, i1);
1695     treal = (ixheaac_shl32_sat(treal, shift));
1696     *filter_states++ = ixheaac_round16(treal);
1697 
1698     timag = ixheaac_negate32_sat(ixheaac_add32_sat(i2, r2));
1699     timag = (ixheaac_shl32_sat(timag, shift));
1700     *filter_states_rev++ = ixheaac_round16(timag);
1701   }
1702 }
1703 
ixheaacd_shiftrountine_with_rnd_hq(WORD32 * qmf_real,WORD32 * qmf_imag,WORD32 * filter_states,WORD32 len,WORD32 shift)1704 VOID ixheaacd_shiftrountine_with_rnd_hq(WORD32 *qmf_real, WORD32 *qmf_imag,
1705                                         WORD32 *filter_states, WORD32 len,
1706                                         WORD32 shift) {
1707   WORD32 *filter_states_rev = filter_states + len;
1708   WORD32 treal, timag;
1709   WORD32 j;
1710 
1711   for (j = (len - 1); j >= 0; j -= 2) {
1712     WORD32 r1, r2, i1, i2;
1713     i2 = qmf_imag[j];
1714     r2 = qmf_real[j];
1715     r1 = *qmf_real++;
1716     i1 = *qmf_imag++;
1717 
1718     timag = ixheaac_add32_sat(i1, r1);
1719     timag = (ixheaac_shl32_sat(timag, shift));
1720     filter_states_rev[j] = timag;
1721 
1722     treal = ixheaac_sub32_sat(i2, r2);
1723     treal = (ixheaac_shl32_sat(treal, shift));
1724     filter_states[j] = treal;
1725 
1726     treal = ixheaac_sub32_sat(i1, r1);
1727     treal = (ixheaac_shl32_sat(treal, shift));
1728     *filter_states++ = treal;
1729 
1730     timag = ixheaac_add32_sat(i2, r2);
1731     timag = (ixheaac_shl32_sat(timag, shift));
1732     *filter_states_rev++ = timag;
1733   }
1734 }
1735 
ixheaacd_radix4bfly(const WORD16 * w,WORD32 * x,WORD32 index1,WORD32 index)1736 VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 index1,
1737                          WORD32 index) {
1738   int i;
1739   WORD32 l1, l2, h2, fft_jmp;
1740   WORD32 xt0_0, yt0_0, xt1_0, yt1_0, xt2_0, yt2_0;
1741   WORD32 xh0_0, xh1_0, xh20_0, xh21_0, xl0_0, xl1_0, xl20_0, xl21_0;
1742   WORD32 x_0, x_1, x_l1_0, x_l1_1, x_l2_0, x_l2_1;
1743   WORD32 x_h2_0, x_h2_1;
1744   WORD16 si10, si20, si30, co10, co20, co30;
1745 
1746   WORD32 mul_1, mul_2, mul_3, mul_4, mul_5, mul_6;
1747   WORD32 mul_7, mul_8, mul_9, mul_10, mul_11, mul_12;
1748   const WORD16 *w_ptr = w;
1749   WORD32 i1;
1750 
1751   h2 = index << 1;
1752   l1 = index << 2;
1753   l2 = (index << 2) + (index << 1);
1754 
1755   fft_jmp = 6 * (index);
1756 
1757   for (i1 = 0; i1 < index1; i1++) {
1758     for (i = 0; i < index; i++) {
1759       si10 = (*w_ptr++);
1760       co10 = (*w_ptr++);
1761       si20 = (*w_ptr++);
1762       co20 = (*w_ptr++);
1763       si30 = (*w_ptr++);
1764       co30 = (*w_ptr++);
1765 
1766       x_0 = x[0];
1767       x_h2_0 = x[h2];
1768       x_l1_0 = x[l1];
1769       x_l2_0 = x[l2];
1770 
1771       xh0_0 = ixheaac_add32_sat(x_0, x_l1_0);
1772       xl0_0 = ixheaac_sub32_sat(x_0, x_l1_0);
1773 
1774       xh20_0 = ixheaac_add32_sat(x_h2_0, x_l2_0);
1775       xl20_0 = ixheaac_sub32_sat(x_h2_0, x_l2_0);
1776 
1777       x[0] = ixheaac_add32_sat(xh0_0, xh20_0);
1778       xt0_0 = ixheaac_sub32_sat(xh0_0, xh20_0);
1779 
1780       x_1 = x[1];
1781       x_h2_1 = x[h2 + 1];
1782       x_l1_1 = x[l1 + 1];
1783       x_l2_1 = x[l2 + 1];
1784 
1785       xh1_0 = ixheaac_add32_sat(x_1, x_l1_1);
1786       xl1_0 = ixheaac_sub32_sat(x_1, x_l1_1);
1787 
1788       xh21_0 = ixheaac_add32_sat(x_h2_1, x_l2_1);
1789       xl21_0 = ixheaac_sub32_sat(x_h2_1, x_l2_1);
1790 
1791       x[1] = ixheaac_add32_sat(xh1_0, xh21_0);
1792       yt0_0 = ixheaac_sub32_sat(xh1_0, xh21_0);
1793 
1794       xt1_0 = ixheaac_add32_sat(xl0_0, xl21_0);
1795       xt2_0 = ixheaac_sub32_sat(xl0_0, xl21_0);
1796 
1797       yt2_0 = ixheaac_add32_sat(xl1_0, xl20_0);
1798       yt1_0 = ixheaac_sub32_sat(xl1_0, xl20_0);
1799 
1800       mul_11 = ixheaac_mult32x16in32(xt2_0, co30);
1801       mul_3 = ixheaac_mult32x16in32(yt2_0, si30);
1802       x[l2] = (mul_3 + mul_11) << RADIXSHIFT;
1803 
1804       mul_5 = ixheaac_mult32x16in32(xt2_0, si30);
1805       mul_9 = ixheaac_mult32x16in32(yt2_0, co30);
1806       x[l2 + 1] = (mul_9 - mul_5) << RADIXSHIFT;
1807 
1808       mul_12 = ixheaac_mult32x16in32(xt0_0, co20);
1809       mul_2 = ixheaac_mult32x16in32(yt0_0, si20);
1810       x[l1] = (mul_2 + mul_12) << RADIXSHIFT;
1811 
1812       mul_6 = ixheaac_mult32x16in32(xt0_0, si20);
1813       mul_8 = ixheaac_mult32x16in32(yt0_0, co20);
1814       x[l1 + 1] = (mul_8 - mul_6) << RADIXSHIFT;
1815 
1816       mul_4 = ixheaac_mult32x16in32(xt1_0, co10);
1817       mul_1 = ixheaac_mult32x16in32(yt1_0, si10);
1818       x[h2] = (mul_1 + mul_4) << RADIXSHIFT;
1819 
1820       mul_10 = ixheaac_mult32x16in32(xt1_0, si10);
1821       mul_7 = ixheaac_mult32x16in32(yt1_0, co10);
1822       x[h2 + 1] = (mul_7 - mul_10) << RADIXSHIFT;
1823 
1824       x += 2;
1825     }
1826     x += fft_jmp;
1827     w_ptr = w_ptr - fft_jmp;
1828   }
1829 }
1830 
ixheaacd_postradixcompute4(WORD32 * ptr_y,WORD32 * ptr_x,const WORD32 * p_dig_rev_tbl,WORD32 npoints)1831 VOID ixheaacd_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x,
1832                                 const WORD32 *p_dig_rev_tbl, WORD32 npoints) {
1833   WORD32 i, k;
1834   WORD32 h2;
1835   WORD32 xh0_0, xh1_0, xl0_0, xl1_0;
1836   WORD32 xh0_1, xh1_1, xl0_1, xl1_1;
1837   WORD32 x_0, x_1, x_2, x_3;
1838   WORD32 xh0_2, xh1_2, xl0_2, xl1_2, xh0_3, xh1_3, xl0_3, xl1_3;
1839   WORD32 x_4, x_5, x_6, x_7;
1840   WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f;
1841   WORD32 n00, n10, n20, n30, n01, n11, n21, n31;
1842   WORD32 n02, n12, n22, n32, n03, n13, n23, n33;
1843   WORD32 *x2, *x0;
1844   WORD32 *y0, *y1, *y2, *y3;
1845 
1846   y0 = ptr_y;
1847   y2 = ptr_y + (WORD32)npoints;
1848   x0 = ptr_x;
1849   x2 = ptr_x + (WORD32)(npoints >> 1);
1850 
1851   y1 = y0 + (WORD32)(npoints >> 1);
1852   y3 = y2 + (WORD32)(npoints >> 1);
1853 
1854   for (k = 0; k < 2; k++) {
1855     for (i = 0; i<npoints>> 1; i += 8) {
1856       h2 = *p_dig_rev_tbl++ >> 2;
1857       x_0 = *x0++;
1858       x_1 = *x0++;
1859       x_2 = *x0++;
1860       x_3 = *x0++;
1861       x_4 = *x0++;
1862       x_5 = *x0++;
1863       x_6 = *x0++;
1864       x_7 = *x0++;
1865 
1866       xh0_0 = ixheaac_add32_sat(x_0, x_4);
1867       xh1_0 = ixheaac_add32_sat(x_1, x_5);
1868       xl0_0 = ixheaac_sub32_sat(x_0, x_4);
1869       xl1_0 = ixheaac_sub32_sat(x_1, x_5);
1870       xh0_1 = ixheaac_add32_sat(x_2, x_6);
1871       xh1_1 = ixheaac_add32_sat(x_3, x_7);
1872       xl0_1 = ixheaac_sub32_sat(x_2, x_6);
1873       xl1_1 = ixheaac_sub32_sat(x_3, x_7);
1874 
1875       n00 = ixheaac_add32_sat(xh0_0, xh0_1);
1876       n01 = ixheaac_add32_sat(xh1_0, xh1_1);
1877       n10 = ixheaac_add32_sat(xl0_0, xl1_1);
1878       n11 = ixheaac_sub32_sat(xl1_0, xl0_1);
1879       n20 = ixheaac_sub32_sat(xh0_0, xh0_1);
1880       n21 = ixheaac_sub32_sat(xh1_0, xh1_1);
1881       n30 = ixheaac_sub32_sat(xl0_0, xl1_1);
1882       n31 = ixheaac_add32_sat(xl1_0, xl0_1);
1883 
1884       y0[h2] = n00;
1885       y0[h2 + 1] = n01;
1886       y1[h2] = n10;
1887       y1[h2 + 1] = n11;
1888       y2[h2] = n20;
1889       y2[h2 + 1] = n21;
1890       y3[h2] = n30;
1891       y3[h2 + 1] = n31;
1892 
1893       x_8 = *x2++;
1894       x_9 = *x2++;
1895       x_a = *x2++;
1896       x_b = *x2++;
1897       x_c = *x2++;
1898       x_d = *x2++;
1899       x_e = *x2++;
1900       x_f = *x2++;
1901 
1902       xh0_2 = ixheaac_add32_sat(x_8, x_c);
1903       xh1_2 = ixheaac_add32_sat(x_9, x_d);
1904       xl0_2 = ixheaac_sub32_sat(x_8, x_c);
1905       xl1_2 = ixheaac_sub32_sat(x_9, x_d);
1906       xh0_3 = ixheaac_add32_sat(x_a, x_e);
1907       xh1_3 = ixheaac_add32_sat(x_b, x_f);
1908       xl0_3 = ixheaac_sub32_sat(x_a, x_e);
1909       xl1_3 = ixheaac_sub32_sat(x_b, x_f);
1910 
1911       n02 = ixheaac_add32_sat(xh0_2, xh0_3);
1912       n03 = ixheaac_add32_sat(xh1_2, xh1_3);
1913       n12 = ixheaac_add32_sat(xl0_2, xl1_3);
1914       n13 = ixheaac_sub32_sat(xl1_2, xl0_3);
1915       n22 = ixheaac_sub32_sat(xh0_2, xh0_3);
1916       n23 = ixheaac_sub32_sat(xh1_2, xh1_3);
1917       n32 = ixheaac_sub32_sat(xl0_2, xl1_3);
1918       n33 = ixheaac_add32_sat(xl1_2, xl0_3);
1919 
1920       y0[h2 + 2] = n02;
1921       y0[h2 + 3] = n03;
1922       y1[h2 + 2] = n12;
1923       y1[h2 + 3] = n13;
1924       y2[h2 + 2] = n22;
1925       y2[h2 + 3] = n23;
1926       y3[h2 + 2] = n32;
1927       y3[h2 + 3] = n33;
1928     }
1929     x0 += (WORD32)npoints >> 1;
1930     x2 += (WORD32)npoints >> 1;
1931   }
1932 }
1933 
ixheaacd_postradixcompute2(WORD32 * ptr_y,WORD32 * ptr_x,const WORD32 * pdig_rev_tbl,WORD32 npoints)1934 VOID ixheaacd_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x,
1935                                 const WORD32 *pdig_rev_tbl, WORD32 npoints) {
1936   WORD32 i, k;
1937   WORD32 h2;
1938   WORD32 x_0, x_1, x_2, x_3;
1939   WORD32 x_4, x_5, x_6, x_7;
1940   WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f;
1941   WORD32 n00, n10, n20, n30, n01, n11, n21, n31;
1942   WORD32 n02, n12, n22, n32, n03, n13, n23, n33;
1943   WORD32 *x2, *x0;
1944   WORD32 *y0, *y1, *y2, *y3;
1945 
1946   y0 = ptr_y;
1947   y2 = ptr_y + (WORD32)npoints;
1948   x0 = ptr_x;
1949   x2 = ptr_x + (WORD32)(npoints >> 1);
1950 
1951   y1 = y0 + (WORD32)(npoints >> 2);
1952   y3 = y2 + (WORD32)(npoints >> 2);
1953 
1954   for (k = 0; k < 2; k++) {
1955     for (i = 0; i<npoints>> 1; i += 8) {
1956       h2 = *pdig_rev_tbl++ >> 2;
1957 
1958       x_0 = *x0++;
1959       x_1 = *x0++;
1960       x_2 = *x0++;
1961       x_3 = *x0++;
1962       x_4 = *x0++;
1963       x_5 = *x0++;
1964       x_6 = *x0++;
1965       x_7 = *x0++;
1966 
1967       n00 = ixheaac_add32_sat(x_0, x_2);
1968       n01 = ixheaac_add32_sat(x_1, x_3);
1969       n20 = ixheaac_sub32_sat(x_0, x_2);
1970       n21 = ixheaac_sub32_sat(x_1, x_3);
1971       n10 = ixheaac_add32_sat(x_4, x_6);
1972       n11 = ixheaac_add32_sat(x_5, x_7);
1973       n30 = ixheaac_sub32_sat(x_4, x_6);
1974       n31 = ixheaac_sub32_sat(x_5, x_7);
1975 
1976       y0[h2] = n00;
1977       y0[h2 + 1] = n01;
1978       y1[h2] = n10;
1979       y1[h2 + 1] = n11;
1980       y2[h2] = n20;
1981       y2[h2 + 1] = n21;
1982       y3[h2] = n30;
1983       y3[h2 + 1] = n31;
1984 
1985       x_8 = *x2++;
1986       x_9 = *x2++;
1987       x_a = *x2++;
1988       x_b = *x2++;
1989       x_c = *x2++;
1990       x_d = *x2++;
1991       x_e = *x2++;
1992       x_f = *x2++;
1993 
1994       n02 = ixheaac_add32_sat(x_8, x_a);
1995       n03 = ixheaac_add32_sat(x_9, x_b);
1996       n22 = ixheaac_sub32_sat(x_8, x_a);
1997       n23 = ixheaac_sub32_sat(x_9, x_b);
1998       n12 = ixheaac_add32_sat(x_c, x_e);
1999       n13 = ixheaac_add32_sat(x_d, x_f);
2000       n32 = ixheaac_sub32_sat(x_c, x_e);
2001       n33 = ixheaac_sub32_sat(x_d, x_f);
2002 
2003       y0[h2 + 2] = n02;
2004       y0[h2 + 3] = n03;
2005       y1[h2 + 2] = n12;
2006       y1[h2 + 3] = n13;
2007       y2[h2 + 2] = n22;
2008       y2[h2 + 3] = n23;
2009       y3[h2 + 2] = n32;
2010       y3[h2 + 3] = n33;
2011     }
2012     x0 += (WORD32)npoints >> 1;
2013     x2 += (WORD32)npoints >> 1;
2014   }
2015 }
2016 #endif
2017