Coverage Report

Created: 2025-08-24 07:12

/src/libxaac/decoder/ixheaacd_lpfuncs.c
Line
Count
Source (jump to first uncovered line)
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
#include "ixheaacd_sbr_common.h"
22
#include "ixheaac_type_def.h"
23
24
#include "ixheaac_constants.h"
25
#include "ixheaac_basic_ops32.h"
26
#include "ixheaac_basic_ops16.h"
27
#include "ixheaac_basic_ops40.h"
28
#include "ixheaac_basic_ops.h"
29
#include "ixheaacd_bitbuffer.h"
30
31
#include "ixheaac_basic_op.h"
32
#include "ixheaacd_intrinsics.h"
33
34
#include "ixheaacd_defines.h"
35
36
#include "ixheaacd_aac_rom.h"
37
38
#include "ixheaacd_definitions.h"
39
40
#include "ixheaacd_error_codes.h"
41
42
#include "ixheaacd_pulsedata.h"
43
44
#include "ixheaacd_pns.h"
45
#include "ixheaacd_drc_data_struct.h"
46
47
#include "ixheaacd_lt_predict.h"
48
#include "ixheaacd_cnst.h"
49
#include "ixheaacd_ec_defines.h"
50
#include "ixheaacd_ec_struct_def.h"
51
#include "ixheaacd_channelinfo.h"
52
#include "ixheaacd_drc_dec.h"
53
54
#include "ixheaacd_sbrdecoder.h"
55
56
#include "ixheaacd_block.h"
57
#include "ixheaacd_channel.h"
58
59
#include "ixheaacd_sbr_payload.h"
60
#include "ixheaacd_common_rom.h"
61
#include "ixheaacd_sbrdecsettings.h"
62
#include "ixheaacd_sbr_scale.h"
63
#include "ixheaacd_env_extr_part.h"
64
#include "ixheaacd_sbr_rom.h"
65
66
#include "ixheaacd_lpp_tran.h"
67
#include "ixheaacd_hybrid.h"
68
#include "ixheaacd_ps_dec.h"
69
70
#include "ixheaacd_env_extr.h"
71
#include "ixheaacd_adts.h"
72
#include "ixheaacd_audioobjtypes.h"
73
#include "ixheaacd_memory_standards.h"
74
75
#include "ixheaacd_latmdemux.h"
76
77
#include "ixheaacd_qmf_dec.h"
78
#include "ixheaacd_aacdec.h"
79
#include "ixheaacd_mps_polyphase.h"
80
#include "ixheaacd_config.h"
81
#include "ixheaacd_mps_macro_def.h"
82
#include "ixheaacd_mps_struct_def.h"
83
#include "ixheaacd_mps_res_rom.h"
84
#include "ixheaacd_mps_aac_struct.h"
85
#include "ixheaacd_mps_dec.h"
86
#include "ixheaacd_struct_def.h"
87
88
#include "ixheaacd_tns.h"
89
#include "ixheaacd_aac_imdct.h"
90
91
#include "ixheaacd_multichannel.h"
92
#include "ixheaacd_function_selector.h"
93
94
VOID ixheaacd_process_win_seq(WORD32 *coef, WORD32 *prev, WORD32 *out,
95
                              const WORD16 *window_long,
96
                              const WORD16 *window_short, WORD16 q_shift,
97
37.6k
                              WORD16 ch_fac, WORD16 flag, WORD16 size_01) {
98
37.6k
  WORD32 i, accu;
99
37.6k
  WORD32 *coef_1;
100
37.6k
  const WORD16 *temp_win_sh, *temp_win_long;
101
37.6k
  WORD32 *out1, *out2;
102
37.6k
  WORD32 *temp_prev;
103
104
37.6k
  WORD16 size_07 = 7 * size_01;
105
37.6k
  WORD16 size_08 = 8 * size_01;
106
37.6k
  WORD16 size_09 = 9 * size_01;
107
37.6k
  WORD16 size_14 = 14 * size_01;
108
37.6k
  WORD16 size_15 = 15 * size_01;
109
110
37.6k
  if (flag == 1) {
111
8.66M
    for (i = 0; i < size_07; i++) {
112
8.64M
      WORD32 temp1 = ixheaac_shl32_dir_sat_limit(
113
8.64M
          ixheaac_mult32x16in32(coef[size_08 + i], window_long[2 * i]),
114
8.64M
          (q_shift + 1));
115
116
8.64M
      accu = ixheaac_add32_sat(temp1, ((WORD32)prev[i] << 16));
117
8.64M
      out[ch_fac * i] = accu;
118
119
8.64M
      accu = ixheaac_shl32_dir_sat_limit(
120
8.64M
          ixheaac_mult32x16in32(-(coef[size_15 - 1 - i]),
121
8.64M
                                 window_long[2 * (size_07 - i) - 1]),
122
8.64M
          q_shift);
123
8.64M
      out[ch_fac * (i + size_09)] = (accu << 1);
124
8.64M
    }
125
126
19.6k
    temp_win_sh = &(window_short[0]);
127
19.6k
    coef_1 = &(coef[size_15]);
128
19.6k
    temp_win_long = &(window_long[size_14]);
129
19.6k
    temp_prev = &(prev[size_08 - 1]);
130
19.6k
    out1 = &(out[ch_fac * (size_07)]);
131
19.6k
    out2 = &(out[ch_fac * (size_09 - 1)]);
132
133
19.6k
  } else {
134
7.90M
    for (i = 0; i < size_07; i++) {
135
7.89M
      accu = ixheaac_mult32x16in32_sat(
136
7.89M
          prev[size_08 - 1 - i], ixheaac_negate16(window_long[2 * i + 1]));
137
138
7.89M
      out[ch_fac * i] = accu;
139
140
7.89M
      accu = ixheaac_sub32_sat(
141
7.89M
          ixheaac_shl32_dir_sat_limit(-(coef[size_15 - 1 - i]), (q_shift - 1)),
142
7.89M
          ixheaac_mult32x16in32_sat(prev[i + size_01],
143
7.89M
                                     window_long[2 * size_07 - 2 - 2 * i]));
144
145
7.89M
      out[ch_fac * (size_09 + i)] = accu;
146
7.89M
    }
147
148
17.9k
    temp_win_sh = &(window_long[size_14]);
149
17.9k
    coef_1 = &(coef[size_15]);
150
17.9k
    temp_win_long = &(window_short[0]);
151
17.9k
    temp_prev = &(prev[size_01 - 1]);
152
17.9k
    out1 = &(out[ch_fac * (size_07)]);
153
17.9k
    out2 = &(out[ch_fac * (size_09 - 1)]);
154
17.9k
  }
155
156
2.39M
  for (i = size_01 - 1; i >= 0; i--) {
157
2.36M
    WORD32 temp_coef = *coef_1++;
158
2.36M
    WORD16 win1 = *temp_win_long++;
159
2.36M
    WORD16 win2 = *temp_win_long++;
160
2.36M
    WORD32 prev1 = *temp_prev--;
161
2.36M
    WORD16 win4 = *temp_win_sh++;
162
2.36M
    WORD16 win3 = *temp_win_sh++;
163
2.36M
    accu = ixheaac_sub32_sat(
164
2.36M
        ixheaac_shl32_dir_sat_limit(ixheaac_mult32x16in32(temp_coef, win1),
165
2.36M
                                     q_shift),
166
2.36M
        ixheaac_mult32x16in32_sat(prev1, win3));
167
2.36M
    *out1 = accu << flag;
168
2.36M
    out1 += ch_fac;
169
170
2.36M
    accu = ixheaac_sub32_sat(
171
2.36M
        ixheaac_shl32_dir_sat_limit(
172
2.36M
            ixheaac_mult32x16in32(ixheaac_negate32_sat(temp_coef), win2),
173
2.36M
            q_shift),
174
2.36M
        ixheaac_mult32x16in32_sat(prev1, win4));
175
2.36M
    *out2 = accu << flag;
176
2.36M
    out2 -= ch_fac;
177
2.36M
  }
178
37.6k
}
179
180
static PLATFORM_INLINE VOID ixheaacd_long_short_win_process(
181
    WORD32 *current, WORD32 *prev, WORD32 *out, const WORD16 *short_window,
182
    const WORD16 *long_window_prev, WORD16 q_shift, WORD16 ch_fac,
183
74.0k
    WORD32 flag, WORD16 size_01) {
184
185
74.0k
  WORD16 size_02 = 2 * size_01;
186
74.0k
  WORD16 size_03 = 3 * size_01;
187
74.0k
  WORD i;
188
74.0k
  WORD32 accu;
189
74.0k
  WORD32 *current_tmp1 = &(current[(size_03 - 1)]);
190
74.0k
  WORD32 *current_tmp2 = &(current[-size_01]);
191
74.0k
  const WORD16 *short_ptr = &(short_window[size_02 - 1]);
192
193
4.72M
  for (i = size_01 - 1; i >= 0; i--) {
194
4.64M
    WORD32 tmp1_cur = *current_tmp1--;
195
4.64M
    WORD32 tmp2_cur = *current_tmp2++;
196
4.64M
    WORD16 short1 = *short_ptr--;
197
4.64M
    WORD16 short2 = *short_ptr--;
198
4.64M
    accu = ixheaac_sub32_sat(
199
4.64M
        ixheaac_shl32_dir_sat_limit((ixheaac_mult32x16in32(tmp1_cur, short2) -
200
4.64M
                                      ixheaac_mult32x16in32(tmp2_cur, short1)),
201
4.64M
                                     q_shift),
202
4.64M
        ixheaac_mult32x16in32_sat(prev[i], long_window_prev[0 - 2 - 2 * i]));
203
4.64M
    out[ch_fac * (0 + i)] = accu;
204
205
4.64M
    if (flag) {
206
3.48M
      accu = ixheaac_sub32_sat(
207
3.48M
          ixheaac_shl32_dir_sat_limit(
208
3.48M
              (ixheaac_mult32x16in32(ixheaac_negate32_sat(tmp1_cur), short1) -
209
3.48M
               ixheaac_mult32x16in32(tmp2_cur, short2)),
210
3.48M
              q_shift),
211
3.48M
          ixheaac_mult32x16in32_sat(prev[size_02 - 1 - i],
212
3.48M
                                     long_window_prev[-2 * size_02 + 2 * i]));
213
3.48M
      out[ch_fac * (size_02 - 1 - i)] = accu;
214
3.48M
    }
215
4.64M
  }
216
74.0k
}
217
218
VOID ixheaacd_long_short_win_seq(WORD32 *current, WORD32 *prev, WORD32 *out,
219
                                 const WORD16 *short_window,
220
                                 const WORD16 *short_window_prev,
221
                                 const WORD16 *long_window_prev, WORD16 q_shift,
222
18.5k
                                 WORD16 ch_fac, WORD16 size_01) {
223
224
18.5k
  WORD16 size_02 = 2 * size_01;
225
18.5k
  WORD16 size_06 = 6 * size_01;
226
18.5k
  WORD16 size_07 = 7 * size_01;
227
18.5k
  WORD16 size_08 = 8 * size_01;
228
18.5k
  WORD16 size_09 = 9 * size_01;
229
18.5k
  WORD16 size_10 = 10 * size_01;
230
18.5k
  WORD16 size_16 = 16 * size_01;
231
232
18.5k
  WORD32 i, flag;
233
18.5k
  WORD32 accu;
234
8.15M
  for (i = 0; i < size_07; i++) {
235
8.13M
    accu = ixheaac_mult32x16in32_sat(
236
8.13M
        prev[size_08 - 1 - i], ixheaac_negate16(long_window_prev[2 * i + 1]));
237
8.13M
    out[ch_fac * i] = accu;
238
8.13M
  }
239
240
1.18M
  for (i = 0; i < size_01; i++) {
241
1.16M
    accu = ixheaac_sub32_sat(
242
1.16M
        ixheaac_shl32_dir_sat_limit(
243
1.16M
            ixheaac_mult32x16in32(current[size_01 + i],
244
1.16M
                                   short_window_prev[2 * i]),
245
1.16M
            q_shift),
246
1.16M
        ixheaac_mult32x16in32_sat(prev[size_01 - 1 - i],
247
1.16M
                                   long_window_prev[2 * size_07 + 1 + 2 * i]));
248
1.16M
    out[ch_fac * (size_07 + i)] = accu;
249
1.16M
  }
250
251
1.18M
  for (i = 0; i < size_01; i++) {
252
1.16M
    accu = ixheaac_sub32_sat(
253
1.16M
        ixheaac_shl32_dir_sat_limit(
254
1.16M
            ixheaac_mult32x16in32(ixheaac_negate32_sat(current[size_02 - 1 - i]),
255
1.16M
                                   short_window_prev[size_02 - 2 * i - 1]),
256
1.16M
            q_shift),
257
1.16M
        ixheaac_mult32x16in32_sat(prev[i],
258
1.16M
                                   long_window_prev[size_16 - 2 - (2 * i)]));
259
1.16M
    out[ch_fac * (size_08 + i)] = accu;
260
1.16M
  }
261
262
18.5k
  flag = 1;
263
92.5k
  for (i = 0; i < 4; i++) {
264
74.0k
    WORD32 inc = i * size_02;
265
266
74.0k
    if (i == 3) {
267
18.5k
      flag = 0;
268
18.5k
    }
269
270
74.0k
    ixheaacd_long_short_win_process(&current[size_01 + inc], &prev[size_01 + inc],
271
74.0k
                                    &out[ch_fac * (size_09 + inc)], short_window,
272
74.0k
                                    &long_window_prev[2 * (size_07 - inc)],
273
74.0k
                                    q_shift, ch_fac, flag, size_01);
274
74.0k
  }
275
276
1.18M
  for (i = 0; i < size_01; i++) {
277
1.16M
    accu = (ixheaac_mult32x16in32(-(current[size_10 - 1 - i]),
278
1.16M
                                   short_window[size_02 - 2 * i - 1]) -
279
1.16M
            ixheaac_mult32x16in32(current[size_06 + i],
280
1.16M
                                   short_window[size_02 - 2 * i - 2]));
281
1.16M
    prev[i] =
282
1.16M
        ixheaac_round16(ixheaac_shl32_dir_sat_limit(accu, (q_shift + 1)));
283
1.16M
  }
284
18.5k
}
285
286
VOID ixheaacd_nolap1_32(WORD32 *coef, WORD32 *out, WORD16 q_shift,
287
21.5k
                        WORD16 ch_fac, WORD16 size_01) {
288
21.5k
  WORD16 size_07 = 7 * size_01;
289
21.5k
  WORD32 i;
290
291
9.57M
  for (i = 0; i < size_07; i++) {
292
9.55M
    out[ch_fac * i] = ixheaac_shr32_sat(
293
9.55M
        ixheaac_negate32_sat(coef[size_07 - 1 - i]), 16 - q_shift);
294
9.55M
  }
295
21.5k
}
296
297
VOID ixheaacd_neg_shift_spec_dec(WORD32 *coef, WORD32 *out, WORD16 q_shift,
298
7.09k
                                 WORD16 ch_fac) {
299
7.09k
  WORD32 i;
300
3.18M
  for (i = 0; i < SIZE07; i++) {
301
3.17M
    out[ch_fac * i] = (ixheaac_shl32_dir_sat_limit(
302
3.17M
        ixheaac_negate32_sat(coef[SIZE07 - 1 - i]), q_shift));
303
3.17M
  }
304
7.09k
}
305
306
VOID ixheaacd_Nolap_dec(WORD32 *coef, WORD32 *out, WORD16 q_shift,
307
2.63k
                        WORD16 ch_fac, WORD16 size_01) {
308
2.63k
  WORD16 size_07 = 7 * size_01;
309
2.63k
  WORD32 i;
310
1.10M
  for (i = 0; i < size_07; i++) {
311
1.10M
    out[ch_fac * i] = ixheaac_shl32_dir_sat_limit(
312
1.10M
        ixheaac_negate32_sat(coef[size_07 - 1 - i]), q_shift);
313
1.10M
  }
314
2.63k
}
315
316
VOID ixheaacd_spec_to_overlapbuf_dec(WORD32 *ptr_overlap_buf,
317
                                     WORD32 *ptr_spec_coeff, WORD32 q_shift,
318
269k
                                     WORD32 size) {
319
269k
  WORD32 i;
320
49.7M
  for (i = 0; i < size; i++) {
321
49.4M
    ptr_overlap_buf[i] = ixheaac_shr32_sat(ptr_spec_coeff[i], 16 - q_shift);
322
49.4M
  }
323
269k
}
324
325
VOID ixheaacd_overlap_buf_out_dec(WORD32 *out_samples, WORD32 *ptr_overlap_buf,
326
40.1k
                                  WORD32 size, const WORD16 ch_fac) {
327
40.1k
  WORD32 i;
328
329
17.7M
  for (i = 0; i < size; i++) {
330
17.6M
    out_samples[ch_fac * i] =
331
17.6M
        (ixheaac_shl32_sat((WORD16)ptr_overlap_buf[i], 15));
332
17.6M
  }
333
40.1k
}
334
335
VOID ixheaacd_overlap_out_copy_dec(WORD32 *out_samples, WORD32 *ptr_overlap_buf,
336
                                   WORD32 *ptr_overlap_buf1,
337
33.0k
                                   const WORD16 ch_fac, WORD16 size_01) {
338
33.0k
  WORD32 i;
339
340
2.10M
  for (i = 0; i < size_01; i++) {
341
2.07M
    out_samples[ch_fac * i] =
342
2.07M
        ixheaac_shl32_sat((WORD16)ptr_overlap_buf[i], 15);
343
2.07M
    ptr_overlap_buf[i] = ptr_overlap_buf1[i];
344
2.07M
  }
345
33.0k
}
346
347
VOID ixheaacd_imdct_process(ia_aac_dec_overlap_info *ptr_aac_dec_overlap_info,
348
                            WORD32 *ptr_spec_coeff,
349
                            ia_ics_info_struct *ptr_ics_info, VOID *out_samples,
350
                            const WORD16 ch_fac, WORD32 *scratch,
351
                            ia_aac_dec_tables_struct *ptr_aac_tables,
352
                            WORD32 object_type, WORD32 ld_mps_present,
353
289k
                            WORD slot_element) {
354
289k
  WORD32 *ptr_overlap_buf;
355
289k
  const WORD16 *ptr_long_window;
356
289k
  const WORD16 *ptr_short_window;
357
289k
  WORD16 max_bin_long = ptr_ics_info->frame_length;
358
289k
  WORD16 size_01;
359
289k
  if (max_bin_long == 960)
360
59.0k
    size_01 = (max_bin_long / 16);
361
230k
  else
362
230k
    size_01 = (MAX_BINS_LONG / 16);
363
289k
  WORD16 size_02 = 2 * size_01;
364
289k
  WORD16 size_04 = 4 * size_01;
365
289k
  WORD16 size_06 = 6 * size_01;
366
289k
  WORD16 size_07 = 7 * size_01;
367
289k
  WORD16 size_08 = 8 * size_01;
368
289k
  WORD16 size_09 = 9 * size_01;
369
289k
  WORD16 size_10 = 10 * size_01;
370
289k
  WORD16 size_14 = 14 * size_01;
371
289k
  WORD16 size_15 = 15 * size_01;
372
373
289k
  ptr_overlap_buf = ptr_aac_dec_overlap_info->ptr_overlap_buf;
374
289k
  ptr_long_window =
375
289k
      ptr_aac_dec_overlap_info
376
289k
          ->ptr_long_window[(WORD32)ptr_aac_dec_overlap_info->window_shape];
377
289k
  ptr_short_window =
378
289k
      ptr_aac_dec_overlap_info
379
289k
          ->ptr_short_window[(WORD32)ptr_aac_dec_overlap_info->window_shape];
380
381
289k
  if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) {
382
238k
    WORD16 q_shift;
383
238k
    WORD32 expo, imdct_scale;
384
385
238k
    if ((512 == ptr_ics_info->frame_length) ||
386
238k
        (480 == ptr_ics_info->frame_length)) {
387
124k
      ptr_ics_info->qshift_adj = -2;
388
389
124k
      if (512 == ptr_ics_info->frame_length) {
390
87.4k
        WORD32 *ld_cos_sin_ptr =
391
87.4k
            (WORD32 *)ptr_aac_tables->pstr_imdct_tables->cosine_array_1024;
392
393
87.4k
        ixheaacd_inverse_transform_512(
394
87.4k
            ptr_spec_coeff, scratch, &imdct_scale, ld_cos_sin_ptr,
395
87.4k
            ptr_aac_tables->pstr_imdct_tables, object_type);
396
397
87.4k
      } else {
398
37.4k
        ixheaacd_mdct_480_ld(ptr_spec_coeff, scratch, &imdct_scale, 0,
399
37.4k
                             ptr_aac_tables->pstr_imdct_tables, object_type);
400
37.4k
      }
401
402
124k
      if (object_type == AOT_ER_AAC_ELD) {
403
60.0k
        int i, N = (ptr_ics_info->frame_length << 1);
404
405
29.8M
        for (i = 0; i < N / 2; i++) {
406
29.7M
          ptr_spec_coeff[i] = -ptr_spec_coeff[i + N];
407
29.7M
          ptr_spec_coeff[i + N + N / 2] = -ptr_spec_coeff[i + N / 2];
408
29.7M
        }
409
60.0k
      }
410
124k
    } else if (960 == ptr_ics_info->frame_length) {
411
42.7k
      ixheaacd_mdct_960(ptr_spec_coeff, scratch, &imdct_scale, 0,
412
42.7k
                        ptr_aac_tables->pstr_imdct_tables);
413
70.4k
    } else {
414
70.4k
      expo = (*ixheaacd_calc_max_spectral_line)(ptr_spec_coeff, 1024) - 1;
415
416
70.4k
      expo = 8 - expo;
417
418
70.4k
      imdct_scale = ixheaacd_inverse_transform(
419
70.4k
          ptr_spec_coeff, scratch, ptr_aac_tables->pstr_imdct_tables, expo,
420
70.4k
          1024);
421
70.4k
    }
422
423
238k
    q_shift = (31 + imdct_scale) + (-1 - 16 - 9);
424
425
238k
    switch (ptr_ics_info->window_sequence) {
426
188k
      case ONLY_LONG_SEQUENCE:
427
428
188k
        switch (ptr_aac_dec_overlap_info->window_sequence) {
429
177k
          case ONLY_LONG_SEQUENCE:
430
181k
          case LONG_STOP_SEQUENCE:
431
432
181k
            if (1024 == ptr_ics_info->frame_length) {
433
59.4k
              ia_ics_info_struct *tmp_ptr_ics_info = ptr_ics_info;
434
435
59.4k
              (*ixheaacd_post_twid_overlap_add)(
436
59.4k
                  (WORD32 *)out_samples, ptr_spec_coeff,
437
59.4k
                  ptr_aac_tables->pstr_imdct_tables, 1024, ptr_overlap_buf,
438
59.4k
                  q_shift, ptr_long_window, ch_fac);
439
440
59.4k
              ptr_ics_info->qshift_adj = 2;
441
59.4k
              ptr_ics_info = tmp_ptr_ics_info;
442
59.4k
            }
443
444
181k
            if (960 == ptr_ics_info->frame_length)
445
28.0k
            {
446
28.0k
                ixheaacd_over_lap_add1_dec(ptr_spec_coeff, ptr_overlap_buf,
447
28.0k
                    (WORD32*)out_samples, ptr_long_window, q_shift,
448
28.0k
                    480, ch_fac);
449
450
28.0k
                ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
451
28.0k
                                            q_shift, 480);
452
453
28.0k
                ptr_ics_info->qshift_adj = 2;
454
28.0k
            }
455
456
181k
            if ((512 == ptr_ics_info->frame_length) ||
457
181k
                (480 == ptr_ics_info->frame_length)) {
458
94.0k
              if (object_type != AOT_ER_AAC_ELD) {
459
34.0k
                if (512 == ptr_ics_info->frame_length) {
460
31.0k
                  ixheaacd_lap1_512_480(ptr_spec_coeff, ptr_overlap_buf,
461
31.0k
                                        (WORD16 *)out_samples, ptr_long_window,
462
31.0k
                                        q_shift, size_04, ch_fac, slot_element);
463
31.0k
                  ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
464
31.0k
                                              q_shift, size_04);
465
31.0k
                } else if (480 == ptr_ics_info->frame_length) {
466
3.00k
                  ixheaacd_lap1_512_480(ptr_spec_coeff, ptr_overlap_buf,
467
3.00k
                                        (WORD16 *)out_samples, ptr_long_window,
468
3.00k
                                        q_shift, 240, ch_fac, slot_element);
469
3.00k
                  ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
470
3.00k
                                              q_shift, 240);
471
3.00k
                }
472
60.0k
              } else {
473
60.0k
                if (ld_mps_present == 1) {
474
18.7k
                  ixheaacd_eld_dec_windowing_32bit(
475
18.7k
                      ptr_spec_coeff, ptr_long_window,
476
18.7k
                      ptr_ics_info->frame_length, q_shift, ptr_overlap_buf,
477
18.7k
                      ch_fac, (WORD32 *)out_samples);
478
41.2k
                } else {
479
41.2k
                  ixheaacd_eld_dec_windowing(
480
41.2k
                      ptr_spec_coeff, ptr_long_window,
481
41.2k
                      ptr_ics_info->frame_length, q_shift, ptr_overlap_buf,
482
41.2k
                      ch_fac, (WORD16 *)out_samples, slot_element);
483
41.2k
                }
484
60.0k
                ptr_ics_info->qshift_adj = -2;
485
60.0k
              }
486
94.0k
            }
