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 <math.h> 21 #include <stdlib.h> 22 #include <string.h> 23 24 #include "ixheaacd_type_def.h" 25 26 #include "ixheaacd_bitbuffer.h" 27 28 #include "ixheaacd_interface.h" 29 30 #include "ixheaacd_tns_usac.h" 31 #include "ixheaacd_cnst.h" 32 33 #include "ixheaacd_acelp_info.h" 34 35 #include "ixheaacd_sbrdecsettings.h" 36 #include "ixheaacd_info.h" 37 #include "ixheaacd_sbr_common.h" 38 #include "ixheaacd_drc_data_struct.h" 39 #include "ixheaacd_drc_dec.h" 40 #include "ixheaacd_sbrdecoder.h" 41 #include "ixheaacd_mps_polyphase.h" 42 #include "ixheaacd_sbr_const.h" 43 44 #include "ixheaacd_env_extr_part.h" 45 #include "ixheaacd_sbr_rom.h" 46 #include "ixheaacd_common_rom.h" 47 #include "ixheaacd_hybrid.h" 48 #include "ixheaacd_sbr_scale.h" 49 #include "ixheaacd_ps_dec.h" 50 #include "ixheaacd_freq_sca.h" 51 #include "ixheaacd_lpp_tran.h" 52 #include "ixheaacd_bitbuffer.h" 53 #include "ixheaacd_env_extr.h" 54 #include "ixheaacd_qmf_dec.h" 55 #include "ixheaacd_env_calc.h" 56 #include "ixheaacd_pvc_dec.h" 57 58 #include "ixheaacd_sbr_dec.h" 59 #include "ixheaacd_error_standards.h" 60 #include "ixheaacd_sbrqmftrans.h" 61 #include "ixheaacd_qmf_poly.h" 62 63 #include "ixheaacd_constants.h" 64 #include "ixheaacd_basic_ops32.h" 65 #include "ixheaacd_basic_op.h" 66 67 #include "ixheaacd_esbr_rom.h" 68 69 #define SBR_CONST_PMIN 1.0f 70 71 static FLOAT32 *ixheaacd_map_prot_filter(WORD32 filt_length) { 72 switch (filt_length) { 73 case 4: 74 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[0]; 75 break; 76 case 8: 77 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[40]; 78 break; 79 case 12: 80 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[120]; 81 break; 82 case 16: 83 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[240]; 84 break; 85 case 20: 86 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[400]; 87 break; 88 case 24: 89 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[600]; 90 break; 91 case 32: 92 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[840]; 93 break; 94 case 40: 95 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[1160]; 96 break; 97 default: 98 return (FLOAT32 *)&ixheaacd_sub_samp_qmf_window_coeff[0]; 99 } 100 } 101 102 WORD32 ixheaacd_qmf_hbe_data_reinit(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 103 WORD16 *p_freq_band_tab[2], 104 WORD16 *p_num_sfb, WORD32 upsamp_4_flag) { 105 WORD32 synth_size, sfb, patch, stop_patch; 106 107 if (ptr_hbe_txposer != NULL) { 108 ptr_hbe_txposer->start_band = p_freq_band_tab[LOW][0]; 109 ptr_hbe_txposer->end_band = p_freq_band_tab[LOW][p_num_sfb[LOW]]; 110 111 ptr_hbe_txposer->synth_size = 112 4 * ((ptr_hbe_txposer->start_band + 4) / 8 + 1); 113 ptr_hbe_txposer->k_start = 114 ixheaacd_start_subband2kL_tbl[ptr_hbe_txposer->start_band]; 115 116 ptr_hbe_txposer->upsamp_4_flag = upsamp_4_flag; 117 118 if (upsamp_4_flag) { 119 if (ptr_hbe_txposer->k_start + ptr_hbe_txposer->synth_size > 16) 120 ptr_hbe_txposer->k_start = 16 - ptr_hbe_txposer->synth_size; 121 } else if (ptr_hbe_txposer->core_frame_length == 768) { 122 if (ptr_hbe_txposer->k_start + ptr_hbe_txposer->synth_size > 24) 123 ptr_hbe_txposer->k_start = 24 - ptr_hbe_txposer->synth_size; 124 } 125 126 memset(ptr_hbe_txposer->synth_buf, 0, 1280 * sizeof(FLOAT32)); 127 synth_size = ptr_hbe_txposer->synth_size; 128 ptr_hbe_txposer->synth_buf_offset = 18 * synth_size; 129 switch (synth_size) { 130 case 4: 131 ptr_hbe_txposer->synth_cos_tab = 132 (FLOAT32 *)ixheaacd_synth_cos_table_kl_4; 133 ptr_hbe_txposer->analy_cos_sin_tab = 134 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_8; 135 ptr_hbe_txposer->ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; 136 ptr_hbe_txposer->ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; 137 break; 138 case 8: 139 ptr_hbe_txposer->synth_cos_tab = 140 (FLOAT32 *)ixheaacd_synth_cos_table_kl_8; 141 ptr_hbe_txposer->analy_cos_sin_tab = 142 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_16; 143 ptr_hbe_txposer->ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; 144 ptr_hbe_txposer->ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; 145 break; 146 case 12: 147 ptr_hbe_txposer->synth_cos_tab = 148 (FLOAT32 *)ixheaacd_synth_cos_table_kl_12; 149 ptr_hbe_txposer->analy_cos_sin_tab = 150 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_24; 151 ptr_hbe_txposer->ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p3; 152 ptr_hbe_txposer->ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p3; 153 break; 154 case 16: 155 ptr_hbe_txposer->synth_cos_tab = 156 (FLOAT32 *)ixheaacd_synth_cos_table_kl_16; 157 ptr_hbe_txposer->analy_cos_sin_tab = 158 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_32; 159 ptr_hbe_txposer->ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; 160 ptr_hbe_txposer->ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; 161 break; 162 case 20: 163 ptr_hbe_txposer->synth_cos_tab = 164 (FLOAT32 *)ixheaacd_synth_cos_table_kl_20; 165 ptr_hbe_txposer->analy_cos_sin_tab = 166 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_40; 167 break; 168 default: 169 ptr_hbe_txposer->synth_cos_tab = 170 (FLOAT32 *)ixheaacd_synth_cos_table_kl_4; 171 ptr_hbe_txposer->analy_cos_sin_tab = 172 (FLOAT32 *)ixheaacd_analy_cos_sin_table_kl_8; 173 ptr_hbe_txposer->ixheaacd_real_synth_fft = &ixheaacd_real_synth_fft_p2; 174 ptr_hbe_txposer->ixheaacd_cmplx_anal_fft = &ixheaacd_cmplx_anal_fft_p2; 175 } 176 177 ptr_hbe_txposer->synth_wind_coeff = ixheaacd_map_prot_filter(synth_size); 178 179 memset(ptr_hbe_txposer->analy_buf, 0, 640 * sizeof(FLOAT32)); 180 synth_size = 2 * ptr_hbe_txposer->synth_size; 181 ptr_hbe_txposer->analy_wind_coeff = ixheaacd_map_prot_filter(synth_size); 182 183 memset(ptr_hbe_txposer->x_over_qmf, 0, MAX_NUM_PATCHES * sizeof(WORD32)); 184 sfb = 0; 185 if (upsamp_4_flag) { 186 stop_patch = MAX_NUM_PATCHES; 187 ptr_hbe_txposer->max_stretch = MAX_STRETCH; 188 } else { 189 stop_patch = MAX_STRETCH; 190 } 191 192 for (patch = 1; patch <= stop_patch; patch++) { 193 while (sfb <= p_num_sfb[LOW] && 194 p_freq_band_tab[LOW][sfb] <= patch * ptr_hbe_txposer->start_band) 195 sfb++; 196 if (sfb <= p_num_sfb[LOW]) { 197 if ((patch * ptr_hbe_txposer->start_band - 198 p_freq_band_tab[LOW][sfb - 1]) <= 3) { 199 ptr_hbe_txposer->x_over_qmf[patch - 1] = 200 p_freq_band_tab[LOW][sfb - 1]; 201 } else { 202 WORD32 sfb = 0; 203 while (sfb <= p_num_sfb[HIGH] && 204 p_freq_band_tab[HIGH][sfb] <= 205 patch * ptr_hbe_txposer->start_band) 206 sfb++; 207 ptr_hbe_txposer->x_over_qmf[patch - 1] = 208 p_freq_band_tab[HIGH][sfb - 1]; 209 } 210 } else { 211 ptr_hbe_txposer->x_over_qmf[patch - 1] = ptr_hbe_txposer->end_band; 212 ptr_hbe_txposer->max_stretch = min(patch, MAX_STRETCH); 213 break; 214 } 215 } 216 if (ptr_hbe_txposer->k_start < 0) { 217 return -1; 218 } 219 } 220 return 0; 221 } 222 223 WORD32 ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 224 FLOAT32 qmf_buf_real[][64], 225 FLOAT32 qmf_buf_imag[][64], WORD32 num_columns, 226 FLOAT32 pv_qmf_buf_real[][64], 227 FLOAT32 pv_qmf_buf_imag[][64], 228 WORD32 pitch_in_bins) { 229 WORD32 i, qmf_band_idx; 230 WORD32 qmf_voc_columns = ptr_hbe_txposer->no_bins / 2; 231 WORD32 err_code = 0; 232 233 memcpy(ptr_hbe_txposer->ptr_input_buf, 234 ptr_hbe_txposer->ptr_input_buf + 235 ptr_hbe_txposer->no_bins * ptr_hbe_txposer->synth_size, 236 ptr_hbe_txposer->synth_size * sizeof(FLOAT32)); 237 238 ixheaacd_real_synth_filt(ptr_hbe_txposer, num_columns, qmf_buf_real, 239 qmf_buf_imag); 240 241 for (i = 0; i < HBE_OPER_WIN_LEN - 1; i++) { 242 memcpy(ptr_hbe_txposer->qmf_in_buf[i], 243 ptr_hbe_txposer->qmf_in_buf[i + qmf_voc_columns], 244 TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); 245 } 246 247 err_code = ixheaacd_complex_anal_filt(ptr_hbe_txposer); 248 if (err_code) return err_code; 249 250 for (i = 0; i < (ptr_hbe_txposer->hbe_qmf_out_len - ptr_hbe_txposer->no_bins); 251 i++) { 252 memcpy(ptr_hbe_txposer->qmf_out_buf[i], 253 ptr_hbe_txposer->qmf_out_buf[i + ptr_hbe_txposer->no_bins], 254 TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); 255 } 256 257 for (; i < ptr_hbe_txposer->hbe_qmf_out_len; i++) { 258 memset(ptr_hbe_txposer->qmf_out_buf[i], 0, 259 TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); 260 } 261 262 err_code = ixheaacd_hbe_post_anal_process(ptr_hbe_txposer, pitch_in_bins, 263 ptr_hbe_txposer->upsamp_4_flag); 264 if (err_code) return err_code; 265 266 for (i = 0; i < ptr_hbe_txposer->no_bins; i++) { 267 for (qmf_band_idx = ptr_hbe_txposer->start_band; 268 qmf_band_idx < ptr_hbe_txposer->end_band; qmf_band_idx++) { 269 pv_qmf_buf_real[i][qmf_band_idx] = 270 (FLOAT32)(ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx] * 271 ixheaacd_phase_vocoder_cos_table[qmf_band_idx] - 272 ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx + 1] * 273 ixheaacd_phase_vocoder_sin_table[qmf_band_idx]); 274 275 pv_qmf_buf_imag[i][qmf_band_idx] = 276 (FLOAT32)(ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx] * 277 ixheaacd_phase_vocoder_sin_table[qmf_band_idx] + 278 ptr_hbe_txposer->qmf_out_buf[i][2 * qmf_band_idx + 1] * 279 ixheaacd_phase_vocoder_cos_table[qmf_band_idx]); 280 } 281 } 282 return 0; 283 } 284 285 VOID ixheaacd_norm_qmf_in_buf_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 286 WORD32 qmf_band_idx) { 287 WORD32 i; 288 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * qmf_band_idx]; 289 FLOAT32 *norm_buf = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * qmf_band_idx]; 290 291 for (; qmf_band_idx <= ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { 292 for (i = 0; i < ptr_hbe_txposer->hbe_qmf_in_len; i++) { 293 FLOAT32 mag_scaling_fac = 0.0f; 294 FLOAT32 x_r, x_i, temp; 295 FLOAT64 base = 1e-17; 296 x_r = in_buf[0]; 297 x_i = in_buf[1]; 298 299 temp = x_r * x_r; 300 base = base + temp; 301 temp = x_i * x_i; 302 base = base + temp; 303 304 temp = (FLOAT32)sqrt(sqrt(base)); 305 mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); 306 307 mag_scaling_fac = 1 / mag_scaling_fac; 308 309 x_r *= mag_scaling_fac; 310 x_i *= mag_scaling_fac; 311 312 norm_buf[0] = x_r; 313 norm_buf[1] = x_i; 314 315 in_buf += 128; 316 norm_buf += 128; 317 } 318 319 in_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); 320 norm_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); 321 } 322 } 323 324 VOID ixheaacd_norm_qmf_in_buf_2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 325 WORD32 qmf_band_idx) { 326 WORD32 i; 327 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * qmf_band_idx]; 328 FLOAT32 *norm_buf = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * qmf_band_idx]; 329 330 for (; qmf_band_idx <= ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { 331 for (i = 0; i < ptr_hbe_txposer->hbe_qmf_in_len; i++) { 332 FLOAT32 mag_scaling_fac = 0.0f; 333 FLOAT32 x_r, x_i, temp; 334 FLOAT64 base = 1e-17; 335 x_r = in_buf[0]; 336 x_i = in_buf[1]; 337 338 temp = x_r * x_r; 339 base = base + temp; 340 temp = x_i * x_i; 341 base = base + x_i * x_i; 342 343 mag_scaling_fac = (FLOAT32)(1.0f / base); 344 mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); 345 346 x_r *= mag_scaling_fac; 347 x_i *= mag_scaling_fac; 348 349 norm_buf[0] = x_r; 350 norm_buf[1] = x_i; 351 352 in_buf += 128; 353 norm_buf += 128; 354 } 355 356 in_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); 357 norm_buf -= (128 * (ptr_hbe_txposer->hbe_qmf_in_len) - 2); 358 } 359 } 360 361 VOID ixheaacd_hbe_xprod_proc_3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 362 WORD32 qmf_band_idx, WORD32 qmf_col_idx, 363 FLOAT32 p, WORD32 pitch_in_bins_idx) { 364 WORD32 tr, n1, n2, max_trans_fac, max_n1, max_n2; 365 WORD32 k, addrshift; 366 WORD32 inp_band_idx = 2 * qmf_band_idx / 3; 367 368 FLOAT64 temp_fac; 369 FLOAT32 max_mag_value; 370 FLOAT32 mag_zero_band, mag_n1_band, mag_n2_band, temp; 371 FLOAT32 temp_r, temp_i; 372 FLOAT32 mag_cmplx_gain = 1.8856f; 373 374 FLOAT32 *qmf_in_buf_ri = 375 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX]; 376 377 mag_zero_band = 378 qmf_in_buf_ri[2 * inp_band_idx] * qmf_in_buf_ri[2 * inp_band_idx] + 379 qmf_in_buf_ri[2 * inp_band_idx + 1] * qmf_in_buf_ri[2 * inp_band_idx + 1]; 380 max_mag_value = 0; 381 max_n1 = max_n2 = max_trans_fac = 0; 382 383 for (tr = 1; tr < 3; tr++) { 384 temp_fac = (2.0f * qmf_band_idx + 1 - tr * p) * 0.3333334; 385 386 n1 = (WORD32)(temp_fac); 387 n2 = (WORD32)(temp_fac + p); 388 389 mag_n1_band = qmf_in_buf_ri[2 * n1] * qmf_in_buf_ri[2 * n1] + 390 qmf_in_buf_ri[2 * n1 + 1] * qmf_in_buf_ri[2 * n1 + 1]; 391 mag_n2_band = qmf_in_buf_ri[2 * n2] * qmf_in_buf_ri[2 * n2] + 392 qmf_in_buf_ri[2 * n2 + 1] * qmf_in_buf_ri[2 * n2 + 1]; 393 temp = min(mag_n1_band, mag_n2_band); 394 395 if (temp > max_mag_value) { 396 max_mag_value = temp; 397 max_trans_fac = tr; 398 max_n1 = n1; 399 max_n2 = n2; 400 } 401 } 402 403 if (max_mag_value > mag_zero_band && max_n1 >= 0 && 404 max_n2 < NO_QMF_SYNTH_CHANNELS) { 405 FLOAT32 vec_y_r[2], vec_y_i[2], vec_o_r[2], vec_o_i[2]; 406 FLOAT32 coeff_real[2], coeff_imag[2]; 407 FLOAT32 d1, d2; 408 WORD32 mid_trans_fac, idx; 409 FLOAT64 base = 1e-17; 410 FLOAT32 mag_scaling_fac = 0; 411 FLOAT32 x_zero_band_r; 412 FLOAT32 x_zero_band_i; 413 414 x_zero_band_r = 0; 415 x_zero_band_i = 0; 416 mid_trans_fac = 3 - max_trans_fac; 417 if (max_trans_fac == 1) { 418 WORD32 idx; 419 d1 = 0; 420 d2 = 1.5; 421 x_zero_band_r = qmf_in_buf_ri[2 * max_n1]; 422 x_zero_band_i = qmf_in_buf_ri[2 * max_n1 + 1]; 423 424 idx = max_n2 & 3; 425 idx = (idx + 1) & 3; 426 coeff_real[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][0]; 427 coeff_imag[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][1]; 428 429 coeff_real[1] = coeff_real[0]; 430 coeff_imag[1] = -coeff_imag[0]; 431 432 vec_y_r[1] = qmf_in_buf_ri[2 * max_n2]; 433 vec_y_i[1] = qmf_in_buf_ri[2 * max_n2 + 1]; 434 435 addrshift = -2; 436 temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 437 HBE_ZERO_BAND_IDX][2 * max_n2]; 438 temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 439 HBE_ZERO_BAND_IDX][2 * max_n2 + 1]; 440 441 vec_y_r[0] = coeff_real[1] * temp_r - coeff_imag[1] * temp_i; 442 vec_y_i[0] = coeff_imag[1] * temp_r + coeff_real[1] * temp_i; 443 444 temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + 445 HBE_ZERO_BAND_IDX][2 * max_n2]; 446 temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + 447 HBE_ZERO_BAND_IDX][2 * max_n2 + 1]; 448 449 vec_y_r[0] += coeff_real[0] * temp_r - coeff_imag[0] * temp_i; 450 vec_y_i[0] += coeff_imag[0] * temp_r + coeff_real[0] * temp_i; 451 452 } else { 453 WORD32 idx; 454 d1 = 1.5; 455 d2 = 0; 456 mid_trans_fac = max_trans_fac; 457 max_trans_fac = 3 - max_trans_fac; 458 459 x_zero_band_r = qmf_in_buf_ri[2 * max_n2]; 460 x_zero_band_i = qmf_in_buf_ri[2 * max_n2 + 1]; 461 462 idx = (max_n1 & 3); 463 idx = (idx + 1) & 3; 464 coeff_real[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][0]; 465 coeff_imag[0] = ixheaacd_hbe_post_anal_proc_interp_coeff[idx][1]; 466 467 coeff_real[1] = coeff_real[0]; 468 coeff_imag[1] = -coeff_imag[0]; 469 470 vec_y_r[1] = qmf_in_buf_ri[2 * max_n1]; 471 vec_y_i[1] = qmf_in_buf_ri[2 * max_n1 + 1]; 472 473 addrshift = -2; 474 475 temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 476 HBE_ZERO_BAND_IDX][2 * max_n1]; 477 temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 478 HBE_ZERO_BAND_IDX][2 * max_n1 + 1]; 479 480 vec_y_r[0] = coeff_real[1] * temp_r - coeff_imag[1] * temp_i; 481 vec_y_i[0] = coeff_imag[1] * temp_r + coeff_real[1] * temp_i; 482 483 temp_r = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + 484 HBE_ZERO_BAND_IDX][2 * max_n1]; 485 temp_i = ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + addrshift + 1 + 486 HBE_ZERO_BAND_IDX][2 * max_n1 + 1]; 487 488 vec_y_r[0] += coeff_real[0] * temp_r - coeff_imag[0] * temp_i; 489 vec_y_i[0] += coeff_imag[0] * temp_r + coeff_real[0] * temp_i; 490 } 491 492 base = 1e-17; 493 base = base + x_zero_band_r * x_zero_band_r; 494 base = base + x_zero_band_i * x_zero_band_i; 495 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base)); 496 x_zero_band_r *= mag_scaling_fac; 497 x_zero_band_i *= mag_scaling_fac; 498 for (k = 0; k < 2; k++) { 499 base = 1e-17; 500 base = base + vec_y_r[k] * vec_y_r[k]; 501 base = base + vec_y_i[k] * vec_y_i[k]; 502 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base)); 503 vec_y_r[k] *= mag_scaling_fac; 504 vec_y_i[k] *= mag_scaling_fac; 505 } 506 507 temp_r = x_zero_band_r; 508 temp_i = x_zero_band_i; 509 for (idx = 0; idx < mid_trans_fac - 1; idx++) { 510 FLOAT32 tmp = x_zero_band_r; 511 x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; 512 x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; 513 } 514 515 for (k = 0; k < 2; k++) { 516 temp_r = vec_y_r[k]; 517 temp_i = vec_y_i[k]; 518 for (idx = 0; idx < max_trans_fac - 1; idx++) { 519 FLOAT32 tmp = vec_y_r[k]; 520 vec_y_r[k] = vec_y_r[k] * temp_r - vec_y_i[k] * temp_i; 521 vec_y_i[k] = tmp * temp_i + vec_y_i[k] * temp_r; 522 } 523 } 524 525 for (k = 0; k < 2; k++) { 526 vec_o_r[k] = vec_y_r[k] * x_zero_band_r - vec_y_i[k] * x_zero_band_i; 527 vec_o_i[k] = vec_y_r[k] * x_zero_band_i + vec_y_i[k] * x_zero_band_r; 528 } 529 530 { 531 FLOAT32 cos_theta = 532 ixheaacd_hbe_x_prod_cos_table_trans_3[(pitch_in_bins_idx << 1) + 0]; 533 FLOAT32 sin_theta = 534 ixheaacd_hbe_x_prod_cos_table_trans_3[(pitch_in_bins_idx << 1) + 1]; 535 if (d2 < d1) { 536 sin_theta = -sin_theta; 537 } 538 temp_r = vec_o_r[0]; 539 temp_i = vec_o_i[0]; 540 vec_o_r[0] = (FLOAT32)(cos_theta * temp_r - sin_theta * temp_i); 541 vec_o_i[0] = (FLOAT32)(cos_theta * temp_i + sin_theta * temp_r); 542 } 543 544 for (k = 0; k < 2; k++) { 545 ptr_hbe_txposer->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 546 1)][2 * qmf_band_idx] += 547 (FLOAT32)(mag_cmplx_gain * vec_o_r[k]); 548 ptr_hbe_txposer 549 ->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 1)] 550 [2 * qmf_band_idx + 1] += 551 (FLOAT32)(mag_cmplx_gain * vec_o_i[k]); 552 } 553 } 554 } 555 556 VOID ixheaacd_hbe_xprod_proc_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 557 WORD32 qmf_band_idx, WORD32 qmf_col_idx, 558 FLOAT32 p, WORD32 pitch_in_bins_idx) { 559 WORD32 k; 560 WORD32 inp_band_idx = qmf_band_idx >> 1; 561 WORD32 tr, n1, n2, max_trans_fac, max_n1, max_n2; 562 563 FLOAT64 temp_fac; 564 FLOAT32 max_mag_value, mag_zero_band, mag_n1_band, mag_n2_band, temp; 565 FLOAT32 temp_r, temp_i; 566 FLOAT32 mag_cmplx_gain = 2.0f; 567 568 FLOAT32 *qmf_in_buf_ri = 569 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX]; 570 571 mag_zero_band = 572 qmf_in_buf_ri[2 * inp_band_idx] * qmf_in_buf_ri[2 * inp_band_idx] + 573 qmf_in_buf_ri[2 * inp_band_idx + 1] * qmf_in_buf_ri[2 * inp_band_idx + 1]; 574 575 max_mag_value = 0; 576 max_n1 = max_n2 = max_trans_fac = 0; 577 578 for (tr = 1; tr < 4; tr++) { 579 temp_fac = (2.0 * qmf_band_idx + 1 - tr * p) * 0.25; 580 n1 = ((WORD32)(temp_fac)) << 1; 581 n2 = ((WORD32)(temp_fac + p)) << 1; 582 583 mag_n1_band = qmf_in_buf_ri[n1] * qmf_in_buf_ri[n1] + 584 qmf_in_buf_ri[n1 + 1] * qmf_in_buf_ri[n1 + 1]; 585 mag_n2_band = qmf_in_buf_ri[n2] * qmf_in_buf_ri[n2] + 586 qmf_in_buf_ri[n2 + 1] * qmf_in_buf_ri[n2 + 1]; 587 588 temp = min(mag_n1_band, mag_n2_band); 589 590 if (temp > max_mag_value) { 591 max_mag_value = temp; 592 max_trans_fac = tr; 593 max_n1 = n1; 594 max_n2 = n2; 595 } 596 } 597 if (max_mag_value > mag_zero_band && max_n1 >= 0 && 598 max_n2 < TWICE_QMF_SYNTH_CHANNELS_NUM) { 599 FLOAT32 vec_y_r[2], vec_y_i[2], vec_o_r[2], vec_o_i[2]; 600 FLOAT32 d1, d2; 601 WORD32 mid_trans_fac, idx; 602 FLOAT32 x_zero_band_r; 603 FLOAT32 x_zero_band_i; 604 FLOAT64 base = 1e-17; 605 FLOAT32 mag_scaling_fac = 0.0f; 606 607 x_zero_band_r = 0; 608 x_zero_band_i = 0; 609 mid_trans_fac = 4 - max_trans_fac; 610 611 if (max_trans_fac == 1) { 612 d1 = 0; 613 d2 = 2; 614 x_zero_band_r = qmf_in_buf_ri[max_n1]; 615 x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; 616 for (k = 0; k < 2; k++) { 617 vec_y_r[k] = 618 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + 619 2 * (k - 1)][max_n2]; 620 vec_y_i[k] = 621 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + 622 2 * (k - 1)][max_n2 + 1]; 623 } 624 } else if (max_trans_fac == 2) { 625 d1 = 0; 626 d2 = 1; 627 x_zero_band_r = qmf_in_buf_ri[max_n1]; 628 x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; 629 for (k = 0; k < 2; k++) { 630 vec_y_r[k] = 631 ptr_hbe_txposer 632 ->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + (k - 1)][max_n2]; 633 vec_y_i[k] = 634 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + 635 (k - 1)][max_n2 + 1]; 636 } 637 } else { 638 d1 = 2; 639 d2 = 0; 640 mid_trans_fac = max_trans_fac; 641 max_trans_fac = 4 - max_trans_fac; 642 x_zero_band_r = qmf_in_buf_ri[max_n2]; 643 x_zero_band_i = qmf_in_buf_ri[max_n2 + 1]; 644 for (k = 0; k < 2; k++) { 645 vec_y_r[k] = 646 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + 647 2 * (k - 1)][max_n1]; 648 vec_y_i[k] = 649 ptr_hbe_txposer->qmf_in_buf[qmf_col_idx + HBE_ZERO_BAND_IDX + 650 2 * (k - 1)][max_n1 + 1]; 651 } 652 } 653 654 base = 1e-17; 655 base = base + x_zero_band_r * x_zero_band_r; 656 base = base + x_zero_band_i * x_zero_band_i; 657 { 658 temp = (FLOAT32)sqrt(sqrt(base)); 659 mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); 660 mag_scaling_fac = 1 / mag_scaling_fac; 661 } 662 663 x_zero_band_r *= mag_scaling_fac; 664 x_zero_band_i *= mag_scaling_fac; 665 for (k = 0; k < 2; k++) { 666 base = 1e-17; 667 base = base + vec_y_r[k] * vec_y_r[k]; 668 base = base + vec_y_i[k] * vec_y_i[k]; 669 { 670 temp = (FLOAT32)sqrt(sqrt(base)); 671 mag_scaling_fac = temp * (FLOAT32)(sqrt(temp)); 672 673 mag_scaling_fac = 1 / mag_scaling_fac; 674 } 675 vec_y_r[k] *= mag_scaling_fac; 676 vec_y_i[k] *= mag_scaling_fac; 677 } 678 679 temp_r = x_zero_band_r; 680 temp_i = x_zero_band_i; 681 for (idx = 0; idx < mid_trans_fac - 1; idx++) { 682 FLOAT32 tmp = x_zero_band_r; 683 x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; 684 x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; 685 } 686 687 for (k = 0; k < 2; k++) { 688 temp_r = vec_y_r[k]; 689 temp_i = vec_y_i[k]; 690 for (idx = 0; idx < max_trans_fac - 1; idx++) { 691 FLOAT32 tmp = vec_y_r[k]; 692 vec_y_r[k] = vec_y_r[k] * temp_r - vec_y_i[k] * temp_i; 693 vec_y_i[k] = tmp * temp_i + vec_y_i[k] * temp_r; 694 } 695 } 696 697 for (k = 0; k < 2; k++) { 698 vec_o_r[k] = vec_y_r[k] * x_zero_band_r - vec_y_i[k] * x_zero_band_i; 699 vec_o_i[k] = vec_y_r[k] * x_zero_band_i + vec_y_i[k] * x_zero_band_r; 700 } 701 702 { 703 FLOAT32 cos_theta; 704 FLOAT32 sin_theta; 705 706 if (d2 == 1) { 707 cos_theta = 708 ixheaacd_hbe_x_prod_cos_table_trans_4_1[(pitch_in_bins_idx << 1) + 709 0]; 710 sin_theta = 711 ixheaacd_hbe_x_prod_cos_table_trans_4_1[(pitch_in_bins_idx << 1) + 712 1]; 713 } else { 714 cos_theta = 715 ixheaacd_hbe_x_prod_cos_table_trans_4[(pitch_in_bins_idx << 1) + 0]; 716 sin_theta = 717 ixheaacd_hbe_x_prod_cos_table_trans_4[(pitch_in_bins_idx << 1) + 1]; 718 if (d2 < d1) { 719 sin_theta = -sin_theta; 720 } 721 } 722 temp_r = vec_o_r[0]; 723 temp_i = vec_o_i[0]; 724 vec_o_r[0] = (FLOAT32)(cos_theta * temp_r - sin_theta * temp_i); 725 vec_o_i[0] = (FLOAT32)(cos_theta * temp_i + sin_theta * temp_r); 726 } 727 728 for (k = 0; k < 2; k++) { 729 ptr_hbe_txposer->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 730 1)][2 * qmf_band_idx] += 731 (FLOAT32)(mag_cmplx_gain * vec_o_r[k]); 732 ptr_hbe_txposer 733 ->qmf_out_buf[qmf_col_idx * 2 + (k + HBE_ZERO_BAND_IDX - 1)] 734 [2 * qmf_band_idx + 1] += 735 (FLOAT32)(mag_cmplx_gain * vec_o_i[k]); 736 } 737 } 738 } 739 740 VOID ixheaacd_hbe_post_anal_prod2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 741 WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { 742 WORD32 i; 743 FLOAT32 *norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[1][2 * qmf_band_idx]; 744 FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[1][2 * qmf_band_idx]; 745 FLOAT32 *x_norm_ptr = 746 &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * qmf_band_idx]; 747 748 ixheaacd_norm_qmf_in_buf_2(ptr_hbe_txposer, qmf_band_idx); 749 750 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { 751 for (i = 0; i < qmf_voc_columns; i++) { 752 WORD32 k; 753 FLOAT32 x_zero_band_r, x_zero_band_i; 754 755 x_zero_band_r = *x_norm_ptr++; 756 x_zero_band_i = *x_norm_ptr++; 757 758 for (k = 0; k < HBE_OPER_BLK_LEN_2; k++) { 759 register FLOAT32 tmp_r, tmp_i; 760 tmp_r = *norm_ptr++; 761 tmp_i = *norm_ptr++; 762 763 *out_ptr++ += 764 ((tmp_r * x_zero_band_r - tmp_i * x_zero_band_i) * 0.3333333f); 765 766 *out_ptr++ += 767 ((tmp_r * x_zero_band_i + tmp_i * x_zero_band_r) * 0.3333333f); 768 769 norm_ptr += 126; 770 out_ptr += 126; 771 } 772 773 norm_ptr -= 128 * 9; 774 out_ptr -= 128 * 8; 775 x_norm_ptr += 126; 776 } 777 out_ptr -= (128 * 2 * qmf_voc_columns) - 2; 778 norm_ptr -= (128 * qmf_voc_columns) - 2; 779 x_norm_ptr -= (128 * qmf_voc_columns) - 2; 780 } 781 } 782 783 VOID ixheaacd_hbe_post_anal_prod3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 784 WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { 785 WORD32 i, inp_band_idx, rem; 786 787 FLOAT32 *out_buf = &ptr_hbe_txposer->qmf_out_buf[2][2 * qmf_band_idx]; 788 789 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[2]; qmf_band_idx++) { 790 FLOAT32 temp_r, temp_i; 791 FLOAT32 temp_r1, temp_i1; 792 const FLOAT32 *ptr_sel, *ptr_sel1; 793 794 inp_band_idx = (2 * qmf_band_idx) / 3; 795 ptr_sel = &ixheaacd_sel_case[(inp_band_idx + 1) & 3][0]; 796 ptr_sel1 = &ixheaacd_sel_case[((inp_band_idx + 1) & 3) + 1][0]; 797 rem = 2 * qmf_band_idx - 3 * inp_band_idx; 798 799 if (rem == 0 || rem == 1) { 800 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; 801 802 for (i = 0; i < qmf_voc_columns; i += 1) { 803 WORD32 k; 804 FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; 805 FLOAT32 *ptr_vec_x = &vec_x[0]; 806 FLOAT32 x_zero_band_r, x_zero_band_i; 807 808 FLOAT32 mag_scaling_fac; 809 810 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { 811 FLOAT64 base1; 812 FLOAT64 base = 1e-17; 813 814 temp_r = in_buf[0]; 815 temp_i = in_buf[1]; 816 817 in_buf += 256; 818 819 base1 = base + temp_r * temp_r; 820 base1 = base1 + temp_i * temp_i; 821 822 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 823 824 ptr_vec_x[0] = temp_r * mag_scaling_fac; 825 ptr_vec_x[1] = temp_i * mag_scaling_fac; 826 827 temp_r = in_buf[0]; 828 temp_i = in_buf[1]; 829 830 in_buf -= 128; 831 832 temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; 833 temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; 834 835 temp_r = in_buf[0]; 836 temp_i = in_buf[1]; 837 838 temp_r1 += ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; 839 temp_i1 += ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; 840 841 temp_r1 *= 0.3984033437f; 842 temp_i1 *= 0.3984033437f; 843 844 base1 = base + temp_r1 * temp_r1; 845 base1 = base1 + temp_i1 * temp_i1; 846 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 847 848 ptr_vec_x[2] = temp_r1 * mag_scaling_fac; 849 ptr_vec_x[3] = temp_i1 * mag_scaling_fac; 850 851 ptr_vec_x += 4; 852 in_buf += 256; 853 } 854 ptr_vec_x = &vec_x[0]; 855 temp_r = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; 856 temp_i = vec_x[(2 * (HBE_ZERO_BAND_IDX - 2)) + 1]; 857 858 x_zero_band_r = temp_r * temp_r - temp_i * temp_i; 859 x_zero_band_i = temp_r * temp_i + temp_i * temp_r; 860 861 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { 862 temp_r = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; 863 temp_i = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; 864 865 out_buf[0] += (temp_r * 0.4714045f); 866 out_buf[1] += (temp_i * 0.4714045f); 867 868 ptr_vec_x += 2; 869 out_buf += 128; 870 } 871 872 in_buf -= 128 * 11; 873 out_buf -= 128 * 6; 874 } 875 } else { 876 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; 877 FLOAT32 *in_buf1 = 878 &ptr_hbe_txposer->qmf_in_buf[0][2 * (inp_band_idx + 1)]; 879 880 for (i = 0; i < qmf_voc_columns; i++) { 881 WORD32 k; 882 FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; 883 FLOAT32 vec_x_cap[2 * HBE_OPER_WIN_LEN]; 884 885 FLOAT32 x_zero_band_r, x_zero_band_i; 886 FLOAT32 *ptr_vec_x = &vec_x[0]; 887 FLOAT32 *ptr_vec_x_cap = &vec_x_cap[0]; 888 889 FLOAT32 mag_scaling_fac; 890 891 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { 892 FLOAT32 tmp_vr, tmp_vi; 893 FLOAT32 tmp_cr, tmp_ci; 894 FLOAT64 base1; 895 FLOAT64 base = 1e-17; 896 897 temp_r1 = in_buf[0]; 898 temp_i1 = in_buf[1]; 899 temp_r = in_buf1[0]; 900 temp_i = in_buf1[1]; 901 902 base1 = base + temp_r * temp_r; 903 base1 = base1 + temp_i * temp_i; 904 905 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 906 907 ptr_vec_x[0] = temp_r * mag_scaling_fac; 908 ptr_vec_x[1] = temp_i * mag_scaling_fac; 909 910 base1 = base + temp_r1 * temp_r1; 911 base1 = base1 + temp_i1 * temp_i1; 912 913 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 914 915 ptr_vec_x_cap[0] = temp_r1 * mag_scaling_fac; 916 ptr_vec_x_cap[1] = temp_i1 * mag_scaling_fac; 917 918 in_buf += 256; 919 920 temp_r = in_buf[0]; 921 temp_i = in_buf[1]; 922 923 temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; 924 temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; 925 926 in_buf -= 128; 927 928 temp_r = in_buf[0]; 929 temp_i = in_buf[1]; 930 931 tmp_cr = temp_r1 + ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; 932 tmp_ci = temp_i1 + ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; 933 934 in_buf1 += 256; 935 936 temp_r = in_buf1[0]; 937 temp_i = in_buf1[1]; 938 939 temp_r1 = ptr_sel1[0] * temp_r + ptr_sel1[1] * temp_i; 940 temp_i1 = ptr_sel1[2] * temp_r + ptr_sel1[3] * temp_i; 941 942 in_buf1 -= 128; 943 944 temp_r = in_buf1[0]; 945 temp_i = in_buf1[1]; 946 947 tmp_vr = temp_r1 + ptr_sel1[4] * temp_r + ptr_sel1[5] * temp_i; 948 tmp_vi = temp_i1 + ptr_sel1[6] * temp_r + ptr_sel1[7] * temp_i; 949 950 tmp_cr *= 0.3984033437f; 951 tmp_ci *= 0.3984033437f; 952 953 tmp_vr *= 0.3984033437f; 954 tmp_vi *= 0.3984033437f; 955 956 base1 = base + tmp_vr * tmp_vr; 957 base1 = base1 + tmp_vi * tmp_vi; 958 959 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 960 961 ptr_vec_x[2] = tmp_vr * mag_scaling_fac; 962 ptr_vec_x[3] = tmp_vi * mag_scaling_fac; 963 964 base1 = base + tmp_cr * tmp_cr; 965 base1 = base1 + tmp_ci * tmp_ci; 966 967 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 968 969 ptr_vec_x_cap[2] = tmp_cr * mag_scaling_fac; 970 ptr_vec_x_cap[3] = tmp_ci * mag_scaling_fac; 971 972 in_buf += 256; 973 in_buf1 += 256; 974 ptr_vec_x += 4; 975 ptr_vec_x_cap += 4; 976 } 977 ptr_vec_x = &vec_x[0]; 978 ptr_vec_x_cap = &vec_x_cap[0]; 979 980 temp_r = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2)]; 981 temp_i = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; 982 temp_r1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; 983 temp_i1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; 984 985 x_zero_band_r = temp_r * temp_r - temp_i * temp_i; 986 x_zero_band_i = temp_r * temp_i + temp_i * temp_r; 987 988 temp_r = temp_r1 * temp_r1 - temp_i1 * temp_i1; 989 temp_i = temp_r1 * temp_i1 + temp_i1 * temp_r1; 990 991 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { 992 temp_r1 = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; 993 temp_i1 = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; 994 995 temp_r1 += ptr_vec_x_cap[0] * temp_r - ptr_vec_x_cap[1] * temp_i; 996 temp_i1 += ptr_vec_x_cap[0] * temp_i + ptr_vec_x_cap[1] * temp_r; 997 998 out_buf[0] += (temp_r1 * 0.23570225f); 999 out_buf[1] += (temp_i1 * 0.23570225f); 1000 1001 out_buf += 128; 1002 ptr_vec_x += 2; 1003 ptr_vec_x_cap += 2; 1004 } 1005 1006 in_buf -= 128 * 11; 1007 in_buf1 -= 128 * 11; 1008 out_buf -= 128 * 6; 1009 } 1010 } 1011 1012 out_buf -= (256 * qmf_voc_columns) - 2; 1013 } 1014 } 1015 1016 VOID ixheaacd_hbe_post_anal_prod4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 1017 WORD32 qmf_voc_columns, WORD32 qmf_band_idx) { 1018 WORD32 i, inp_band_idx; 1019 FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[3][2 * qmf_band_idx]; 1020 1021 ixheaacd_norm_qmf_in_buf_4(ptr_hbe_txposer, ((qmf_band_idx >> 1) - 1)); 1022 1023 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { 1024 WORD32 ip_idx; 1025 FLOAT32 temp, temp_r, temp_i; 1026 FLOAT32 *norm_ptr, *x_norm_ptr; 1027 inp_band_idx = qmf_band_idx >> 1; 1028 ip_idx = (qmf_band_idx & 1) ? (inp_band_idx + 1) : (inp_band_idx - 1); 1029 1030 norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * ip_idx]; 1031 x_norm_ptr = 1032 &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * inp_band_idx]; 1033 1034 for (i = 0; i < qmf_voc_columns; i++) { 1035 WORD32 k; 1036 FLOAT32 x_zero_band_r, x_zero_band_i; 1037 1038 temp_r = x_zero_band_r = *x_norm_ptr++; 1039 temp_i = x_zero_band_i = *x_norm_ptr++; 1040 1041 temp = x_zero_band_r * x_zero_band_r - x_zero_band_i * x_zero_band_i; 1042 x_zero_band_i = 1043 x_zero_band_r * x_zero_band_i + x_zero_band_i * x_zero_band_r; 1044 1045 x_zero_band_r = temp_r * temp - temp_i * x_zero_band_i; 1046 x_zero_band_i = temp_r * x_zero_band_i + temp_i * temp; 1047 1048 for (k = 0; k < HBE_OPER_BLK_LEN_4; k++) { 1049 temp = *norm_ptr++; 1050 temp_i = *norm_ptr++; 1051 1052 temp_r = temp * x_zero_band_r - temp_i * x_zero_band_i; 1053 temp_i = temp * x_zero_band_i + temp_i * x_zero_band_r; 1054 1055 *out_ptr++ += (temp_r * 0.6666667f); 1056 *out_ptr++ += (temp_i * 0.6666667f); 1057 1058 norm_ptr += 254; 1059 out_ptr += 126; 1060 } 1061 1062 norm_ptr -= 128 * 11; 1063 out_ptr -= 128 * 4; 1064 x_norm_ptr += 126; 1065 } 1066 1067 out_ptr -= (128 * 2 * qmf_voc_columns) - 2; 1068 } 1069 } 1070 1071 VOID ixheaacd_hbe_post_anal_xprod2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 1072 WORD32 qmf_voc_columns, WORD32 qmf_band_idx, 1073 FLOAT32 p, FLOAT32 *cos_sin_theta) { 1074 WORD32 i; 1075 FLOAT32 *norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[1][2 * qmf_band_idx]; 1076 FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[1][2 * qmf_band_idx]; 1077 FLOAT32 *x_norm_ptr = 1078 &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * qmf_band_idx]; 1079 1080 ixheaacd_norm_qmf_in_buf_2(ptr_hbe_txposer, qmf_band_idx); 1081 1082 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[1]; qmf_band_idx++) { 1083 WORD32 n1, n2; 1084 FLOAT64 temp_fac; 1085 FLOAT32 mag_cmplx_gain = 1.666666667f; 1086 temp_fac = (2.0 * qmf_band_idx + 1 - p) * 0.5; 1087 n1 = ((WORD32)(temp_fac)) << 1; 1088 n2 = ((WORD32)(temp_fac + p)) << 1; 1089 1090 for (i = 0; i < qmf_voc_columns; i++) { 1091 WORD32 k; 1092 FLOAT32 x_zero_band_r, x_zero_band_i; 1093 1094 x_zero_band_r = *x_norm_ptr++; 1095 x_zero_band_i = *x_norm_ptr++; 1096 1097 for (k = 1; k < (HBE_OPER_BLK_LEN_2 + 1); k++) { 1098 register FLOAT32 tmp_r, tmp_i; 1099 tmp_r = *norm_ptr++; 1100 tmp_i = *norm_ptr++; 1101 1102 *out_ptr++ += 1103 ((tmp_r * x_zero_band_r - tmp_i * x_zero_band_i) * 0.3333333f); 1104 1105 *out_ptr++ += 1106 ((tmp_r * x_zero_band_i + tmp_i * x_zero_band_r) * 0.3333333f); 1107 1108 norm_ptr += 126; 1109 out_ptr += 126; 1110 } 1111 norm_ptr -= 128 * 9; 1112 out_ptr -= 128 * 8; 1113 x_norm_ptr += 126; 1114 1115 { 1116 WORD32 max_trans_fac, max_n1, max_n2; 1117 FLOAT32 max_mag_value; 1118 FLOAT32 mag_zero_band, mag_n1_band, mag_n2_band, temp; 1119 1120 FLOAT32 *qmf_in_buf_ri = 1121 ptr_hbe_txposer->qmf_in_buf[i + HBE_ZERO_BAND_IDX]; 1122 1123 mag_zero_band = 1124 qmf_in_buf_ri[2 * qmf_band_idx] * qmf_in_buf_ri[2 * qmf_band_idx] + 1125 qmf_in_buf_ri[2 * qmf_band_idx + 1] * 1126 qmf_in_buf_ri[2 * qmf_band_idx + 1]; 1127 1128 mag_n1_band = qmf_in_buf_ri[n1] * qmf_in_buf_ri[n1] + 1129 qmf_in_buf_ri[n1 + 1] * qmf_in_buf_ri[n1 + 1]; 1130 mag_n2_band = qmf_in_buf_ri[n2] * qmf_in_buf_ri[n2] + 1131 qmf_in_buf_ri[n2 + 1] * qmf_in_buf_ri[n2 + 1]; 1132 1133 temp = min(mag_n1_band, mag_n2_band); 1134 1135 max_mag_value = 0; 1136 max_trans_fac = 0; 1137 max_n1 = 0; 1138 max_n2 = 0; 1139 1140 if (temp > 0) { 1141 max_mag_value = temp; 1142 max_trans_fac = 1; 1143 max_n1 = n1; 1144 max_n2 = n2; 1145 } 1146 1147 if (max_mag_value > mag_zero_band && max_n1 >= 0 && 1148 max_n2 < TWICE_QMF_SYNTH_CHANNELS_NUM) { 1149 FLOAT32 vec_y_r[2], vec_y_i[2]; 1150 FLOAT32 temp_r, temp_i, tmp_r1; 1151 WORD32 mid_trans_fac, idx; 1152 FLOAT64 base; 1153 WORD32 k; 1154 FLOAT32 mag_scaling_fac = 0.0f; 1155 FLOAT32 x_zero_band_r = 0; 1156 FLOAT32 x_zero_band_i = 0; 1157 1158 mid_trans_fac = 2 - max_trans_fac; 1159 1160 x_zero_band_r = qmf_in_buf_ri[max_n1]; 1161 x_zero_band_i = qmf_in_buf_ri[max_n1 + 1]; 1162 base = 1e-17; 1163 base = base + x_zero_band_r * x_zero_band_r; 1164 base = base + x_zero_band_i * x_zero_band_i; 1165 1166 mag_scaling_fac = (FLOAT32)(1.0f / base); 1167 mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); 1168 1169 x_zero_band_r *= mag_scaling_fac; 1170 x_zero_band_i *= mag_scaling_fac; 1171 1172 temp_r = x_zero_band_r; 1173 temp_i = x_zero_band_i; 1174 for (idx = 0; idx < mid_trans_fac - 1; idx++) { 1175 FLOAT32 tmp = x_zero_band_r; 1176 x_zero_band_r = x_zero_band_r * temp_r - x_zero_band_i * temp_i; 1177 x_zero_band_i = tmp * temp_i + x_zero_band_i * temp_r; 1178 } 1179 1180 for (k = 0; k < 2; k++) { 1181 temp_r = ptr_hbe_txposer 1182 ->qmf_in_buf[i + HBE_ZERO_BAND_IDX - 1 + k][max_n2]; 1183 temp_i = 1184 ptr_hbe_txposer 1185 ->qmf_in_buf[i + HBE_ZERO_BAND_IDX - 1 + k][max_n2 + 1]; 1186 1187 base = 1e-17; 1188 base = base + temp_r * temp_r; 1189 base = base + temp_i * temp_i; 1190 1191 mag_scaling_fac = (FLOAT32)(1.0f / base); 1192 mag_scaling_fac = (FLOAT32)sqrt(sqrt(mag_scaling_fac)); 1193 1194 temp_r *= mag_scaling_fac; 1195 temp_i *= mag_scaling_fac; 1196 1197 vec_y_r[k] = temp_r; 1198 vec_y_i[k] = temp_i; 1199 } 1200 1201 temp_r = vec_y_r[0] * x_zero_band_r - vec_y_i[0] * x_zero_band_i; 1202 temp_i = vec_y_r[0] * x_zero_band_i + vec_y_i[0] * x_zero_band_r; 1203 1204 tmp_r1 = 1205 (FLOAT32)(cos_sin_theta[0] * temp_r - cos_sin_theta[1] * temp_i); 1206 temp_i = 1207 (FLOAT32)(cos_sin_theta[0] * temp_i + cos_sin_theta[1] * temp_r); 1208 1209 ptr_hbe_txposer->qmf_out_buf[i * 2 + (HBE_ZERO_BAND_IDX - 1)] 1210 [2 * qmf_band_idx] += 1211 (FLOAT32)(mag_cmplx_gain * tmp_r1); 1212 1213 ptr_hbe_txposer->qmf_out_buf[i * 2 + (HBE_ZERO_BAND_IDX - 1)] 1214 [2 * qmf_band_idx + 1] += 1215 (FLOAT32)(mag_cmplx_gain * temp_i); 1216 1217 temp_r = vec_y_r[1] * x_zero_band_r - vec_y_i[1] * x_zero_band_i; 1218 temp_i = vec_y_r[1] * x_zero_band_i + vec_y_i[1] * x_zero_band_r; 1219 1220 ptr_hbe_txposer->qmf_out_buf[i * 2 + (1 + HBE_ZERO_BAND_IDX - 1)] 1221 [2 * qmf_band_idx] += 1222 (FLOAT32)(mag_cmplx_gain * temp_r); 1223 1224 ptr_hbe_txposer->qmf_out_buf[i * 2 + (1 + HBE_ZERO_BAND_IDX - 1)] 1225 [2 * qmf_band_idx + 1] += 1226 (FLOAT32)(mag_cmplx_gain * temp_i); 1227 } 1228 } 1229 } 1230 1231 out_ptr -= (128 * 2 * qmf_voc_columns) - 2; 1232 norm_ptr -= (128 * qmf_voc_columns) - 2; 1233 x_norm_ptr -= (128 * qmf_voc_columns) - 2; 1234 } 1235 } 1236 1237 VOID ixheaacd_hbe_post_anal_xprod3(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 1238 WORD32 qmf_voc_columns, WORD32 qmf_band_idx, 1239 FLOAT32 p, WORD32 pitch_in_bins_idx) { 1240 WORD32 i, inp_band_idx, rem; 1241 1242 FLOAT32 *out_buf = &ptr_hbe_txposer->qmf_out_buf[2][2 * qmf_band_idx]; 1243 1244 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[2]; qmf_band_idx++) { 1245 FLOAT32 temp_r, temp_i; 1246 FLOAT32 temp_r1, temp_i1; 1247 const FLOAT32 *ptr_sel, *ptr_sel1; 1248 1249 inp_band_idx = (2 * qmf_band_idx) / 3; 1250 ptr_sel = &ixheaacd_sel_case[(inp_band_idx + 1) & 3][0]; 1251 ptr_sel1 = &ixheaacd_sel_case[((inp_band_idx + 1) & 3) + 1][0]; 1252 rem = 2 * qmf_band_idx - 3 * inp_band_idx; 1253 1254 if (rem == 0 || rem == 1) { 1255 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; 1256 1257 for (i = 0; i < qmf_voc_columns; i += 1) { 1258 WORD32 k; 1259 FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; 1260 FLOAT32 *ptr_vec_x = &vec_x[0]; 1261 FLOAT32 x_zero_band_r, x_zero_band_i; 1262 1263 FLOAT32 mag_scaling_fac; 1264 1265 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { 1266 FLOAT64 base1; 1267 FLOAT64 base = 1e-17; 1268 1269 temp_r = in_buf[0]; 1270 temp_i = in_buf[1]; 1271 1272 in_buf += 256; 1273 1274 base1 = base + temp_r * temp_r; 1275 base1 = base1 + temp_i * temp_i; 1276 1277 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1278 1279 ptr_vec_x[0] = temp_r * mag_scaling_fac; 1280 ptr_vec_x[1] = temp_i * mag_scaling_fac; 1281 1282 temp_r = in_buf[0]; 1283 temp_i = in_buf[1]; 1284 1285 in_buf -= 128; 1286 1287 temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; 1288 temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; 1289 1290 temp_r = in_buf[0]; 1291 temp_i = in_buf[1]; 1292 1293 temp_r1 += ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; 1294 temp_i1 += ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; 1295 1296 temp_r1 *= 0.3984033437f; 1297 temp_i1 *= 0.3984033437f; 1298 1299 base1 = base + temp_r1 * temp_r1; 1300 base1 = base1 + temp_i1 * temp_i1; 1301 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1302 1303 ptr_vec_x[2] = temp_r1 * mag_scaling_fac; 1304 ptr_vec_x[3] = temp_i1 * mag_scaling_fac; 1305 1306 ptr_vec_x += 4; 1307 in_buf += 256; 1308 } 1309 ptr_vec_x = &vec_x[0]; 1310 temp_r = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; 1311 temp_i = vec_x[(2 * (HBE_ZERO_BAND_IDX - 2)) + 1]; 1312 1313 x_zero_band_r = temp_r * temp_r - temp_i * temp_i; 1314 x_zero_band_i = temp_r * temp_i + temp_i * temp_r; 1315 1316 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { 1317 temp_r = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; 1318 temp_i = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; 1319 1320 out_buf[0] += (temp_r * 0.4714045f); 1321 out_buf[1] += (temp_i * 0.4714045f); 1322 1323 ptr_vec_x += 2; 1324 out_buf += 128; 1325 } 1326 1327 ixheaacd_hbe_xprod_proc_3(ptr_hbe_txposer, qmf_band_idx, i, p, 1328 pitch_in_bins_idx); 1329 1330 in_buf -= 128 * 11; 1331 out_buf -= 128 * 6; 1332 } 1333 } else { 1334 FLOAT32 *in_buf = &ptr_hbe_txposer->qmf_in_buf[0][2 * inp_band_idx]; 1335 FLOAT32 *in_buf1 = 1336 &ptr_hbe_txposer->qmf_in_buf[0][2 * (inp_band_idx + 1)]; 1337 1338 for (i = 0; i < qmf_voc_columns; i++) { 1339 WORD32 k; 1340 FLOAT32 vec_x[2 * HBE_OPER_WIN_LEN]; 1341 FLOAT32 vec_x_cap[2 * HBE_OPER_WIN_LEN]; 1342 1343 FLOAT32 x_zero_band_r, x_zero_band_i; 1344 FLOAT32 *ptr_vec_x = &vec_x[0]; 1345 FLOAT32 *ptr_vec_x_cap = &vec_x_cap[0]; 1346 1347 FLOAT32 mag_scaling_fac; 1348 1349 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k += 2) { 1350 FLOAT32 tmp_vr, tmp_vi; 1351 FLOAT32 tmp_cr, tmp_ci; 1352 FLOAT64 base1; 1353 FLOAT64 base = 1e-17; 1354 1355 temp_r1 = in_buf[0]; 1356 temp_i1 = in_buf[1]; 1357 temp_r = in_buf1[0]; 1358 temp_i = in_buf1[1]; 1359 1360 base1 = base + temp_r * temp_r; 1361 base1 = base1 + temp_i * temp_i; 1362 1363 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1364 1365 ptr_vec_x[0] = temp_r * mag_scaling_fac; 1366 ptr_vec_x[1] = temp_i * mag_scaling_fac; 1367 1368 base1 = base + temp_r1 * temp_r1; 1369 base1 = base1 + temp_i1 * temp_i1; 1370 1371 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1372 1373 ptr_vec_x_cap[0] = temp_r1 * mag_scaling_fac; 1374 ptr_vec_x_cap[1] = temp_i1 * mag_scaling_fac; 1375 1376 in_buf += 256; 1377 1378 temp_r = in_buf[0]; 1379 temp_i = in_buf[1]; 1380 1381 temp_r1 = ptr_sel[0] * temp_r + ptr_sel[1] * temp_i; 1382 temp_i1 = ptr_sel[2] * temp_r + ptr_sel[3] * temp_i; 1383 1384 in_buf -= 128; 1385 1386 temp_r = in_buf[0]; 1387 temp_i = in_buf[1]; 1388 1389 tmp_cr = temp_r1 + ptr_sel[4] * temp_r + ptr_sel[5] * temp_i; 1390 tmp_ci = temp_i1 + ptr_sel[6] * temp_r + ptr_sel[7] * temp_i; 1391 1392 in_buf1 += 256; 1393 1394 temp_r = in_buf1[0]; 1395 temp_i = in_buf1[1]; 1396 1397 temp_r1 = ptr_sel1[0] * temp_r + ptr_sel1[1] * temp_i; 1398 temp_i1 = ptr_sel1[2] * temp_r + ptr_sel1[3] * temp_i; 1399 1400 in_buf1 -= 128; 1401 1402 temp_r = in_buf1[0]; 1403 temp_i = in_buf1[1]; 1404 1405 tmp_vr = temp_r1 + ptr_sel1[4] * temp_r + ptr_sel1[5] * temp_i; 1406 tmp_vi = temp_i1 + ptr_sel1[6] * temp_r + ptr_sel1[7] * temp_i; 1407 1408 tmp_cr *= 0.3984033437f; 1409 tmp_ci *= 0.3984033437f; 1410 1411 tmp_vr *= 0.3984033437f; 1412 tmp_vi *= 0.3984033437f; 1413 1414 base1 = base + tmp_vr * tmp_vr; 1415 base1 = base1 + tmp_vi * tmp_vi; 1416 1417 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1418 1419 ptr_vec_x[2] = tmp_vr * mag_scaling_fac; 1420 ptr_vec_x[3] = tmp_vi * mag_scaling_fac; 1421 1422 base1 = base + tmp_cr * tmp_cr; 1423 base1 = base1 + tmp_ci * tmp_ci; 1424 1425 mag_scaling_fac = (FLOAT32)(ixheaacd_cbrt_calc((FLOAT32)base1)); 1426 1427 ptr_vec_x_cap[2] = tmp_cr * mag_scaling_fac; 1428 ptr_vec_x_cap[3] = tmp_ci * mag_scaling_fac; 1429 1430 in_buf += 256; 1431 in_buf1 += 256; 1432 ptr_vec_x += 4; 1433 ptr_vec_x_cap += 4; 1434 } 1435 ptr_vec_x = &vec_x[0]; 1436 ptr_vec_x_cap = &vec_x_cap[0]; 1437 1438 temp_r = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2)]; 1439 temp_i = vec_x_cap[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; 1440 temp_r1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2)]; 1441 temp_i1 = vec_x[2 * (HBE_ZERO_BAND_IDX - 2) + 1]; 1442 1443 x_zero_band_r = temp_r * temp_r - temp_i * temp_i; 1444 x_zero_band_i = temp_r * temp_i + temp_i * temp_r; 1445 1446 temp_r = temp_r1 * temp_r1 - temp_i1 * temp_i1; 1447 temp_i = temp_r1 * temp_i1 + temp_i1 * temp_r1; 1448 1449 for (k = 0; k < (HBE_OPER_BLK_LEN_3); k++) { 1450 temp_r1 = ptr_vec_x[0] * x_zero_band_r - ptr_vec_x[1] * x_zero_band_i; 1451 temp_i1 = ptr_vec_x[0] * x_zero_band_i + ptr_vec_x[1] * x_zero_band_r; 1452 1453 temp_r1 += ptr_vec_x_cap[0] * temp_r - ptr_vec_x_cap[1] * temp_i; 1454 temp_i1 += ptr_vec_x_cap[0] * temp_i + ptr_vec_x_cap[1] * temp_r; 1455 1456 out_buf[0] += (temp_r1 * 0.23570225f); 1457 out_buf[1] += (temp_i1 * 0.23570225f); 1458 1459 out_buf += 128; 1460 ptr_vec_x += 2; 1461 ptr_vec_x_cap += 2; 1462 } 1463 1464 ixheaacd_hbe_xprod_proc_3(ptr_hbe_txposer, qmf_band_idx, i, p, 1465 pitch_in_bins_idx); 1466 1467 in_buf -= 128 * 11; 1468 in_buf1 -= 128 * 11; 1469 out_buf -= 128 * 6; 1470 } 1471 } 1472 1473 out_buf -= (256 * qmf_voc_columns) - 2; 1474 } 1475 } 1476 1477 VOID ixheaacd_hbe_post_anal_xprod4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, 1478 WORD32 qmf_voc_columns, WORD32 qmf_band_idx, 1479 FLOAT32 p, WORD32 pitch_in_bins_idx) { 1480 WORD32 i, inp_band_idx; 1481 FLOAT32 *out_ptr = &ptr_hbe_txposer->qmf_out_buf[3][2 * qmf_band_idx]; 1482 1483 ixheaacd_norm_qmf_in_buf_4(ptr_hbe_txposer, ((qmf_band_idx >> 1) - 1)); 1484 1485 for (; qmf_band_idx < ptr_hbe_txposer->x_over_qmf[3]; qmf_band_idx++) { 1486 WORD32 ip_idx; 1487 FLOAT32 temp, temp_r, temp_i; 1488 FLOAT32 *norm_ptr, *x_norm_ptr; 1489 inp_band_idx = qmf_band_idx >> 1; 1490 ip_idx = (qmf_band_idx & 1) ? (inp_band_idx + 1) : (inp_band_idx - 1); 1491 1492 norm_ptr = &ptr_hbe_txposer->norm_qmf_in_buf[0][2 * ip_idx]; 1493 x_norm_ptr = 1494 &ptr_hbe_txposer->norm_qmf_in_buf[HBE_ZERO_BAND_IDX][2 * inp_band_idx]; 1495 1496 for (i = 0; i < qmf_voc_columns; i++) { 1497 WORD32 k; 1498 FLOAT32 x_zero_band_r, x_zero_band_i; 1499 1500 temp_r = x_zero_band_r = *x_norm_ptr++; 1501 temp_i = x_zero_band_i = *x_norm_ptr++; 1502 1503 temp = x_zero_band_r * x_zero_band_r - x_zero_band_i * x_zero_band_i; 1504 x_zero_band_i = 1505 x_zero_band_r * x_zero_band_i + x_zero_band_i * x_zero_band_r; 1506 1507 x_zero_band_r = temp_r * temp - temp_i * x_zero_band_i; 1508 x_zero_band_i = temp_r * x_zero_band_i + temp_i * temp; 1509 1510 for (k = 0; k < HBE_OPER_BLK_LEN_4; k++) { 1511 temp = *norm_ptr++; 1512 temp_i = *norm_ptr++; 1513 1514 temp_r = temp * x_zero_band_r - temp_i * x_zero_band_i; 1515 temp_i = temp * x_zero_band_i + temp_i * x_zero_band_r; 1516 1517 *out_ptr++ += (temp_r * 0.6666667f); 1518 *out_ptr++ += (temp_i * 0.6666667f); 1519 1520 norm_ptr += 254; 1521 out_ptr += 126; 1522 } 1523 1524 norm_ptr -= 128 * 11; 1525 out_ptr -= 128 * 4; 1526 x_norm_ptr += 126; 1527 1528 ixheaacd_hbe_xprod_proc_4(ptr_hbe_txposer, qmf_band_idx, i, p, 1529 pitch_in_bins_idx); 1530 } 1531 1532 out_ptr -= (128 * 2 * qmf_voc_columns) - 2; 1533 } 1534 } 1535 1536 IA_ERRORCODE ixheaacd_hbe_post_anal_process( 1537 ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, WORD32 pitch_in_bins, 1538 WORD32 sbr_upsamp_4_flg) { 1539 FLOAT32 p; 1540 WORD32 trans_fac; 1541 WORD32 qmf_voc_columns = ptr_hbe_txposer->no_bins / 2; 1542 FLOAT32 cos_sin_theta[2]; 1543 1544 p = (sbr_upsamp_4_flg) ? (FLOAT32)(pitch_in_bins * 0.04166666666666) 1545 : (FLOAT32)(pitch_in_bins * 0.08333333333333); 1546 1547 if (p < SBR_CONST_PMIN) { 1548 trans_fac = 2; 1549 if (trans_fac <= ptr_hbe_txposer->max_stretch) 1550 ixheaacd_hbe_post_anal_prod2(ptr_hbe_txposer, qmf_voc_columns, 1551 ptr_hbe_txposer->x_over_qmf[0]); 1552 1553 trans_fac = 3; 1554 if (trans_fac <= ptr_hbe_txposer->max_stretch) 1555 ixheaacd_hbe_post_anal_prod3(ptr_hbe_txposer, qmf_voc_columns, 1556 ptr_hbe_txposer->x_over_qmf[1]); 1557 1558 trans_fac = 4; 1559 if (trans_fac <= ptr_hbe_txposer->max_stretch) { 1560 if (ptr_hbe_txposer->x_over_qmf[2] <= 1) return IA_FATAL_ERROR; 1561 ixheaacd_hbe_post_anal_prod4(ptr_hbe_txposer, qmf_voc_columns, 1562 ptr_hbe_txposer->x_over_qmf[2]); 1563 } 1564 1565 } else { 1566 trans_fac = 2; 1567 if (trans_fac <= ptr_hbe_txposer->max_stretch) { 1568 cos_sin_theta[0] = ixheaacd_hbe_x_prod_cos_table_trans_2 1569 [((pitch_in_bins + sbr_upsamp_4_flg * 128) << 1) + 0]; 1570 cos_sin_theta[1] = ixheaacd_hbe_x_prod_cos_table_trans_2 1571 [((pitch_in_bins + sbr_upsamp_4_flg * 128) << 1) + 1]; 1572 1573 ixheaacd_hbe_post_anal_xprod2(ptr_hbe_txposer, qmf_voc_columns, 1574 ptr_hbe_txposer->x_over_qmf[0], p, 1575 cos_sin_theta); 1576 } 1577 1578 trans_fac = 3; 1579 if (trans_fac <= ptr_hbe_txposer->max_stretch) 1580 ixheaacd_hbe_post_anal_xprod3(ptr_hbe_txposer, qmf_voc_columns, 1581 ptr_hbe_txposer->x_over_qmf[1], p, 1582 (pitch_in_bins + sbr_upsamp_4_flg * 128)); 1583 1584 trans_fac = 4; 1585 if (trans_fac <= ptr_hbe_txposer->max_stretch) { 1586 if (ptr_hbe_txposer->x_over_qmf[2] <= 1) return IA_FATAL_ERROR; 1587 ixheaacd_hbe_post_anal_xprod4(ptr_hbe_txposer, qmf_voc_columns, 1588 ptr_hbe_txposer->x_over_qmf[2], p, 1589 (pitch_in_bins + sbr_upsamp_4_flg * 128)); 1590 } 1591 } 1592 return IA_NO_ERROR; 1593 } 1594