Coverage Report

Created: 2026-03-21 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_calc_m1m2_common.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2023 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
*/
20
#include "ixheaac_type_def.h"
21
#include "ixheaacd_mps_struct_def.h"
22
#include "ixheaacd_mps_res_rom.h"
23
#include "ixheaacd_mps_aac_struct.h"
24
#include "ixheaac_constants.h"
25
#include "ixheaac_basic_ops32.h"
26
#include "ixheaac_basic_ops40.h"
27
#include "ixheaacd_bitbuffer.h"
28
#include "ixheaacd_common_rom.h"
29
#include "ixheaacd_sbrdecsettings.h"
30
#include "ixheaacd_sbr_scale.h"
31
#include "ixheaacd_env_extr_part.h"
32
#include "ixheaacd_sbr_rom.h"
33
#include "ixheaacd_hybrid.h"
34
#include "ixheaacd_ps_dec.h"
35
#include "ixheaac_error_standards.h"
36
#include "ixheaacd_mps_polyphase.h"
37
#include "ixheaacd_config.h"
38
#include "ixheaacd_qmf_dec.h"
39
#include "ixheaacd_mps_dec.h"
40
#include "ixheaacd_mps_macro_def.h"
41
#include "ixheaacd_mps_basic_op.h"
42
43
ATTR_NO_SANITIZE_INTEGER
44
VOID ixheaacd_get_matrix_inversion_weights(
45
    WORD32 iid_lf_ls_idx, WORD32 iid_rf_rs_idx, WORD32 prediction_mode, WORD32 c1, WORD32 c2,
46
21.5k
    WORD32 *weight1, WORD32 *weight2, ia_mps_dec_mps_tables_struct *ia_mps_dec_mps_table_ptr) {
47
21.5k
  WORD32 temp, temp_1, temp_2, temp_one;
48
21.5k
  WORD16 qtemp;
49
21.5k
  WORD32 w1 = ia_mps_dec_mps_table_ptr->m1_m2_table_ptr->cld_tab_2[iid_lf_ls_idx + 15];
50
21.5k
  WORD32 w2 = ia_mps_dec_mps_table_ptr->m1_m2_table_ptr->cld_tab_2[iid_rf_rs_idx + 15];
51
52
21.5k
  if (prediction_mode == 1) {
53
12.5k
    if (abs(c1) >= ONE_IN_Q15) {
54
6.56k
      c1 = ONE_IN_Q15;
55
6.56k
    } else if ((c1 < MINUS_ONE_IN_Q14) && (c1 > MINUS_ONE_IN_Q15)) {
56
0
      c1 = MINUS_ONE_IN_Q15 - (c1 << 1);
57
1.22k
    } else {
58
1.22k
      qtemp = 15;
59
1.22k
      temp = ixheaacd_mps_mult32(TWO_BY_THREE_Q15, c1, &qtemp, 15);
60
1.22k
      temp = ixheaacd_mps_convert_to_qn(temp, qtemp, 15);
61
1.22k
      c1 = ONE_BY_THREE_Q15 + temp;
62
1.22k
    }
63
64
12.7k
    if (abs(c2) >= ONE_IN_Q15) {
65
6.84k
      c2 = ONE_IN_Q15;
66
6.84k
    } else if ((c2 < MINUS_ONE_IN_Q14) && (c2 > MINUS_ONE_IN_Q15)) {
67
0
      c2 = MINUS_ONE_IN_Q15 - (c2 << 1);
68
951
    } else {
69
951
      qtemp = 15;
70
951
      temp = ixheaacd_mps_mult32(TWO_BY_THREE_Q15, c2, &qtemp, 15);
71
951
      temp = ixheaacd_mps_convert_to_qn(temp, qtemp, 15);
72
951
      qtemp = 15;
73
951
      temp = ixheaacd_mps_add32(temp, ONE_BY_THREE_Q15, &qtemp, 15);
74
951
      c2 = ixheaacd_mps_convert_to_qn(temp, qtemp, 15);
75
951
    }
76
13.7k
  } else {
77
13.7k
    WORD32 c1p, c2p;
78
13.7k
    WORD64 acc;
79
13.7k
    const WORD32 *cld_tab_3 = ia_mps_dec_mps_table_ptr->m1_m2_table_ptr->cld_tab_3;
80
13.7k
    const WORD32 *sqrt_tab = ia_mps_dec_mps_table_ptr->common_table_ptr->sqrt_tab;
81
82
13.7k
    c1p = cld_tab_3[c1 + 15];
83
13.7k
    c2p = cld_tab_3[c2 + 15];
84
85
13.7k
    acc = (WORD64)((WORD64)c1p * (WORD64)c2p);
86
13.7k
    acc >>= 15;
87
13.7k
    temp = (WORD32)acc;
88
13.7k
    temp_1 = (ONE_IN_Q15 + c2p) << 1;
89
13.7k
    acc += temp_1;
90
13.7k
    temp_2 = (WORD32)acc;
91
92
13.7k
    temp = ixheaacd_mps_div_32(temp, temp_2, &qtemp);
93
94
13.7k
    c1 = ixheaacd_mps_sqrt(temp, &qtemp, sqrt_tab);
95
13.7k
    c1 = ixheaacd_mps_convert_to_qn(c1, qtemp, 15);
96
97
13.7k
    temp_2 = ixheaac_add32_sat(c1p, temp_1);
98
13.7k
    temp = ixheaacd_mps_div_32(c1p, temp_2, &qtemp);
99
13.7k
    c2 = ixheaacd_mps_sqrt(temp, &qtemp, sqrt_tab);
100
13.7k
    c2 = ixheaacd_mps_convert_to_qn(c2, qtemp, 15);
101
13.7k
  }
102
21.5k
  temp_one = ONE_IN_Q15;
103
21.5k
  if (ixheaac_norm32(w1) == 0) {
104
673
    temp_one = ONE_IN_Q14;
105
673
    w1 = w1 >> 1;
106
673
  }
107
21.5k
  temp_1 = temp_one + w1;
108
21.5k
  temp_2 = ixheaacd_mps_mult32_shr_15(c1, w1);
109
21.5k
  *weight1 = ixheaacd_mps_div32_in_q15(temp_2, temp_1);
110
111
21.5k
  if (ixheaac_norm32(w2) == 0) {
112
907
    temp_one = ONE_IN_Q14;
113
907
    w2 = w2 >> 1;
114
907
  }
115
21.5k
  temp_1 = temp_one + w2;
116
21.5k
  temp_2 = ixheaacd_mps_mult32_shr_15(c2, w2);
117
21.5k
  *weight2 = ixheaacd_mps_div32_in_q15(temp_2, temp_1);
118
21.5k
}
119
120
VOID ixheaacd_invert_matrix(WORD32 weight1, WORD32 weight2, WORD32 h_real[][2],
121
                            WORD32 h_imag[][2],
122
21.5k
                            const ia_mps_dec_common_tables_struct *common_tab_ptr) {
123
21.5k
  WORD32 h11_f_real, h12_f_real, h21_f_real, h22_f_real;
124
21.5k
  WORD32 h11_f_imag, h12_f_imag, h21_f_imag, h22_f_imag;
125
126
21.5k
  WORD32 inv_norm_real, inv_norm_imag, inv_norm;
127
128
21.5k
  WORD32 len1, len2;
129
21.5k
  WORD16 q_len1 = 0, q_len2 = 0;
130
131
21.5k
  WORD64 acc1, acc2;
132
133
21.5k
  len1 = ixheaacd_mps_sqrt(
134
21.5k
      (ONE_IN_Q15 - (weight1 << 1) + ixheaacd_mps_mult32_shr_n(weight1, weight1, 14)), &q_len1,
135
21.5k
      common_tab_ptr->sqrt_tab);
136
137
21.5k
  len2 = ixheaacd_mps_sqrt(
138
21.5k
      (ONE_IN_Q15 - (weight2 << 1) + ixheaacd_mps_mult32_shr_n(weight2, weight2, 14)), &q_len2,
139
21.5k
      common_tab_ptr->sqrt_tab);
140
141
21.5k
  len1 = ixheaacd_mps_convert_to_qn(len1, q_len1, 15);
142
21.5k
  len2 = ixheaacd_mps_convert_to_qn(len2, q_len2, 15);
143
144
21.5k
  h11_f_real = ixheaacd_mps_div32_in_q15((ONE_IN_Q15 - weight1), len1);
145
146
21.5k
  h11_f_imag = ixheaacd_mps_div32_in_q15(weight1, len1);
147
148
21.5k
  h22_f_imag = ixheaac_negate32_sat(ixheaacd_mps_div32_in_q15(weight2, len2));
149
150
21.5k
  h12_f_real = 0;
151
152
21.5k
  h12_f_imag = ixheaacd_mps_mult32_shr_15(h22_f_imag, ONE_BY_SQRT_3_Q15);
153
154
21.5k
  h21_f_real = 0;
155
156
21.5k
  h21_f_imag = ixheaacd_mps_mult32_shr_15(h11_f_imag, -(ONE_BY_SQRT_3_Q15));
157
158
21.5k
  h22_f_real = ixheaacd_mps_div32_in_q15((ONE_IN_Q15 - weight2), len2);
159
160
21.5k
  acc1 =
161
21.5k
      (WORD64)((WORD64)h11_f_real * (WORD64)h22_f_real - (WORD64)h11_f_imag * (WORD64)h22_f_imag);
162
21.5k
  acc1 >>= 15;
163
164
21.5k
  acc2 =
165
21.5k
      (WORD64)((WORD64)h12_f_real * (WORD64)h21_f_real - (WORD64)h12_f_imag * (WORD64)h21_f_imag);
166
21.5k
  acc2 >>= 15;
167
21.5k
  inv_norm_real = (WORD32)(acc1 - acc2);
168
169
21.5k
  acc1 =
170
21.5k
      (WORD64)((WORD64)h11_f_real * (WORD64)h22_f_imag + (WORD64)h11_f_imag * (WORD64)h22_f_real);
171
21.5k
  acc1 >>= 15;
172
173
21.5k
  acc2 =
174
21.5k
      (WORD64)((WORD64)h12_f_real * (WORD64)h21_f_imag + (WORD64)h12_f_imag * (WORD64)h21_f_real);
175
21.5k
  acc2 >>= 15;
176
21.5k
  inv_norm_imag = (WORD32)(acc1 + acc2);
177
178
21.5k
  acc1 = (WORD64)((WORD64)inv_norm_real * (WORD64)inv_norm_real +
179
21.5k
                  (WORD64)inv_norm_imag * (WORD64)inv_norm_imag);
180
21.5k
  acc1 >>= 15;
181
21.5k
  inv_norm = (WORD32)acc1;
182
183
21.5k
  inv_norm_real = ixheaacd_mps_div32_in_q15(inv_norm_real, inv_norm);
184
21.5k
  inv_norm_imag = -(ixheaacd_mps_div32_in_q15(inv_norm_imag, inv_norm));
185
186
21.5k
  acc1 = (WORD64)((WORD64)h22_f_real * (WORD64)inv_norm_real -
187
21.5k
                  (WORD64)h22_f_imag * (WORD64)inv_norm_imag);
188
21.5k
  acc1 >>= 15;
189
21.5k
  h_real[0][0] = (WORD32)acc1;
190
191
21.5k
  acc1 = (WORD64)((WORD64)h22_f_real * (WORD64)inv_norm_imag +
192
21.5k
                  (WORD64)h22_f_imag * (WORD64)inv_norm_real);
193
21.5k
  acc1 >>= 15;
194
21.5k
  h_imag[0][0] = (WORD32)acc1;
195
196
21.5k
  acc1 = (WORD64)((WORD64)h12_f_imag * (WORD64)inv_norm_imag -
197
21.5k
                  (WORD64)h12_f_real * (WORD64)inv_norm_real);
198
21.5k
  acc1 >>= 15;
199
21.5k
  h_real[0][1] = (WORD32)acc1;
200
201
21.5k
  acc1 = (WORD64)((WORD64)h12_f_real * (WORD64)inv_norm_imag +
202
21.5k
                  (WORD64)h12_f_imag * (WORD64)inv_norm_real);
203
21.5k
  acc1 = -(acc1 >> 15);
204
21.5k
  h_imag[0][1] = (WORD32)acc1;
205
206
21.5k
  acc1 = (WORD64)((WORD64)h21_f_imag * (WORD64)inv_norm_imag -
207
21.5k
                  (WORD64)h21_f_real * (WORD64)inv_norm_real);
208
21.5k
  acc1 >>= 15;
209
21.5k
  h_real[1][0] = (WORD32)acc1;
210
211
21.5k
  acc1 = (WORD64)((WORD64)h21_f_real * (WORD64)inv_norm_imag +
212
21.5k
                  (WORD64)h21_f_imag * (WORD64)inv_norm_real);
213
21.5k
  acc1 = -(acc1 >> 15);
214
21.5k
  h_imag[1][0] = (WORD32)acc1;
215
216
21.5k
  acc1 = (WORD64)((WORD64)h11_f_real * (WORD64)inv_norm_real -
217
21.5k
                  (WORD64)h11_f_imag * (WORD64)inv_norm_imag);
218
21.5k
  acc1 >>= 15;
219
21.5k
  h_real[1][1] = (WORD32)acc1;
220
221
21.5k
  acc1 = (WORD64)((WORD64)h11_f_real * (WORD64)inv_norm_imag +
222
21.5k
                  (WORD64)h11_f_imag * (WORD64)inv_norm_real);
223
21.5k
  acc1 >>= 15;
224
21.5k
  h_imag[1][1] = (WORD32)acc1;
225
21.5k
}
226
227
9.60k
WORD32 ixheaacd_dequant_icc_band(WORD32 iccband, WORD32 cldband) {
228
9.60k
  if (iccband < 6) {
229
7.92k
    return iccband;
230
7.92k
  }
231
1.68k
  if (iccband == 6) {
232
564
    if (cldband > 9 && cldband < 21) {
233
235
      switch (cldband) {
234
23
        case 10:
235
48
        case 20:
236
48
          return 10;
237
9
        case 11:
238
22
        case 19:
239
22
          return 11;
240
41
        case 12:
241
50
        case 18:
242
50
          return 12;
243
6
        case 13:
244
20
        case 17:
245
20
          return 13;
246
18
        case 14:
247
30
        case 16:
248
30
          return 14;
249
65
        case 15:
250
65
          return 15;
251
0
        default:
252
0
          return iccband;
253
235
      }
254
329
    } else {
255
329
      return iccband;
256
329
    }
257
564
  }
258
1.11k
  if (7 == iccband) {
259
1.11k
    if (cldband > 7 && cldband < 23) {
260
553
      switch (cldband) {
261
28
        case 8:
262
72
        case 22:
263
72
          return 8;
264
41
        case 9:
265
101
        case 21:
266
101
          return 9;
267
32
        case 10:
268
67
        case 20:
269
67
          return 10;
270
7
        case 11:
271
55
        case 19:
272
55
          return 11;
273
33
        case 12:
274
59
        case 18:
275
59
          return 12;
276
29
        case 13:
277
68
        case 17:
278
68
          return 13;
279
51
        case 14:
280
76
        case 16:
281
76
          return 14;
282
55
        case 15:
283
55
          return 15;
284
0
        default:
285
0
          return iccband;
286
553
      }
287
565
    } else {
288
565
      return iccband;
289
565
    }
290
1.11k
  } else {
291
0
    return iccband;
292
0
  }
293
1.11k
}
294
295
1.94M
WORD32 ixheaacd_dequant_cld_band(WORD32 cld) {
296
1.94M
  switch (cld) {
297
35.5k
    case -4915200:
298
35.5k
      return 0;
299
1.18k
    case -1474560:
300
1.18k
      return 1;
301
1.11k
    case -1310720:
302
1.11k
      return 2;
303
2.02k
    case -1146880:
304
2.02k
      return 3;
305
1.08k
    case -983040:
306
1.08k
      return 4;
307
3.28k
    case -819200:
308
3.28k
      return 5;
309
1.06k
    case -720896:
310
1.06k
      return 6;
311
3.20k
    case -622592:
312
3.20k
      return 7;
313
1.17k
    case -524288:
314
1.17k
      return 8;
315
4.78k
    case -425984:
316
4.78k
      return 9;
317
16.4k
    case -327680:
318
16.4k
      return 10;
319
119k
    case -262144:
320
119k
      return 11;
321
24.0k
    case -196608:
322
24.0k
      return 12;
323
5.89k
    case -131072:
324
5.89k
      return 13;
325
10.8k
    case -65536:
326
10.8k
      return 14;
327
188k
    case 0:
328
188k
      return 15;
329
10.0k
    case 65536:
330
10.0k
      return 16;
331
33.0k
    case 131072:
332
33.0k
      return 17;
333
14.0k
    case 196608:
334
14.0k
      return 18;
335
7.35k
    case 262144:
336
7.35k
      return 19;
337
42.6k
    case 327680:
338
42.6k
      return 20;
339
11.7k
    case 425984:
340
11.7k
      return 21;
341
7.99k
    case 524288:
342
7.99k
      return 22;
343
4.28k
    case 622592:
344
4.28k
      return 23;
345
2.58k
    case 720896:
346
2.58k
      return 24;
347
4.01k
    case 819200:
348
4.01k
      return 25;
349
1.20k
    case 983040:
350
1.20k
      return 26;
351
6.16k
    case 1146880:
352
6.16k
      return 27;
353
1.87k
    case 1310720:
354
1.87k
      return 28;
355
2.14k
    case 1474560:
356
2.14k
      return 29;
357
1.38M
    case 4915200:
358
1.38M
      return 30;
359
0
    default:
360
0
      return 0;
361
1.94M
  }
362
1.94M
}
363
364
VOID ixheaacd_param_2_umx_ps_core_tables(
365
    WORD32 cld[MAX_PARAMETER_BANDS], WORD32 icc[MAX_PARAMETER_BANDS], WORD32 num_ott_bands,
366
    WORD32 res_bands, WORD32 h11[MAX_PARAMETER_BANDS], WORD32 h12[MAX_PARAMETER_BANDS],
367
    WORD32 h21[MAX_PARAMETER_BANDS], WORD32 h22[MAX_PARAMETER_BANDS],
368
    WORD32 h12_res[MAX_PARAMETER_BANDS], WORD32 h22_res[MAX_PARAMETER_BANDS],
369
    WORD16 c_l[MAX_PARAMETER_BANDS], WORD16 c_r[MAX_PARAMETER_BANDS],
370
58.7k
    const ia_mps_dec_m1_m2_tables_struct *ixheaacd_mps_dec_m1_m2_tables) {
371
58.7k
  WORD32 band;
372
58.7k
  WORD32 quant_band_cld, quant_band_icc;
373
374
1.03M
  for (band = 0; band < num_ott_bands; band++) {
375
974k
    quant_band_cld = ixheaacd_dequant_cld_band(cld[band]);
376
377
974k
    c_l[band] = (WORD16)ixheaacd_mps_dec_m1_m2_tables->c_l_table[quant_band_cld];
378
974k
    c_r[band] = (WORD16)ixheaacd_mps_dec_m1_m2_tables->c_l_table[30 - quant_band_cld];
379
974k
  }
380
381
1.03M
  for (band = 0; band < num_ott_bands; band++) {
382
974k
    if (band < res_bands) {
383
9.60k
      quant_band_cld = ixheaacd_dequant_cld_band(cld[band]);
384
9.60k
      quant_band_icc = ixheaacd_dequant_icc_band(icc[band], quant_band_cld);
385
386
9.60k
      h11[band] = ixheaacd_mps_dec_m1_m2_tables->cos_table[quant_band_icc][quant_band_cld];
387
9.60k
      h11[band] = ixheaacd_mps_mult32_shr_15(h11[band], c_l[band]);
388
9.60k
      h21[band] = ixheaacd_mps_dec_m1_m2_tables->cos_table[quant_band_icc][30 - quant_band_cld];
389
9.60k
      h21[band] = ixheaacd_mps_mult32_shr_15(h21[band], c_r[band]);
390
391
9.60k
      h12[band] = 0;
392
9.60k
      h22[band] = 0;
393
9.60k
      h12_res[band] = ONE_IN_Q15;
394
9.60k
      h22_res[band] = MINUS_ONE_IN_Q15;
395
964k
    } else {
396
964k
      quant_band_cld = ixheaacd_dequant_cld_band(cld[band]);
397
964k
      if (quant_band_cld < 0 || quant_band_cld >= 31) {
398
0
        quant_band_cld = 30;
399
0
      }
400
401
964k
      quant_band_icc = icc[band];
402
403
964k
      if (quant_band_icc < 0 || quant_band_icc >= 8) {
404
0
        quant_band_icc = 7;
405
0
      }
406
964k
      h11[band] = ixheaacd_mps_dec_m1_m2_tables->cos_table[quant_band_icc][quant_band_cld];
407
964k
      h11[band] = ixheaacd_mps_mult32_shr_15(h11[band], c_l[band]);
408
964k
      h21[band] = ixheaacd_mps_dec_m1_m2_tables->cos_table[quant_band_icc][30 - quant_band_cld];
409
964k
      h21[band] = ixheaacd_mps_mult32_shr_15(h21[band], c_r[band]);
410
964k
      h12[band] = ixheaacd_mps_dec_m1_m2_tables->sin_table[quant_band_icc][quant_band_cld];
411
964k
      h12[band] = ixheaacd_mps_mult32_shr_15(h12[band], c_l[band]);
412
964k
      h22[band] = -ixheaacd_mps_dec_m1_m2_tables->sin_table[quant_band_icc][30 - quant_band_cld];
413
964k
      h22[band] = ixheaacd_mps_mult32_shr_15(h22[band], c_r[band]);
414
415
964k
      h12_res[band] = 0;
416
964k
      h22_res[band] = 0;
417
964k
    }
418
974k
  }
419
58.7k
  return;
420
58.7k
}
421
422
VOID ixheaacd_param_2_umx_ps(ia_heaac_mps_state_struct *pstr_mps_state, WORD32 *h11, WORD32 *h12,
423
                             WORD32 *h21, WORD32 *h22, WORD32 *h12_res, WORD32 *h22_res,
424
                             WORD16 *c_l, WORD16 *c_r, WORD32 ott_box_indx,
425
58.7k
                             WORD32 parameter_set_indx, WORD32 res_bands) {
426
58.7k
  WORD32 band;
427
58.7k
  ia_mps_dec_spatial_bs_frame_struct *p_cur_bs = pstr_mps_state->bs_frame;
428
58.7k
  ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
429
58.7k
  WORD32 num_parameter_bands = pstr_mps_state->num_parameter_bands;
430
431
58.7k
  ixheaacd_param_2_umx_ps_core_tables(p_aux_struct->ott_cld[ott_box_indx][parameter_set_indx],
432
58.7k
                                      p_cur_bs->ott_icc_idx[ott_box_indx][parameter_set_indx],
433
58.7k
                                      p_aux_struct->num_ott_bands[ott_box_indx], res_bands, h11,
434
58.7k
                                      h12, h21, h22, h12_res, h22_res, c_l, c_r,
435
58.7k
                                      pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr);
436
437
58.7k
  for (band = p_aux_struct->num_ott_bands[ott_box_indx]; band < num_parameter_bands; band++) {
438
0
    h11[band] = h21[band] = h12[band] = h22[band] = h12_res[band] = h22_res[band] = 0;
439
0
  }
440
58.7k
  return;
441
58.7k
}
442
443
31.7k
static WORD32 ixheaacd_dequant_one_by_icc(WORD32 icc) {
444
31.7k
  switch (icc) {
445
17.8k
    case 32768:
446
17.8k
      return 32768;
447
512
    case 30704:
448
512
      return 34971;
449
1.05k
    case 27564:
450
1.05k
      return 38955;
451
5.32k
    case 19691:
452
5.32k
      return 54530;
453
1.92k
    case 12047:
454
1.92k
      return 89131;
455
3.66k
    case 0:
456
3.66k
      return 0;
457
563
    case -19300:
458
563
      return -55633;
459
902
    case -32440:
460
902
      return -33099;
461
0
    default:
462
0
      return 0;
463
31.7k
  }
464
31.7k
}
465
466
145k
static WORD16 ixheaacd_map_cld_index(WORD32 cld_val) {
467
145k
  WORD32 temp = cld_val;
468
145k
  WORD16 idx = 0;
469
145k
  if (cld_val == 0) {
470
55.6k
    return 15;
471
89.8k
  } else {
472
89.8k
    if (cld_val < 0) {
473
29.0k
      temp = -cld_val;
474
29.0k
    }
475
89.8k
    switch (temp) {
476
67.3k
      case 150:
477
67.3k
        idx = 15;
478
67.3k
        break;
479
1.32k
      case 45:
480
1.32k
        idx = 14;
481
1.32k
        break;
482
777
      case 40:
483
777
        idx = 13;
484
777
        break;
485
3.29k
      case 35:
486
3.29k
        idx = 12;
487
3.29k
        break;
488
791
      case 30:
489
791
        idx = 11;
490
791
        break;
491
2.54k
      case 25:
492
2.54k
        idx = 10;
493
2.54k
        break;
494
457
      case 22:
495
457
        idx = 9;
496
457
        break;
497
1.58k
      case 19:
498
1.58k
        idx = 8;
499
1.58k
        break;
500
980
      case 16:
501
980
        idx = 7;
502
980
        break;
503
1.96k
      case 13:
504
1.96k
        idx = 6;
505
1.96k
        break;
506
1.33k
      case 10:
507
1.33k
        idx = 5;
508
1.33k
        break;
509
980
      case 8:
510
980
        idx = 4;
511
980
        break;
512
589
      case 6:
513
589
        idx = 3;
514
589
        break;
515
1.82k
      case 4:
516
1.82k
        idx = 2;
517
1.82k
        break;
518
4.00k
      case 2:
519
4.00k
        idx = 1;
520
4.00k
        break;
521
0
      default:
522
0
        idx = 0;
523
0
        break;
524
89.8k
    }
525
89.8k
  }
526
527
89.8k
  return (cld_val >= 0) ? idx + 15 : 15 - idx;
528
145k
}
529
530
VOID ixheaacd_calculate_ttt(ia_heaac_mps_state_struct *pstr_mps_state, WORD32 ps, WORD32 pb,
531
104k
                            WORD32 ttt_mode, WORD32 m_ttt[][3]) {
532
104k
  ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
533
104k
  WORD32 col;
534
535
104k
  if (ttt_mode < 2) {
536
32.0k
    m_ttt[0][0] = (p_aux_struct->ttt_cpc_1[0][ps][pb] + ONE_IN_Q16);
537
32.0k
    m_ttt[0][1] = (p_aux_struct->ttt_cpc_2[0][ps][pb] - ONE_IN_Q15);
538
32.0k
    m_ttt[1][0] = (p_aux_struct->ttt_cpc_1[0][ps][pb] - ONE_IN_Q15);
539
32.0k
    m_ttt[1][1] = (p_aux_struct->ttt_cpc_2[0][ps][pb] + ONE_IN_Q16);
540
32.0k
    m_ttt[2][0] = (ONE_IN_Q15 - p_aux_struct->ttt_cpc_1[0][ps][pb]);
541
32.0k
    m_ttt[2][1] = (ONE_IN_Q15 - p_aux_struct->ttt_cpc_2[0][ps][pb]);
542
543
32.0k
    if (pb >= pstr_mps_state->res_bands[3]) {
544
31.7k
      WORD32 one_by_icc;
545
31.7k
      one_by_icc = ixheaacd_dequant_one_by_icc(p_aux_struct->ttt_icc[0][ps][pb]);
546
547
31.7k
      m_ttt[0][0] = ixheaacd_mps_mult32_shr_15(m_ttt[0][0], one_by_icc);
548
31.7k
      m_ttt[0][1] = ixheaacd_mps_mult32_shr_15(m_ttt[0][1], one_by_icc);
549
31.7k
      m_ttt[1][0] = ixheaacd_mps_mult32_shr_15(m_ttt[1][0], one_by_icc);
550
31.7k
      m_ttt[1][1] = ixheaacd_mps_mult32_shr_15(m_ttt[1][1], one_by_icc);
551
31.7k
      m_ttt[2][0] = ixheaacd_mps_mult32_shr_15(m_ttt[2][0], one_by_icc);
552
31.7k
      m_ttt[2][1] = ixheaacd_mps_mult32_shr_15(m_ttt[2][1], one_by_icc);
553
31.7k
    }
554
555
32.0k
    m_ttt[0][0] = ixheaac_mult32x16in32(m_ttt[0][0], TWO_BY_THREE_Q15);
556
32.0k
    m_ttt[0][1] = ixheaac_mult32x16in32(m_ttt[0][1], TWO_BY_THREE_Q15);
557
32.0k
    m_ttt[1][0] = ixheaac_mult32x16in32(m_ttt[1][0], TWO_BY_THREE_Q15);
558
32.0k
    m_ttt[1][1] = ixheaac_mult32x16in32(m_ttt[1][1], TWO_BY_THREE_Q15);
559
32.0k
    m_ttt[2][0] = ixheaac_mult32x16in32(m_ttt[2][0], TWO_BY_THREE_Q15);
560
32.0k
    m_ttt[2][1] = ixheaac_mult32x16in32(m_ttt[2][1], TWO_BY_THREE_Q15);
561
72.7k
  } else {
562
72.7k
    WORD32 center_wiener;
563
72.7k
    WORD32 center_subtraction;
564
72.7k
    WORD32 c1d, c2d;
565
72.7k
    WORD64 prod;
566
72.7k
    WORD32 w11, w00, w20, w21;
567
72.7k
    WORD16 q_w11, q_w00, q_w20, q_w21;
568
569
72.7k
    const WORD32 *ten_cld_by_10 =
570
72.7k
        pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr->ten_cld_by_10;
571
572
72.7k
    ia_mps_dec_spatial_bs_frame_struct *p_cur_bs = pstr_mps_state->bs_frame;
573
72.7k
    WORD16 index = ixheaacd_map_cld_index(p_aux_struct->ttt_cld_1[0][ps][pb] >> 15);
574
575
72.7k
    c1d = ten_cld_by_10[index];
576
577
72.7k
    index = ixheaacd_map_cld_index(p_aux_struct->ttt_cld_2[0][ps][pb] >> 15);
578
72.7k
    c2d = ten_cld_by_10[index];
579
580
72.7k
    if (p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb] == 15 ||
581
72.5k
        p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb] == 15) {
582
576
      if (p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb] == 15) {
583
195
        if (p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb] == -15) {
584
8
          w00 = ONE_BY_SQRT_2_Q15;
585
8
          w20 = ONE_BY_SQRT_8_Q15;
586
187
        } else {
587
187
          w00 = ONE_IN_Q15;
588
187
          w20 = 0;
589
187
        }