487
181k
            break;
488
489
2.73k
          case LONG_START_SEQUENCE:
490
7.33k
          case EIGHT_SHORT_SEQUENCE:
491
7.33k
            if (1024 == ptr_ics_info->frame_length) {
492
1.09k
              (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff,
493
1.09k
                                       ptr_aac_tables->pstr_imdct_tables, 1024);
494
1.09k
              ixheaacd_process_win_seq(scratch, ptr_overlap_buf,
495
1.09k
                                       (WORD32*)out_samples, ptr_long_window,
496
1.09k
                                       ptr_short_window, q_shift, ch_fac, 1,
497
1.09k
                                       size_01);
498
1.09k
              (*ixheaacd_spec_to_overlapbuf)(ptr_overlap_buf, scratch, q_shift,
499
1.09k
                                             size_08);
500
1.09k
            }
501
502
7.33k
            if (960 == ptr_ics_info->frame_length) {
503
2.16k
              ixheaacd_process_win_seq(ptr_spec_coeff, ptr_overlap_buf,
504
2.16k
                                       (WORD32*)out_samples, ptr_long_window,
505
2.16k
                                       ptr_short_window, q_shift, ch_fac, 1,
506
2.16k
                                       size_01);
507
2.16k
              ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
508
2.16k
                                          q_shift, 480);
