Coverage Report

Created: 2025-09-17 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_hybrid_filt.c
Line
Count
Source
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 "ixheaac_type_def.h"
22
#include "ixheaacd_bitbuffer.h"
23
#include "ixheaacd_common_rom.h"
24
#include "ixheaacd_sbrdecsettings.h"
25
#include "ixheaacd_sbr_scale.h"
26
#include "ixheaacd_env_extr_part.h"
27
#include "ixheaacd_sbr_rom.h"
28
#include "ixheaacd_hybrid.h"
29
#include "ixheaacd_ps_dec.h"
30
#include "ixheaacd_config.h"
31
#include "ixheaacd_qmf_dec.h"
32
#include "ixheaacd_mps_polyphase.h"
33
#include "ixheaac_constants.h"
34
#include "ixheaacd_mps_struct_def.h"
35
#include "ixheaacd_mps_res_rom.h"
36
#include "ixheaacd_mps_aac_struct.h"
37
#include "ixheaacd_mps_dec.h"
38
#include "ixheaac_basic_ops32.h"
39
#include "ixheaac_basic_ops40.h"
40
#include "ixheaacd_mps_macro_def.h"
41
#include "ixheaacd_mps_basic_op.h"
42
43
extern const FLOAT32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER];
44
extern const FLOAT32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER];
45
46
extern const FLOAT32 ixheaacd_sine[8][8];
47
extern const FLOAT32 ixheaacd_cosine[8][8];
48
49
static VOID ixheaacd_mps_hyb_filt_type1(ia_cmplx_flt_struct *input,
50
                                        ia_cmplx_flt_struct output[8][MAX_TIME_SLOTS],
51
167k
                                        WORD32 num_samples, const FLOAT32 *filt_coeff) {
52
167k
  WORD32 i, n, q;
53
54
167k
  FLOAT32 in_re, in_im;
55
167k
  FLOAT32 coeff;
56
167k
  FLOAT32 acc_re_l, acc_re_h, acc_im_l, acc_im_h;
57
58
6.39M
  for (i = 0; i < num_samples; i++) {
59
6.22M
    FLOAT32 x0_re[13], x0_im[13], x0_1_re[8], x0_1_im[8];
60
6.22M
    FLOAT32 acc_re_val[8], acc_im_val[8];
61
87.2M
    for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) {
62
80.9M
      in_re = input[n + i].re;
63
80.9M
      in_im = input[n + i].im;
64
65
80.9M
      coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
66
67
80.9M
      x0_re[n] = coeff * in_re;
68
80.9M
      x0_im[n] = coeff * in_im;
69
80.9M
    }
70
71
6.22M
    x0_1_re[0] = x0_re[6];
72
6.22M
    x0_1_im[0] = x0_im[6];
73
74
6.22M
    x0_1_re[1] = x0_re[7];
75
6.22M
    x0_1_im[1] = x0_im[7];
76
77
6.22M
    x0_1_re[2] = x0_re[8] - x0_re[0];
78
6.22M
    x0_1_im[2] = x0_im[8] - x0_im[0];
79
80
6.22M
    x0_1_re[3] = x0_re[9] - x0_re[1];
81
6.22M
    x0_1_im[3] = x0_im[9] - x0_im[1];
82
83
6.22M
    x0_1_re[4] = x0_re[10] - x0_re[2];
84
6.22M
    x0_1_im[4] = x0_im[10] - x0_im[2];
85
86
6.22M
    x0_1_re[5] = x0_re[11] - x0_re[3];
87
6.22M
    x0_1_im[5] = x0_im[11] - x0_im[3];
88
89
6.22M
    x0_1_re[6] = x0_re[12] - x0_re[4];
90
6.22M
    x0_1_im[6] = x0_im[12] - x0_im[4];
91
92
6.22M
    x0_1_re[7] = -(x0_re[5]);
93
6.22M
    x0_1_im[7] = -(x0_im[5]);
94
95
6.22M
    acc_re_val[0] = x0_1_re[0];
96
6.22M
    acc_re_val[1] = x0_1_re[1] - x0_1_re[7];
97
6.22M
    acc_re_val[2] = x0_1_re[2] - x0_1_re[6];
98
6.22M
    acc_re_val[3] = x0_1_re[3] - x0_1_re[5];
99
6.22M
    acc_re_val[4] = x0_1_im[1] + x0_1_im[7];
100
6.22M
    acc_re_val[5] = x0_1_im[2] + x0_1_im[6];
101
6.22M
    acc_re_val[6] = x0_1_im[3] + x0_1_im[5];
102
6.22M
    acc_re_val[7] = x0_1_im[4];
103
104
6.22M
    acc_im_val[0] = x0_1_im[0];
105
6.22M
    acc_im_val[1] = x0_1_im[1] - x0_1_im[7];
106
6.22M
    acc_im_val[2] = x0_1_im[2] - x0_1_im[6];
107
6.22M
    acc_im_val[3] = x0_1_im[3] - x0_1_im[5];
108
6.22M
    acc_im_val[4] = x0_1_re[1] + x0_1_re[7];
109
6.22M
    acc_im_val[5] = x0_1_re[2] + x0_1_re[6];
110
6.22M
    acc_im_val[6] = x0_1_re[3] + x0_1_re[5];
111
6.22M
    acc_im_val[7] = x0_1_re[4];
112
113
31.1M
    for (q = 0; q < 4; q++) {
114
24.9M
      acc_re_l = 0;
115
24.9M
      acc_im_l = 0;
116
24.9M
      acc_re_h = 0;
117
24.9M
      acc_im_h = 0;
118
119
24.9M
      acc_re_l += acc_re_val[0];
120
24.9M
      acc_re_l += acc_re_val[1] * ixheaacd_cosine[q][1];
121
24.9M
      acc_re_l += acc_re_val[2] * ixheaacd_cosine[q][2];
122
24.9M
      acc_re_l += acc_re_val[3] * ixheaacd_cosine[q][3];
123
124
24.9M
      acc_re_h = acc_re_l;
125
126
24.9M
      acc_re_l -= acc_re_val[4] * ixheaacd_sine[q][1];
127
24.9M
      acc_re_l -= acc_re_val[5] * ixheaacd_sine[q][2];
128
24.9M
      acc_re_l -= acc_re_val[6] * ixheaacd_sine[q][3];
129
24.9M
      acc_re_l -= acc_re_val[7] * ixheaacd_sine[q][4];
130
131
24.9M
      acc_re_h = acc_re_h - (acc_re_l - acc_re_h);
132
133
24.9M
      acc_im_l += acc_im_val[0];
134
24.9M
      acc_im_l += acc_im_val[1] * ixheaacd_cosine[q][1];
135
24.9M
      acc_im_l += acc_im_val[2] * ixheaacd_cosine[q][2];
136
24.9M
      acc_im_l += acc_im_val[3] * ixheaacd_cosine[q][3];
137
138
24.9M
      acc_im_h = acc_im_l;
139
140
24.9M
      acc_im_l += acc_im_val[4] * ixheaacd_sine[q][1];
141
24.9M
      acc_im_l += acc_im_val[5] * ixheaacd_sine[q][2];
142
24.9M
      acc_im_l += acc_im_val[6] * ixheaacd_sine[q][3];
143
24.9M
      acc_im_l += acc_im_val[7] * ixheaacd_sine[q][4];
144
145
24.9M
      acc_im_h = acc_im_h - (acc_im_l - acc_im_h);
146
147
24.9M
      output[q][i].re = acc_re_l;
148
24.9M
      output[q][i].im = acc_im_l;
149
150
24.9M
      output[7 - q][i].re = acc_re_h;
151
24.9M
      output[7 - q][i].im = acc_im_h;
152
24.9M
    }
153
6.22M
  }