590
591
195
        if (p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb] == 15) {
592
7
          w11 = ONE_BY_SQRT_2_Q15;
593
7
          w21 = ONE_BY_SQRT_8_Q15;
594
188
        } else {
595
188
          w11 = ONE_IN_Q15;
596
188
          w21 = 0;
597
188
        }
598
599
195
        m_ttt[0][0] = w00;
600
195
        m_ttt[2][0] = w20;
601
195
        m_ttt[2][1] = w21;
602
195
        m_ttt[1][1] = w11;
603
195
      }
604
605
576
      if (p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb] == 15) {
606
388
        const WORD32 *w00_cld2_15 =
607
388
            pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr->w00_cld2_15;
608
609
388
        if (p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb] == 15) {
610
7
          w11 = ONE_BY_SQRT_2_Q15;
611
7
          w21 = ONE_BY_SQRT_8_Q15;
612
381
        } else {
613
381
          w11 = 0;
614
381
          w21 = ONE_IN_Q14;
615
381
        }
616
617
388
        w00 = w00_cld2_15[p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb] + 15];
618
388
        w20 = w00_cld2_15[15 - p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb]] / 2;
619
388
        m_ttt[0][0] = w00;
620
388
        m_ttt[2][0] = w20;
621
388
        m_ttt[2][1] = w21;