509
2.16k
            }
510
511
7.33k
            ptr_ics_info->qshift_adj = 1;
512
513
7.33k
            if (512 == ptr_ics_info->frame_length) {
514
3.47k
              ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
515
3.47k
                                          q_shift, size_04);
516
3.47k
            }
517
7.33k
            if (480 == ptr_ics_info->frame_length) {
518
607
              ixheaacd_spec_to_overlapbuf(ptr_overlap_buf, ptr_spec_coeff,
519
607
                                          q_shift, 240);
520
607
            }
521
7.33k
            break;
522
188k
        }
523
524
188k
        break;
525
526
188k
      case LONG_START_SEQUENCE:
527
21.5k
        if (1024 == ptr_ics_info->frame_length) {
528
4.99k
          (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff,
529
4.99k
                                   ptr_aac_tables->pstr_imdct_tables, 1024);
530
4.99k
        }
531
21.5k
        switch (ptr_aac_dec_overlap_info->window_sequence) {
532
4.05k
          case ONLY_LONG_SEQUENCE:
533
5.20k
          case LONG_STOP_SEQUENCE:
534
535
5.20k
            if (1024 == ptr_ics_info->frame_length) {
536
1.21k
              (*ixheaacd_over_lap_add1)(scratch, ptr_overlap_buf,
537
1.21k
                                        (WORD32*)out_samples, ptr_long_window,
538
1.21k
                                        q_shift, size_08, ch_fac);
539
3.99k
            } else {
540
3.99k
              ixheaacd_over_lap_add1_dec(ptr_spec_coeff, ptr_overlap_buf,
541
3.99k
                                         (WORD32*)out_samples, ptr_long_window,
542
3.99k
                                         q_shift, size_08, ch_fac);
543
3.99k
            }
544
5.20k
            ptr_ics_info->qshift_adj = 2;
545
5.20k
            break;
546
547
14.2k
          case LONG_START_SEQUENCE:
548
16.3k
          case EIGHT_SHORT_SEQUENCE:
549
550
16.3k
            if (1024 == ptr_ics_info->frame_length) {
551
3.78k
              ixheaacd_process_win_seq(scratch, ptr_overlap_buf,
552
3.78k
                                       (WORD32*)out_samples, ptr_long_window,
553
3.78k
                                       ptr_short_window, q_shift, ch_fac, 1,
554
3.78k
                                       size_01);
555
12.5k
            } else {
556
12.5k
              ixheaacd_process_win_seq(ptr_spec_coeff, ptr_overlap_buf,
557
12.5k
                                       (WORD32*)out_samples, ptr_long_window,
558
12.5k
                                       ptr_short_window, q_shift, ch_fac, 1,
559
12.5k
                                       size_01);
560
12.5k
            }
561
562
16.3k
            ptr_ics_info->qshift_adj = 1;
563
564
16.3k
            break;
565
21.5k
        }