154
167k
}
155
156
static VOID ixheaacd_mps_hyb_filt_type2(ia_cmplx_flt_struct *input,
157
                                        ia_cmplx_flt_struct output[2][MAX_TIME_SLOTS],
158
335k
                                        WORD32 num_samples, const FLOAT32 *filt_coeff) {
159
335k
  WORD32 i, n;
160
161
335k
  FLOAT32 in_re, in_im;
162
335k
  FLOAT32 coeff;
163
335k
  FLOAT32 acc_re[2], acc_im[2];
164
165
12.7M
  for (i = 0; i < num_samples; i++) {
166
12.4M
    FLOAT32 x_0_re[13], x_0_im[13];
167
168
49.8M
    for (n = 1; n < 6; n = n + 2) {
169
37.3M
      in_re = input[n + i].re;
170
37.3M
      in_im = input[n + i].im;
171
172
37.3M
      in_re += input[12 - n + i].re;
173
37.3M
      in_im += input[12 - n + i].im;
174
175
37.3M
      coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
176
177
37.3M
      x_0_re[n] = coeff * in_re;
178
37.3M
      x_0_im[n] = coeff * in_im;
179
37.3M
    }
180
181
12.4M
    n = 6;
182
12.4M
    in_re = input[n + i].re;
183
12.4M
    in_im = input[n + i].im;
184
185
12.4M
    coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
186
187
12.4M
    x_0_re[n] = coeff * in_re;
188
12.4M
    x_0_im[n] = coeff * in_im;
189
190
12.4M
    x_0_re[1] = x_0_re[1] + x_0_re[3] + x_0_re[5];
191
12.4M
    x_0_im[1] = x_0_im[1] + x_0_im[3] + x_0_im[5];
192
193
12.4M
    acc_re[0] = x_0_re[6] + x_0_re[1];
194
12.4M
    acc_im[0] = x_0_im[6] + x_0_im[1];
195
196
12.4M
    acc_re[1] = x_0_re[6] - x_0_re[1];
197
12.4M
    acc_im[1] = x_0_im[6] - x_0_im[1];
198
199
12.4M
    output[0][i].re = acc_re[0];
200
12.4M
    output[0][i].im = acc_im[0];
201
202
12.4M
    output[1][i].re = acc_re[1];
203
12.4M
    output[1][i].im = acc_im[1];
204
12.4M
  }
205
335k
}
206
207
4.48k
VOID ixheaacd_mps_qmf_hybrid_analysis_init(ia_mps_hybrid_filt_struct *handle) {
208
4.48k
  memset(handle->lf_buffer, 0,
209
4.48k
         QMF_BANDS_TO_HYBRID * BUFFER_LEN_LF_MPS * sizeof(ia_cmplx_w32_struct));
210
4.48k
  memset(handle->hf_buffer, 0,
211
4.48k
         MAX_NUM_QMF_BANDS_MPS * BUFFER_LEN_HF_MPS * sizeof(ia_cmplx_flt_struct));
212
4.48k
}
213
214
VOID ixheaacd_mps_qmf_hybrid_analysis_no_pre_mix(
215
    ia_mps_hybrid_filt_struct *handle,
216
    ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS][MAX_TIME_SLOTS], WORD32 num_bands,
217
141k
    WORD32 num_samples, ia_cmplx_flt_struct v[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]) {
218
141k
  WORD32 lf_samples_shift;
219
141k
  WORD32 hf_samples_shift;
220
141k
  WORD32 lf_qmf_bands;
221
141k
  WORD32 k, n;
222
223
141k
  ia_cmplx_flt_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS];
224
225
141k
  lf_samples_shift = BUFFER_LEN_LF_MPS - num_samples;
226
141k
  hf_samples_shift = BUFFER_LEN_HF_MPS - num_samples;
227
228
141k
  lf_qmf_bands = QMF_BANDS_TO_HYBRID;
229
230
564k
  for (k = 0; k < lf_qmf_bands; k++) {
231
423k
    memmove(&handle->lf_buffer[k][0].re, &handle->lf_buffer[k][num_samples].re,
232
423k
            2 * lf_samples_shift * sizeof(FLOAT32));
233
423k
  }
234
235
564k
  for (k = 0; k < lf_qmf_bands; k++) {
236
423k
    memcpy(&handle->lf_buffer[k][lf_samples_shift].re, &in_qmf[k][0].re,
237
423k
           2 * num_samples * sizeof(FLOAT32));
238
423k
  }
239
240
8.75M
  for (k = 0; k < MAX_NUM_QMF_BANDS_SAC / 2 - lf_qmf_bands; k++) {
241
8.61M
    memmove(&handle->hf_buffer[k][0].re, &handle->hf_buffer[k][num_samples].re,
242
8.61M
            2 * hf_samples_shift * sizeof(FLOAT32));
243
8.61M
  }
244
245
4.77M
  for (k = 0; k < num_bands - lf_qmf_bands; k++) {
246
4.63M
    memcpy(&handle->hf_buffer[k][hf_samples_shift].re, &in_qmf[k + lf_qmf_bands][0].re,
247
4.63M
           2 * num_samples * sizeof(FLOAT32));
248
4.63M
  }