622
388
        m_ttt[1][1] = w11;
623
388
      }
624
625
576
      m_ttt[0][1] = 0;
626
576
      m_ttt[1][0] = 0;
627
72.1k
    } else {
628
72.1k
      WORD32 temporary;
629
72.1k
      const WORD32 *sqrt_tab = pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr->sqrt_tab;
630
72.1k
      prod = ixheaacd_mps_mult32_shr_15(c1d, c2d);
631
632
72.1k
      temporary = ixheaac_add32_sat(ONE_IN_Q15, c2d);
633
72.1k
      temporary = ixheaac_add32_sat(temporary, (WORD32)prod);
634
72.1k
      w00 = ixheaacd_mps_div_32((WORD32)prod, temporary, &q_w00);
635
636
72.1k
      w11 = ixheaacd_mps_div_32(c1d, (ixheaac_add32_sat3(c1d, c2d, ONE_IN_Q15)), &q_w11);
637
638
72.1k
      w20 = ixheaacd_mps_div_32((ixheaac_add32_sat(c2d, ONE_IN_Q15)),
639
72.1k
                                ixheaac_add32_sat3(ONE_IN_Q15, (WORD32)prod, c2d), &q_w20);
640
641
72.1k
      w21 = ixheaacd_mps_div_32(ixheaac_add32_sat(c2d, ONE_IN_Q15),
642
72.1k
                                (ixheaac_add32_sat3(c1d, c2d, ONE_IN_Q15)), &q_w21);
643
644
72.1k
      m_ttt[0][0] = ixheaacd_mps_sqrt(w00, &q_w00, sqrt_tab);
645
72.1k
      m_ttt[0][0] = ixheaacd_mps_convert_to_qn(m_ttt[0][0], q_w00, 15);
646
647
72.1k
      m_ttt[0][1] = 0;
648
72.1k
      m_ttt[1][0] = 0;
649
650
72.1k
      m_ttt[1][1] = ixheaacd_mps_sqrt(w11, &q_w11, sqrt_tab);
651
72.1k
      m_ttt[1][1] = ixheaacd_mps_convert_to_qn(m_ttt[1][1], q_w11, 15);
652
653
72.1k
      m_ttt[2][0] = ixheaacd_mps_sqrt(w20, &q_w20, sqrt_tab) >> 1;
654
655
72.1k
      m_ttt[2][0] = ixheaacd_mps_convert_to_qn(m_ttt[2][0], q_w20, 15);
656
657
72.1k
      m_ttt[2][1] = ixheaacd_mps_sqrt(w21, &q_w21, sqrt_tab) >> 1;
658
659
72.1k
      m_ttt[2][1] = ixheaacd_mps_convert_to_qn(m_ttt[2][1], q_w21, 15);
660
72.1k
      if (p_aux_struct->ttt_cld_1[0][ps][pb] == 4915200) {
661
47.9k
        m_ttt[0][0] = 32767;
662
47.9k
        m_ttt[1][1] = 32767;
663
47.9k
        m_ttt[2][0] = 0;
664
47.9k
        m_ttt[2][1] = 0;
665
47.9k
      }
666
72.1k
    }