566
567
21.5k
        if (960 != ptr_ics_info->frame_length) {
568
17.6k
          ixheaacd_nolap1_32(&scratch[size_01], ptr_overlap_buf, q_shift, 1,
569
17.6k
                             size_01);
570
571
17.6k
          (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[size_07], scratch,
572
17.6k
                                         q_shift, size_01);
573
17.6k
        } else {
574
3.96k
          ixheaacd_nolap1_32(&ptr_spec_coeff[size_01], ptr_overlap_buf,
575
3.96k
                             q_shift, 1, size_01);
576
577
3.96k
          (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[size_07],
578
3.96k
                                         ptr_spec_coeff, q_shift, size_01);
579
3.96k
        }
580
581
21.5k
        break;
582
583
27.7k
      case LONG_STOP_SEQUENCE:
584
27.7k
        if (1024 == ptr_ics_info->frame_length) {
585
4.97k
          (*ixheaacd_post_twiddle)(scratch, ptr_spec_coeff,
586
4.97k
                                   ptr_aac_tables->pstr_imdct_tables, 1024);
587
4.97k
        }
588
589
27.7k
        switch (ptr_aac_dec_overlap_info->window_sequence) {
590
8.62k
          case EIGHT_SHORT_SEQUENCE:
591
9.72k
          case LONG_START_SEQUENCE:
592
593
9.72k
            if (960 != ptr_ics_info->frame_length) {
594
7.09k
              (*ixheaacd_overlap_buf_out)((WORD32*)out_samples,
595
7.09k
                                          ptr_overlap_buf, size_07, ch_fac);
596
7.09k
              (*ixheaacd_over_lap_add1)(
597
7.09k
                  &scratch[size_14], &ptr_overlap_buf[size_07],
598
7.09k
                  ((WORD32*)out_samples + ch_fac * (size_07)),
599
7.09k
                  ptr_short_window, q_shift, size_01, ch_fac);
600
7.09k
            } else {
601
2.63k
              ixheaacd_dec_copy_outsample((WORD32*)out_samples,
602
2.63k
                                          ptr_overlap_buf, size_07, ch_fac);
603
2.63k
              ixheaacd_over_lap_add1_dec(&ptr_spec_coeff[size_14],
604
2.63k
                                         &ptr_overlap_buf[size_07],
605
2.63k
                                         ((WORD32*)out_samples + ch_fac * (size_07)),
606
2.63k
                                         ptr_short_window, q_shift, size_01,
607
2.63k
                                         ch_fac);
608
2.63k
            }
609
610
9.72k
            {
611
9.72k
              if (960 != ptr_ics_info->frame_length) {
612
613
7.09k
                WORD16 q_shift1 = q_shift - 1;
614
7.09k
                (*ixheaacd_neg_shift_spec)(&scratch[size_08],
615
7.09k
                                           ((WORD32*)out_samples + ch_fac * size_09),
616
7.09k
                                           q_shift1, ch_fac);
617
7.09k
              } else {
618
2.63k
                WORD16 q_shift1 = q_shift - 1;
619
2.63k
                ixheaacd_Nolap_dec(&ptr_spec_coeff[size_08],
620
2.63k
                                   ((WORD32*)out_samples + ch_fac * size_09),
621
2.63k
                                   q_shift1, ch_fac, size_01);
622
2.63k
              }
623
9.72k
            }
624
9.72k
            ptr_ics_info->qshift_adj = 2;
625
626
9.72k
            break;
627
5.39k
          case ONLY_LONG_SEQUENCE:
628
17.9k
          case LONG_STOP_SEQUENCE:
629
630
17.9k
            if (1024 == ptr_ics_info->frame_length) {
631
2.36k
              ixheaacd_process_win_seq(scratch, ptr_overlap_buf,
632
2.36k
                                       (WORD32*)out_samples, ptr_long_window,
633
2.36k
                                       ptr_short_window, q_shift, ch_fac, 0,
634
2.36k
                                       size_01);
635
15.6k
            } else {
636
15.6k
              ixheaacd_process_win_seq(ptr_spec_coeff, ptr_overlap_buf,
637
15.6k
                                       (WORD32*)out_samples, ptr_long_window,
638
15.6k
                                       ptr_short_window, q_shift, ch_fac, 0,
639
15.6k
                                       size_01);
640
15.6k
            }
641
642
17.9k
            ptr_ics_info->qshift_adj = 2;
643
17.9k
            break;
644
27.7k
        }