249
250
141k
  ixheaacd_mps_hyb_filt_type1(
251
141k
      &(handle->lf_buffer[0][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
252
141k
      ixheaacd_ia_mps_hyb_filter_coeff_8);
253
254
423k
  for (k = 0; k < 2; k++) {
255
10.3M
    for (n = 0; n < num_samples; n++) {
256
10.1M
      v[n][k].re = scratch[k + 6][n].re;
257
10.1M
      v[n][k + 2].re = scratch[k][n].re;
258
10.1M
      v[n][k + 4].re = scratch[k + 2][n].re;
259
10.1M
      v[n][k + 4].re += scratch[5 - k][n].re;
260
261
10.1M
      v[n][k].im = scratch[k + 6][n].im;
262
10.1M
      v[n][k + 2].im = scratch[k][n].im;
263
10.1M
      v[n][k + 4].im = scratch[k + 2][n].im;
264
10.1M
      v[n][k + 4].im += scratch[5 - k][n].im;
265
10.1M
    }
266
282k
  }
267
268
141k
  ixheaacd_mps_hyb_filt_type2(
269
141k
      &(handle->lf_buffer[1][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
270
141k
      ixheaacd_mps_hyb_filter_coeff_2);
271
272
423k
  for (k = 0; k < 2; k++) {
273
10.3M
    for (n = 0; n < num_samples; n++) {
274
10.1M
      v[n][k + 6].re = scratch[1 - k][n].re;
275
10.1M
      v[n][k + 6].im = scratch[1 - k][n].im;
276
10.1M
    }
277
282k
  }
278
279
141k
  ixheaacd_mps_hyb_filt_type2(
280
141k
      &(handle->lf_buffer[2][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
281
141k
      ixheaacd_mps_hyb_filter_coeff_2);
282
283
423k
  for (k = 0; k < 2; k++) {
284
10.3M
    for (n = 0; n < num_samples; n++) {
285
10.1M
      v[n][k + 8].re = scratch[k][n].re;
286
10.1M
      v[n][k + 8].im = scratch[k][n].im;
287
10.1M
    }
288
282k
  }
289
290
4.77M
  for (k = 0; k < num_bands - lf_qmf_bands; k++) {
291
161M
    for (n = 0; n < num_samples; n++) {
292
156M
      v[n][k + 10].re = (handle->hf_buffer[k][n + hf_samples_shift].re);
293
156M
      v[n][k + 10].im = (handle->hf_buffer[k][n + hf_samples_shift].im);
294
156M
    }
295
4.63M
  }
296
141k
}
297
298
VOID ixheaacd_mps_qmf_hybrid_analysis(
299
    ia_mps_hybrid_filt_struct *handle,
300
    ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS], WORD32 num_bands,
301
26.6k
    WORD32 num_samples, ia_cmplx_flt_struct hyb[MAX_HYBRID_BANDS_MPS][MAX_TIME_SLOTS]) {
302
26.6k
  WORD32 lf_samples_shift;
303
26.6k
  WORD32 hf_samples_shift;
304
26.6k
  WORD32 lf_qmf_bands;
305
26.6k
  WORD32 k, n;
306
307
26.6k
  ia_cmplx_flt_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS];
308
309
26.6k
  lf_samples_shift = BUFFER_LEN_LF_MPS - num_samples;
310
26.6k
  hf_samples_shift = BUFFER_LEN_HF_MPS - num_samples;
311
312
26.6k
  lf_qmf_bands = QMF_BANDS_TO_HYBRID;
313
314
106k
  for (k = 0; k < lf_qmf_bands; k++) {
315
80.0k
    memmove(&handle->lf_buffer[k][0].re, &handle->lf_buffer[k][num_samples].re,
316
80.0k
            2 * lf_samples_shift * sizeof(FLOAT32));
317
80.0k
  }
318
319
106k
  for (k = 0; k < lf_qmf_bands; k++) {
320
80.0k
    memcpy(&handle->lf_buffer[k][lf_samples_shift].re, &in_qmf[k][0].re,
321
80.0k
           2 * num_samples * sizeof(FLOAT32));
322
80.0k
  }
323
324
1.65M
  for (k = 0; k < MAX_NUM_QMF_BANDS_SAC / 2 - lf_qmf_bands; k++) {
325
1.62M
    memmove(&handle->hf_buffer[k][0].re, &handle->hf_buffer[k][num_samples].re,
326
1.62M
            2 * hf_samples_shift * sizeof(FLOAT32));
327
1.62M
  }
328
329
1.29M
  for (k = 0; k < num_bands - lf_qmf_bands; k++) {
330
1.26M
    memcpy(&handle->hf_buffer[k][hf_samples_shift].re, &in_qmf[k + lf_qmf_bands][0].re,
331
1.26M
           2 * num_samples * sizeof(FLOAT32));
332
1.26M
  }
333
334
26.6k
  ixheaacd_mps_hyb_filt_type1(
335
26.6k
      &(handle->lf_buffer[0][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
336
26.6k
      ixheaacd_ia_mps_hyb_filter_coeff_8);
337
338
80.0k
  for (k = 0; k < 2; k++) {
339
2.40M
    for (n = 0; n < num_samples; n++) {
340
2.35M
      hyb[k][n].re = scratch[k + 6][n].re;
341
2.35M
      hyb[k + 2][n].re = scratch[k][n].re;
342
2.35M
      hyb[k + 4][n].re = scratch[k + 2][n].re;
343
2.35M
      hyb[k + 4][n].re += scratch[5 - k][n].re;
344
345
2.35M
      hyb[k][n].im = scratch[k + 6][n].im;
346
2.35M
      hyb[k + 2][n].im = scratch[k][n].im;
347
2.35M
      hyb[k + 4][n].im = scratch[k + 2][n].im;
348
2.35M
      hyb[k + 4][n].im += scratch[5 - k][n].im;
349
2.35M
    }
350
53.3k
  }
351
352
26.6k
  ixheaacd_mps_hyb_filt_type2(
353
26.6k
      &(handle->lf_buffer[1][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
354
26.6k
      ixheaacd_mps_hyb_filter_coeff_2);
355
356
80.0k
  for (k = 0; k < 2; k++) {
357
2.40M
    for (n = 0; n < num_samples; n++) {
358
2.35M
      hyb[k + 6][n].re = scratch[1 - k][n].re;
359
2.35M
      hyb[k + 6][n].im = scratch[1 - k][n].im;
360
2.35M
    }
361
53.3k
  }
362
363
26.6k
  ixheaacd_mps_hyb_filt_type2(
364
26.6k
      &(handle->lf_buffer[2][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]), scratch, num_samples,
365
26.6k
      ixheaacd_mps_hyb_filter_coeff_2);
366
367
80.0k
  for (k = 0; k < 2; k++) {
368
2.40M
    for (n = 0; n < num_samples; n++) {
369
2.35M
      hyb[k + 8][n].re = scratch[k][n].re;
370
2.35M
      hyb[k + 8][n].im = scratch[k][n].im;
371
2.35M
    }
372
53.3k
  }
373
374
1.29M
  for (k = 0; k < num_bands - lf_qmf_bands; k++) {
375
1.26M
    memcpy(&hyb[k + 10][0].re, &handle->hf_buffer[k][hf_samples_shift].re,
376
1.26M
           2 * num_samples * sizeof(FLOAT32));
377
1.26M
  }
378
26.6k
}
379
380
VOID ixheaacd_mps_qmf_hybrid_synthesis(
381
    ia_cmplx_flt_struct hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS], WORD32 num_bands,
382
225k
    WORD32 num_samples, ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS]) {
383
225k
  WORD32 k, n;
384
385
8.40M
  for (n = 0; n < num_samples; n++) {
386
8.17M
    in_qmf[n][0].re = hyb[n][0].re;
387
8.17M
    in_qmf[n][0].im = hyb[n][0].im;
388
389
49.0M
    for (k = 1; k < 6; k++) {
390
40.8M
      in_qmf[n][0].re += hyb[n][k].re;
391
40.8M
      in_qmf[n][0].im += hyb[n][k].im;
392
40.8M
    }
393
394
8.17M
    in_qmf[n][1].re = hyb[n][6].re + hyb[n][7].re;
395
8.17M
    in_qmf[n][1].im = hyb[n][6].im + hyb[n][7].im;
396
397
8.17M
    in_qmf[n][2].re = hyb[n][8].re + hyb[n][9].re;
398
8.17M
    in_qmf[n][2].im = hyb[n][8].im + hyb[n][9].im;
399
400
8.17M
    memcpy(&in_qmf[n][3].re, &hyb[n][10].re, 2 * (num_bands - 3) * sizeof(FLOAT32));
401
8.17M
  }
402
225k
}
403
404
VOID ixheaacd_mps_fft(complex *out, LOOPINDEX idx, WORD32 nob,
405
2.41M
                      const ia_mps_dec_hybrid_tables_struct *hyb_tab) {
406
2.41M
  LOOPINDEX block_per_stage, stage_num, inner;
407
2.41M
  const WORD32 *cosine_array = hyb_tab->cosine_array;
408
2.41M
  const WORD32 *sine_array = hyb_tab->sine_array;
409
2.41M
  WORD32 index_1, index_2, index, tab_modifier;
410
2.41M
  WORD32 len, increment, i;
411
412
2.41M
  WORD32 cos_val;
413
2.41M
  WORD32 sin_val;
414
415
2.41M
  WORD16 index1;
416
2.41M
  WORD32 re_temp;
417
2.41M
  WORD32 im_temp;
418
2.41M
  WORD32 *out1_w32, *out2_w32;
419
420
2.41M
  len = idx;
421
2.41M
  i = 1;
422
2.41M
  increment = 0;
423
424
2.41M
  len = len >> 1;
425
2.41M
  index_1 = 0;
426
2.41M
  increment += 1;
427
428
2.41M
  index = 11 - increment;
429
2.41M
  tab_modifier = ixheaac_shl32(1, index);
430
431
2.41M
  out1_w32 = (WORD32 *)&out[index_1];
432
2.41M
  out2_w32 = (WORD32 *)&out[index_1 + 1];
433
434
12.0M
  for (block_per_stage = 0; block_per_stage < len; block_per_stage++) {
435
9.65M
    re_temp = out2_w32[0];
436
9.65M
    im_temp = out2_w32[1];
437
438
9.65M
    out2_w32[0] = (out1_w32[0] - re_temp);
439
9.65M
    out2_w32[1] = (out1_w32[1] - im_temp);
440
441
9.65M
    out1_w32[0] = (re_temp + out1_w32[0]);
442
9.65M
    out1_w32[1] = (im_temp + out1_w32[1]);
443
444
9.65M
    out1_w32 += 4;
445
9.65M
    out2_w32 += 4;
446
9.65M
  }
447
448
2.41M
  i <<= 1;
449
450
7.24M
  for (stage_num = 1; stage_num < nob; stage_num++) {
451
4.82M
    len = len >> 1;
452
4.82M
    index_1 = 0;
453
4.82M
    increment += 1;
454
455
4.82M
    index = 11 - increment;
456
4.82M
    tab_modifier = ixheaac_shl32(1, index);
457
458
12.0M
    for (block_per_stage = 0; block_per_stage < len; block_per_stage++) {
459
7.24M
      index_2 = index_1 + i;
460
461
7.24M
      out1_w32 = (WORD32 *)&out[index_1];
462
7.24M
      out2_w32 = (WORD32 *)&out[index_2];
463
464
7.24M
      re_temp = out1_w32[0];
465
7.24M
      im_temp = out1_w32[1];
466
467
7.24M
      out1_w32[0] = (re_temp + out2_w32[0]) >> 1;
468
7.24M
      out1_w32[1] = (im_temp + out2_w32[1]) >> 1;
469
470
7.24M
      out2_w32[0] = (re_temp - out2_w32[0]) >> 1;
471
7.24M
      out2_w32[1] = (im_temp - out2_w32[1]) >> 1;
472
473
7.24M
      index1 = tab_modifier;
474
475
7.24M
      out1_w32 += 2;
476
7.24M
      out2_w32 += 2;
477
478
19.3M
      for (inner = 0; inner < ((i - 1) << 1); inner += 2) {
479
12.0M
        cos_val = cosine_array[index1];
480
12.0M
        sin_val = sine_array[index1];
481
482
12.0M
        re_temp = ixheaacd_mps_mult32x16_shr_16(out2_w32[inner], cos_val) +
483
12.0M
                  ixheaacd_mps_mult32x16_shr_16(out2_w32[inner + 1], sin_val);
484
12.0M
        im_temp = ixheaacd_mps_mult32x16_shr_16(out2_w32[inner + 1], cos_val) -
485
12.0M
                  ixheaacd_mps_mult32x16_shr_16(out2_w32[inner], sin_val);
486
487
12.0M
        out1_w32[inner] >>= 1;
488
12.0M
        out1_w32[inner + 1] >>= 1;
489
490
12.0M
        out2_w32[inner] = out1_w32[inner] - re_temp;
491
12.0M
        out2_w32[inner + 1] = out1_w32[inner + 1] - im_temp;
492
493
12.0M
        out1_w32[inner] = (out1_w32[inner] + re_temp);
494
12.0M
        out1_w32[inner + 1] = (out1_w32[inner + 1] + im_temp);
495
496
12.0M
        index1 += tab_modifier;
497
12.0M
      }
498
499
7.24M
      index_1 += ixheaac_shl32(1, increment);
500
7.24M
    }
501
4.82M
    i <<= 1;
502
4.82M
  }
503
2.41M
}
504
505
VOID ixheaacd_8ch_filtering(const WORD32 *p_qmf_real, const WORD32 *p_qmf_imag,
506
                            WORD32 *m_hybrid_real, WORD32 *m_hybrid_imag,
507
2.41M
                            const ia_mps_dec_hybrid_tables_struct *hyb_tab) {
508
2.41M
  WORD32 n;
509
2.41M
  WORD32 real, imag;
510
2.41M
  const WORD16 tcos = COS_PI_BY_8;
511
2.41M
  const WORD16 tsin = SIN_PI_BY_8;
512
2.41M
  WORD32 cum[16];
513
2.41M
  WORD32 *p_complex;
514
2.41M
  const WORD16 *p8_13 = hyb_tab->p8_13;
515
516
2.41M
  real = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[4], p8_13[4]) +
517
2.41M
                         ixheaac_mult32x16in32(p_qmf_real[12], p8_13[12])),
518
2.41M
                        1);
519
2.41M
  imag = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[4], p8_13[4]) +
520
2.41M
                         ixheaac_mult32x16in32(p_qmf_imag[12], p8_13[12])),
521
2.41M
                        1);
