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 <math.h>
22 #include "ixheaacd_sbr_common.h"
23 #include "ixheaacd_type_def.h"
24 #include "ixheaacd_error_standards.h"
25 #include "ixheaacd_constants.h"
26 #include "ixheaacd_basic_ops32.h"
27 #include "ixheaacd_basic_ops16.h"
28 #include "ixheaacd_basic_ops40.h"
29 #include "ixheaacd_basic_ops.h"
30 #include "ixheaacd_basic_op.h"
31 #include "ixheaacd_intrinsics.h"
32 #include "ixheaacd_bitbuffer.h"
33 #include "ixheaacd_sbrdecsettings.h"
34 #include "ixheaacd_sbr_scale.h"
35 #include "ixheaacd_lpp_tran.h"
36 #include "ixheaacd_env_extr_part.h"
37 #include "ixheaacd_sbr_rom.h"
38 #include "ixheaacd_hybrid.h"
39 #include "ixheaacd_ps_dec.h"
40 #include "ixheaacd_env_extr.h"
41 #include "ixheaacd_common_rom.h"
42 #include "ixheaacd_env_dec.h"
43 #include "ixheaacd_sbr_const.h"
44 #include "ixheaacd_basic_funcs.h"
45 #include "ixheaacd_audioobjtypes.h"
46
47 #define add16_m(a, b) ((a) + (b))
48 #define sub16_m(a, b) ((a) - (b))
49
50 #define mult16x16_16(a, b) ixheaacd_mult16((a), (b))
51
ixheaacd_dequant_esbr_env_data(FLOAT32 * ptr_env_sf,WORD32 num_env_sf,WORD32 num_noise_fac,WORD32 amp_res,FLOAT32 * ptr_noise_floor)52 static VOID ixheaacd_dequant_esbr_env_data(FLOAT32 *ptr_env_sf,
53 WORD32 num_env_sf,
54 WORD32 num_noise_fac, WORD32 amp_res,
55 FLOAT32 *ptr_noise_floor) {
56 WORD32 i;
57 const FLOAT32 array[2] = {0.5f, 1.0f};
58 FLOAT32 a_flt = array[amp_res];
59
60 for (i = 0; i < num_env_sf; i++) {
61 ptr_env_sf[i] = (FLOAT32)(pow(2, ptr_env_sf[i] * a_flt) * 64);
62 }
63
64 for (i = 0; i < num_noise_fac; i++) {
65 FLOAT32 temp = ptr_noise_floor[i];
66
67 temp = NOISE_FLOOR_OFFSET - temp;
68 temp = (FLOAT32)pow(2.0f, temp);
69
70 ptr_noise_floor[i] = temp;
71 }
72 }
73
ixheaacd_dequant_pvc_env_data(WORD32 num_noise_fac,FLOAT32 * ptr_noise_floor)74 static VOID ixheaacd_dequant_pvc_env_data(WORD32 num_noise_fac,
75 FLOAT32 *ptr_noise_floor) {
76 WORD32 i;
77
78 for (i = 0; i < num_noise_fac; i++) {
79 FLOAT32 temp = ptr_noise_floor[i];
80
81 temp = NOISE_FLOOR_OFFSET - temp;
82 temp = (FLOAT32)pow(2.0f, temp);
83
84 ptr_noise_floor[i] = temp;
85 }
86 }
87
ixheaacd_map_res_energy(WORD16 curr_val,WORD16 * prev_data,WORD32 ixheaacd_drc_offset,WORD32 index,WORD32 res)88 VOID ixheaacd_map_res_energy(WORD16 curr_val, WORD16 *prev_data,
89 WORD32 ixheaacd_drc_offset, WORD32 index,
90 WORD32 res) {
91 if (res == LOW) {
92 if (ixheaacd_drc_offset >= 0) {
93 if (index < ixheaacd_drc_offset) {
94 prev_data[index] = curr_val;
95 } else {
96 WORD32 index_2;
97 index_2 = ((index + index) - ixheaacd_drc_offset);
98 prev_data[index_2] = curr_val;
99 prev_data[index_2 + 1] = curr_val;
100 }
101 } else {
102 ixheaacd_drc_offset = -(ixheaacd_drc_offset);
103
104 if (index < ixheaacd_drc_offset) {
105 WORD32 index_3;
106 index_3 = ((index + index) + index);
107 prev_data[index_3] = curr_val;
108 prev_data[index_3 + 1] = curr_val;
109 prev_data[index_3 + 2] = curr_val;
110 } else {
111 WORD32 index_2;
112 index_2 = ((index + index) + ixheaacd_drc_offset);
113 prev_data[index_2] = curr_val;
114 prev_data[index_2 + 1] = curr_val;
115 }
116 }
117 } else {
118 prev_data[index] = curr_val;
119 }
120 }
121
ixheaacd_process_del_cod_env_data(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data)122 VOID ixheaacd_process_del_cod_env_data(
123 ia_sbr_header_data_struct *ptr_header_data,
124 ia_sbr_frame_info_data_struct *ptr_sbr_data,
125 ia_sbr_prev_frame_data_struct *ptr_prev_data) {
126 WORD32 i, dtdf_dir, num_sf_bands, band, freq_res;
127 WORD16 temp_val;
128 WORD16 *ptr_prev_env_sf = ptr_prev_data->sfb_nrg_prev;
129 WORD16 *ptr_env_sf = ptr_sbr_data->int_env_sf_arr;
130
131 FLOAT32 *ptr_env_sf_float = ptr_sbr_data->flt_env_sf_arr;
132
133 WORD32 ixheaacd_drc_offset;
134 band = 0;
135
136 ixheaacd_drc_offset =
137 ((ptr_header_data->pstr_freq_band_data->num_sf_bands[LOW] << 1) -
138 ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH]);
139
140 for (i = 0; i < ptr_sbr_data->str_frame_info_details.num_env; i++) {
141 dtdf_dir = ptr_sbr_data->del_cod_dir_arr[i];
142 freq_res = ptr_sbr_data->str_frame_info_details.freq_res[i];
143
144 num_sf_bands = ptr_header_data->pstr_freq_band_data->num_sf_bands[freq_res];
145
146 if (dtdf_dir == DTDF_DIR_FREQ) {
147 ixheaacd_map_res_energy(*ptr_env_sf, ptr_prev_env_sf, ixheaacd_drc_offset,
148 0, freq_res);
149 ptr_env_sf++;
150
151 ptr_env_sf_float++;
152
153 for (band = 1; band < num_sf_bands; band++) {
154 *ptr_env_sf = *ptr_env_sf + *(ptr_env_sf - 1);
155 ixheaacd_map_res_energy(*ptr_env_sf, ptr_prev_env_sf,
156 ixheaacd_drc_offset, band, freq_res);
157
158 *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf);
159 ptr_env_sf_float++;
160
161 ptr_env_sf++;
162 }
163
164 } else {
165 if (freq_res == LOW) {
166 if (ixheaacd_drc_offset < 0) {
167 WORD32 tar, index_3;
168 ixheaacd_drc_offset = -ixheaacd_drc_offset;
169 tar = ixheaacd_min32(ixheaacd_drc_offset, band);
170
171 for (band = 0; band < tar; band++) {
172 index_3 = ((band + band) + band);
173 temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_3]);
174
175 ptr_prev_env_sf[index_3] = temp_val;
176 ptr_prev_env_sf[index_3 + 1] = temp_val;
177 ptr_prev_env_sf[index_3 + 2] = temp_val;
178 *ptr_env_sf++ = temp_val;
179
180 *ptr_env_sf_float = (FLOAT32)temp_val;
181 ptr_env_sf_float++;
182 }
183
184 for (; band < num_sf_bands; band++) {
185 index_3 = (band << 1) + ixheaacd_drc_offset;
186 temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_3]);
187 ptr_prev_env_sf[index_3] = temp_val;
188 ptr_prev_env_sf[index_3 + 1] = temp_val;
189 *ptr_env_sf++ = temp_val;
190 *ptr_env_sf_float = (FLOAT32)temp_val;
191 ptr_env_sf_float++;
192 }
193 } else {
194 WORD32 tar, index_2;
195 WORD16 *ptr2 = ptr_prev_env_sf;
196 tar = ixheaacd_min32(ixheaacd_drc_offset, band);
197 for (band = 0; band < tar; band++) {
198 *ptr_env_sf = add16_m(*ptr_env_sf, *ptr2);
199 *ptr2 = *ptr_env_sf;
200
201 *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf);
202 ptr_env_sf_float++;
203
204 ptr2++;
205 ptr_env_sf++;
206 }
207
208 for (; band < num_sf_bands; band++) {
209 index_2 = (band < ixheaacd_drc_offset)
210 ? band
211 : ((band << 1) - ixheaacd_drc_offset);
212 temp_val = add16_m(*ptr_env_sf, ptr_prev_env_sf[index_2]);
213 ptr_prev_env_sf[index_2] = temp_val;
214 ptr_prev_env_sf[index_2 + 1] = temp_val;
215 *ptr_env_sf++ = temp_val;
216
217 *ptr_env_sf_float = (FLOAT32)temp_val;
218 ptr_env_sf_float++;
219 }
220 }
221
222 } else {
223 WORD16 *ptr2 = ptr_prev_env_sf;
224 for (band = num_sf_bands - 1; band >= 0; band--) {
225 *ptr_env_sf = add16_m(*ptr_env_sf, *ptr2);
226 *ptr2 = *ptr_env_sf;
227 *ptr_env_sf_float = (FLOAT32)(*ptr_env_sf);
228 ptr_env_sf_float++;
229 ptr2++;
230 ptr_env_sf++;
231 }
232 band = num_sf_bands;
233 }
234 }
235 }
236 }
237
238 static PLATFORM_INLINE WORD32
ixheaacd_wrong_timing_compensate(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data,ixheaacd_misc_tables * pstr_common_tables)239 ixheaacd_wrong_timing_compensate(ia_sbr_header_data_struct *ptr_header_data,
240 ia_sbr_frame_info_data_struct *ptr_sbr_data,
241 ia_sbr_prev_frame_data_struct *ptr_prev_data,
242 ixheaacd_misc_tables *pstr_common_tables) {
243 WORD32 i, num_env_sf;
244 ia_frame_info_struct *p_frame_info = &ptr_sbr_data->str_frame_info_details;
245 WORD16 *num_sf_bands = ptr_header_data->pstr_freq_band_data->num_sf_bands;
246 WORD32 start_pos_est;
247 WORD32 ref_len, new_len, shift;
248 WORD16 delta_exp;
249
250 start_pos_est =
251 (ptr_prev_data->end_position - ptr_header_data->num_time_slots);
252
253 ref_len = (p_frame_info->border_vec[1] - p_frame_info->border_vec[0]);
254
255 new_len = (p_frame_info->border_vec[1] - start_pos_est);
256
257 if (new_len <= 0) {
258 new_len = ref_len;
259 start_pos_est = p_frame_info->border_vec[0];
260 }
261
262 delta_exp = pstr_common_tables->log_dual_is_table[ref_len];
263 delta_exp -= pstr_common_tables->log_dual_is_table[new_len];
264
265 shift = (SHORT_BITS - ENV_EXP_FRACT - 3 - ptr_sbr_data->amp_res);
266 delta_exp = ixheaacd_shr16(delta_exp, (WORD16)shift);
267 p_frame_info->border_vec[0] = start_pos_est;
268 p_frame_info->noise_border_vec[0] = start_pos_est;
269
270 if (start_pos_est < 0) return -1;
271
272 if (ptr_sbr_data->coupling_mode != COUPLING_BAL) {
273 num_env_sf =
274 ((p_frame_info->freq_res[0]) ? num_sf_bands[HIGH] : num_sf_bands[LOW]);
275
276 for (i = 0; i < num_env_sf; i++) {
277 ptr_sbr_data->int_env_sf_arr[i] =
278 add16_m(ptr_sbr_data->int_env_sf_arr[i], delta_exp);
279 ptr_sbr_data->flt_env_sf_arr[i] =
280 (FLOAT32)(ptr_sbr_data->int_env_sf_arr[i]);
281 }
282 }
283
284 return 0;
285 }
286
ixheaacd_check_env_data(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data)287 WORD16 ixheaacd_check_env_data(ia_sbr_header_data_struct *ptr_header_data,
288 ia_sbr_frame_info_data_struct *ptr_sbr_data,
289 ia_sbr_prev_frame_data_struct *ptr_prev_data) {
290 WORD16 *ptr_evn_sf = ptr_sbr_data->int_env_sf_arr;
291 FLOAT32 *ptr_evn_sf_float = ptr_sbr_data->flt_env_sf_arr;
292 WORD16 *ptr_prev_evn_sf = ptr_prev_data->sfb_nrg_prev;
293 WORD32 i;
294 FLAG error_code = 0;
295 WORD16 sbr_max_env_sf;
296 WORD32 amp_res = ptr_sbr_data->amp_res;
297
298 sbr_max_env_sf = (SBR_ENV_SF_MAX_VAL_1_5 >> amp_res);
299
300 for (i = 0; i < ptr_sbr_data->num_env_sfac; i++) {
301 if (ptr_evn_sf[i] > sbr_max_env_sf) {
302 error_code = 1;
303 }
304 if (ptr_evn_sf[i] < 0) {
305 ptr_evn_sf[i] = 0;
306 ptr_evn_sf_float[i] = 0;
307 }
308 }
309
310 for (i = 0; i < ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH];
311 i++) {
312 if (ptr_prev_evn_sf[i] < 0) {
313 ptr_prev_evn_sf[i] = 0;
314 } else {
315 if (ptr_prev_evn_sf[i] > sbr_max_env_sf)
316 ptr_prev_evn_sf[i] = sbr_max_env_sf;
317 }
318 }
319 return (WORD16)(error_code);
320 }
321
ixheaacd_dequant_env_data(ia_sbr_frame_info_data_struct * ptr_sbr_data,WORD32 amp_res)322 VOID ixheaacd_dequant_env_data(ia_sbr_frame_info_data_struct *ptr_sbr_data,
323 WORD32 amp_res) {
324 WORD32 i;
325 WORD32 num_env_sf = ptr_sbr_data->num_env_sfac;
326 WORD32 mantissa;
327 WORD32 amp_res_1;
328 WORD32 exponent;
329 WORD32 exp_add = (7 + NRG_EXP_OFFSET);
330 WORD16 *ptr_env_sf = ptr_sbr_data->int_env_sf_arr;
331 const WORD32 mant_arr[2] = {0x4000, 0x5a80};
332
333 amp_res_1 = (1 - amp_res);
334
335 for (i = num_env_sf - 1; i >= 0; i--) {
336 exponent = *ptr_env_sf;
337 mantissa = mant_arr[(exponent & amp_res_1)];
338 exponent = (exponent >> amp_res_1);
339 exponent = (exponent + exp_add);
340 *ptr_env_sf++ = (WORD16)(mantissa | (exponent & MASK_FOR_EXP));
341 }
342 }
343
344 static PLATFORM_INLINE VOID
ixheaacd_limit_noise_floor_fac(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data)345 ixheaacd_limit_noise_floor_fac(ia_sbr_header_data_struct *ptr_header_data,
346 ia_sbr_frame_info_data_struct *ptr_sbr_data) {
347 WORD32 i, tot_nf_bands;
348 WORD32 value;
349 WORD32 num_nf_bands;
350 WORD16 *ptr_noise_floor;
351 FLOAT32 *ptr_noise_floor_flt;
352
353 num_nf_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands;
354
355 tot_nf_bands =
356 ptr_sbr_data->str_frame_info_details.num_noise_env * num_nf_bands;
357
358 ptr_noise_floor = ptr_sbr_data->int_noise_floor;
359
360 ptr_noise_floor_flt = &ptr_sbr_data->flt_noise_floor[0];
361
362 for (i = tot_nf_bands - 1; i >= 0; i--) {
363 value = *ptr_noise_floor;
364 if (value > MAX_NOISE_FLOOR_FAC_VAL) {
365 *ptr_noise_floor = MAX_NOISE_FLOOR_FAC_VAL;
366 *ptr_noise_floor_flt = MAX_NOISE_FLOOR_FAC_VAL;
367 } else {
368 if (value < MIN_NOISE_FLOOR_FAC_VAL) {
369 *ptr_noise_floor = MIN_NOISE_FLOOR_FAC_VAL;
370 *ptr_noise_floor_flt = MIN_NOISE_FLOOR_FAC_VAL;
371 }
372 }
373 ptr_noise_floor++;
374 ptr_noise_floor_flt++;
375 }
376 }
377
ixheaacd_add_arr(WORD16 * ptr1,WORD16 * ptr2,WORD32 num)378 VOID ixheaacd_add_arr(WORD16 *ptr1, WORD16 *ptr2, WORD32 num) {
379 WORD32 i;
380 for (i = num - 1; i >= 0; i--) {
381 *ptr2 = (*ptr2 + *ptr1);
382 ptr2++;
383 ptr1++;
384 }
385 }
386
ixheaacd_add_farr(FLOAT32 * ptr1,FLOAT32 * ptr2,WORD32 num)387 VOID ixheaacd_add_farr(FLOAT32 *ptr1, FLOAT32 *ptr2, WORD32 num) {
388 WORD32 i;
389 for (i = num - 1; i >= 0; i--) {
390 *ptr2 = (*ptr2 + *ptr1);
391 ptr2++;
392 ptr1++;
393 }
394 }
395
ixheaacd_calc_noise_floor(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data,WORD32 audio_object_type)396 IA_ERRORCODE ixheaacd_calc_noise_floor(
397 ia_sbr_header_data_struct *ptr_header_data,
398 ia_sbr_frame_info_data_struct *ptr_sbr_data,
399 ia_sbr_prev_frame_data_struct *ptr_prev_data,
400 WORD32 audio_object_type) {
401 WORD32 i;
402 WORD32 num_nf_bands;
403 WORD32 num_noise_env;
404 WORD32 ixheaacd_drc_offset;
405 WORD16 *ptr_noise_floor = ptr_sbr_data->int_noise_floor;
406
407 WORD16 *ptr_prev_noise_floor = ptr_prev_data->prev_noise_level;
408 WORD16 *ptr1, *ptr2;
409 FLOAT32 *f_ptr1, *f_ptr2;
410 WORD32 num;
411 FLOAT32 *ptr_noise_floor_float = ptr_sbr_data->flt_noise_floor;
412
413 num_nf_bands = ptr_header_data->pstr_freq_band_data->num_nf_bands;
414 num_noise_env = ptr_sbr_data->str_frame_info_details.num_noise_env;
415
416 if (ptr_sbr_data->del_cod_dir_noise_arr[0] == DTDF_DIR_FREQ) {
417 ptr1 = ptr_noise_floor++;
418 ptr2 = ptr_noise_floor;
419 num = num_nf_bands - 1;
420 f_ptr1 = &ptr_noise_floor_float[0];
421 f_ptr2 = &ptr_noise_floor_float[1];
422 } else {
423 ptr1 = ptr_prev_noise_floor;
424 ptr2 = ptr_sbr_data->int_noise_floor;
425 f_ptr1 = &ptr_sbr_data->prev_noise_level[0];
426 f_ptr2 = &ptr_noise_floor_float[0];
427 num = num_nf_bands;
428 }
429
430 ixheaacd_add_arr(ptr1, ptr2, num);
431 ixheaacd_add_farr(f_ptr1, f_ptr2, num);
432
433 if (num_noise_env > 1) {
434 if (ptr_sbr_data->del_cod_dir_noise_arr[1] == DTDF_DIR_FREQ) {
435 ptr1 = &ptr_sbr_data->int_noise_floor[num_nf_bands];
436 ptr2 = &ptr_sbr_data->int_noise_floor[(num_nf_bands + 1)];
437 f_ptr1 = &ptr_sbr_data->flt_noise_floor[num_nf_bands];
438 f_ptr2 = &ptr_sbr_data->flt_noise_floor[(num_nf_bands + 1)];
439 num = num_nf_bands - 1;
440 } else {
441 ptr1 = &ptr_sbr_data->int_noise_floor[0];
442 ptr2 = &ptr_sbr_data->int_noise_floor[num_nf_bands];
443 f_ptr1 = &ptr_sbr_data->flt_noise_floor[0];
444 f_ptr2 = &ptr_sbr_data->flt_noise_floor[num_nf_bands];
445 num = num_nf_bands;
446 }
447 ixheaacd_add_arr(ptr1, ptr2, num);
448 ixheaacd_add_farr(f_ptr1, f_ptr2, num);
449 }
450
451 ixheaacd_limit_noise_floor_fac(ptr_header_data, ptr_sbr_data);
452
453 ixheaacd_drc_offset = num_nf_bands * (num_noise_env - 1);
454 if (ixheaacd_drc_offset < 0 || ixheaacd_drc_offset >= MAX_NUM_NOISE_VALUES)
455 return IA_FATAL_ERROR;
456 ptr1 = &ptr_sbr_data->int_noise_floor[ixheaacd_drc_offset];
457 ptr2 = ptr_prev_noise_floor;
458
459 memcpy(ptr2, ptr1, sizeof(WORD16) * (num_nf_bands));
460 if (!ptr_header_data->usac_flag) {
461 for (i = 0; i < num_nf_bands; i++) {
462 ptr_sbr_data->prev_noise_level[i] = ptr_prev_noise_floor[i];
463 }
464 }
465 if (audio_object_type != AOT_ER_AAC_ELD) {
466 WORD32 noise_floor_exp, tot_nf_bands;
467
468 tot_nf_bands = (num_nf_bands * num_noise_env);
469 ptr_noise_floor = &ptr_sbr_data->int_noise_floor[0];
470
471 for (i = 0; i < tot_nf_bands; i++) {
472 noise_floor_exp =
473 (NOISE_FLOOR_OFFSET_INT + 1 + NOISE_EXP_OFFSET - *ptr_noise_floor);
474
475 *ptr_noise_floor_float++ = *ptr_noise_floor;
476 *ptr_noise_floor++ = (WORD16)(0x4000 + (noise_floor_exp & MASK_FOR_EXP));
477 }
478 } else {
479 if (ptr_sbr_data->coupling_mode != COUPLING_BAL) {
480 WORD32 noise_floor_exp, tot_nf_bands;
481
482 tot_nf_bands = (num_nf_bands * num_noise_env);
483 ptr_noise_floor = &ptr_sbr_data->int_noise_floor[0];
484
485 for (i = 0; i < tot_nf_bands; i++) {
486 noise_floor_exp =
487 (NOISE_FLOOR_OFFSET_INT + 1 + NOISE_EXP_OFFSET - *ptr_noise_floor);
488 *ptr_noise_floor_float++ = *ptr_noise_floor;
489 *ptr_noise_floor++ = (WORD16)(0x4000 + (noise_floor_exp & MASK_FOR_EXP));
490 }
491 }
492 }
493 return IA_NO_ERROR;
494 }
495
ixheaacd_dec_sbrdata_for_pvc(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data,WORD32 audio_object_type)496 IA_ERRORCODE ixheaacd_dec_sbrdata_for_pvc(
497 ia_sbr_header_data_struct *ptr_header_data,
498 ia_sbr_frame_info_data_struct *ptr_sbr_data,
499 ia_sbr_prev_frame_data_struct *ptr_prev_data,
500 WORD32 audio_object_type) {
501 WORD32 err = 0;
502 err = ixheaacd_calc_noise_floor(ptr_header_data, ptr_sbr_data, ptr_prev_data,
503 audio_object_type);
504 if (err) return err;
505
506 if (!ptr_sbr_data->coupling_mode) {
507 ptr_sbr_data->num_noise_sfac =
508 ptr_header_data->pstr_freq_band_data->num_nf_bands *
509 ptr_sbr_data->str_frame_info_details.num_noise_env;
510 ixheaacd_dequant_pvc_env_data(ptr_sbr_data->num_noise_sfac,
511 ptr_sbr_data->flt_noise_floor);
512 }
513 return IA_NO_ERROR;
514 }
515
ixheaacd_sbr_env_dequant_coup_fix(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_data_left,ia_sbr_frame_info_data_struct * ptr_data_right,ixheaacd_misc_tables * pstr_common_tables)516 VOID ixheaacd_sbr_env_dequant_coup_fix(
517 ia_sbr_header_data_struct *ptr_header_data,
518 ia_sbr_frame_info_data_struct *ptr_data_left,
519 ia_sbr_frame_info_data_struct *ptr_data_right,
520 ixheaacd_misc_tables *pstr_common_tables) {
521 WORD32 i;
522 WORD32 num_env_sf = ptr_data_left->num_env_sfac;
523 WORD16 temp_left_mant, temp_right_mant, temp_right_plus1_mant, new_left_mant,
524 new_right_mant;
525 WORD16 temp_left_exp, temp_right_exp, temp_rightplus1_exp, new_left_exp,
526 new_right_exp;
527 WORD32 i_end;
528 WORD16 *r_data = ptr_data_right->int_env_sf_arr;
529 WORD16 *l_data = ptr_data_left->int_env_sf_arr;
530
531 for (i = 0; i < num_env_sf; i++) {
532 temp_right_mant = (WORD16)(*r_data & MASK_M);
533 temp_right_exp = (WORD16)(*r_data & MASK_FOR_EXP);
534
535 temp_right_exp = sub16_m(temp_right_exp, add16_m(18, NRG_EXP_OFFSET));
536 temp_left_mant = (WORD16)(*l_data & MASK_M);
537 temp_left_exp = (WORD16)(*l_data & MASK_FOR_EXP);
538
539 temp_left_exp = sub16_m(temp_left_exp, NRG_EXP_OFFSET);
540
541 ixheaacd_fix_mant_exp_add(temp_right_mant, temp_right_exp, 0x4000, 1,
542 &temp_right_plus1_mant, &temp_rightplus1_exp);
543
544 new_right_exp = ixheaacd_fix_mant_div(temp_left_mant, temp_right_plus1_mant,
545 &new_right_mant, pstr_common_tables);
546
547 new_right_exp += temp_left_exp - temp_rightplus1_exp + 2;
548
549 new_left_mant = ixheaacd_mult16_shl(temp_right_mant, new_right_mant);
550
551 new_left_exp = add16_m(temp_right_exp, new_right_exp);
552
553 *r_data++ = (WORD16)(((new_right_mant + ROUNDING) & MASK_M) +
554 ((new_right_exp + NRG_EXP_OFFSET) & MASK_FOR_EXP));
555 *l_data++ = (WORD16)(((new_left_mant + ROUNDING) & MASK_M) +
556 ((new_left_exp + NRG_EXP_OFFSET) & MASK_FOR_EXP));
557 }
558
559 i_end = ptr_header_data->pstr_freq_band_data->num_nf_bands *
560 ptr_data_left->str_frame_info_details.num_noise_env;
561 r_data = ptr_data_right->int_noise_floor;
562 l_data = ptr_data_left->int_noise_floor;
563
564 for (i = i_end - 1; i >= 0; i--) {
565 temp_left_exp =
566 sub16_m((WORD16)(*l_data & (WORD16)MASK_FOR_EXP), NOISE_EXP_OFFSET);
567 temp_right_exp = sub16_m(*r_data, 12);
568
569 ixheaacd_fix_mant_exp_add(0x4000, ixheaacd_add16(1, temp_right_exp), 0x4000,
570 1, &temp_right_plus1_mant, &temp_rightplus1_exp);
571
572 new_right_exp = ixheaacd_fix_mant_div(0x4000, temp_right_plus1_mant,
573 &new_right_mant, pstr_common_tables);
574
575 new_right_exp += temp_left_exp - temp_rightplus1_exp + 2;
576
577 new_left_mant = new_right_mant;
578 new_left_exp = add16_m(new_right_exp, temp_right_exp);
579 *r_data++ = (WORD16)(((new_right_mant + ROUNDING) & MASK_M) +
580 ((new_right_exp + NOISE_EXP_OFFSET) & MASK_FOR_EXP));
581 *l_data++ = (WORD16)(((new_left_mant + ROUNDING) & MASK_M) +
582 ((new_left_exp + NOISE_EXP_OFFSET) & MASK_FOR_EXP));
583 }
584 }
585
ixheaacd_sbr_env_dequant_coup(ia_sbr_frame_info_data_struct * ptr_data_ch_0,ia_sbr_frame_info_data_struct * ptr_data_ch_1)586 VOID ixheaacd_sbr_env_dequant_coup(
587 ia_sbr_frame_info_data_struct *ptr_data_ch_0,
588 ia_sbr_frame_info_data_struct *ptr_data_ch_1) {
589 FLOAT32 *ptr_env_sf_left = ptr_data_ch_0->flt_env_sf_arr;
590 FLOAT32 *ptr_env_sf_right = ptr_data_ch_1->flt_env_sf_arr;
591 FLOAT32 *ptr_noise_floor_left = ptr_data_ch_0->flt_noise_floor;
592 FLOAT32 *ptr_noise_floor_right = ptr_data_ch_1->flt_noise_floor;
593 WORD32 num_env_sf = ptr_data_ch_0->num_env_sfac;
594 WORD32 num_noise_fac = ptr_data_ch_0->num_noise_sfac;
595 WORD32 amp_res = ptr_data_ch_0->amp_res;
596
597 WORD32 i;
598 FLOAT32 temp_l, temp_r;
599 const FLOAT32 pan_offset[2] = {24.0f, 12.0f};
600 const FLOAT32 a_arr[2] = {0.5f, 1.0f};
601
602 FLOAT32 a = a_arr[amp_res];
603
604 for (i = 0; i < num_env_sf; i++) {
605 temp_l = ptr_env_sf_left[i];
606 temp_r = ptr_env_sf_right[i];
607
608 ptr_env_sf_left[i] =
609 (FLOAT32)(64 * (pow(2, temp_l * a + 1) /
610 (1 + pow(2, (pan_offset[amp_res] - temp_r) * a))));
611 ptr_env_sf_right[i] =
612 (FLOAT32)(64 * (pow(2, temp_l * a + 1) /
613 (1 + pow(2, (temp_r - pan_offset[amp_res]) * a))));
614 }
615
616 for (i = 0; i < num_noise_fac; i++) {
617 temp_l = ptr_noise_floor_left[i];
618 temp_r = ptr_noise_floor_right[i];
619
620 ptr_noise_floor_left[i] =
621 (FLOAT32)(pow(2, NOISE_FLOOR_OFFSET - temp_l + 1) /
622 (1 + pow(2, pan_offset[1] - temp_r)));
623 ptr_noise_floor_right[i] =
624 (FLOAT32)(pow(2, NOISE_FLOOR_OFFSET - temp_l + 1) /
625 (1 + pow(2, temp_r - pan_offset[1])));
626 }
627 }
ixheaacd_dec_sbrdata(ia_sbr_header_data_struct * ptr_header_data_ch_0,ia_sbr_header_data_struct * ptr_header_data_ch_1,ia_sbr_frame_info_data_struct * ptr_sbr_data_ch_0,ia_sbr_prev_frame_data_struct * ptr_prev_data_ch_0,ia_sbr_frame_info_data_struct * ptr_sbr_data_ch_1,ia_sbr_prev_frame_data_struct * ptr_prev_data_ch_1,ixheaacd_misc_tables * ptr_common_tables,WORD32 ldmps_present,WORD32 audio_object_type,WORD32 ec_flag)628 IA_ERRORCODE ixheaacd_dec_sbrdata(ia_sbr_header_data_struct *ptr_header_data_ch_0,
629 ia_sbr_header_data_struct *ptr_header_data_ch_1,
630 ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_0,
631 ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_0,
632 ia_sbr_frame_info_data_struct *ptr_sbr_data_ch_1,
633 ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1,
634 ixheaacd_misc_tables *ptr_common_tables, WORD32 ldmps_present,
635 WORD32 audio_object_type, WORD32 ec_flag) {
636 FLAG error_code;
637 WORD32 err = 0;
638 WORD16 temp_sfb_nrg_prev[MAX_FREQ_COEFFS];
639 WORD32 usac_flag = ptr_header_data_ch_0->usac_flag |
640 ptr_header_data_ch_0->enh_sbr;
641
642 if (ec_flag) {
643 memcpy(temp_sfb_nrg_prev, ptr_prev_data_ch_0->sfb_nrg_prev, MAX_FREQ_COEFFS * sizeof(WORD16));
644 }
645
646 err = ixheaacd_dec_envelope(ptr_header_data_ch_0, ptr_sbr_data_ch_0, ptr_prev_data_ch_0,
647 ptr_prev_data_ch_1, ptr_common_tables, audio_object_type, ec_flag);
648
649 if (err) return err;
650
651 err = ixheaacd_calc_noise_floor(ptr_header_data_ch_0, ptr_sbr_data_ch_0,
652 ptr_prev_data_ch_0, audio_object_type);
653 if (err) return err;
654 if ((!ptr_sbr_data_ch_0->coupling_mode &&
655 ((usac_flag) && (audio_object_type != AOT_ER_AAC_ELD))) || ldmps_present) {
656 ptr_sbr_data_ch_0->num_noise_sfac =
657 ptr_header_data_ch_0->pstr_freq_band_data->num_nf_bands *
658 ptr_sbr_data_ch_0->str_frame_info_details.num_noise_env;
659
660 ixheaacd_dequant_esbr_env_data(
661 ptr_sbr_data_ch_0->flt_env_sf_arr, ptr_sbr_data_ch_0->num_env_sfac,
662 ptr_sbr_data_ch_0->num_noise_sfac, ptr_sbr_data_ch_0->amp_res,
663 ptr_sbr_data_ch_0->flt_noise_floor);
664 }
665
666 if (ptr_sbr_data_ch_1 != NULL) {
667 error_code = ptr_header_data_ch_0->err_flag;
668 err =
669 ixheaacd_dec_envelope(ptr_header_data_ch_1, ptr_sbr_data_ch_1, ptr_prev_data_ch_1,
670 ptr_prev_data_ch_0, ptr_common_tables, audio_object_type, ec_flag);
671
672 if (err) return err;
673
674 err = ixheaacd_calc_noise_floor(ptr_header_data_ch_1, ptr_sbr_data_ch_1,
675 ptr_prev_data_ch_1, audio_object_type);
676
677 if (err) return err;
678
679 if (!ptr_sbr_data_ch_1->coupling_mode &&
680 ((usac_flag) && (audio_object_type != AOT_ER_AAC_ELD))) {
681 ptr_sbr_data_ch_1->num_noise_sfac =
682 ptr_header_data_ch_1->pstr_freq_band_data->num_nf_bands *
683 ptr_sbr_data_ch_1->str_frame_info_details.num_noise_env;
684
685 ixheaacd_dequant_esbr_env_data(
686 ptr_sbr_data_ch_1->flt_env_sf_arr, ptr_sbr_data_ch_1->num_env_sfac,
687 ptr_sbr_data_ch_1->num_noise_sfac, ptr_sbr_data_ch_1->amp_res,
688 ptr_sbr_data_ch_1->flt_noise_floor);
689 }
690 if (ec_flag) {
691 if ((!ptr_header_data_ch_0->usac_flag) || (audio_object_type == AOT_ER_AAC_ELD)) {
692 if (!error_code && ptr_header_data_ch_0->err_flag) {
693 memcpy(ptr_prev_data_ch_0->sfb_nrg_prev, temp_sfb_nrg_prev,
694 MAX_FREQ_COEFFS * sizeof(WORD16));
695 err = ixheaacd_dec_envelope(ptr_header_data_ch_0, ptr_sbr_data_ch_0, ptr_prev_data_ch_0,
696 ptr_prev_data_ch_1, ptr_common_tables, audio_object_type,
697 ec_flag);
698
699 if (err) return err;
700 }
701 }
702 } else {
703 if ((!usac_flag) || (audio_object_type == AOT_ER_AAC_ELD)) {
704 if (!error_code && ptr_header_data_ch_0->err_flag) {
705 err = ixheaacd_dec_envelope(ptr_header_data_ch_0, ptr_sbr_data_ch_0, ptr_prev_data_ch_0,
706 ptr_prev_data_ch_1, ptr_common_tables, audio_object_type,
707 ec_flag);
708
709 if (err) return err;
710 }
711 }
712 }
713
714 if (ptr_sbr_data_ch_0->coupling_mode) {
715 ptr_sbr_data_ch_0->num_noise_sfac =
716 ptr_header_data_ch_1->pstr_freq_band_data->num_nf_bands *
717 ptr_sbr_data_ch_1->str_frame_info_details.num_noise_env;
718 ixheaacd_sbr_env_dequant_coup_fix(ptr_header_data_ch_0, ptr_sbr_data_ch_0,
719 ptr_sbr_data_ch_1, ptr_common_tables);
720
721 ixheaacd_sbr_env_dequant_coup(ptr_sbr_data_ch_0, ptr_sbr_data_ch_1);
722 }
723 }
724
725 return 0;
726 }
ixheaacd_dec_envelope(ia_sbr_header_data_struct * ptr_header_data,ia_sbr_frame_info_data_struct * ptr_sbr_data,ia_sbr_prev_frame_data_struct * ptr_prev_data_ch_0,ia_sbr_prev_frame_data_struct * ptr_prev_data_ch_1,ixheaacd_misc_tables * pstr_common_tables,WORD32 audio_object_type,WORD32 ec_flag)727 IA_ERRORCODE ixheaacd_dec_envelope(ia_sbr_header_data_struct *ptr_header_data,
728 ia_sbr_frame_info_data_struct *ptr_sbr_data,
729 ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_0,
730 ia_sbr_prev_frame_data_struct *ptr_prev_data_ch_1,
731 ixheaacd_misc_tables *pstr_common_tables,
732 WORD32 audio_object_type, WORD32 ec_flag) {
733 FLAG error_code;
734 WORD32 err;
735 WORD16 env_sf_local_arr[MAX_FREQ_COEFFS];
736 WORD32 enh_sbr = ptr_header_data->enh_sbr;
737 WORD32 usac_flag = enh_sbr | ptr_header_data->usac_flag;
738 WORD32 temp_1 =
739 ptr_prev_data_ch_0->end_position - ptr_header_data->num_time_slots;
740
741 if (temp_1 < 0) return IA_FATAL_ERROR;
742 temp_1 = ptr_sbr_data->str_frame_info_details.border_vec[0] - temp_1;
743
744 if ((!ptr_header_data->err_flag_prev) && (!ptr_header_data->err_flag) &&
745 (temp_1 != 0)) {
746 if (ptr_sbr_data->del_cod_dir_arr[0] == DTDF_DIR_TIME) {
747 ptr_header_data->err_flag = 1;
748 } else {
749 ptr_header_data->err_flag_prev = 1;
750 }
751 }
752 if (ec_flag) {
753 if (ptr_header_data->err_flag_prev && (!ptr_header_data->err_flag)) {
754 if (ptr_sbr_data->del_cod_dir_arr[0] != 0) {
755 ptr_header_data->err_flag = 1;
756 }
757 }
758 }
759 if (ec_flag && ptr_header_data->err_flag &&
760 ((!ptr_header_data->usac_flag) || (audio_object_type == AOT_ER_AAC_ELD))) {
761 ixheaacd_lean_sbrconcealment(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0);
762
763 ixheaacd_process_del_cod_env_data(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0);
764 } else if (ptr_header_data->err_flag &&
765 ((!usac_flag) || (audio_object_type == AOT_ER_AAC_ELD))) {
766 ixheaacd_lean_sbrconcealment(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0);
767
768 ixheaacd_process_del_cod_env_data(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0);
769 } else {
770 WORD32 num = ptr_header_data->pstr_freq_band_data->num_sf_bands[HIGH];
771 if (ptr_header_data->err_flag_prev && ((!usac_flag) ||
772 (audio_object_type == AOT_ER_AAC_ELD))) {
773 WORD16 *ptr1, *ptr2;
774 WORD32 i;
775
776 err = ixheaacd_wrong_timing_compensate(ptr_header_data, ptr_sbr_data,
777 ptr_prev_data_ch_0,
778 pstr_common_tables);
779
780 if (err) return err;
781
782 if (ptr_sbr_data->coupling_mode !=
783 (WORD16)ptr_prev_data_ch_0->coupling_mode) {
784 if (ptr_prev_data_ch_0->coupling_mode == COUPLING_BAL) {
785 memcpy(ptr_prev_data_ch_0->sfb_nrg_prev,
786 ptr_prev_data_ch_1->sfb_nrg_prev, sizeof(WORD16) * num);
787 } else {
788 if (ptr_sbr_data->coupling_mode == COUPLING_LEVEL) {
789 ptr1 = ptr_prev_data_ch_0->sfb_nrg_prev;
790 ptr2 = ptr_prev_data_ch_1->sfb_nrg_prev;
791
792 for (i = 0; i < num; i++) {
793 *ptr1 = (add16_m(*ptr1, *ptr2) >> 1);
794 ptr2++;
795 ptr1++;
796 }
797 } else {
798 if (ptr_sbr_data->coupling_mode == COUPLING_BAL) {
799 memset(ptr_prev_data_ch_0->sfb_nrg_prev, SBR_ENERGY_PAN_OFFSET,
800 sizeof(WORD16) * num);
801 }
802 }
803 }
804 }
805 }
806
807 memcpy(env_sf_local_arr, ptr_prev_data_ch_0->sfb_nrg_prev,
808 sizeof(WORD16) * MAX_FREQ_COEFFS);
809
810 ixheaacd_process_del_cod_env_data(ptr_header_data, ptr_sbr_data,
811 ptr_prev_data_ch_0);
812
813 if ((!usac_flag)||(audio_object_type == AOT_ER_AAC_ELD)) {
814 error_code = ixheaacd_check_env_data(ptr_header_data, ptr_sbr_data,
815 ptr_prev_data_ch_0);
816
817 if (error_code) {
818 ptr_header_data->err_flag = 1;
819
820 memcpy(ptr_prev_data_ch_0->sfb_nrg_prev, env_sf_local_arr,
821 sizeof(WORD16) * MAX_FREQ_COEFFS);
822
823 err = ixheaacd_dec_envelope(ptr_header_data, ptr_sbr_data, ptr_prev_data_ch_0,
824 ptr_prev_data_ch_1, pstr_common_tables, audio_object_type,
825 ec_flag);
826
827 if (err) return err;
828 return 0;
829 }
830 }
831 }
832 if (ec_flag) {
833 if ((!ptr_header_data->usac_flag) || (audio_object_type == AOT_ER_AAC_ELD)) {
834 ixheaacd_dequant_env_data(ptr_sbr_data, ptr_sbr_data->amp_res);
835 }
836 } else {
837 if ((!usac_flag) || (audio_object_type == AOT_ER_AAC_ELD)) {
838 ixheaacd_dequant_env_data(ptr_sbr_data, ptr_sbr_data->amp_res);
839 }
840 }
841
842 return 0;
843 }
844
ixheaacd_adj_timeslot(WORD32 * ptr_buf_real,WORD32 * ptr_buf_imag,WORD16 * ptr_filt_buf,WORD16 * ptr_filt_buf_noise,WORD16 * ptr_gain_buf,WORD16 * ptr_noise_floor,WORD16 * ptr_sine_lvl_buf,WORD16 noise_floor_exp,WORD16 * ptr_harm_index,WORD16 sub_band_start,WORD16 num_sub_bands,WORD16 scale_change,WORD16 smooth_ratio,FLAG num_noise_flg,WORD16 * ptr_phase_index,ia_sbr_tables_struct * ptr_sbr_tables)845 VOID ixheaacd_adj_timeslot(WORD32 *ptr_buf_real, WORD32 *ptr_buf_imag,
846 WORD16 *ptr_filt_buf, WORD16 *ptr_filt_buf_noise,
847 WORD16 *ptr_gain_buf, WORD16 *ptr_noise_floor,
848 WORD16 *ptr_sine_lvl_buf, WORD16 noise_floor_exp,
849 WORD16 *ptr_harm_index, WORD16 sub_band_start,
850 WORD16 num_sub_bands, WORD16 scale_change,
851 WORD16 smooth_ratio, FLAG num_noise_flg,
852 WORD16 *ptr_phase_index,
853 ia_sbr_tables_struct *ptr_sbr_tables) {
854 WORD16 k;
855 WORD16 *ptr_smoothed_gain, *ptr_smoothed_noise;
856 WORD16 direct_ratio;
857 WORD32 index = *ptr_phase_index;
858 WORD32 harm_idx = *ptr_harm_index;
859 WORD32 freq_inv_flag;
860 const WORD32 *ptr_rand_ph_buf;
861 WORD32 factor = 0;
862
863 direct_ratio = ixheaacd_sub16_sat(0x7fff, smooth_ratio);
864 freq_inv_flag = (sub_band_start & 1);
865
866 scale_change = scale_change - 1;
867
868 ptr_rand_ph_buf = &ptr_sbr_tables->sbr_rand_ph[index];
869 *ptr_phase_index =
870 (WORD16)((index + num_sub_bands) & (SBR_NF_NO_RANDOM_VAL - 1));
871
872 if (smooth_ratio) {
873 WORD16 *ptr_filt_buf_local = &ptr_filt_buf[0];
874 WORD16 *ptr_gain_buf_local = &ptr_gain_buf[0];
875 WORD16 *ptr_filt_noise_local = &ptr_filt_buf_noise[0];
876 WORD16 *ptr_noise_floor_local = &ptr_noise_floor[0];
877
878 WORD16 tmp, tmp1;
879
880 for (k = 0; k < num_sub_bands; k++) {
881 tmp = add16_m(mult16x16_16(smooth_ratio, *ptr_filt_buf_local),
882 mult16x16_16(direct_ratio, *ptr_gain_buf_local++));
883
884 ptr_gain_buf_local++;
885
886 tmp1 = add16_m(mult16x16_16(smooth_ratio, *ptr_filt_noise_local),
887 mult16x16_16(direct_ratio, *ptr_noise_floor_local++));
888
889 ptr_noise_floor_local++;
890
891 *ptr_filt_buf_local++ = tmp << 1;
892 ptr_filt_buf_local++;
893 *ptr_filt_noise_local++ = tmp1 << 1;
894 }
895 ptr_smoothed_gain = ptr_filt_buf;
896 ptr_smoothed_noise = ptr_filt_buf_noise;
897 factor = 1;
898 } else {
899 ptr_smoothed_gain = ptr_gain_buf;
900 ptr_smoothed_noise = ptr_noise_floor;
901 factor = 2;
902 }
903
904 switch (harm_idx) {
905 case 0:
906 case 2:
907 ixheaacd_harm_idx_zerotwo(num_noise_flg, num_sub_bands, ptr_buf_real,
908 ptr_buf_imag, ptr_smoothed_gain,
909 ptr_smoothed_noise, factor, ptr_gain_buf,
910 scale_change, ptr_rand_ph_buf, ptr_sine_lvl_buf,
911 noise_floor_exp, harm_idx);
912 break;
913 case 1:
914 case 3:
915 ixheaacd_harm_idx_onethree(
916 num_noise_flg, num_sub_bands, ptr_buf_real, ptr_buf_imag,
917 ptr_smoothed_gain, ptr_smoothed_noise, factor, ptr_gain_buf,
918 scale_change, ptr_rand_ph_buf, ptr_sine_lvl_buf, noise_floor_exp,
919 freq_inv_flag, harm_idx);
920 break;
921 }
922 *ptr_harm_index = (WORD16)((harm_idx + 1) & 3);
923 }
924