667
668
72.7k
    center_wiener = 0;
669
72.7k
    center_subtraction = (ttt_mode == 2 || ttt_mode == 3);
670
671
72.7k
    if (center_wiener) {
672
0
      WORD32 cld_1_idx = p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb];
673
0
      WORD32 cld_2_idx = p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb];
674
675
0
      if (cld_1_idx == 15 && cld_2_idx == 15) {
676
0
        m_ttt[2][0] = 0;
677
0
        m_ttt[2][1] = ONE_BY_SQRT_2_Q15;
678
0
      } else if (cld_1_idx == 15) {
679
0
        if (cld_2_idx == -15)
680
0
          m_ttt[2][0] = ONE_BY_SQRT_2_Q15;
681
0
        else
682
0
          m_ttt[2][0] = 0;
683
0
        m_ttt[2][1] = 0;
684
0
      } else if (cld_2_idx == 15) {
685
0
        m_ttt[2][0] = 0;
686
0
        m_ttt[2][1] = ONE_IN_Q15;
687
0
      } else {
688
0
        WORD32 temp;
689
0
        WORD16 q_temp;
690
0
        const WORD32 *sqrt_tab = pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr->sqrt_tab;
691
692
0
        prod = ixheaacd_mps_mult32_shr_15(c2d, (c2d + c1d + ONE_IN_Q16)) + ONE_IN_Q15;
693
694
0
        temp = ixheaacd_mps_div_32((WORD32)ONE_IN_Q15, (WORD32)prod, &q_temp);
695
696
0
        m_ttt[2][0] = ixheaacd_mps_sqrt(temp, &q_temp, sqrt_tab);
697
0
        m_ttt[2][0] = ixheaacd_mps_convert_to_qn(m_ttt[2][0], q_temp, 15);
698
699
0
        m_ttt[2][1] = ixheaacd_mps_mult32_shr_15(c2d, m_ttt[2][0]);
700
0
      }