522
523
2.41M
  cum[5] = imag - real;
524
2.41M
  cum[4] = -(imag + real);
525
526
2.41M
  real = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[3], p8_13[3]) +
527
2.41M
                         ixheaac_mult32x16in32(p_qmf_real[11], p8_13[11])),
528
2.41M
                        1);
529
2.41M
  imag = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[3], p8_13[3]) +
530
2.41M
                         ixheaac_mult32x16in32(p_qmf_imag[11], p8_13[11])),
531
2.41M
                        1);
532
533
2.41M
  cum[13] = ixheaac_shl32(
534
2.41M
      (ixheaac_mult32x16in32(imag, tcos) - ixheaac_mult32x16in32(real, tsin)), 1);
535
2.41M
  cum[12] = ixheaac_shl32(
536
2.41M
      -((ixheaac_mult32x16in32(imag, tsin) + ixheaac_mult32x16in32(real, tcos))), 1);
537
538
2.41M
  cum[2] = ixheaac_shl32(ixheaac_mult32x16in32((p_qmf_real[2] - p_qmf_real[10]), p8_13[10]), 1);
539
2.41M
  cum[3] = ixheaac_shl32(ixheaac_mult32x16in32((p_qmf_imag[2] - p_qmf_imag[10]), p8_13[2]), 1);
540
541
2.41M
  real = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[1], p8_13[1]) +
542
2.41M
                         ixheaac_mult32x16in32(p_qmf_real[9], p8_13[9])),
543
2.41M
                        1);
544
2.41M
  imag = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[1], p8_13[1]) +
545
2.41M
                         ixheaac_mult32x16in32(p_qmf_imag[9], p8_13[9])),
546
2.41M
                        1);
547
548
2.41M
  cum[11] = ixheaac_shl32(
549
2.41M
      (ixheaac_mult32x16in32(imag, tcos) + ixheaac_mult32x16in32(real, tsin)), 1);
550
2.41M
  cum[10] = ixheaac_shl32(
551
2.41M
      (ixheaac_mult32x16in32(imag, tsin) - ixheaac_mult32x16in32(real, tcos)), 1);
552
553
2.41M
  real = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[0], p8_13[0]) +
554
2.41M
                         ixheaac_mult32x16in32(p_qmf_real[8], p8_13[8])),
555
2.41M
                        1);
556
2.41M
  imag = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[0], p8_13[0]) +
557
2.41M
                         ixheaac_mult32x16in32(p_qmf_imag[8], p8_13[8])),
558
2.41M
                        1);
559
560
2.41M
  cum[7] = imag + real;
561
2.41M
  cum[6] = imag - real;
562
563
2.41M
  cum[15] = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[7], p8_13[14]) +
564
2.41M
                            ixheaac_mult32x16in32(p_qmf_real[7], p8_13[13])),
565
2.41M
                           1);
566
2.41M
  cum[14] = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_imag[7], p8_13[13]) -
567
2.41M
                            ixheaac_mult32x16in32(p_qmf_real[7], p8_13[14])),
568
2.41M
                           1);
569
570
2.41M
  cum[1] = ixheaac_shl32(
571
2.41M
      ixheaac_mult32x16in32(p_qmf_real[HYBRID_FILTER_DELAY], p8_13[HYBRID_FILTER_DELAY]), 1);
572
2.41M
  cum[0] = ixheaac_shl32(
573
2.41M
      ixheaac_mult32x16in32(p_qmf_imag[HYBRID_FILTER_DELAY], p8_13[HYBRID_FILTER_DELAY]), 1);
574
575
2.41M
  cum[9] = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[5], p8_13[13]) -
576
2.41M
                           ixheaac_mult32x16in32(p_qmf_imag[5], p8_13[14])),
577
2.41M
                          1);
578
2.41M
  cum[8] = ixheaac_shl32((ixheaac_mult32x16in32(p_qmf_real[5], p8_13[14]) +
579
2.41M
                           ixheaac_mult32x16in32(p_qmf_imag[5], p8_13[13])),
580
2.41M
                          1);
581
582
2.41M
  ixheaacd_mps_fft((complex *)cum, 8, 3, hyb_tab);
583
584
2.41M
  p_complex = cum;
585
586
21.7M
  for (n = 0; n < 8; n++) {
587
19.3M
    m_hybrid_imag[n] = *p_complex++;
588
19.3M
    m_hybrid_real[n] = *p_complex++;
589
19.3M
  }
590
2.41M
}
591
592
VOID ixheaacd_2ch_filtering(WORD32 *p_qmf, WORD32 *m_hybrid,
593
9.65M
                            const ia_mps_dec_hybrid_tables_struct *hyb_tab_ptr) {
594
9.65M
  WORD32 cum0, cum1;
595
9.65M
  WORD64 temp;
596
9.65M
  const WORD16 *p2_6 = hyb_tab_ptr->p2_6;
597
598
9.65M
  cum0 = (WORD32)p_qmf[HYBRID_FILTER_DELAY] >> 1;
599
600
9.65M
  temp = (WORD64)((WORD64)p2_6[0] * (WORD64)(p_qmf[1] + p_qmf[11]) +
601
9.65M
                  (WORD64)p2_6[1] * (WORD64)(p_qmf[3] + p_qmf[9]));
602
9.65M
  temp += (WORD64)p2_6[2] * (WORD64)(p_qmf[5] + p_qmf[7]);
603
9.65M
  cum1 = (WORD32)(temp >> 16);
604
605
9.65M
  m_hybrid[0] = cum0 + cum1;
606
9.65M
  m_hybrid[1] = cum0 - cum1;
607
9.65M
}
608
609
WORD32 ixheaacd_get_qmf_sb(
610
    WORD32 hybrid_subband,
611
3.42M
    const ia_mps_dec_mdct2qmf_table_struct *ixheaacd_mps_dec_mdct2qmf_table) {
612
3.42M
  return ixheaacd_mps_dec_mdct2qmf_table->hybrid_2_qmf[hybrid_subband];
613
3.42M
}
614
615
14.8k
VOID ixheaacd_init_ana_hyb_filt_bank(ia_mps_dec_thyb_filter_state_struct *hyb_state) {
616
14.8k
  WORD32 k, n;
617
618
59.5k
  for (k = 0; k < QMF_BANDS_TO_HYBRID; k++) {
619
3.79M
    for (n = 0; n < PROTO_LEN - 1 + MAX_TIME_SLOTS; n++) {
620
3.75M
      hyb_state->buffer_lf_real[k][n] = 0;
621
3.75M
      hyb_state->buffer_lf_imag[k][n] = 0;
622
3.75M
      hyb_state->qmf_lf_real[k][n] = 0;
623
3.75M
      hyb_state->qmf_lf_imag[k][n] = 0;
624
3.75M
    }
625
44.6k
  }
626
627
967k
  for (k = 0; k < MAX_NUM_QMF_BANDS; k++) {
628
75.2M
    for (n = 0; n < ((PROTO_LEN - 1) >> 1) + MAX_TIME_SLOTS; n++) {
629
74.3M
      hyb_state->buffer_hf_real[k][n] = 0;
630
74.3M
      hyb_state->buffer_hf_imag[k][n] = 0;
631
74.3M
    }
632
953k
  }
633
14.8k
}
634
635
VOID ixheaacd_apply_ana_hyb_filt_bank_create_x(
636
    ia_mps_dec_thyb_filter_state_struct *hyb_state, WORD32 *m_qmf_real, WORD32 *m_qmf_imag,
637
    WORD32 nr_bands, WORD32 nr_samples, WORD32 *m_hybrid_real, WORD32 *m_hybrid_imag,
638
77.4k
    const ia_mps_dec_hybrid_tables_struct *hyb_tab_ptr) {
639
77.4k
  WORD32 nr_samples_shift_lf;
640
77.4k
  WORD32 nr_qmf_bands_lf;
641
77.4k
  WORD32 k, n;
642
77.4k
  WORD32 time_slot;
643
644
77.4k
  WORD32 proto_len = (PROTO_LEN - 1) >> 1;
645
77.4k
  WORD32 val = nr_samples - proto_len;
646
77.4k
  WORD32 val_xhb = val * MAX_HYBRID_BANDS;
647
77.4k
  WORD32 loop_cnt, loop_cnt_x4;
648
77.4k
  WORD32 *p_qmf_real, *p_qmf_re, *p_qmf_imag, *p_qmf_im;
649
650
77.4k
  WORD32 m_temp_output_real[MAX_HYBRID_ONLY_BANDS_PER_QMF];
651
77.4k
  WORD32 m_temp_output_imag[MAX_HYBRID_ONLY_BANDS_PER_QMF];
652
653
77.4k
  WORD32 *p_hybrid_real = m_hybrid_real + 10;
654
77.4k
  WORD32 *p_hybrid_imag = m_hybrid_imag + 10;
655
656
77.4k
  WORD32 *p_hybrid_re, *p_hybrid_im;
657
658
77.4k
  nr_samples_shift_lf = BUFFER_LEN_LF - nr_samples;
659
660
77.4k
  nr_qmf_bands_lf = QMF_BANDS_TO_HYBRID;
661
77.4k
  loop_cnt = nr_bands - nr_qmf_bands_lf;
662
77.4k
  loop_cnt_x4 = (loop_cnt << 2);
663
664
309k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
665
12.5M
    for (n = 0; n < nr_samples_shift_lf; n++) {
666
12.3M
      hyb_state->buffer_lf_real[k][n] = hyb_state->buffer_lf_real[k][n + nr_samples];
667
12.3M
      hyb_state->buffer_lf_imag[k][n] = hyb_state->buffer_lf_imag[k][n + nr_samples];
668
669
12.3M
      hyb_state->qmf_lf_real[k][n] = hyb_state->qmf_lf_real[k][n + nr_samples];
670
12.3M
      hyb_state->qmf_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n + nr_samples];
671
12.3M
    }
