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