Coverage Report

Created: 2025-08-26 06:53

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