701
0
    }
702
703
72.7k
    if (center_subtraction) {
704
26.1k
      WORD32 wl1, wl2, wr1, wr2;
705
26.1k
      WORD16 q_wl1, q_wr1;
706
26.1k
      WORD32 cld_1_idx = p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb];
707
26.1k
      WORD32 cld_2_idx = p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb];
708
709
26.1k
      if (cld_1_idx == 15 && cld_2_idx == 15) {
710
7
        m_ttt[0][0] = ONE_IN_Q15;
711
7
        m_ttt[0][1] = MINUS_ONE_IN_Q14;
712
7
        m_ttt[1][1] = ONE_BY_SQRT_2_Q15;
713
7
        m_ttt[1][0] = 0;
714
26.1k
      } else if (cld_1_idx == 15) {
715
156
        if (cld_2_idx == -15) {
716
8
          m_ttt[0][0] = ONE_BY_SQRT_2_Q15;
717
8
          m_ttt[1][0] = MINUS_ONE_IN_Q14;
718
148
        } else {
719
148
          m_ttt[0][0] = ONE_IN_Q15;
720
148
          m_ttt[1][0] = 0;
721
148
        }
722
723
156
        m_ttt[0][1] = 0;
724
156
        m_ttt[1][1] = ONE_IN_Q15;
725
25.9k
      } else if (cld_2_idx == 15) {
726
309
        m_ttt[0][0] = ONE_IN_Q15;
727
309
        m_ttt[0][1] = MINUS_ONE_IN_Q15;
728
309
        m_ttt[1][1] = 0;
729
309
        m_ttt[1][0] = 0;
730
25.6k
      } else {
731
25.6k
        WORD32 temp, temp_1, q_a;
732
25.6k
        WORD16 q_c, q_l, q_r, q_temp, q_temp1;
733
25.6k
        WORD32 c;
734
25.6k
        WORD32 r;
735
25.6k
        WORD32 l;
736
25.6k
        const WORD32 *sqrt_tab = pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr->sqrt_tab;
737
738
25.6k
        c = ixheaacd_mps_div_32(ONE_IN_Q15, (ixheaac_add32_sat(c1d, ONE_IN_Q15)), &q_c);
739
25.6k
        r = ixheaacd_mps_div_32(c1d, (ixheaac_add32_sat(c2d, ONE_IN_Q15)), &q_r);
740
25.6k
        r = ixheaacd_mps_mult32_shr_30(r, c);
741
25.6k
        q_r = q_r + q_c - 30;
742
743
25.6k
        l = ixheaacd_mps_mult32_shr_30(c2d, r);
744
25.6k
        q_l = q_r - 15;
745
746
25.6k
        temp = ixheaacd_mps_div_32(r, l, &q_temp);
747
25.6k
        q_temp += (q_r - q_l);
748
749
25.6k
        if (q_temp > 28) {
750
15.0k
          temp = temp >> (q_temp - 28);
751
15.0k
          q_temp = 28;
752
15.0k
        }
753
754
25.6k
        temp += ((1 << q_temp) - 1);
755
756
25.6k
        temp = ixheaac_add32_sat(
757
25.6k
            ixheaacd_mps_mult32_shr_n(c, temp, (WORD16)(q_c + q_temp - q_r)), r);
758
25.6k
        q_temp = q_r;
759
760
25.6k
        if (q_c > q_r) {
761
12.0k
          temp_1 = r + (c >> (q_c - q_r));
762
12.0k
          q_temp1 = q_r;
763
13.5k
        } else {
764
13.5k
          temp_1 = ixheaac_add32_sat((r >> (q_r - q_c)), c);
765
13.5k
          q_temp1 = q_c;
766
13.5k
        }
767
768
25.6k
        temp = ixheaac_div32(temp_1, temp, &q_a);
769
25.6k
        q_wl1 = q_a + q_temp1 - q_temp;
770
25.6k
        wl1 = ixheaacd_mps_sqrt(temp, &q_wl1, sqrt_tab);
771
25.6k
        m_ttt[0][0] = ixheaacd_mps_convert_to_qn(wl1, q_wl1, 15);
772
773
25.6k
        temp = ixheaac_div32(wl1, temp_1, &q_a);
774
25.6k
        q_temp = q_a + (q_wl1 - q_temp1);
775
25.6k
        wl2 = ixheaacd_mps_mult32_shr_n(c, temp, (WORD16)(q_c + q_temp - 15));
776
25.6k
        m_ttt[0][1] = ixheaac_negate32_sat(wl2);
777
778
25.6k
        temp = ixheaacd_mps_div_32(l, r, &q_temp);
779
25.6k
        q_temp += (q_l - q_r);
780
781
25.6k
        if (q_temp > 28) {
782
15.7k
          temp = temp >> (q_temp - 28);
783
15.7k
          q_temp = 28;
784
15.7k
        }
785
786
25.6k
        temp = ixheaac_add32_sat((1 << q_temp) - 1, temp);
787
788
25.6k
        temp = ixheaac_add32_sat(
789
25.6k
                   ixheaacd_mps_mult32_shr_n(c, temp, (WORD16)(q_c + q_temp - q_l)), l);
790
791
25.6k
        q_temp = q_l;
792
793
25.6k
        if (q_c > q_l) {
794
17.6k
          temp_1 = l + (c >> (q_c - q_l));
795
17.6k
          q_temp1 = q_l;
796
17.6k
        } else {
797
8.01k
          temp_1 = ixheaac_add32_sat((l >> (q_l - q_c)), c);
798
8.01k
          q_temp1 = q_c;
799
8.01k
        }
800
801
25.6k
        temp = ixheaac_div32(temp_1, temp, &q_a);
802
25.6k
        q_wr1 = q_a + q_temp1 - q_temp;
803
25.6k
        wr1 = ixheaacd_mps_sqrt(temp, &q_wr1, sqrt_tab);
804
25.6k
        m_ttt[1][1] = ixheaacd_mps_convert_to_qn(wr1, q_wr1, 15);
805
806
25.6k
        temp = ixheaac_div32(wr1, temp_1, &q_a);
807
25.6k
        q_temp = q_a + (q_wl1 - q_temp1);
808
25.6k
        wr2 = ixheaacd_mps_mult32_shr_n(c, temp, (WORD16)(q_c + q_temp - 15));
809
25.6k
        m_ttt[1][0] = ixheaac_negate32_sat(wr2);
810
25.6k
      }