645
646
27.7k
        if (1024 == ptr_ics_info->frame_length) {
647
4.97k
          (*ixheaacd_spec_to_overlapbuf)(ptr_overlap_buf, scratch, q_shift,
648
4.97k
                                         size_08);
649
22.7k
        } else {
650
22.7k
          (*ixheaacd_spec_to_overlapbuf)(ptr_overlap_buf, ptr_spec_coeff,
651
22.7k
                                         q_shift, size_08);
652
22.7k
        }
653
654
27.7k
        break;
655
238k
    }
656
657
238k
  } else {
658
51.5k
    WORD16 q_shift, max_scale;
659
51.5k
    WORD32 imdct_scale[8], i;
660
51.5k
    const WORD16 *short_window;
661
662
51.5k
    short_window = ptr_aac_dec_overlap_info
663
51.5k
                       ->ptr_short_window[(WORD32)ptr_ics_info->window_shape];
664
665
51.5k
    {
666
51.5k
      WORD32 expo;
667
668
51.5k
      if (1024 == ptr_ics_info->frame_length) {
669
14.7k
        expo = (*ixheaacd_calc_max_spectral_line)(ptr_spec_coeff, 1024) - 1;
670
671
14.7k
        expo = 5 - expo;
672
673
132k
        for (i = 0; i < MAX_WINDOWS; i++) {
674
118k
          imdct_scale[i] = ixheaacd_inverse_transform(
675
118k
              &ptr_spec_coeff[i * size_02], &scratch[i * size_02],
676
118k
              ptr_aac_tables->pstr_imdct_tables, expo, 128);
677
678
118k
        (*ixheaacd_post_twiddle)(&scratch[i * size_02],
679
118k
                                 &ptr_spec_coeff[i * size_02],
680
118k
                                 ptr_aac_tables->pstr_imdct_tables, 128);
681
118k
        }
682
14.7k
        max_scale = 31 + imdct_scale[0];
683
14.7k
        q_shift = max_scale + (-16 - 6 - 1);
684
36.7k
      } else {
685
36.7k
        expo = (*ixheaacd_calc_max_spectral_line)(ptr_spec_coeff, 960) - 1;
686
36.7k
        memcpy(scratch, ptr_spec_coeff, sizeof(WORD32) * 960);
687
688
330k
        for (i = 0; i < MAX_WINDOWS; i++) {
689
294k
            ixheaacd_inverse_transform_960(
690
294k
                &ptr_spec_coeff[i * size_02], &scratch[i * size_02],
691
294k
                ptr_aac_tables->pstr_imdct_tables, expo, &imdct_scale[i]);
692
693
294k
                imdct_scale[i] -= expo;
694
294k
        }
695
36.7k
        max_scale = 31 + imdct_scale[0];
696
36.7k
        q_shift = max_scale + (-16 - 6 - 1);
697
698
36.7k
      }
699
51.5k
    }
700
51.5k
    switch (ptr_aac_dec_overlap_info->window_sequence) {
701
0
      WORD32 overlap_buf_loc[64];
702
703
31.0k
      case EIGHT_SHORT_SEQUENCE:
704
33.0k
      case LONG_START_SEQUENCE:
705
706
33.0k
        (*ixheaacd_overlap_buf_out)((WORD32 *)out_samples, ptr_overlap_buf,
707
33.0k
                                    size_07, ch_fac);
708
709
33.0k
        if (1024 == ptr_ics_info->frame_length) {
710
11.3k
          (*ixheaacd_over_lap_add1)(&scratch[0], &ptr_overlap_buf[size_07],
711
11.3k
                                    ((WORD32*)out_samples + ch_fac * size_07),
712
11.3k
                                    ptr_short_window, q_shift, size_01, ch_fac);
713
21.7k
        } else {
714
21.7k
          ixheaacd_over_lap_add1_dec(&ptr_spec_coeff[0], &ptr_overlap_buf[size_07],
715
21.7k
                                     ((WORD32*)out_samples + ch_fac * size_07),
716
21.7k
                                     ptr_short_window, q_shift, size_01, ch_fac);
717
21.7k
        }
718
719
132k
        for (i = 0; i < 3; i++) {
720
99.0k
          WORD32 inc = (i * size_02);
721
722
99.0k
          if (1024 == ptr_ics_info->frame_length) {
723
33.9k
            (*ixheaacd_spec_to_overlapbuf)(overlap_buf_loc, &scratch[inc],
724
33.9k
                                           q_shift, size_01);
725
726
33.9k
            (*ixheaacd_over_lap_add1)(&scratch[size_02 + inc], overlap_buf_loc,
727
33.9k
                                      ((WORD32*)out_samples + ch_fac * (size_09 + inc)),
728
33.9k
                                      short_window, q_shift, size_01, ch_fac);
729
65.1k
          } else {
730
65.1k
            (*ixheaacd_spec_to_overlapbuf)(overlap_buf_loc, &ptr_spec_coeff[inc],
731
65.1k
                                           q_shift, size_01);
732
733
65.1k
            ixheaacd_over_lap_add1_dec(&ptr_spec_coeff[size_02 + inc], overlap_buf_loc,
734
65.1k
                                       ((WORD32*)out_samples + ch_fac * (size_09 + inc)),
735
65.1k
                                       short_window, q_shift, size_01, ch_fac);
736
65.1k
          }
737
99.0k
        }
738
739
33.0k
        if (1024 == ptr_ics_info->frame_length) {
740
11.3k
          (*ixheaacd_over_lap_add2)(&scratch[size_08], &scratch[size_06],
741
11.3k
                                    ptr_overlap_buf, short_window, q_shift,
742
11.3k
                                    size_01, 1);
743
21.7k
        } else {
744
21.7k
          ixheaacd_over_lap_add2_dec(&ptr_spec_coeff[size_08], &ptr_spec_coeff[size_06],
745
21.7k
                                     ptr_overlap_buf, short_window, q_shift,
746
21.7k
                                     size_01, 1);
747
21.7k
        }
748
749
750
33.0k
        (*ixheaacd_overlap_out_copy)(((WORD32 *)out_samples + ch_fac * size_15),
751
33.0k
                                     ptr_overlap_buf, &ptr_overlap_buf[size_01],
752
33.0k
                                     ch_fac, size_01);
753
754
33.0k
        ptr_ics_info->qshift_adj = 2;
755
756
33.0k
        break;
757
758
10.1k
      case ONLY_LONG_SEQUENCE:
759
18.5k
      case LONG_STOP_SEQUENCE:
760
761
18.5k
        if (1024 == ptr_ics_info->frame_length) {
762
763
3.46k
          ixheaacd_long_short_win_seq(
764
3.46k
              scratch, ptr_overlap_buf, (WORD32*)out_samples, short_window,
765
3.46k
              ptr_short_window, ptr_long_window, q_shift, ch_fac, size_01);
766
15.0k
        } else {
767
15.0k
          ixheaacd_long_short_win_seq(
768
15.0k
              ptr_spec_coeff, ptr_overlap_buf, (WORD32*)out_samples, short_window,
769
15.0k
              ptr_short_window, ptr_long_window, q_shift, ch_fac, size_01);
770
15.0k
        }
771
772
18.5k
        ptr_ics_info->qshift_adj = 2;
773
18.5k
        break;
774
51.5k
    }
775
776
206k
    for (i = 0; i < 3; i++) {
777
154k
      WORD32 inc = (i * size_02);
778
779
154k
      if (1024 == ptr_ics_info->frame_length) {
780
44.3k
        (*ixheaacd_over_lap_add2)(&scratch[size_10 + inc], &scratch[size_08 + inc],
781
44.3k
                                  &ptr_overlap_buf[size_01 + inc], short_window,
782
44.3k
                                  q_shift, size_01, 1);
783
110k
      } else {
784
110k
        ixheaacd_over_lap_add2_dec(&ptr_spec_coeff[size_10 + inc],
785
110k
                                   &ptr_spec_coeff[size_08 + inc],
786
110k
                                   &ptr_overlap_buf[size_01 + inc],
787
110k
                                   short_window, q_shift, size_01, 1);
788
110k
      }
789
154k
    }
790
791
51.5k
    if (1024 == ptr_ics_info->frame_length) {
792
14.7k
      (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[size_07], &scratch[size_14],
793
14.7k
                                     q_shift, size_01);
794
36.7k
    } else {
795
36.7k
      (*ixheaacd_spec_to_overlapbuf)(&ptr_overlap_buf[size_07], &ptr_spec_coeff[size_14],
796
36.7k
                                     q_shift, size_01);
797
36.7k
    }
798
51.5k
  }