672
232k
  }
673
674
77.4k
  p_qmf_real = m_qmf_real;
675
77.4k
  p_qmf_imag = m_qmf_imag;
676
309k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
677
232k
    p_qmf_re = p_qmf_real;
678
232k
    p_qmf_im = p_qmf_imag;
679
680
7.44M
    for (n = 0; n < nr_samples; n++) {
681
7.21M
      hyb_state->buffer_lf_real[k][n + nr_samples_shift_lf] = *p_qmf_re;
682
7.21M
      hyb_state->buffer_lf_imag[k][n + nr_samples_shift_lf] = *p_qmf_im;
683
684
7.21M
      hyb_state->qmf_lf_imag[k][n + nr_samples_shift_lf] = *p_qmf_im;
685
7.21M
      hyb_state->qmf_lf_real[k][n + nr_samples_shift_lf] = *p_qmf_re;
686
687
7.21M
      p_qmf_re += MAX_HYBRID_BANDS;
688
7.21M
      p_qmf_im += MAX_HYBRID_BANDS;
689
7.21M
    }
690
691
232k
    p_qmf_real++;
692
232k
    p_qmf_imag++;
693
232k
  }
694
695
77.4k
  p_qmf_real = m_qmf_real + nr_qmf_bands_lf + val_xhb;
696
77.4k
  p_qmf_imag = m_qmf_imag + nr_qmf_bands_lf + val_xhb;
697
698
542k
  for (n = 0; n < proto_len; n++) {
699
464k
    p_qmf_re = p_qmf_real;
700
464k
    p_qmf_im = p_qmf_imag;
701
702
464k
    p_hybrid_re = p_hybrid_real;
703
464k
    p_hybrid_im = p_hybrid_imag;
704
705
23.2M
    for (k = 0; k < loop_cnt; k++) {
706
22.7M
      *p_hybrid_re++ = hyb_state->buffer_hf_real[k][n];
707
22.7M
      *p_hybrid_im++ = hyb_state->buffer_hf_imag[k][n];
708
709
22.7M
      hyb_state->buffer_hf_real[k][n] = *p_qmf_re++;
710
22.7M
      hyb_state->buffer_hf_imag[k][n] = *p_qmf_im++;
711
22.7M
    }
712
464k
    p_qmf_real += MAX_HYBRID_BANDS;
713
464k
    p_qmf_imag += MAX_HYBRID_BANDS;
714
715
464k
    p_hybrid_real += MAX_HYBRID_BANDS;
716
464k
    p_hybrid_imag += MAX_HYBRID_BANDS;
717
464k
  }
718
719
77.4k
  p_qmf_real = m_qmf_real;
720
77.4k
  p_qmf_imag = m_qmf_imag;
721
722
77.4k
  p_hybrid_real = m_hybrid_real + 10;
723
77.4k
  p_hybrid_imag = m_hybrid_imag + 10;
724
725
77.4k
  k = proto_len * MAX_HYBRID_BANDS;
726
727
77.4k
  p_hybrid_re = p_hybrid_real + k;
728
77.4k
  p_hybrid_im = p_hybrid_imag + k;
729
730
77.4k
  p_qmf_re = p_qmf_real + nr_qmf_bands_lf;
731
77.4k
  p_qmf_im = p_qmf_imag + nr_qmf_bands_lf;
732
733
2.01M
  for (n = 0; n < val; n++) {
734
1.93M
    memcpy(p_hybrid_re, p_qmf_re, loop_cnt_x4);
735
1.93M
    memcpy(p_hybrid_im, p_qmf_im, loop_cnt_x4);
736
737
1.93M
    p_qmf_re += MAX_HYBRID_BANDS;
738
1.93M
    p_qmf_im += MAX_HYBRID_BANDS;
739
740
1.93M
    p_hybrid_re += MAX_HYBRID_BANDS;
741
1.93M
    p_hybrid_im += MAX_HYBRID_BANDS;
742
1.93M
  }
743
744
77.4k
  p_hybrid_real = m_hybrid_real;
745
77.4k
  p_hybrid_imag = m_hybrid_imag;