811
26.1k
    }
812
72.7k
  }
813
814
104k
  m_ttt[0][2] = ONE_BY_THREE_Q15;
815
104k
  m_ttt[1][2] = ONE_BY_THREE_Q15;
816
104k
  m_ttt[2][2] = MINUS_ONE_BY_THREE_Q15;
817
818
419k
  for (col = 0; col < 3; col++) {
819
314k
    m_ttt[2][col] = ixheaacd_mps_mult32_shr_15(m_ttt[2][col], SQRT_TWO_Q15);
820
314k
  }
821
104k
}
822
823
VOID ixheaacd_calculate_mtx_inv(ia_heaac_mps_state_struct *pstr_mps_state, WORD32 ps, WORD32 pb,
824
21.5k
                                WORD32 mode, WORD32 h_real[][2], WORD32 h_imag[][2]) {
825
21.5k
  ia_mps_dec_auxilary_struct *p_aux_struct = pstr_mps_state->aux_struct;
826
827
21.5k
  WORD32 weight1;
828
21.5k
  WORD32 weight2;
829
21.5k
  ia_mps_dec_spatial_bs_frame_struct *p_cur_bs = pstr_mps_state->bs_frame;
830
831
21.5k
  if (mode < 2) {
832
7.79k
    ixheaacd_get_matrix_inversion_weights(
833
7.79k
        p_cur_bs->ott_cld_idx[1][ps][pb], p_cur_bs->ott_cld_idx[2][ps][pb], 1,
834
7.79k
        p_aux_struct->ttt_cpc_1[0][ps][pb], p_aux_struct->ttt_cpc_2[0][ps][pb], &weight1,
835
7.79k
        &weight2, &(pstr_mps_state->ia_mps_dec_mps_table));
836
13.7k
  } else {
837
13.7k
    ixheaacd_get_matrix_inversion_weights(
838
13.7k
        p_cur_bs->ott_cld_idx[1][ps][pb], p_cur_bs->ott_cld_idx[2][ps][pb], 0,
839
13.7k
        p_cur_bs->cmp_ttt_cld_1_idx[0][ps][pb], p_cur_bs->cmp_ttt_cld_2_idx[0][ps][pb], &weight1,
840
13.7k
        &weight2, &(pstr_mps_state->ia_mps_dec_mps_table));
841
13.7k
  }
842
843
21.5k
  ixheaacd_invert_matrix(weight1, weight2, h_real, h_imag,
844
21.5k
                         pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr);
845
21.5k
}
846
847
VOID ixheaacd_calculate_arb_dmx_mtx(ia_heaac_mps_state_struct *pstr_mps_state, WORD32 ps,
848
44.1k
                                    WORD32 pb, WORD32 g_real[]) {
849
44.1k
  WORD32 ch;
850
44.1k
  WORD32 gain;
851
852
44.1k
  WORD32 *arbdmx_alpha_prev = pstr_mps_state->mps_persistent_mem.arbdmx_alpha_prev;
853
44.1k
  WORD32 *arbdmx_alpha_upd_set = pstr_mps_state->aux_struct->arbdmx_alpha_upd_set;
854
44.1k
  WORD32 *arbdmx_alpha = pstr_mps_state->aux_struct->arbdmx_alpha;
855
856
44.1k
  WORD32 n_ch_in = pstr_mps_state->num_input_channels;
857
44.1k
  WORD32 temp_1;
858
109k
  for (ch = 0; ch < n_ch_in; ch++) {
859
65.0k
    temp_1 = pstr_mps_state->bs_frame->arbdmx_gain_idx[ch][ps][pb] + 15;
860
65.0k
    gain = pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr->dec_pow[temp_1];
861
862
65.0k
    if (pb < pstr_mps_state->arbdmx_residual_bands) {
863
2.22k
      if ((ps == 0) && (arbdmx_alpha_upd_set[ch] == 1)) {
864
307
        g_real[ch] = ixheaacd_mps_mult32_shr_15(*arbdmx_alpha_prev, gain);
865
1.91k
      } else {
866
1.91k
        g_real[ch] = ixheaacd_mps_mult32_shr_15(arbdmx_alpha[ch], gain);
867
1.91k
      }
868
62.8k
    } else {
869
62.8k
      g_real[ch] = gain;
870
62.8k
    }
871
65.0k
    arbdmx_alpha_prev++;
872
65.0k
  }
873
44.1k
}
874
875
30.2k
WORD32 ixheaacd_quantize(WORD32 cld) {
876
30.2k
  switch (cld) {
877
1.39k
    case -150:
878
1.39k
      return -15;
879
130
    case -45:
880
130
      return -14;
881
71
    case -40:
882
71
      return -13;
883
175
    case -35:
884
175
      return -12;
885
214
    case -30:
886
214
      return -11;
887
182
    case -25:
888
182
      return -10;
889
298
    case -22:
890
298
      return -9;
891
3.58k
    case -19:
892
3.58k
      return -8;
893
206
    case -16:
894
206
      return -7;
895
256
    case -13:
896
256
      return -6;
897
490
    case -10:
898
490
      return -5;
899
1.05k
    case -8:
900
1.05k
      return -4;
901
270
    case -6:
902
270
      return -3;
903
310
    case -4:
904
310
      return -2;
905
1.10k
    case -2:
906
1.10k
      return -1;
907
1.36k
    case 0:
908
1.36k
      return 0;
909
226
    case 2:
910
226
      return 1;
911
326
    case 4:
912
326
      return 2;
913
469
    case 6:
914
469
      return 3;
915
624
    case 8:
916
624
      return 4;
917
229
    case 10:
918
229
      return 5;
919
863
    case 13:
920
863
      return 6;
921
163
    case 16:
922
163
      return 7;
923
411
    case 19:
924
411
      return 8;
925
213
    case 22:
926
213
      return 9;
927
190
    case 25:
928
190
      return 10;
929
199
    case 30:
930
199
      return 11;
931
183
    case 35:
932
183
      return 12;
933
151
    case 40:
934
151
      return 13;
935
659
    case 45:
936
659
      return 14;
937
14.2k
    case 150:
938
14.2k
      return 15;
939
0
    default:
940
0
      return 0;
941
30.2k
  }
942
30.2k
}