799
800
289k
  ptr_aac_dec_overlap_info->window_shape = ptr_ics_info->window_shape;
801
289k
  ptr_aac_dec_overlap_info->window_sequence = ptr_ics_info->window_sequence;
802
289k
}
803
804
void ixheaacd_eld_dec_windowing(WORD32 *ptr_spect_coeff, const WORD16 *p_win,
805
                                WORD32 framesize, WORD16 q_shift,
806
                                WORD32 *p_overlap_buffer, const WORD16 stride,
807
41.2k
                                VOID *out_samples_t, WORD slot_element) {
808
41.2k
  int i = 0;
809
41.2k
  int loop_size;
810
41.2k
  WORD32 *ptr_z = ptr_spect_coeff;
811
812
41.2k
  WORD32 *ptr_out, *p_out2;
813
41.2k
  WORD32 *p_overlap_buffer32 = (WORD32 *)p_overlap_buffer;
814
41.2k
  WORD32 delay = framesize >> 2;
815
816
41.2k
  WORD16 *out_samples = (WORD16 *)out_samples_t - slot_element;
817
818
41.2k
  ptr_z = ptr_spect_coeff + delay;
819
41.2k
  p_win += delay;
820
41.2k
  ptr_out = p_overlap_buffer32;
821
822
41.2k
  q_shift = q_shift + 2;
823
824
41.2k
  if (q_shift >= 0) {
825
1.04M
    for (i = (delay)-1; i >= 0; i--) {
826
1.03M
      WORD32 win_op;
827
1.03M
      WORD32 win_ovadd_op;
828
1.03M
      WORD16 win_val;
829
830
1.03M
      win_val = *p_win++;
831
832
1.03M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
833
834
1.03M
      win_ovadd_op =
835
1.03M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
836
837
1.03M
      *out_samples = ixheaac_round16(ixheaac_shl32_sat(win_ovadd_op, 1));
838
1.03M
      out_samples += stride;
839
840
1.03M
      win_val = *p_win++;
841
842
1.03M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
843
844
1.03M
      win_ovadd_op =
845
1.03M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
846
847
1.03M
      *out_samples = ixheaac_round16(ixheaac_shl32_sat(win_ovadd_op, 1));
848
1.03M
      out_samples += stride;
849
1.03M
      win_val = *p_win++;
850
851
1.03M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
852
853
1.03M
      win_ovadd_op =
854
1.03M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
855
856
1.03M
      *out_samples = ixheaac_round16(ixheaac_shl32_sat(win_ovadd_op, 1));
857
1.03M
      out_samples += stride;
858
859
1.03M
      win_val = *p_win++;
860
861
1.03M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
862
863
1.03M
      win_ovadd_op =
864
1.03M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
865
866
1.03M
      *out_samples = ixheaac_round16(ixheaac_shl32_sat(win_ovadd_op, 1));
867
1.03M
      out_samples += stride;
868
1.03M
    }
869
870
8.52k
    p_out2 = p_overlap_buffer32;
871
8.52k
    loop_size = (((framesize * 3) - framesize) >> 2) - 1;
872
873
2.08M
    for (i = loop_size; i >= 0; i--) {
874
2.07M
      WORD32 win_op;
875
2.07M
      WORD16 win_val;
876
2.07M
      win_val = *p_win++;
877
2.07M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
878
2.07M
      *p_out2++ =
879
2.07M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
880
881
2.07M
      win_val = *p_win++;
882
2.07M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
883
2.07M
      *p_out2++ =
884
2.07M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
885
886
2.07M
      win_val = *p_win++;
887
2.07M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
888
2.07M
      *p_out2++ =
889
2.07M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
890
891
2.07M
      win_val = *p_win++;
892
2.07M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
893
2.07M
      *p_out2++ =
894
2.07M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
895
2.07M
    }
896
897
8.52k
    loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1;
898
788k
    for (i = loop_size; i >= 0; i--) {
899
779k
      WORD32 win_op;
900
779k
      WORD16 win_val;
901
902
779k
      win_val = *p_win++;
903
779k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
904
779k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
905
906
779k
      win_val = *p_win++;
907
779k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
908
779k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
909
910
779k
      win_val = *p_win++;
911
779k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
912
779k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
913
914
779k
      win_val = *p_win++;
915
779k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
916
779k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
917
779k
    }
918
32.7k
  } else {
919
32.7k
    q_shift = -q_shift;
920
921
4.09M
    for (i = (delay)-1; i >= 0; i--) {
922
4.06M
      WORD32 win_op;
923
4.06M
      WORD32 win_ovadd_op;
924
4.06M
      WORD16 win_val;
925
926
4.06M
      win_val = *p_win++;
927
4.06M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
928
929
4.06M
      win_ovadd_op =
930
4.06M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
931
932
4.06M
      *out_samples = ixheaac_round16(ixheaac_shl32(win_ovadd_op, 1));
933
4.06M
      out_samples += stride;
934
935
4.06M
      win_val = *p_win++;
936
4.06M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
937
938
4.06M
      win_ovadd_op =
939
4.06M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
940
941
4.06M
      *out_samples = ixheaac_round16(ixheaac_shl32(win_ovadd_op, 1));
942
4.06M
      out_samples += stride;
943
944
4.06M
      win_val = *p_win++;
945
4.06M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
946
947
4.06M
      win_ovadd_op =
948
4.06M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
949
950
4.06M
      *out_samples = ixheaac_round16(ixheaac_shl32(win_ovadd_op, 1));
951
4.06M
      out_samples += stride;
952
953
4.06M
      win_val = *p_win++;
954
4.06M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
955
956
4.06M
      win_ovadd_op =
957
4.06M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
958
959
4.06M
      *out_samples = ixheaac_round16(ixheaac_shl32(win_ovadd_op, 1));
960
4.06M
      out_samples += stride;
961
4.06M
    }
962
963
32.7k
    p_out2 = p_overlap_buffer32;
964
32.7k
    loop_size = (((framesize * 3) - framesize) >> 2) - 1;
965
966
8.16M
    for (i = loop_size; i >= 0; i--) {
967
8.13M
      WORD32 win_op;
968
8.13M
      WORD16 win_val;
969
8.13M
      win_val = *p_win++;
970
8.13M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
971
8.13M
      *p_out2++ =
972
8.13M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
973
974
8.13M
      win_val = *p_win++;
975
8.13M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
976
8.13M
      *p_out2++ =
977
8.13M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
978
979
8.13M
      win_val = *p_win++;
980
8.13M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
981
8.13M
      *p_out2++ =
982
8.13M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
983
984
8.13M
      win_val = *p_win++;
985
8.13M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
986
8.13M
      *p_out2++ =
987
8.13M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
988
8.13M
    }
989
32.7k
    loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1;
990
3.08M
    for (i = loop_size; i >= 0; i--) {
991
3.04M
      WORD32 win_op;
992
3.04M
      WORD16 win_val;
993
3.04M
      win_val = *p_win++;
994
3.04M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
995
3.04M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
996
997
3.04M
      win_val = *p_win++;
998
3.04M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
999
3.04M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1000
1001
3.04M
      win_val = *p_win++;
1002
3.04M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1003
3.04M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1004
1005
3.04M
      win_val = *p_win++;
1006
3.04M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1007
3.04M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1008
3.04M
    }
1009
32.7k
  }
1010
41.2k
}
1011
1012
void ixheaacd_eld_dec_windowing_32bit(WORD32 *ptr_spect_coeff,
1013
                                      const WORD16 *p_win, WORD32 framesize,
1014
                                      WORD16 q_shift, WORD32 *p_overlap_buffer,
1015
                                      const WORD16 stride, WORD32 *out_samples)