746
747
2.48M
  for (time_slot = 0; time_slot < nr_samples; time_slot++) {
748
2.40M
    p_hybrid_re = p_hybrid_real;
749
2.40M
    p_hybrid_im = p_hybrid_imag;
750
751
2.40M
    ixheaacd_8ch_filtering(
752
2.40M
        &(hyb_state->buffer_lf_real[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
753
2.40M
        &(hyb_state->buffer_lf_imag[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
754
2.40M
        m_temp_output_real, m_temp_output_imag, hyb_tab_ptr);
755
756
2.40M
    *p_hybrid_re++ = m_temp_output_real[6];
757
2.40M
    *p_hybrid_re++ = m_temp_output_real[7];
758
2.40M
    *p_hybrid_re++ = m_temp_output_real[0];
759
2.40M
    *p_hybrid_re++ = m_temp_output_real[1];
760
2.40M
    *p_hybrid_re++ = (m_temp_output_real[2] + m_temp_output_real[5]);
761
2.40M
    *p_hybrid_re++ = (m_temp_output_real[3] + m_temp_output_real[4]);
762
763
2.40M
    *p_hybrid_im++ = m_temp_output_imag[6];
764
2.40M
    *p_hybrid_im++ = m_temp_output_imag[7];
765
2.40M
    *p_hybrid_im++ = m_temp_output_imag[0];
766
2.40M
    *p_hybrid_im++ = m_temp_output_imag[1];
767
2.40M
    *p_hybrid_im++ = (m_temp_output_imag[2] + m_temp_output_imag[5]);
768
2.40M
    *p_hybrid_im++ = (m_temp_output_imag[3] + m_temp_output_imag[4]);
769
770
2.40M
    ixheaacd_2ch_filtering(
771
2.40M
        &(hyb_state->buffer_lf_real[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
772
2.40M
        m_temp_output_real, hyb_tab_ptr);
773
774
2.40M
    ixheaacd_2ch_filtering(
775
2.40M
        &(hyb_state->buffer_lf_imag[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
776
2.40M
        m_temp_output_imag, hyb_tab_ptr);
777
778
2.40M
    *p_hybrid_re++ = m_temp_output_real[1];
779
2.40M
    *p_hybrid_re++ = m_temp_output_real[0];
780
781
2.40M
    *p_hybrid_im++ = m_temp_output_imag[1];
782
2.40M
    *p_hybrid_im++ = m_temp_output_imag[0];
783
784
2.40M
    ixheaacd_2ch_filtering(
785
2.40M
        &(hyb_state->buffer_lf_real[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
786
2.40M
        m_temp_output_real, hyb_tab_ptr);
787
788
2.40M
    ixheaacd_2ch_filtering(
789
2.40M
        &(hyb_state->buffer_lf_imag[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
790
2.40M
        m_temp_output_imag, hyb_tab_ptr);
791
792
2.40M
    *p_hybrid_re++ = m_temp_output_real[0];
793
2.40M
    *p_hybrid_re++ = m_temp_output_real[1];
794
795
2.40M
    *p_hybrid_im++ = m_temp_output_imag[0];
796
2.40M
    *p_hybrid_im++ = m_temp_output_imag[1];
797
798
2.40M
    p_hybrid_real += MAX_HYBRID_BANDS;
799
2.40M
    p_hybrid_imag += MAX_HYBRID_BANDS;
800
2.40M
  }
801
802
77.4k
  p_qmf_real = m_qmf_real;
803
77.4k
  p_qmf_imag = m_qmf_imag;
804
309k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
805
232k
    p_qmf_re = p_qmf_real;
806
232k
    p_qmf_im = p_qmf_imag;
807
232k
    for (n = MAX_TIME_SLOTS; n < nr_samples_shift_lf; n++) {
808
0
      hyb_state->buffer_lf_real[k][n] = hyb_state->qmf_lf_real[k][n];
809
0
      hyb_state->buffer_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n];
810
0
    }
811
7.44M
    for (n = 0; n < nr_samples; n++) {
812
7.21M
      hyb_state->buffer_lf_real[k][n + nr_samples_shift_lf] = *p_qmf_re;
813
7.21M
      hyb_state->buffer_lf_imag[k][n + nr_samples_shift_lf] = *p_qmf_im;
814
815
7.21M
      p_qmf_re += MAX_HYBRID_BANDS;
816
7.21M
      p_qmf_im += MAX_HYBRID_BANDS;
817
7.21M
    }
818
232k
    p_qmf_real++;
819
232k
    p_qmf_imag++;
820
232k
  }
821
77.4k
}
822
823
VOID ixheaacd_apply_ana_hyb_filt_bank_merge_res_decor(
824
    ia_mps_dec_thyb_filter_state_struct *hyb_state, WORD32 *m_qmf_real, WORD32 *m_qmf_imag,
825
    WORD32 nr_bands, WORD32 nr_samples, WORD32 *m_hybrid_real, WORD32 *m_hybrid_imag,
826
302
    const ia_mps_dec_hybrid_tables_struct *hyb_tab_ptr) {
827
302
  WORD32 nr_samples_shift_lf;
828
302
  WORD32 nr_qmf_bands_lf;
829
302
  WORD32 k, n;
830
302
  WORD32 time_slot;
831
832
302
  WORD32 m_temp_output_real[MAX_HYBRID_ONLY_BANDS_PER_QMF];
833
302
  WORD32 m_temp_output_imag[MAX_HYBRID_ONLY_BANDS_PER_QMF];
834
835
302
  WORD32 proto_len = (PROTO_LEN - 1) >> 1;
836
302
  WORD32 val = nr_samples - proto_len;
837
302
  WORD32 loop_cnt;
838
839
302
  WORD32 *p_qmf_real = m_qmf_real;
840
302
  WORD32 *p_qmf_imag = m_qmf_imag;
841
842
302
  WORD32 *p_hybrid_real = m_hybrid_real + 10;
843
302
  WORD32 *p_hybrid_imag = m_hybrid_imag + 10;
844
302
  WORD32 *p_buffer_lf_real, *p_buffer_lf_imag;
845
846
302
  WORD32 nr_samples_x4 = nr_samples << 2;
847
848
302
  nr_samples_shift_lf = BUFFER_LEN_LF - nr_samples;
849
850
302
  nr_qmf_bands_lf = QMF_BANDS_TO_HYBRID;
851
302
  loop_cnt = nr_bands - nr_qmf_bands_lf;
852
853
1.20k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
854
56.6k
    for (n = 0; n < nr_samples_shift_lf; n++) {
855
55.7k
      hyb_state->buffer_lf_real[k][n] = hyb_state->buffer_lf_real[k][n + nr_samples];
856
55.7k
      hyb_state->buffer_lf_imag[k][n] = hyb_state->buffer_lf_imag[k][n + nr_samples];
857
858
55.7k
      hyb_state->qmf_lf_real[k][n] = hyb_state->qmf_lf_real[k][n + nr_samples];
859
55.7k
      hyb_state->qmf_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n + nr_samples];
860
55.7k
    }
861
906
  }
862
1.20k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
863
906
    WORD32 *qmf_real = p_qmf_real;
864
906
    WORD32 *qmf_imag = p_qmf_imag;
865
21.2k
    for (n = 0; n < nr_samples; n++) {
866
20.3k
      hyb_state->buffer_lf_real[k][n + nr_samples_shift_lf] = *qmf_real;
867
20.3k
      hyb_state->buffer_lf_imag[k][n + nr_samples_shift_lf] = *qmf_imag;
868
869
20.3k
      hyb_state->qmf_lf_imag[k][n + nr_samples_shift_lf] = *qmf_imag++;
870
20.3k
      hyb_state->qmf_lf_real[k][n + nr_samples_shift_lf] = *qmf_real++;
871
20.3k
    }
872
906
    p_qmf_real += MAX_TIME_SLOTS;
873
906
    p_qmf_imag += MAX_TIME_SLOTS;
874
906
  }
875
876
302
  p_qmf_real = m_qmf_real + nr_qmf_bands_lf * MAX_TIME_SLOTS;
877
302
  p_qmf_imag = m_qmf_imag + nr_qmf_bands_lf * MAX_TIME_SLOTS;
878
879
9.06k
  for (k = 0; k < loop_cnt; k++) {
880
8.75k
    WORD32 *qmf_real = p_qmf_real + val;
881
8.75k
    WORD32 *qmf_imag = p_qmf_imag + val;
882
883
8.75k
    WORD32 *hybrid_real = p_hybrid_real;
884
8.75k
    WORD32 *hybrid_imag = p_hybrid_imag;
885
886
61.3k
    for (n = 0; n < proto_len; n++) {
887
52.5k
      *hybrid_real = hyb_state->buffer_hf_real[k][n];
888
52.5k
      *hybrid_imag = hyb_state->buffer_hf_imag[k][n];
889
890
52.5k
      hyb_state->buffer_hf_real[k][n] = *qmf_real++;
891
52.5k
      hyb_state->buffer_hf_imag[k][n] = *qmf_imag++;
892
893
52.5k
      hybrid_real += MAX_HYBRID_BANDS;
894
52.5k
      hybrid_imag += MAX_HYBRID_BANDS;
895
52.5k
    }
896
897
8.75k
    p_qmf_real += MAX_TIME_SLOTS;
898
8.75k
    p_qmf_imag += MAX_TIME_SLOTS;
899
900
8.75k
    p_hybrid_real++;
901
8.75k
    p_hybrid_imag++;
902
8.75k
  }
903
904
302
  p_qmf_real = m_qmf_real + NR_QMF_BANDS_LFXTS;
905
302
  p_qmf_imag = m_qmf_imag + NR_QMF_BANDS_LFXTS;
906
907
302
  p_hybrid_real = m_hybrid_real + 10;
908
302
  p_hybrid_imag = m_hybrid_imag + 10;
909
910
9.06k
  for (k = 0; k < loop_cnt; k++) {
911
8.75k
    WORD32 *qmf_real = p_qmf_real;
912
8.75k
    WORD32 *qmf_imag = p_qmf_imag;
913
914
8.75k
    WORD32 *hybrid_real = p_hybrid_real + proto_len * MAX_HYBRID_BANDS;
915
8.75k
    WORD32 *hybrid_imag = p_hybrid_imag + proto_len * MAX_HYBRID_BANDS;
916
917
152k
    for (n = 0; n < val; n++) {
918
143k
      *hybrid_real = *qmf_real++;
919
143k
      *hybrid_imag = *qmf_imag++;
920
921
143k
      hybrid_real += MAX_HYBRID_BANDS;
922
143k
      hybrid_imag += MAX_HYBRID_BANDS;
923
143k
    }
924
925
8.75k
    p_qmf_real += MAX_TIME_SLOTS;
926
8.75k
    p_qmf_imag += MAX_TIME_SLOTS;
927
928
8.75k
    p_hybrid_real++;
929
8.75k
    p_hybrid_imag++;
930
8.75k
  }
931
932
302
  p_hybrid_real = m_hybrid_real;
933
302
  p_hybrid_imag = m_hybrid_imag;
934
935
7.07k
  for (time_slot = 0; time_slot < nr_samples; time_slot++) {
936
6.77k
    WORD32 *hybrid_real = p_hybrid_real;
937
6.77k
    WORD32 *hybrid_imag = p_hybrid_imag;
938
939
6.77k
    ixheaacd_8ch_filtering(
940
6.77k
        &(hyb_state->buffer_lf_real[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
941
6.77k
        &(hyb_state->buffer_lf_imag[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
942
6.77k
        m_temp_output_real, m_temp_output_imag, hyb_tab_ptr);
943
944
6.77k
    *hybrid_real++ = m_temp_output_real[6];
945
6.77k
    *hybrid_real++ = m_temp_output_real[7];
946
6.77k
    *hybrid_real++ = m_temp_output_real[0];
947
6.77k
    *hybrid_real++ = m_temp_output_real[1];
948
6.77k
    *hybrid_imag++ = (m_temp_output_imag[2] + m_temp_output_imag[5]);
949
6.77k
    *hybrid_real++ = (m_temp_output_real[3] + m_temp_output_real[4]);
950
951
6.77k
    *hybrid_imag++ = m_temp_output_imag[6];
952
6.77k
    *hybrid_imag++ = m_temp_output_imag[7];
953
6.77k
    *hybrid_imag++ = m_temp_output_imag[0];
954
6.77k
    *hybrid_imag++ = m_temp_output_imag[1];
955
6.77k
    *hybrid_real++ = (m_temp_output_real[2] + m_temp_output_real[5]);
956
6.77k
    *hybrid_imag++ = (m_temp_output_imag[3] + m_temp_output_imag[4]);
957
958
6.77k
    ixheaacd_2ch_filtering(
959
6.77k
        &(hyb_state->buffer_lf_real[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
960
6.77k
        m_temp_output_real, hyb_tab_ptr);
961
962
6.77k
    ixheaacd_2ch_filtering(
963
6.77k
        &(hyb_state->buffer_lf_imag[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
964
6.77k
        m_temp_output_imag, hyb_tab_ptr);
965
966
6.77k
    *hybrid_real++ = m_temp_output_real[1];
967
6.77k
    *hybrid_real++ = m_temp_output_real[0];
968
969
6.77k
    *hybrid_imag++ = m_temp_output_imag[0];
970
6.77k
    *hybrid_imag++ = m_temp_output_imag[1];
971
972
6.77k
    ixheaacd_2ch_filtering(
973
6.77k
        &(hyb_state->buffer_lf_real[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
974
6.77k
        m_temp_output_real, hyb_tab_ptr);
975
976
6.77k
    ixheaacd_2ch_filtering(
977
6.77k
        &(hyb_state->buffer_lf_imag[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
978
6.77k
        m_temp_output_imag, hyb_tab_ptr);
979
980
6.77k
    *hybrid_real++ = m_temp_output_real[0];
981
6.77k
    *hybrid_real++ = m_temp_output_real[1];
982
983
6.77k
    *hybrid_imag++ = m_temp_output_imag[0];
984
6.77k
    *hybrid_imag++ = m_temp_output_imag[1];
985
986
6.77k
    p_hybrid_real += MAX_HYBRID_BANDS;
987
6.77k
    p_hybrid_imag += MAX_HYBRID_BANDS;
988
6.77k
  }
989
990
302
  p_qmf_real = m_qmf_real;
991
302
  p_qmf_imag = m_qmf_imag;
992
993
302
  p_buffer_lf_real = &hyb_state->buffer_lf_real[0][nr_samples_shift_lf];
994
302
  p_buffer_lf_imag = &hyb_state->buffer_lf_imag[0][nr_samples_shift_lf];
995
996
1.20k
  for (k = 0; k < nr_qmf_bands_lf; k++) {
997
906
    for (n = MAX_TIME_SLOTS; n < nr_samples_shift_lf; n++) {
998
0
      hyb_state->buffer_lf_real[k][n] = hyb_state->qmf_lf_real[k][n];
999
0
      hyb_state->buffer_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n];
1000
0
    }
1001
906
    {
1002
906
      memcpy(p_buffer_lf_real, p_qmf_real, nr_samples_x4);
1003
906
      memcpy(p_buffer_lf_imag, p_qmf_imag, nr_samples_x4);
1004
906
    }
1005
906
    p_qmf_real += MAX_TIME_SLOTS;
1006
906
    p_qmf_imag += MAX_TIME_SLOTS;
1007
1008
906
    p_buffer_lf_real += BUFFER_LEN_LF;
1009
906
    p_buffer_lf_imag += BUFFER_LEN_LF;
1010
906
  }
1011
302
}
1012
1013
VOID ixheaacd_apply_ana_hyb_filt_bank_create_x_res(
1014
    ia_mps_dec_thyb_filter_state_struct *hyb_state, WORD32 *m_qmf_real, WORD32 *m_qmf_imag,
1015
    WORD32 nr_bands, WORD32 nr_samples, WORD32 *m_hybrid_real, WORD32 *m_hybrid_imag,
1016
    SIZE_T *indx, WORD32 res, WORD32 hyb_bands, WORD32 num_parameter_bands, WORD32 *counter,
1017
143
    const ia_mps_dec_hybrid_tables_struct *hyb_tab_ptr) {
1018
143
  WORD32 nr_samples_shift_lf;
1019
143
  WORD32 nr_qmf_bands_lf;
1020
143
  WORD32 k, n, qs;
1021
143
  WORD32 time_slot, ch_off_set;
1022
143
  SIZE_T *idx = indx;
1023
1024
143
  WORD32 proto_len = (PROTO_LEN - 1) >> 1;
1025
143
  WORD32 val = nr_samples - proto_len;
1026
1027
143
  WORD32 *p_qmf_real = m_qmf_real;
1028
143
  WORD32 *p_qmf_imag = m_qmf_imag;
1029
143
  WORD32 loop_cnt;
1030
1031
143
  WORD32 m_temp_output_real[MAX_HYBRID_ONLY_BANDS_PER_QMF];
1032
143
  WORD32 m_temp_output_imag[MAX_HYBRID_ONLY_BANDS_PER_QMF];
1033
1034
143
  WORD32 *p_hybrid_real = m_hybrid_real + 10;
1035
143
  WORD32 *p_hybrid_imag = m_hybrid_imag + 10;
1036
1037
143
  WORD32 *p_hybrid_re, *p_hybrid_im;
1038
1039
143
  WORD32 *p_buffer_lf_real, *p_buffer_lf_imag;
1040
1041
143
  WORD32 nr_samples_x4 = nr_samples << 2;
1042
1043
143
  nr_samples_shift_lf = BUFFER_LEN_LF - nr_samples;
1044
1045
143
  nr_qmf_bands_lf = QMF_BANDS_TO_HYBRID;
1046
143
  loop_cnt = nr_bands - nr_qmf_bands_lf;
1047
143
  ch_off_set = 0;
1048
1049
572
  for (k = 0; k < nr_qmf_bands_lf; k++) {
1050
27.8k
    for (n = 0; n < nr_samples_shift_lf; n++) {
1051
27.3k
      hyb_state->buffer_lf_real[k][n] = hyb_state->buffer_lf_real[k][n + nr_samples];
1052
27.3k
      hyb_state->buffer_lf_imag[k][n] = hyb_state->buffer_lf_imag[k][n + nr_samples];
1053
1054
27.3k
      hyb_state->qmf_lf_real[k][n] = hyb_state->qmf_lf_real[k][n + nr_samples];
1055
27.3k
      hyb_state->qmf_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n + nr_samples];
1056
27.3k
    }
1057
429
  }
1058
572
  for (k = 0; k < nr_qmf_bands_lf; k++) {
1059
429
    WORD32 *qmf_real = p_qmf_real;
1060
429
    WORD32 *qmf_imag = p_qmf_imag;
1061
1062
9.06k
    for (n = 0; n < nr_samples; n++) {
1063
8.64k
      hyb_state->buffer_lf_real[k][n + nr_samples_shift_lf] = *qmf_real;
1064
8.64k
      hyb_state->buffer_lf_imag[k][n + nr_samples_shift_lf] = *qmf_imag;
1065
1066
8.64k
      hyb_state->qmf_lf_imag[k][n + nr_samples_shift_lf] = *qmf_imag++;
1067
8.64k
      hyb_state->qmf_lf_real[k][n + nr_samples_shift_lf] = *qmf_real++;
1068
8.64k
    }
1069
429
    p_qmf_real += MAX_TIME_SLOTS;
1070
429
    p_qmf_imag += MAX_TIME_SLOTS;
1071
429
  }
1072
1073
143
  p_qmf_real = m_qmf_real + NR_QMF_BANDS_LFXTS;
1074
143
  p_qmf_imag = m_qmf_imag + NR_QMF_BANDS_LFXTS;
1075
1076
4.41k
  for (k = 0; k < loop_cnt; k++) {
1077
4.27k
    WORD32 *qmf_real = p_qmf_real + val;
1078
4.27k
    WORD32 *qmf_imag = p_qmf_imag + val;
1079
1080
4.27k
    p_hybrid_re = p_hybrid_real;
1081
4.27k
    p_hybrid_im = p_hybrid_imag;
1082
1083
29.9k
    for (n = 0; n < proto_len; n++) {
1084
25.6k
      *p_hybrid_re = hyb_state->buffer_hf_real[k][n];
1085
25.6k
      *p_hybrid_im = hyb_state->buffer_hf_imag[k][n];
1086
1087
25.6k
      hyb_state->buffer_hf_real[k][n] = *qmf_real++;
1088
25.6k
      hyb_state->buffer_hf_imag[k][n] = *qmf_imag++;
1089
1090
25.6k
      p_hybrid_re += MAX_HYBRID_BANDS;
1091
25.6k
      p_hybrid_im += MAX_HYBRID_BANDS;
1092
25.6k
    }
1093
4.27k
    p_qmf_real += MAX_TIME_SLOTS;
1094
4.27k
    p_qmf_imag += MAX_TIME_SLOTS;
1095
1096
4.27k
    p_hybrid_real++;
1097
4.27k
    p_hybrid_imag++;
1098
4.27k
  }
1099
1100
143
  p_qmf_real = m_qmf_real + NR_QMF_BANDS_LFXTS;
1101
143
  p_qmf_imag = m_qmf_imag + NR_QMF_BANDS_LFXTS;
1102
1103
143
  p_hybrid_real = m_hybrid_real + 10;
1104
143
  p_hybrid_imag = m_hybrid_imag + 10;
1105
1106
4.41k
  for (k = 0; k < loop_cnt; k++) {
1107
4.27k
    WORD32 *qmf_real = p_qmf_real;
1108
4.27k
    WORD32 *qmf_imag = p_qmf_imag;
1109
1110
4.27k
    p_hybrid_re = p_hybrid_real + proto_len * MAX_HYBRID_BANDS;
1111
4.27k
    p_hybrid_im = p_hybrid_imag + proto_len * MAX_HYBRID_BANDS;
1112
1113
64.1k
    for (n = 0; n < val; n++) {
1114
59.9k
      *p_hybrid_re = *qmf_real++;
1115
59.9k
      *p_hybrid_im = *qmf_imag++;
1116
1117
59.9k
      p_hybrid_re += MAX_HYBRID_BANDS;
1118
59.9k
      p_hybrid_im += MAX_HYBRID_BANDS;
1119
59.9k
    }
1120
4.27k
    p_qmf_real += MAX_TIME_SLOTS;
1121
4.27k
    p_qmf_imag += MAX_TIME_SLOTS;
1122
1123
4.27k
    p_hybrid_real++;
1124
4.27k
    p_hybrid_imag++;
1125
4.27k
  }
1126
1127
143
  if (res == 1 && (num_parameter_bands == 20 || num_parameter_bands == 28))
1128
21
    *counter = 3;
1129
122
  else {
1130
122
    idx = indx;
1131
2.69k
    for (qs = 0; qs < hyb_bands; qs++) {
1132
2.56k
      if (*idx++ >= (SIZE_T)res) {
1133
95
        *counter = qs;
1134
95
        qs = hyb_bands;
1135
95
      }
1136
2.56k
    }
1137
122
  }
1138
1139
143
  p_hybrid_real = m_hybrid_real;
1140
143
  p_hybrid_imag = m_hybrid_imag;
1141
3.02k
  for (time_slot = 0; time_slot < nr_samples; time_slot++) {
1142
2.88k
    idx = indx;
1143
2.88k
    p_hybrid_re = p_hybrid_real;
1144
2.88k
    p_hybrid_im = p_hybrid_imag;
1145
1146
2.88k
    ixheaacd_8ch_filtering(
1147
2.88k
        &(hyb_state->buffer_lf_real[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1148
2.88k
        &(hyb_state->buffer_lf_imag[0][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1149
2.88k
        m_temp_output_real, m_temp_output_imag, hyb_tab_ptr);
1150
1151
2.88k
    *p_hybrid_re++ = m_temp_output_real[6];
1152
2.88k
    *p_hybrid_re++ = m_temp_output_real[7];
1153
2.88k
    *p_hybrid_re++ = m_temp_output_real[0];
1154
1155
2.88k
    *p_hybrid_re++ = m_temp_output_real[1];
1156
1157
2.88k
    *p_hybrid_im++ = m_temp_output_imag[6];
1158
2.88k
    *p_hybrid_im++ = m_temp_output_imag[7];
1159
2.88k
    *p_hybrid_im++ = m_temp_output_imag[0];
1160
2.88k
    *p_hybrid_im++ = m_temp_output_imag[1];
1161
1162
2.88k
    if (*counter > 4) {
1163
1.22k
      *p_hybrid_re++ = (m_temp_output_real[2] + m_temp_output_real[5]);
1164
1.22k
      *p_hybrid_im++ = (m_temp_output_imag[2] + m_temp_output_imag[5]);
1165
1.22k
    }
1166
1167
2.88k
    if (*counter > 5) {
1168
1.07k
      *p_hybrid_re++ = (m_temp_output_real[3] + m_temp_output_real[4]);
1169
1.07k
      *p_hybrid_im++ = (m_temp_output_imag[3] + m_temp_output_imag[4]);
1170
1.07k
    }
1171
1172
2.88k
    ch_off_set = 6;
1173
2.88k
    p_hybrid_re = p_hybrid_real + ch_off_set;
1174
2.88k
    p_hybrid_im = p_hybrid_imag + ch_off_set;
1175
1176
2.88k
    ixheaacd_2ch_filtering(
1177
2.88k
        &(hyb_state->buffer_lf_real[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1178
2.88k
        m_temp_output_real, hyb_tab_ptr);
1179
1180
2.88k
    ixheaacd_2ch_filtering(
1181
2.88k
        &(hyb_state->buffer_lf_imag[1][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1182
2.88k
        m_temp_output_imag, hyb_tab_ptr);
1183
1184
2.88k
    *p_hybrid_re++ = m_temp_output_real[1];
1185
2.88k
    *p_hybrid_re++ = m_temp_output_real[0];
1186
1187
2.88k
    *p_hybrid_im++ = m_temp_output_imag[1];
1188
2.88k
    *p_hybrid_im++ = m_temp_output_imag[0];
1189
1190
2.88k
    ixheaacd_2ch_filtering(
1191
2.88k
        &(hyb_state->buffer_lf_real[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1192
2.88k
        m_temp_output_real, hyb_tab_ptr);
1193
1194
2.88k
    ixheaacd_2ch_filtering(
1195
2.88k
        &(hyb_state->buffer_lf_imag[2][time_slot + nr_samples_shift_lf + 1 - PROTO_LEN]),
1196
2.88k
        m_temp_output_imag, hyb_tab_ptr);
1197
1198
2.88k
    *p_hybrid_re++ = m_temp_output_real[0];
1199
2.88k
    *p_hybrid_re++ = m_temp_output_real[1];
1200
1201
2.88k
    *p_hybrid_im++ = m_temp_output_imag[0];
1202
2.88k
    *p_hybrid_im++ = m_temp_output_imag[1];
1203
1204
2.88k
    p_hybrid_real += MAX_HYBRID_BANDS;
1205
2.88k
    p_hybrid_imag += MAX_HYBRID_BANDS;
1206
2.88k
  }
1207
143
  p_qmf_real = m_qmf_real;
1208
143
  p_qmf_imag = m_qmf_imag;
1209
1210
143
  p_buffer_lf_real = &hyb_state->buffer_lf_real[0][nr_samples_shift_lf];
1211
143
  p_buffer_lf_imag = &hyb_state->buffer_lf_imag[0][nr_samples_shift_lf];
1212
1213
572
  for (k = 0; k < nr_qmf_bands_lf; k++) {
1214
429
    for (n = MAX_TIME_SLOTS; n < nr_samples_shift_lf; n++) {
1215
0
      hyb_state->buffer_lf_real[k][n] = hyb_state->qmf_lf_real[k][n];
1216
0
      hyb_state->buffer_lf_imag[k][n] = hyb_state->qmf_lf_imag[k][n];
1217
0
    }
1218
429
    {
1219
429
      memcpy(p_buffer_lf_real, p_qmf_real, nr_samples_x4);
1220
429
      memcpy(p_buffer_lf_imag, p_qmf_imag, nr_samples_x4);
1221
429
    }
1222
429
    p_qmf_real += MAX_TIME_SLOTS;
1223
429
    p_qmf_imag += MAX_TIME_SLOTS;
1224
1225
429
    p_buffer_lf_real += BUFFER_LEN_LF;
1226
429
    p_buffer_lf_imag += BUFFER_LEN_LF;
1227
429
  }
1228
143
}