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