1016
1017
18.7k
{
1018
18.7k
  WORD32 i = 0;
1019
18.7k
  WORD32 loop_size;
1020
18.7k
  WORD32 *ptr_z = ptr_spect_coeff;
1021
1022
18.7k
  WORD32 *ptr_out, *p_out2;
1023
18.7k
  WORD32 *p_overlap_buffer32 = (WORD32 *)p_overlap_buffer;
1024
18.7k
  WORD32 delay = framesize >> 2;
1025
1026
18.7k
  ptr_z = ptr_spect_coeff + delay;
1027
18.7k
  p_win += delay;
1028
18.7k
  ptr_out = p_overlap_buffer32;
1029
1030
18.7k
  q_shift = q_shift + 2;
1031
1032
18.7k
  if (q_shift >= 0) {
1033
842k
    for (i = (delay)-1; i >= 0; i--) {
1034
835k
      WORD32 win_op;
1035
835k
      WORD16 win_val;
1036
1037
835k
      win_val = *p_win++;
1038
1039
835k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1040
1041
835k
      *out_samples =
1042
835k
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1043
1044
835k
      out_samples += stride;
1045
1046
835k
      win_val = *p_win++;
1047
1048
835k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1049
1050
835k
      *out_samples =
1051
835k
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1052
1053
835k
      out_samples += stride;
1054
835k
      win_val = *p_win++;
1055
1056
835k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1057
1058
835k
      *out_samples =
1059
835k
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1060
1061
835k
      out_samples += stride;
1062
1063
835k
      win_val = *p_win++;
1064
1065
835k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1066
1067
835k
      *out_samples =
1068
835k
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1069
1070
835k
      out_samples += stride;
1071
835k
    }
1072
1073
6.81k
    p_out2 = p_overlap_buffer32;
1074
6.81k
    loop_size = (((framesize * 3) - framesize) >> 2) - 1;
1075
1076
1.67M
    for (i = loop_size; i >= 0; i--) {
1077
1.67M
      WORD32 win_op;
1078
1.67M
      WORD16 win_val;
1079
1.67M
      win_val = *p_win++;
1080
1.67M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1081
1.67M
      *p_out2++ =
1082
1.67M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1083
1084
1.67M
      win_val = *p_win++;
1085
1.67M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1086
1.67M
      *p_out2++ =
1087
1.67M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1088
1089
1.67M
      win_val = *p_win++;
1090
1.67M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1091
1.67M
      *p_out2++ =
1092
1.67M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1093
1094
1.67M
      win_val = *p_win++;
1095
1.67M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1096
1.67M
      *p_out2++ =
1097
1.67M
          ixheaac_add32_sat(ixheaac_shl32(win_op, q_shift), *ptr_out++);
1098
1.67M
    }
1099
1100
6.81k
    loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1;
1101
633k
    for (i = loop_size; i >= 0; i--) {
1102
626k
      WORD32 win_op;
1103
626k
      WORD16 win_val;
1104
1105
626k
      win_val = *p_win++;
1106
626k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1107
626k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
1108
1109
626k
      win_val = *p_win++;
1110
626k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1111
626k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
1112
1113
626k
      win_val = *p_win++;
1114
626k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1115
626k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
1116
1117
626k
      win_val = *p_win++;
1118
626k
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1119
626k
      *p_out2++ = ixheaac_shl32(win_op, q_shift);
1120
626k
    }
1121
11.9k
  } else {
1122
11.9k
    q_shift = -q_shift;
1123
1124
1.50M
    for (i = (delay)-1; i >= 0; i--) {
1125
1.49M
      WORD32 win_op;
1126
1.49M
      WORD16 win_val;
1127
1128
1.49M
      win_val = *p_win++;
1129
1.49M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1130
1131
1.49M
      *out_samples =
1132
1.49M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1133
1134
1.49M
      out_samples += stride;
1135
1136
1.49M
      win_val = *p_win++;
1137
1.49M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1138
1139
1.49M
      *out_samples =
1140
1.49M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1141
1142
1.49M
      out_samples += stride;
1143
1144
1.49M
      win_val = *p_win++;
1145
1.49M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1146
1147
1.49M
      *out_samples =
1148
1.49M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1149
1150
1.49M
      out_samples += stride;
1151
1152
1.49M
      win_val = *p_win++;
1153
1.49M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1154
1155
1.49M
      *out_samples =
1156
1.49M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1157
1158
1.49M
      out_samples += stride;
1159
1.49M
    }
1160
1161
11.9k
    p_out2 = p_overlap_buffer32;
1162
11.9k
    loop_size = (((framesize * 3) - framesize) >> 2) - 1;
1163
1164
3.00M
    for (i = loop_size; i >= 0; i--) {
1165
2.99M
      WORD32 win_op;
1166
2.99M
      WORD16 win_val;
1167
2.99M
      win_val = *p_win++;
1168
2.99M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1169
2.99M
      *p_out2++ =
1170
2.99M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1171
1172
2.99M
      win_val = *p_win++;
1173
2.99M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1174
2.99M
      *p_out2++ =
1175
2.99M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1176
1177
2.99M
      win_val = *p_win++;
1178
2.99M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1179
2.99M
      *p_out2++ =
1180
2.99M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1181
1182
2.99M
      win_val = *p_win++;
1183
2.99M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1184
2.99M
      *p_out2++ =
1185
2.99M
          ixheaac_add32_sat(ixheaac_shr32(win_op, q_shift), *ptr_out++);
1186
2.99M
    }
1187
11.9k
    loop_size = ((((framesize << 2) - delay) - (framesize * 3)) >> 2) - 1;
1188
1.13M
    for (i = loop_size; i >= 0; i--) {
1189
1.12M
      WORD32 win_op;
1190
1.12M
      WORD16 win_val;
1191
1.12M
      win_val = *p_win++;
1192
1.12M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1193
1.12M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1194
1195
1.12M
      win_val = *p_win++;
1196
1.12M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1197
1.12M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1198
1199
1.12M
      win_val = *p_win++;
1200
1.12M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1201
1.12M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1202
1203
1.12M
      win_val = *p_win++;
1204
1.12M
      win_op = ixheaac_mult32x16in32(*ptr_z++, (win_val));
1205
1.12M
      *p_out2++ = ixheaac_shr32(win_op, q_shift);
1206
1.12M
    }
1207
11.9k
  }
1208
18.7k
}