/src/libxaac/decoder/ixheaacd_sbrdec_initfuncs.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * * |
3 | | * Copyright (C) 2018 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | #include <string.h> |
21 | | #include "ixheaacd_sbr_common.h" |
22 | | #include "ixheaac_type_def.h" |
23 | | |
24 | | #include "ixheaac_constants.h" |
25 | | #include "ixheaac_basic_ops32.h" |
26 | | #include "ixheaac_basic_ops16.h" |
27 | | #include "ixheaac_basic_ops40.h" |
28 | | #include "ixheaac_basic_ops.h" |
29 | | #include "ixheaacd_defines.h" |
30 | | |
31 | | #include "ixheaacd_intrinsics.h" |
32 | | #include "ixheaac_sbr_const.h" |
33 | | #include "ixheaac_basic_op.h" |
34 | | #include "ixheaacd_defines.h" |
35 | | #include "ixheaacd_bitbuffer.h" |
36 | | #include "ixheaacd_pns.h" |
37 | | |
38 | | #include "ixheaacd_aac_rom.h" |
39 | | #include "ixheaacd_pulsedata.h" |
40 | | |
41 | | #include "ixheaacd_drc_data_struct.h" |
42 | | #include "ixheaacd_lt_predict.h" |
43 | | #include "ixheaacd_cnst.h" |
44 | | #include "ixheaacd_ec_defines.h" |
45 | | #include "ixheaacd_ec_struct_def.h" |
46 | | #include "ixheaacd_channelinfo.h" |
47 | | #include "ixheaacd_drc_dec.h" |
48 | | |
49 | | #include "ixheaacd_sbrdecoder.h" |
50 | | |
51 | | #include "ixheaacd_sbrdecsettings.h" |
52 | | #include "ixheaacd_sbr_scale.h" |
53 | | #include "ixheaacd_lpp_tran.h" |
54 | | #include "ixheaacd_env_extr_part.h" |
55 | | #include "ixheaacd_sbr_rom.h" |
56 | | #include "ixheaacd_hybrid.h" |
57 | | #include "ixheaacd_ps_dec.h" |
58 | | #include "ixheaacd_ps_bitdec.h" |
59 | | #include "ixheaacd_env_extr.h" |
60 | | #include "ixheaacd_common_rom.h" |
61 | | #include "ixheaacd_freq_sca.h" |
62 | | |
63 | | #include "ixheaacd_qmf_dec.h" |
64 | | |
65 | | #include "ixheaacd_env_calc.h" |
66 | | |
67 | | #include "ixheaacd_pvc_dec.h" |
68 | | #include "ixheaacd_sbr_dec.h" |
69 | | #include "ixheaacd_env_dec.h" |
70 | | #include "ixheaacd_basic_funcs.h" |
71 | | #include "ixheaacd_sbr_crc.h" |
72 | | |
73 | | #include "ixheaacd_sbrqmftrans.h" |
74 | | |
75 | | #include "ixheaacd_audioobjtypes.h" |
76 | | |
77 | | extern const WORD32 ixheaacd_ldmps_polyphase_filter_coeff_fix[1280]; |
78 | | |
79 | | #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) |
80 | | |
81 | 31.9k | #define FD_OVERSAMPLING_FAC (1.5f) |
82 | | |
83 | 63.3k | WORD32 ixheaacd_getsize_sbr_persistent() { |
84 | 63.3k | return (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_pers_struct), BYTE_ALIGN_8)); |
85 | 63.3k | } |
86 | | |
87 | | VOID ixheaacd_esbr_hbe_data_init( |
88 | | ia_esbr_hbe_txposer_struct *pstr_esbr_hbe_txposer, |
89 | | const WORD32 num_aac_samples, WORD32 samp_fac_4_flag, |
90 | | const WORD32 num_out_samples, VOID *persistent_hbe_mem, |
91 | 31.9k | WORD32 *total_persistant) { |
92 | 31.9k | WORD32 i; |
93 | 31.9k | WORD32 used_persistent = 0; |
94 | | |
95 | 31.9k | if (pstr_esbr_hbe_txposer) { |
96 | 31.9k | memset(pstr_esbr_hbe_txposer, 0, |
97 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); |
98 | | |
99 | 31.9k | pstr_esbr_hbe_txposer->core_frame_length = num_aac_samples; |
100 | | |
101 | 31.9k | pstr_esbr_hbe_txposer->no_bins = num_out_samples / NO_QMF_SYNTH_CHANNELS; |
102 | 31.9k | pstr_esbr_hbe_txposer->hbe_qmf_in_len = |
103 | 31.9k | pstr_esbr_hbe_txposer->no_bins; |
104 | 31.9k | pstr_esbr_hbe_txposer->hbe_qmf_out_len = |
105 | 31.9k | 2 * pstr_esbr_hbe_txposer->hbe_qmf_in_len; |
106 | | |
107 | 31.9k | pstr_esbr_hbe_txposer->ptr_input_buf = |
108 | 31.9k | (FLOAT32 *)((WORD8 *)persistent_hbe_mem); |
109 | 31.9k | used_persistent += |
110 | 31.9k | (num_aac_samples + NO_QMF_SYNTH_CHANNELS) * sizeof(FLOAT32); |
111 | | |
112 | 31.9k | pstr_esbr_hbe_txposer->qmf_in_buf = |
113 | 31.9k | (FLOAT32 **)((WORD8 *)persistent_hbe_mem + used_persistent); |
114 | 31.9k | used_persistent += |
115 | 31.9k | pstr_esbr_hbe_txposer->hbe_qmf_in_len * sizeof(FLOAT32 *); |
116 | | |
117 | 1.08M | for (i = 0; i < pstr_esbr_hbe_txposer->hbe_qmf_in_len; i++) { |
118 | 1.04M | pstr_esbr_hbe_txposer->qmf_in_buf[i] = |
119 | 1.04M | (FLOAT32 *)((WORD8 *)persistent_hbe_mem + used_persistent); |
120 | | |
121 | 1.04M | used_persistent += (TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); |
122 | 1.04M | } |
123 | | |
124 | 31.9k | pstr_esbr_hbe_txposer->qmf_out_buf = |
125 | 31.9k | (FLOAT32 **)((WORD8 *)persistent_hbe_mem + used_persistent); |
126 | 31.9k | used_persistent += |
127 | 31.9k | (pstr_esbr_hbe_txposer->hbe_qmf_out_len * sizeof(FLOAT32 *)); |
128 | | |
129 | 2.12M | for (i = 0; i < pstr_esbr_hbe_txposer->hbe_qmf_out_len; i++) { |
130 | 2.09M | pstr_esbr_hbe_txposer->qmf_out_buf[i] = |
131 | 2.09M | (FLOAT32 *)((WORD8 *)persistent_hbe_mem + used_persistent); |
132 | 2.09M | used_persistent += (TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32)); |
133 | 2.09M | } |
134 | 31.9k | pstr_esbr_hbe_txposer->upsamp_4_flag = samp_fac_4_flag; |
135 | 31.9k | if (pstr_esbr_hbe_txposer) { |
136 | 31.9k | pstr_esbr_hbe_txposer->fft_size[0] = num_aac_samples; |
137 | 31.9k | pstr_esbr_hbe_txposer->fft_size[1] = (WORD32)(FD_OVERSAMPLING_FAC * num_aac_samples); |
138 | | |
139 | 31.9k | pstr_esbr_hbe_txposer->ptr_spectrum = &pstr_esbr_hbe_txposer->spectrum_buf[0]; |
140 | 31.9k | pstr_esbr_hbe_txposer->ptr_spectrum_tx = |
141 | 31.9k | &pstr_esbr_hbe_txposer->spectrum_transposed_buf[0]; |
142 | 31.9k | pstr_esbr_hbe_txposer->mag = &pstr_esbr_hbe_txposer->mag_buf[0]; |
143 | 31.9k | pstr_esbr_hbe_txposer->phase = &pstr_esbr_hbe_txposer->phase_buf[0]; |
144 | 31.9k | pstr_esbr_hbe_txposer->ptr_output_buf = &pstr_esbr_hbe_txposer->output_buf[0]; |
145 | 31.9k | } |
146 | 31.9k | } |
147 | 31.9k | *total_persistant = used_persistent; |
148 | 31.9k | return; |
149 | 31.9k | } |
150 | | |
151 | | VOID ixheaacd_set_sbr_persistent_table_pointer( |
152 | | VOID *sbr_persistent_mem_v, ia_sbr_tables_struct *sbr_tables_ptr, |
153 | 38.7k | ixheaacd_misc_tables *pstr_common_tables) { |
154 | 38.7k | ia_sbr_pers_struct *sbr_persistent_mem = |
155 | 38.7k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
156 | 38.7k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables = sbr_tables_ptr; |
157 | 38.7k | sbr_persistent_mem->str_sbr_dec_inst.pstr_common_tables = pstr_common_tables; |
158 | 38.7k | } |
159 | | |
160 | | VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, |
161 | | WORD32 *persistent_used, |
162 | 38.7k | WORD32 num_channel, WORD ps_enable) { |
163 | 38.7k | WORD32 i = 0; |
164 | 38.7k | WORD32 used_persistent = *persistent_used; |
165 | 38.7k | WORD32 temp, temp1, temp2, temp3; |
166 | 38.7k | struct ia_sbr_pers_struct *sbr_persistent_mem = |
167 | 38.7k | (struct ia_sbr_pers_struct *)sbr_persistent_mem_v; |
168 | | |
169 | 38.7k | struct ia_sbr_dec_inst_struct *p_str_sbr_dec_inst = |
170 | 38.7k | &sbr_persistent_mem->str_sbr_dec_inst; |
171 | | |
172 | 38.7k | num_channel = max(2, num_channel); |
173 | 38.7k | memset(sbr_persistent_mem, 0, |
174 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_sbr_pers_struct), BYTE_ALIGN_8)); |
175 | | |
176 | 38.7k | sbr_persistent_mem->sbr_qmf_analy_states = |
177 | 38.7k | (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
178 | 38.7k | temp = num_channel * |
179 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * |
180 | 38.7k | sizeof(sbr_persistent_mem->sbr_qmf_analy_states[0]), |
181 | 38.7k | BYTE_ALIGN_8); |
182 | 38.7k | used_persistent += temp; |
183 | | |
184 | 38.7k | sbr_persistent_mem->sbr_qmf_analy_states_32 = |
185 | 38.7k | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
186 | 38.7k | temp1 = num_channel * |
187 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * |
188 | 38.7k | sizeof(sbr_persistent_mem->sbr_qmf_analy_states_32[0]), |
189 | 38.7k | BYTE_ALIGN_8); |
190 | 38.7k | used_persistent += temp1; |
191 | | |
192 | 38.7k | sbr_persistent_mem->sbr_qmf_synth_states = |
193 | 38.7k | (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
194 | | |
195 | 38.7k | temp2 = (num_channel * |
196 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * |
197 | 38.7k | sizeof(sbr_persistent_mem->sbr_qmf_synth_states[0]), |
198 | 38.7k | BYTE_ALIGN_8)); |
199 | 38.7k | used_persistent += temp2; |
200 | | |
201 | 38.7k | sbr_persistent_mem->sbr_qmf_synth_states_32 = |
202 | 38.7k | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
203 | | |
204 | 38.7k | temp3 = (num_channel * |
205 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * |
206 | 38.7k | sizeof(sbr_persistent_mem->sbr_qmf_synth_states_32[0]), |
207 | 38.7k | BYTE_ALIGN_8)); |
208 | 38.7k | used_persistent += temp3; |
209 | | |
210 | 38.7k | memset(sbr_persistent_mem->sbr_qmf_analy_states, 0, |
211 | 38.7k | (temp + temp1 + temp2 + temp3)); |
212 | | |
213 | 116k | for (i = 0; i < num_channel; i++) { |
214 | 77.5k | sbr_persistent_mem->ptr_sbr_overlap_buf[i] = |
215 | 77.5k | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
216 | | |
217 | 77.5k | if (ps_enable) { |
218 | 71.8k | memset( |
219 | 71.8k | sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, |
220 | 71.8k | 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * |
221 | 71.8k | sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), |
222 | 71.8k | BYTE_ALIGN_8)); |
223 | 71.8k | used_persistent += |
224 | 71.8k | 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * |
225 | 71.8k | sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), |
226 | 71.8k | BYTE_ALIGN_8); |
227 | 71.8k | } else { |
228 | 5.73k | memset(sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, |
229 | 5.73k | IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * |
230 | 5.73k | sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), |
231 | 5.73k | BYTE_ALIGN_8)); |
232 | 5.73k | used_persistent += |
233 | 5.73k | IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * |
234 | 5.73k | sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), |
235 | 5.73k | BYTE_ALIGN_8); |
236 | 5.73k | } |
237 | 77.5k | } |
238 | | |
239 | 116k | for (i = 0; i < num_channel; i++) { |
240 | 77.5k | WORD32 j; |
241 | 77.5k | sbr_persistent_mem->sbr_lpc_filter_states_real[i] = |
242 | 77.5k | (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
243 | 77.5k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
244 | 77.5k | LPC_ORDER * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][0]), BYTE_ALIGN_8); |
245 | 232k | for (j = 0; j < LPC_ORDER; j++) { |
246 | 155k | sbr_persistent_mem->sbr_lpc_filter_states_real[i][j] = |
247 | 155k | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
248 | | |
249 | 155k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
250 | 155k | NO_ANALYSIS_CHANNELS * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j][0]), |
251 | 155k | BYTE_ALIGN_8); |
252 | | |
253 | 155k | memset(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j], 0, |
254 | 155k | IXHEAAC_GET_SIZE_ALIGNED( |
255 | 155k | NO_ANALYSIS_CHANNELS * |
256 | 155k | sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j][0]), |
257 | 155k | BYTE_ALIGN_8)); |
258 | 155k | } |
259 | 77.5k | } |
260 | | |
261 | 38.7k | if (ps_enable) { |
262 | 107k | for (i = 0; i < num_channel; i++) { |
263 | 71.8k | WORD32 j; |
264 | | |
265 | 71.8k | sbr_persistent_mem->sbr_lpc_filter_states_imag[i] = |
266 | 71.8k | (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
267 | 71.8k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
268 | 71.8k | LPC_ORDER * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][0]), BYTE_ALIGN_8); |
269 | 215k | for (j = 0; j < LPC_ORDER; j++) { |
270 | 143k | sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j] = |
271 | 143k | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
272 | | |
273 | 143k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
274 | 143k | NO_ANALYSIS_CHANNELS * |
275 | 143k | sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j][0]), |
276 | 143k | BYTE_ALIGN_8); |
277 | | |
278 | 143k | memset(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j], 0, |
279 | 143k | IXHEAAC_GET_SIZE_ALIGNED( |
280 | 143k | NO_ANALYSIS_CHANNELS * |
281 | 143k | sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j][0]), |
282 | 143k | BYTE_ALIGN_8)); |
283 | 143k | } |
284 | 71.8k | } |
285 | 35.9k | } |
286 | 116k | for (i = 0; i < num_channel; i++) { |
287 | 77.5k | WORD32 initial_used = used_persistent; |
288 | 77.5k | WORD32 temp_used = used_persistent; |
289 | | |
290 | 77.5k | sbr_persistent_mem->sbr_smooth_gain_buf[i] = |
291 | 77.5k | (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
292 | 77.5k | temp_used += 2 * IXHEAAC_GET_SIZE_ALIGNED( |
293 | 77.5k | MAX_FREQ_COEFFS * sizeof(sbr_persistent_mem->sbr_smooth_gain_buf[i][0]), |
294 | 77.5k | BYTE_ALIGN_8); |
295 | | |
296 | 77.5k | sbr_persistent_mem->sbr_smooth_noise_buf[i] = |
297 | 77.5k | (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
298 | | |
299 | 77.5k | temp_used += IXHEAAC_GET_SIZE_ALIGNED( |
300 | 77.5k | MAX_FREQ_COEFFS * sizeof(sbr_persistent_mem->sbr_smooth_noise_buf[i][0]), BYTE_ALIGN_8); |
301 | | |
302 | 77.5k | p_str_sbr_dec_inst->pstr_freq_band_data[i] = |
303 | 77.5k | (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
304 | | |
305 | 77.5k | temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_freq_band_data_struct), BYTE_ALIGN_8); |
306 | | |
307 | 77.5k | sbr_persistent_mem->pstr_prev_frame_data[i] = |
308 | 77.5k | (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
309 | | |
310 | 77.5k | temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_prev_frame_data_struct), BYTE_ALIGN_8); |
311 | | |
312 | 77.5k | p_str_sbr_dec_inst->pstr_sbr_channel[i] = |
313 | 77.5k | (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
314 | | |
315 | 77.5k | temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_channel_struct), BYTE_ALIGN_8); |
316 | | |
317 | 77.5k | p_str_sbr_dec_inst->pstr_sbr_header[i] = |
318 | 77.5k | (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); |
319 | | |
320 | 77.5k | temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_header_data_struct), BYTE_ALIGN_8); |
321 | | |
322 | 77.5k | memset(sbr_persistent_mem->sbr_smooth_gain_buf[i], 0, |
323 | 77.5k | temp_used - initial_used); |
324 | | |
325 | 77.5k | used_persistent = temp_used; |
326 | 77.5k | } |
327 | | |
328 | 38.7k | if (ps_enable) { |
329 | 35.9k | p_str_sbr_dec_inst->pstr_ps_stereo_dec = |
330 | 35.9k | (ia_ps_dec_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
331 | | |
332 | 35.9k | memset(p_str_sbr_dec_inst->pstr_ps_stereo_dec, 0, |
333 | 35.9k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8)); |
334 | | |
335 | 35.9k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8); |
336 | 35.9k | } |
337 | | |
338 | 38.7k | p_str_sbr_dec_inst->frame_buffer[0] = |
339 | 38.7k | (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
340 | 38.7k | memset(p_str_sbr_dec_inst->frame_buffer[0], 0, |
341 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
342 | 38.7k | sizeof(ia_sbr_frame_info_data_struct) + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, |
343 | 38.7k | BYTE_ALIGN_8)); |
344 | 38.7k | used_persistent = |
345 | 38.7k | used_persistent + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + |
346 | 38.7k | MAX_FREQ_COEFFS * sizeof(WORD32) + 8, |
347 | 38.7k | BYTE_ALIGN_8); |
348 | | |
349 | 38.7k | p_str_sbr_dec_inst->frame_buffer[1] = |
350 | 38.7k | (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
351 | 38.7k | memset(p_str_sbr_dec_inst->frame_buffer[1], 0, |
352 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
353 | 38.7k | sizeof(ia_sbr_frame_info_data_struct) + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, |
354 | 38.7k | BYTE_ALIGN_8)); |
355 | 38.7k | used_persistent = |
356 | 38.7k | used_persistent + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + |
357 | 38.7k | MAX_FREQ_COEFFS * sizeof(WORD32) + 8, |
358 | 38.7k | BYTE_ALIGN_8); |
359 | | |
360 | 38.7k | { |
361 | 38.7k | WORD32 index = 0; |
362 | 38.7k | p_str_sbr_dec_inst->ptr_pvc_data_str = |
363 | 38.7k | (ia_pvc_data_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
364 | 38.7k | memset(p_str_sbr_dec_inst->ptr_pvc_data_str, 0, |
365 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8)); |
366 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8); |
367 | | |
368 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer = |
369 | 38.7k | (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
370 | 38.7k | memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer, 0, |
371 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); |
372 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); |
373 | | |
374 | 38.7k | if (num_channel == 2) { |
375 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer = |
376 | 38.7k | (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
377 | 38.7k | memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer, 0, |
378 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); |
379 | 38.7k | used_persistent += |
380 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); |
381 | 38.7k | } |
382 | | |
383 | 38.7k | p_str_sbr_dec_inst->hbe_txposer_buffers = |
384 | 38.7k | (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
385 | 38.7k | memset(p_str_sbr_dec_inst->hbe_txposer_buffers, 0, |
386 | 38.7k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8)); |
387 | 38.7k | used_persistent += |
388 | 38.7k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); |
389 | | |
390 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real = |
391 | 38.7k | (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
392 | 38.7k | memset( |
393 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real, 0, |
394 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
395 | 38.7k | MAX_QMF_BUF_LEN * |
396 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[0]), |
397 | 38.7k | BYTE_ALIGN_8)); |
398 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
399 | 38.7k | MAX_QMF_BUF_LEN * |
400 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[0]), |
401 | 38.7k | BYTE_ALIGN_8); |
402 | | |
403 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag = |
404 | 38.7k | (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
405 | 38.7k | memset( |
406 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag, 0, |
407 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
408 | 38.7k | MAX_QMF_BUF_LEN * |
409 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[0]), |
410 | 38.7k | BYTE_ALIGN_8)); |
411 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
412 | 38.7k | MAX_QMF_BUF_LEN * |
413 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[0]), |
414 | 38.7k | BYTE_ALIGN_8); |
415 | | |
416 | 38.7k | if (num_channel == 2) { |
417 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real = |
418 | 38.7k | (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
419 | 38.7k | memset( |
420 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real, 0, |
421 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
422 | 38.7k | MAX_QMF_BUF_LEN * |
423 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real[0]), |
424 | 38.7k | BYTE_ALIGN_8)); |
425 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
426 | 38.7k | MAX_QMF_BUF_LEN * |
427 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real[0]), |
428 | 38.7k | BYTE_ALIGN_8); |
429 | | |
430 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag = |
431 | 38.7k | (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
432 | 38.7k | memset( |
433 | 38.7k | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag, 0, |
434 | 38.7k | IXHEAAC_GET_SIZE_ALIGNED( |
435 | 38.7k | MAX_QMF_BUF_LEN * |
436 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag[0]), |
437 | 38.7k | BYTE_ALIGN_8)); |
438 | 38.7k | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
439 | 38.7k | MAX_QMF_BUF_LEN * |
440 | 38.7k | sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag[0]), |
441 | 38.7k | BYTE_ALIGN_8); |
442 | 38.7k | } |
443 | | |
444 | 3.06M | for (index = 0; index < MAX_QMF_BUF_LEN; index++) { |
445 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[0] |
446 | 3.02M | ->str_sbr_dec.pp_qmf_buf_real[index] = |
447 | 3.02M | (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
448 | 3.02M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
449 | 3.02M | MAX_QMF_BUF_LEN * |
450 | 3.02M | sizeof( |
451 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[index][0]), |
452 | 3.02M | BYTE_ALIGN_8); |
453 | 3.02M | } |
454 | | |
455 | 3.06M | for (index = 0; index < MAX_QMF_BUF_LEN; index++) { |
456 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[0] |
457 | 3.02M | ->str_sbr_dec.pp_qmf_buf_imag[index] = |
458 | 3.02M | (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
459 | 3.02M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
460 | 3.02M | MAX_QMF_BUF_LEN * |
461 | 3.02M | sizeof( |
462 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[index][0]), |
463 | 3.02M | BYTE_ALIGN_8); |
464 | 3.02M | } |
465 | | |
466 | 38.7k | if (num_channel == 2) { |
467 | 3.06M | for (index = 0; index < MAX_QMF_BUF_LEN; index++) { |
468 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[1] |
469 | 3.02M | ->str_sbr_dec.pp_qmf_buf_real[index] = |
470 | 3.02M | (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
471 | 3.02M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
472 | 3.02M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
473 | 3.02M | ->str_sbr_dec.pp_qmf_buf_real[index][0]), |
474 | 3.02M | BYTE_ALIGN_8); |
475 | 3.02M | } |
476 | | |
477 | 3.06M | for (index = 0; index < MAX_QMF_BUF_LEN; index++) { |
478 | 3.02M | p_str_sbr_dec_inst->pstr_sbr_channel[1] |
479 | 3.02M | ->str_sbr_dec.pp_qmf_buf_imag[index] = |
480 | 3.02M | (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
481 | 3.02M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
482 | 3.02M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
483 | 3.02M | ->str_sbr_dec.pp_qmf_buf_imag[index][0]), |
484 | 3.02M | BYTE_ALIGN_8); |
485 | 3.02M | } |
486 | 38.7k | } |
487 | | |
488 | 1.51M | for (i = 0; i < MAX_ENV_COLS; i++) { |
489 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i] = |
490 | 1.47M | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
491 | 1.47M | memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i], 0, |
492 | 1.47M | IXHEAAC_GET_SIZE_ALIGNED( |
493 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0] |
494 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), |
495 | 1.47M | BYTE_ALIGN_8)); |
496 | 1.47M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
497 | 1.47M | MAX_QMF_BUF_LEN * |
498 | 1.47M | sizeof( |
499 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i][0]), |
500 | 1.47M | BYTE_ALIGN_8); |
501 | | |
502 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i] = |
503 | 1.47M | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
504 | 1.47M | memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i], 0, |
505 | 1.47M | IXHEAAC_GET_SIZE_ALIGNED( |
506 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0] |
507 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), |
508 | 1.47M | BYTE_ALIGN_8)); |
509 | 1.47M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
510 | 1.47M | MAX_QMF_BUF_LEN * |
511 | 1.47M | sizeof( |
512 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), |
513 | 1.47M | BYTE_ALIGN_8); |
514 | 1.47M | } |
515 | | |
516 | 38.7k | if (num_channel == 2) { |
517 | 1.51M | for (i = 0; i < MAX_ENV_COLS; i++) { |
518 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_real[i] = |
519 | 1.47M | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
520 | 1.47M | memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_real[i], 0, |
521 | 1.47M | IXHEAAC_GET_SIZE_ALIGNED( |
522 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
523 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), |
524 | 1.47M | BYTE_ALIGN_8)); |
525 | 1.47M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
526 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
527 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), |
528 | 1.47M | BYTE_ALIGN_8); |
529 | | |
530 | 1.47M | p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_imag[i] = |
531 | 1.47M | (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); |
532 | 1.47M | memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_imag[i], 0, |
533 | 1.47M | IXHEAAC_GET_SIZE_ALIGNED( |
534 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
535 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), |
536 | 1.47M | BYTE_ALIGN_8)); |
537 | 1.47M | used_persistent += IXHEAAC_GET_SIZE_ALIGNED( |
538 | 1.47M | MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] |
539 | 1.47M | ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), |
540 | 1.47M | BYTE_ALIGN_8); |
541 | 1.47M | } |
542 | 38.7k | } |
543 | 38.7k | } |
544 | | |
545 | 38.7k | *persistent_used = used_persistent; |
546 | 38.7k | } |
547 | | |
548 | | static PLATFORM_INLINE VOID ixheaacd_init_headerdata( |
549 | | ia_sbr_header_data_struct *ptr_header_data, WORD32 sample_rate_dec, |
550 | | WORD32 samp_per_frame, ia_freq_band_data_struct *freq_band_data, |
551 | 45.5k | ia_sbr_tables_struct *sbr_tables, WORD audio_obj_type) { |
552 | 45.5k | ia_freq_band_data_struct *pstr_freq_band_data = freq_band_data; |
553 | 45.5k | WORD32 tmp; |
554 | | |
555 | 45.5k | if (audio_obj_type != AOT_ER_AAC_ELD) { |
556 | 31.4k | memcpy(ptr_header_data, |
557 | 31.4k | &sbr_tables->env_extr_tables_ptr->str_sbr_default_header, |
558 | 31.4k | sizeof(ia_sbr_header_data_struct)); |
559 | 31.4k | } |
560 | | |
561 | 45.5k | if (audio_obj_type == AOT_ER_AAC_ELD) ptr_header_data->time_step -= 1; |
562 | | |
563 | 45.5k | pstr_freq_band_data->freq_band_table[LOW] = |
564 | 45.5k | pstr_freq_band_data->freq_band_tbl_lo; |
565 | 45.5k | pstr_freq_band_data->freq_band_table[HIGH] = |
566 | 45.5k | pstr_freq_band_data->freq_band_tbl_hi; |
567 | 45.5k | ptr_header_data->pstr_freq_band_data = pstr_freq_band_data; |
568 | | |
569 | 45.5k | ptr_header_data->core_frame_size = samp_per_frame; |
570 | 45.5k | ptr_header_data->out_sampling_freq = sample_rate_dec << 1; |
571 | | |
572 | 45.5k | if (audio_obj_type != AOT_ER_AAC_ELD) { |
573 | 31.4k | tmp = ptr_header_data->time_step + 4; |
574 | | |
575 | 31.4k | if (tmp < 0) |
576 | 0 | ptr_header_data->num_time_slots = |
577 | 0 | ixheaac_extract16l(samp_per_frame << (-tmp)); |
578 | 31.4k | else |
579 | 31.4k | ptr_header_data->num_time_slots = |
580 | 31.4k | ixheaac_extract16l(samp_per_frame >> tmp); |
581 | 31.4k | } else { |
582 | 14.1k | ptr_header_data->time_step = 1; |
583 | | |
584 | 14.1k | ptr_header_data->num_time_slots = |
585 | 14.1k | (samp_per_frame / 32 >> (ptr_header_data->time_step - 1)); |
586 | 14.1k | } |
587 | 45.5k | } |
588 | | |
589 | | VOID ixheaacd_setesbr_flags(VOID *sbr_persistent_mem_v, FLAG pvc_flag, |
590 | 4.72k | FLAG hbe_flag, FLAG inter_tes_flag) { |
591 | 4.72k | ia_sbr_pers_struct *sbr_persistent_mem; |
592 | 4.72k | sbr_persistent_mem = (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
593 | 4.72k | sbr_persistent_mem->str_sbr_dec_inst.hbe_flag = hbe_flag; |
594 | 4.72k | sbr_persistent_mem->str_sbr_dec_inst.pvc_flag = pvc_flag; |
595 | 4.72k | sbr_persistent_mem->str_sbr_dec_inst.inter_tes_flag = inter_tes_flag; |
596 | 4.72k | return; |
597 | 4.72k | } |
598 | | |
599 | | ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( |
600 | | WORD32 sample_rate_dec, WORD32 samp_per_frame, FLAG *down_sample_flag, |
601 | | VOID *sbr_persistent_mem_v, WORD32 *ptr_overlap_buf, WORD32 channel, |
602 | | WORD32 ps_enable, WORD32 sbr_ratio_idx, WORD32 output_frame_size, |
603 | | WORD32 *use_hbe, VOID *p_usac_dflt_header, |
604 | | ia_sbr_header_data_struct str_sbr_config, WORD32 audio_object_type, |
605 | 24.7k | WORD32 ldmps_present, WORD32 ldsbr_present) { |
606 | 24.7k | WORD16 i; |
607 | 24.7k | WORD16 err; |
608 | 24.7k | ia_sbr_header_data_struct *ptr_header_data[MAXNRSBRCHANNELS]; |
609 | 24.7k | ia_sbr_dec_struct *ptr_sbr_dec[2]; |
610 | 24.7k | ia_qmf_dec_tables_struct *qmf_dec_tables_ptr; |
611 | 24.7k | ia_sbr_pers_struct *sbr_persistent_mem; |
612 | | |
613 | 24.7k | sbr_persistent_mem = (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
614 | 24.7k | ptr_sbr_dec[0] = |
615 | 24.7k | &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[0]->str_sbr_dec; |
616 | 24.7k | ptr_sbr_dec[1] = |
617 | 24.7k | &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[1]->str_sbr_dec; |
618 | | |
619 | 24.7k | qmf_dec_tables_ptr = |
620 | 24.7k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr; |
621 | | |
622 | 24.7k | if (sample_rate_dec > 48000) { |
623 | 1.70k | *down_sample_flag = 1; |
624 | 1.70k | } |
625 | | |
626 | 70.2k | for (i = 0; i < channel; i++) { |
627 | 45.5k | if (audio_object_type == AOT_ER_AAC_ELD) { |
628 | 14.1k | memcpy(sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[i], |
629 | 14.1k | &str_sbr_config, sizeof(ia_sbr_header_data_struct)); |
630 | 14.1k | } |
631 | 45.5k | ptr_header_data[i] = |
632 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[i]; |
633 | | |
634 | 45.5k | ixheaacd_init_headerdata( |
635 | 45.5k | ptr_header_data[i], sample_rate_dec, samp_per_frame, |
636 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_freq_band_data[i], |
637 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables, |
638 | 45.5k | audio_object_type); |
639 | | |
640 | 45.5k | err = ixheaacd_create_sbrdec( |
641 | | |
642 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_common_tables, |
643 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[i], |
644 | 45.5k | ptr_header_data[i], i, *down_sample_flag, sbr_persistent_mem, ps_enable, |
645 | 45.5k | audio_object_type, ldmps_present, ldsbr_present); |
646 | | |
647 | 45.5k | ptr_header_data[i]->status = 1; |
648 | 45.5k | ptr_sbr_dec[i]->band_count = 64; |
649 | 45.5k | ptr_header_data[i]->pstr_freq_band_data[0].qmf_sb_prev = 64; |
650 | 45.5k | ptr_header_data[i]->pstr_freq_band_data[1].qmf_sb_prev = 64; |
651 | | |
652 | 45.5k | if (err) { |
653 | 95 | return NULL; |
654 | 95 | } |
655 | 45.5k | } |
656 | | |
657 | 24.6k | if (channel != 1) { |
658 | 20.8k | if (ps_enable) { |
659 | 17.0k | if (audio_object_type == AOT_ER_AAC_ELD) |
660 | 7.04k | ixheaacd_create_psdec( |
661 | 7.04k | sbr_persistent_mem->str_sbr_dec_inst.pstr_ps_stereo_dec, |
662 | 7.04k | sbr_persistent_mem, &ptr_overlap_buf[512 * 4], samp_per_frame); |
663 | 10.0k | else |
664 | 10.0k | ixheaacd_create_psdec( |
665 | 10.0k | sbr_persistent_mem->str_sbr_dec_inst.pstr_ps_stereo_dec, |
666 | 10.0k | sbr_persistent_mem, ptr_overlap_buf, samp_per_frame); |
667 | 17.0k | } |
668 | 20.8k | } |
669 | | |
670 | 24.6k | if ((use_hbe != NULL) && !((audio_object_type == AOT_ER_AAC_ELD) || |
671 | 24.6k | (audio_object_type == AOT_ER_AAC_LD))) { |
672 | 15.9k | ia_sbr_header_data_struct *ptr_sbr_dflt_header = |
673 | 15.9k | &sbr_persistent_mem->str_sbr_dec_inst.str_sbr_dflt_header; |
674 | 15.9k | ia_sbr_header_data_struct *ptr_usac_dflt_header = |
675 | 15.9k | (ia_sbr_header_data_struct *)p_usac_dflt_header; |
676 | 15.9k | struct ia_sbr_dec_inst_struct *p_str_sbr_dec_inst = |
677 | 15.9k | &sbr_persistent_mem->str_sbr_dec_inst; |
678 | 15.9k | VOID *hbe_txposer_buffers = p_str_sbr_dec_inst->hbe_txposer_buffers; |
679 | | |
680 | 15.9k | ptr_header_data[0] = p_str_sbr_dec_inst->pstr_sbr_header[0]; |
681 | 15.9k | ptr_header_data[1] = p_str_sbr_dec_inst->pstr_sbr_header[1]; |
682 | | |
683 | 15.9k | ptr_header_data[0]->sbr_ratio_idx = sbr_ratio_idx; |
684 | 15.9k | ptr_header_data[0]->output_framesize = output_frame_size; |
685 | 15.9k | ptr_header_data[0]->pstr_freq_band_data->sub_band_start = 64; |
686 | 15.9k | ptr_header_data[0]->esbr_start_up = 1; |
687 | 15.9k | ptr_header_data[0]->esbr_start_up_pvc = 1; |
688 | | |
689 | 15.9k | if (channel > 1) { |
690 | 12.1k | ptr_header_data[1]->sbr_ratio_idx = sbr_ratio_idx; |
691 | 12.1k | ptr_header_data[1]->output_framesize = output_frame_size; |
692 | 12.1k | ptr_header_data[1]->pstr_freq_band_data->sub_band_start = 64; |
693 | 12.1k | ptr_header_data[1]->esbr_start_up = 1; |
694 | 12.1k | ptr_header_data[1]->esbr_start_up_pvc = 1; |
695 | 12.1k | } |
696 | 15.9k | if (hbe_txposer_buffers != NULL) { |
697 | 15.9k | WORD32 persistant_used = 0; |
698 | 15.9k | ixheaacd_esbr_hbe_data_init(ptr_sbr_dec[0]->p_hbe_txposer, samp_per_frame, |
699 | 15.9k | sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, |
700 | 15.9k | output_frame_size, hbe_txposer_buffers, &persistant_used); |
701 | | |
702 | 15.9k | hbe_txposer_buffers = (WORD8 *)hbe_txposer_buffers + |
703 | 15.9k | IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); |
704 | | |
705 | 15.9k | ixheaacd_esbr_hbe_data_init(ptr_sbr_dec[1]->p_hbe_txposer, samp_per_frame, |
706 | 15.9k | sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, |
707 | 15.9k | output_frame_size, hbe_txposer_buffers, &persistant_used); |
708 | 15.9k | } |
709 | | |
710 | 15.9k | p_str_sbr_dec_inst->ptr_pvc_data_str->prev_first_bnd_idx = -1; |
711 | 15.9k | p_str_sbr_dec_inst->ptr_pvc_data_str->prev_pvc_rate = -1; |
712 | 15.9k | p_str_sbr_dec_inst->ptr_pvc_data_str->prev_sbr_mode = UNKNOWN_SBR; |
713 | | |
714 | 15.9k | p_str_sbr_dec_inst->pstr_sbr_channel[0] |
715 | 15.9k | ->str_sbr_dec.str_codec_qmf_bank.num_time_slots = |
716 | 15.9k | output_frame_size / 64; |
717 | 15.9k | p_str_sbr_dec_inst->pstr_sbr_channel[1] |
718 | 15.9k | ->str_sbr_dec.str_codec_qmf_bank.num_time_slots = |
719 | 15.9k | output_frame_size / 64; |
720 | | |
721 | 15.9k | ptr_header_data[0]->core_frame_size = samp_per_frame; |
722 | 15.9k | ptr_header_data[1]->core_frame_size = samp_per_frame; |
723 | | |
724 | 15.9k | switch (sbr_ratio_idx) { |
725 | 0 | case SBR_UPSAMPLE_IDX_0_0: |
726 | 0 | ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 32; |
727 | 0 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = |
728 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; |
729 | 0 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
730 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; |
731 | 0 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = |
732 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; |
733 | 0 | ptr_header_data[0]->is_usf_4 = 0; |
734 | 0 | ptr_header_data[0]->upsamp_fac = 1; |
735 | |
|
736 | 0 | ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 32; |
737 | 0 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = |
738 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; |
739 | 0 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
740 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; |
741 | 0 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = |
742 | 0 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; |
743 | 0 | ptr_header_data[1]->is_usf_4 = 0; |
744 | 0 | ptr_header_data[1]->upsamp_fac = 1; |
745 | 0 | break; |
746 | 14.5k | case SBR_UPSAMPLE_IDX_2_1: |
747 | 14.5k | ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 32; |
748 | 14.5k | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = |
749 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; |
750 | 14.5k | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
751 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; |
752 | 14.5k | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = |
753 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; |
754 | 14.5k | ptr_header_data[0]->is_usf_4 = 0; |
755 | 14.5k | ptr_header_data[0]->upsamp_fac = 2; |
756 | | |
757 | 14.5k | ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 32; |
758 | 14.5k | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = |
759 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l32; |
760 | 14.5k | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
761 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l32; |
762 | 14.5k | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = |
763 | 14.5k | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l32; |
764 | 14.5k | ptr_header_data[1]->is_usf_4 = 0; |
765 | 14.5k | ptr_header_data[1]->upsamp_fac = 2; |
766 | 14.5k | break; |
767 | 981 | case SBR_UPSAMPLE_IDX_8_3: |
768 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 24; |
769 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.filter_pos_32 = |
770 | 981 | qmf_dec_tables_ptr->esbr_qmf_c_24; |
771 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.analy_win_coeff_32 = |
772 | 981 | qmf_dec_tables_ptr->esbr_qmf_c_24; |
773 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = |
774 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l24; |
775 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
776 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l24; |
777 | 981 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = |
778 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l24; |
779 | | |
780 | 981 | ptr_header_data[0]->is_usf_4 = 0; |
781 | 981 | ptr_header_data[0]->upsamp_fac = 2; |
782 | | |
783 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 24; |
784 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.filter_pos_32 = |
785 | 981 | qmf_dec_tables_ptr->esbr_qmf_c_24; |
786 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.analy_win_coeff_32 = |
787 | 981 | qmf_dec_tables_ptr->esbr_qmf_c_24; |
788 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = |
789 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l24; |
790 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
791 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l24; |
792 | 981 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = |
793 | 981 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l24; |
794 | | |
795 | 981 | ptr_header_data[1]->is_usf_4 = 0; |
796 | 981 | ptr_header_data[1]->upsamp_fac = 2; |
797 | 981 | break; |
798 | 491 | case SBR_UPSAMPLE_IDX_4_1: |
799 | 491 | ptr_sbr_dec[0]->str_codec_qmf_bank.no_channels = 16; |
800 | 491 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_cos_twiddle = |
801 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l16; |
802 | 491 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
803 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l16; |
804 | 491 | ptr_sbr_dec[0]->str_codec_qmf_bank.esbr_t_cos = |
805 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l16; |
806 | 491 | ptr_header_data[0]->is_usf_4 = 1; |
807 | 491 | ptr_header_data[0]->upsamp_fac = 4; |
808 | 491 | ptr_header_data[0]->out_sampling_freq = |
809 | 491 | ptr_header_data[0]->out_sampling_freq * 2; |
810 | | |
811 | 491 | ptr_sbr_dec[1]->str_codec_qmf_bank.no_channels = 16; |
812 | 491 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_cos_twiddle = |
813 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l16; |
814 | 491 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_alt_sin_twiddle = |
815 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l16; |
816 | 491 | ptr_sbr_dec[1]->str_codec_qmf_bank.esbr_t_cos = |
817 | 491 | (WORD32 *)qmf_dec_tables_ptr->esbr_t_cos_sin_l16; |
818 | 491 | ptr_header_data[1]->is_usf_4 = 1; |
819 | 491 | ptr_header_data[1]->upsamp_fac = 4; |
820 | 491 | ptr_header_data[1]->out_sampling_freq = |
821 | 491 | ptr_header_data[1]->out_sampling_freq * 2; |
822 | 491 | break; |
823 | 15.9k | } |
824 | | |
825 | 15.9k | if (ptr_usac_dflt_header != NULL) { |
826 | 4.72k | ptr_sbr_dflt_header->start_freq = ptr_usac_dflt_header->start_freq; |
827 | 4.72k | ptr_sbr_dflt_header->stop_freq = ptr_usac_dflt_header->stop_freq; |
828 | | |
829 | 4.72k | if (ptr_usac_dflt_header->header_extra_1) { |
830 | 2.00k | ptr_sbr_dflt_header->freq_scale = ptr_usac_dflt_header->freq_scale; |
831 | 2.00k | ptr_sbr_dflt_header->alter_scale = ptr_usac_dflt_header->alter_scale; |
832 | 2.00k | ptr_sbr_dflt_header->noise_bands = ptr_usac_dflt_header->noise_bands; |
833 | 2.71k | } else { |
834 | 2.71k | ptr_sbr_dflt_header->freq_scale = SBR_FREQ_SCALE_DEFAULT; |
835 | 2.71k | ptr_sbr_dflt_header->alter_scale = SBR_ALTER_SCALE_DEFAULT; |
836 | 2.71k | ptr_sbr_dflt_header->noise_bands = SBR_NOISE_BANDS_DEFAULT; |
837 | 2.71k | } |
838 | | |
839 | 4.72k | if (ptr_usac_dflt_header->header_extra_2) { |
840 | 797 | ptr_sbr_dflt_header->limiter_bands = ptr_usac_dflt_header->limiter_bands; |
841 | 797 | ptr_sbr_dflt_header->limiter_gains = ptr_usac_dflt_header->limiter_gains; |
842 | 797 | ptr_sbr_dflt_header->interpol_freq = ptr_usac_dflt_header->interpol_freq; |
843 | 797 | ptr_sbr_dflt_header->smoothing_mode = |
844 | 797 | ptr_usac_dflt_header->smoothing_mode; |
845 | 3.92k | } else { |
846 | 3.92k | ptr_sbr_dflt_header->limiter_bands = SBR_LIMITER_BANDS_DEFAULT; |
847 | 3.92k | ptr_sbr_dflt_header->limiter_gains = SBR_LIMITER_GAINS_DEFAULT; |
848 | 3.92k | ptr_sbr_dflt_header->interpol_freq = SBR_INTERPOL_FREQ_DEFAULT; |
849 | 3.92k | ptr_sbr_dflt_header->smoothing_mode = SBR_SMOOTHING_LENGTH_DEFAULT; |
850 | 3.92k | } |
851 | 4.72k | } |
852 | 15.9k | } |
853 | 24.6k | return &(sbr_persistent_mem->str_sbr_dec_inst); |
854 | 24.6k | } |
855 | | |
856 | | static PLATFORM_INLINE WORD16 ixheaacd_create_sbr_env_calc( |
857 | | |
858 | | ixheaacd_misc_tables *pstr_common_table, ia_sbr_calc_env_struct *hs, |
859 | | WORD16 chan, VOID *sbr_persistent_mem_v, |
860 | 45.5k | ia_sbr_header_data_struct *ptr_header_data, WORD audio_object_type) { |
861 | 45.5k | WORD16 err; |
862 | 45.5k | ia_sbr_pers_struct *sbr_persistent_mem = |
863 | 45.5k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
864 | | |
865 | 45.5k | err = 0; |
866 | 45.5k | memset(&hs->harm_flags_prev[0], 0, sizeof(WORD8) * MAX_FREQ_COEFFS); |
867 | | |
868 | 45.5k | hs->harm_index = 0; |
869 | | |
870 | 45.5k | hs->filt_buf_me = sbr_persistent_mem->sbr_smooth_gain_buf[chan]; |
871 | 45.5k | hs->filt_buf_noise_m = sbr_persistent_mem->sbr_smooth_noise_buf[chan]; |
872 | 45.5k | hs->tansient_env_prev = -1; |
873 | | |
874 | 45.5k | ixheaacd_reset_sbrenvelope_calc(hs); |
875 | | |
876 | 45.5k | if ((chan == 0) && (audio_object_type == AOT_ER_AAC_ELD)) { |
877 | 7.13k | err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data, pstr_common_table); |
878 | 7.13k | } |
879 | | |
880 | 45.5k | return err; |
881 | 45.5k | } |
882 | | |
883 | | static PLATFORM_INLINE VOID ixheaacd_init_sbr_prev_framedata( |
884 | 45.5k | ia_sbr_prev_frame_data_struct *ptr_prev_data, WORD16 time_slots) { |
885 | 45.5k | WORD16 *psfb_nrg_prev = ptr_prev_data->sfb_nrg_prev; |
886 | 45.5k | WORD16 *psfb_noise_level = ptr_prev_data->prev_noise_level; |
887 | 45.5k | WORD32 *ppsbr_invf_mode = ptr_prev_data->sbr_invf_mode; |
888 | | |
889 | 45.5k | memset(psfb_nrg_prev, 0, sizeof(WORD16) * (MAX_FREQ_COEFFS)); |
890 | 45.5k | memset(psfb_noise_level, 0, sizeof(WORD16) * (MAX_NOISE_COEFFS)); |
891 | | |
892 | 45.5k | memset(ppsbr_invf_mode, 0, sizeof(WORD32) * MAX_INVF_BANDS); |
893 | | |
894 | 45.5k | ptr_prev_data->end_position = time_slots; |
895 | 45.5k | ptr_prev_data->coupling_mode = COUPLING_OFF; |
896 | 45.5k | ptr_prev_data->amp_res = 0; |
897 | 45.5k | ptr_prev_data->max_qmf_subband_aac = 0; |
898 | 45.5k | } |
899 | | |
900 | | static PLATFORM_INLINE VOID |
901 | | ixheaacd_create_hyb_filterbank(ia_hybrid_struct *ptr_hybrid, WORD32 **p_ptr, |
902 | 17.0k | ia_sbr_tables_struct *sbr_tables_ptr) { |
903 | 17.0k | WORD16 i; |
904 | 17.0k | WORD32 *ptr = (WORD32 *)*p_ptr; |
905 | | |
906 | 17.0k | ptr_hybrid->ptr_resol = sbr_tables_ptr->ps_tables_ptr->hyb_resol; |
907 | 17.0k | ptr_hybrid->ptr_qmf_buf = HYBRID_FILTER_LENGTH - 1; |
908 | | |
909 | 17.0k | ptr_hybrid->ptr_temp_re = ptr; |
910 | 17.0k | ptr += NO_HYBRID_CHANNELS_HIGH; |
911 | 17.0k | ptr_hybrid->ptr_temp_im = ptr; |
912 | 17.0k | ptr += NO_HYBRID_CHANNELS_HIGH; |
913 | | |
914 | 17.0k | memset(ptr_hybrid->ptr_temp_re, 0, |
915 | 17.0k | 2 * NO_HYBRID_CHANNELS_HIGH * sizeof(WORD32)); |
916 | | |
917 | 17.0k | ptr_hybrid->ptr_work_re = ptr; |
918 | 17.0k | ptr += 16; |
919 | 17.0k | ptr_hybrid->ptr_work_im = ptr; |
920 | 17.0k | ptr += 16; |
921 | | |
922 | 68.2k | for (i = 0; i < NO_QMF_CHANNELS_IN_HYBRID; i++) { |
923 | 51.2k | ptr_hybrid->ptr_qmf_buf_re[i] = ptr; |
924 | 51.2k | ptr += ptr_hybrid->ptr_qmf_buf; |
925 | | |
926 | 51.2k | ptr_hybrid->ptr_qmf_buf_im[i] = ptr; |
927 | 51.2k | ptr += ptr_hybrid->ptr_qmf_buf; |
928 | | |
929 | 51.2k | memset(ptr_hybrid->ptr_qmf_buf_re[i], 0, |
930 | 51.2k | 2 * ptr_hybrid->ptr_qmf_buf * sizeof(WORD32)); |
931 | 51.2k | } |
932 | | |
933 | 17.0k | *p_ptr = ptr; |
934 | | |
935 | 17.0k | return; |
936 | 17.0k | } |
937 | | |
938 | | static PLATFORM_INLINE VOID ixheaacd_create_hf_generator( |
939 | | ia_sbr_hf_generator_struct *ptr_hf_gen_str, WORD16 num_columns, WORD16 chan, |
940 | 45.5k | VOID *sbr_persistent_mem_v, WORD32 ps_enable) { |
941 | 45.5k | WORD16 i; |
942 | 45.5k | ia_sbr_pers_struct *sbr_persistent_mem = |
943 | 45.5k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
944 | | |
945 | 45.5k | ptr_hf_gen_str->pstr_settings = &sbr_persistent_mem->str_sbr_tran_settings; |
946 | | |
947 | 45.5k | ptr_hf_gen_str->lpc_filt_states_real[0] = |
948 | 45.5k | sbr_persistent_mem->sbr_lpc_filter_states_real[chan][0]; |
949 | 45.5k | ptr_hf_gen_str->lpc_filt_states_real[1] = |
950 | 45.5k | sbr_persistent_mem->sbr_lpc_filter_states_real[chan][1]; |
951 | | |
952 | 45.5k | if (ps_enable) { |
953 | 34.1k | ptr_hf_gen_str->lpc_filt_states_imag[0] = |
954 | 34.1k | sbr_persistent_mem->sbr_lpc_filter_states_imag[chan][0]; |
955 | 34.1k | ptr_hf_gen_str->lpc_filt_states_imag[1] = |
956 | 34.1k | sbr_persistent_mem->sbr_lpc_filter_states_imag[chan][1]; |
957 | 34.1k | } |
958 | | |
959 | 136k | for (i = 0; i < LPC_ORDER; i++) { |
960 | 91.0k | if (ptr_hf_gen_str->lpc_filt_states_real[i] != NULL) { |
961 | 91.0k | memset(ptr_hf_gen_str->lpc_filt_states_real[i], 0, |
962 | 91.0k | NO_ANALYSIS_CHANNELS * sizeof(WORD32)); |
963 | 91.0k | } |
964 | | |
965 | 91.0k | if (ps_enable) |
966 | 68.2k | memset(ptr_hf_gen_str->lpc_filt_states_imag[i], 0, |
967 | 68.2k | NO_ANALYSIS_CHANNELS * sizeof(WORD32)); |
968 | 91.0k | } |
969 | | |
970 | 45.5k | if (chan == 0) { |
971 | 24.6k | ptr_hf_gen_str->pstr_settings->num_columns = num_columns; |
972 | 24.6k | } |
973 | 45.5k | return; |
974 | 45.5k | } |
975 | | |
976 | | VOID ixheaacd_create_psdec(ia_ps_dec_struct *ptr_ps_dec, |
977 | | VOID *sbr_persistent_mem_v, |
978 | 17.0k | WORD32 *ptr_overlap_buf, WORD32 frame_size) { |
979 | 17.0k | ia_sbr_pers_struct *sbr_persistent_mem = |
980 | 17.0k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
981 | | |
982 | 17.0k | WORD16 *ptr1 = (WORD16 *)&( |
983 | 17.0k | sbr_persistent_mem->ptr_sbr_overlap_buf[MAXNRSBRCHANNELS - 1][0]); |
984 | 17.0k | WORD32 *ptr2 = (WORD32 *)&ptr_overlap_buf[512]; |
985 | 17.0k | WORD16 *initial_ptr; |
986 | 17.0k | WORD16 delay; |
987 | 17.0k | WORD32 temp; |
988 | | |
989 | 17.0k | ia_sbr_tables_struct *sbr_tables_ptr = |
990 | 17.0k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables; |
991 | | |
992 | 17.0k | memset(ptr_ps_dec, 0, sizeof(ia_ps_dec_struct)); |
993 | | |
994 | 17.0k | ptr_ps_dec->ps_data_present = 0; |
995 | 17.0k | ptr_ps_dec->enable_iid = 0; |
996 | 17.0k | ptr_ps_dec->enable_icc = 0; |
997 | 17.0k | ptr_ps_dec->enable_ext = 0; |
998 | 17.0k | ptr_ps_dec->iid_mode = 0; |
999 | 17.0k | ptr_ps_dec->icc_mode = 0; |
1000 | | |
1001 | 17.0k | ptr_ps_dec->ptr_hyb_left_re = ptr2; |
1002 | 17.0k | ptr2 += 16; |
1003 | 17.0k | ptr_ps_dec->ptr_hyb_left_im = ptr2; |
1004 | 17.0k | ptr2 += 16; |
1005 | 17.0k | ptr_ps_dec->ptr_hyb_right_re = ptr2; |
1006 | 17.0k | ptr2 += 16; |
1007 | 17.0k | ptr_ps_dec->ptr_hyb_right_im = ptr2; |
1008 | 17.0k | ptr2 += 16; |
1009 | | |
1010 | 17.0k | memset(ptr_ps_dec->ptr_hyb_left_re, 0, sizeof(WORD32) * 16 * 4); |
1011 | | |
1012 | 17.0k | ixheaacd_create_hyb_filterbank(&ptr_ps_dec->str_hybrid, &ptr2, |
1013 | 17.0k | sbr_tables_ptr); |
1014 | | |
1015 | 17.0k | ptr_ps_dec->peak_decay_diff = ptr2; |
1016 | 17.0k | ptr2 += NUM_OF_BINS; |
1017 | 17.0k | ptr_ps_dec->energy_prev = ptr2; |
1018 | 17.0k | ptr2 += NUM_OF_BINS; |
1019 | 17.0k | ptr_ps_dec->peak_decay_diff_prev = ptr2; |
1020 | 17.0k | ptr2 += NUM_OF_BINS; |
1021 | | |
1022 | 17.0k | memset(ptr_ps_dec->peak_decay_diff, 0, 3 * sizeof(WORD32) * NUM_OF_BINS); |
1023 | | |
1024 | 17.0k | ptr_ps_dec->delay_buf_idx = 0; |
1025 | 17.0k | ptr_ps_dec->delay_buf_idx_long = 0; |
1026 | | |
1027 | 17.0k | memset(ptr_ps_dec->delay_buf_qmf_sub_re_im, 0, |
1028 | 17.0k | 2 * 16 * DEL_ALL_PASS * sizeof(WORD16)); |
1029 | 17.0k | memset(ptr_ps_dec->delay_buf_qmf_sub_ser_re_im, 0, |
1030 | 17.0k | 2 * 16 * NUM_SER_AP_LINKS * 5 * sizeof(WORD16)); |
1031 | | |
1032 | 17.0k | initial_ptr = ptr1; |
1033 | 17.0k | ptr_ps_dec->delay_buf_qmf_ser_re_im = (VOID *)ptr1; |
1034 | 17.0k | ptr1 += 2 * NUM_SER_AP_LINKS * 32 * 5; |
1035 | | |
1036 | 17.0k | delay = 2; |
1037 | 17.0k | ptr_ps_dec->delay_buf_qmf_ap_re_im = (VOID *)ptr1; |
1038 | 17.0k | ptr1 += 2 * delay * 32; |
1039 | | |
1040 | 17.0k | delay = HIGH_DEL; |
1041 | 17.0k | ptr_ps_dec->delay_buf_qmf_ld_re_im = (VOID *)ptr1; |
1042 | 17.0k | ptr1 += 2 * delay * SMALL_DEL_STRT; |
1043 | | |
1044 | 17.0k | delay = SMALL_DEL; |
1045 | 17.0k | ptr_ps_dec->delay_buf_qmf_sd_re_im = (VOID *)ptr1; |
1046 | 17.0k | ptr1 += |
1047 | 17.0k | 2 * delay * (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS - |
1048 | 17.0k | (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)); |
1049 | | |
1050 | 17.0k | temp = (WORD32)(ptr1 - initial_ptr); |
1051 | 17.0k | memset(ptr_ps_dec->delay_buf_qmf_ser_re_im, 0, temp * sizeof(WORD16)); |
1052 | | |
1053 | 17.0k | memset(ptr_ps_dec->delay_buf_idx_ser, 0, NUM_SER_AP_LINKS * sizeof(WORD16)); |
1054 | 17.0k | memcpy(ptr_ps_dec->delay_sample_ser, |
1055 | 17.0k | sbr_tables_ptr->ps_tables_ptr->rev_link_delay_ser, |
1056 | 17.0k | NUM_SER_AP_LINKS * sizeof(WORD16)); |
1057 | | |
1058 | 17.0k | memset(ptr_ps_dec->h11_h12_vec, 0xff, |
1059 | 17.0k | (NO_IID_GROUPS + 2) * 2 * sizeof(WORD16)); |
1060 | 17.0k | memset(ptr_ps_dec->h21_h22_vec, 0, sizeof(ptr_ps_dec->h21_h22_vec)); |
1061 | | |
1062 | 17.0k | if (frame_size == 960) |
1063 | 908 | ptr_ps_dec->num_sub_samples = NUM_SUB_SAMPLES_960; |
1064 | 16.1k | else |
1065 | 16.1k | ptr_ps_dec->num_sub_samples = NUM_SUB_SAMPLES; |
1066 | | |
1067 | | |
1068 | 17.0k | ixheaacd_create_ps_esbr_dec(ptr_ps_dec, sbr_tables_ptr->ps_tables_ptr, |
1069 | 17.0k | 64, ptr_ps_dec->num_sub_samples, 0); |
1070 | | |
1071 | 17.0k | return; |
1072 | 17.0k | } |
1073 | | |
1074 | | static PLATFORM_INLINE VOID ixheaacd_create_cplx_anal_qmfbank( |
1075 | | ia_sbr_qmf_filter_bank_struct *ptr_sbr_qmf, |
1076 | | ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 no_bins, WORD16 usb, |
1077 | | WORD16 chan, WORD16 *sbr_qmf_analy_states, WORD32 *sbr_qmf_analy_states_32, |
1078 | | ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, WORD32 audio_object_type, |
1079 | 45.5k | WORD32 ldmps_present, WORD32 no_ldsbr) { |
1080 | 45.5k | memset(ptr_sbr_qmf, 0, sizeof(ia_sbr_qmf_filter_bank_struct)); |
1081 | | |
1082 | 45.5k | ptr_sbr_qmf->analy_win_coeff_32 = qmf_dec_tables_ptr->esbr_qmf_c; |
1083 | 45.5k | if (audio_object_type != AOT_ER_AAC_ELD && |
1084 | 45.5k | audio_object_type != AOT_ER_AAC_LD) { |
1085 | 28.1k | ptr_sbr_qmf->analy_win_coeff = qmf_dec_tables_ptr->qmf_c; |
1086 | 28.1k | } else { |
1087 | 17.3k | ptr_sbr_qmf->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3; |
1088 | 17.3k | if (ldmps_present == 1) |
1089 | 1.97k | ptr_sbr_qmf->analy_win_coeff_32 = qmf_dec_tables_ptr->qmf_c_ldsbr_mps; |
1090 | 17.3k | if (no_ldsbr == 1) |
1091 | 4.40k | ptr_sbr_qmf->analy_win_coeff_32 = |
1092 | 4.40k | (WORD32 *)ixheaacd_ldmps_polyphase_filter_coeff_fix; |
1093 | 17.3k | } |
1094 | | |
1095 | 45.5k | ptr_sbr_qmf->no_channels = NO_ANALYSIS_CHANNELS; |
1096 | 45.5k | if (no_ldsbr) ptr_sbr_qmf->no_channels = 64; |
1097 | 45.5k | ptr_sbr_qmf->num_time_slots = no_bins; |
1098 | | |
1099 | 45.5k | ptr_sbr_qmf->lsb = 0; |
1100 | 45.5k | ptr_sbr_qmf->usb = usb; |
1101 | | |
1102 | 45.5k | ptr_sbr_qmf->anal_filter_states = |
1103 | 45.5k | &(sbr_qmf_analy_states[chan ? QMF_FILTER_STATE_ANA_SIZE : 0]); |
1104 | | |
1105 | 45.5k | memset(ptr_sbr_qmf->anal_filter_states, 0, |
1106 | 45.5k | sizeof(WORD16) * QMF_FILTER_STATE_ANA_SIZE); |
1107 | | |
1108 | 45.5k | ptr_sbr_qmf->anal_filter_states_32 = |
1109 | 45.5k | &(sbr_qmf_analy_states_32[chan ? QMF_FILTER_STATE_ANA_SIZE : 0]); |
1110 | | |
1111 | 45.5k | memset(ptr_sbr_qmf->anal_filter_states_32, 0, |
1112 | 45.5k | sizeof(WORD32) * QMF_FILTER_STATE_ANA_SIZE); |
1113 | | |
1114 | 45.5k | ptr_sbr_qmf->core_samples_buffer = ptr_sbr_qmf->anal_filter_states; |
1115 | 45.5k | ptr_sbr_qmf->core_samples_buffer_32 = ptr_sbr_qmf->anal_filter_states_32; |
1116 | | |
1117 | 45.5k | ptr_sbr_qmf->filter_pos_32 = (WORD32 *)qmf_dec_tables_ptr->esbr_qmf_c; |
1118 | 45.5k | ptr_sbr_qmf->state_new_samples_pos_low_32 = |
1119 | 45.5k | ptr_sbr_qmf->anal_filter_states_32; |
1120 | 45.5k | if (audio_object_type != AOT_ER_AAC_ELD && |
1121 | 45.5k | audio_object_type != AOT_ER_AAC_LD) { |
1122 | 28.1k | ptr_sbr_qmf->filter_pos = (WORD16 *)qmf_dec_tables_ptr->qmf_c; |
1123 | 28.1k | } else { |
1124 | 17.3k | ptr_sbr_qmf->filter_pos = (WORD16 *)qmf_dec_tables_ptr->qmf_c_eld3; |
1125 | 17.3k | if (ldmps_present == 1) |
1126 | 1.97k | ptr_sbr_qmf->filter_pos_32 = |
1127 | 1.97k | (WORD32 *)qmf_dec_tables_ptr->qmf_c_ldsbr_mps; |
1128 | 17.3k | if (no_ldsbr == 1) |
1129 | 4.40k | ptr_sbr_qmf->filter_pos_32 = |
1130 | 4.40k | (WORD32 *)ixheaacd_ldmps_polyphase_filter_coeff_fix; |
1131 | 17.3k | } |
1132 | | |
1133 | 45.5k | sbr_scale_factor->st_lb_scale = 0; |
1134 | | |
1135 | 45.5k | sbr_scale_factor->st_syn_scale = -6; |
1136 | | |
1137 | 45.5k | if (audio_object_type == AOT_ER_AAC_ELD || |
1138 | 45.5k | audio_object_type == AOT_ER_AAC_LD) { |
1139 | 17.3k | ptr_sbr_qmf->filter_2_32 = |
1140 | 17.3k | ptr_sbr_qmf->filter_pos_32 + ptr_sbr_qmf->no_channels; |
1141 | 17.3k | ptr_sbr_qmf->fp1_anal_32 = ptr_sbr_qmf->anal_filter_states_32; |
1142 | 17.3k | ptr_sbr_qmf->fp2_anal_32 = |
1143 | 17.3k | ptr_sbr_qmf->anal_filter_states_32 + ptr_sbr_qmf->no_channels; |
1144 | | |
1145 | 17.3k | ptr_sbr_qmf->filter_2 = ptr_sbr_qmf->filter_pos + ptr_sbr_qmf->no_channels; |
1146 | 17.3k | ptr_sbr_qmf->fp1_anal = ptr_sbr_qmf->anal_filter_states; |
1147 | 17.3k | ptr_sbr_qmf->fp2_anal = |
1148 | 17.3k | ptr_sbr_qmf->anal_filter_states + ptr_sbr_qmf->no_channels; |
1149 | 17.3k | } |
1150 | | |
1151 | 45.5k | return; |
1152 | 45.5k | } |
1153 | | |
1154 | | static PLATFORM_INLINE VOID ixheaacd_create_cplx_synt_qmfbank( |
1155 | | ia_sbr_qmf_filter_bank_struct *ptr_sbr_qmf, WORD16 no_bins, WORD16 lsb, |
1156 | | WORD16 usb, WORD16 chan, FLAG down_sample_flag, |
1157 | | WORD16 *sbr_qmf_synth_states, WORD32 *sbr_qmf_synth_states_32, |
1158 | 45.5k | ia_qmf_dec_tables_struct *qmf_dec_tables_ptr, WORD32 audio_object_type) { |
1159 | 45.5k | WORD32 L; |
1160 | | |
1161 | 45.5k | WORD32 qmf_filter_state_size; |
1162 | | |
1163 | 45.5k | memset(ptr_sbr_qmf, 0, sizeof(ia_sbr_qmf_filter_bank_struct)); |
1164 | | |
1165 | 45.5k | if (down_sample_flag) { |
1166 | 10.5k | L = NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED; |
1167 | 10.5k | qmf_filter_state_size = QMF_FILTER_STATE_SYN_SIZE_DOWN_SAMPLED; |
1168 | 10.5k | ptr_sbr_qmf->usb = NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED; |
1169 | 34.9k | } else { |
1170 | 34.9k | L = NO_SYNTHESIS_CHANNELS; |
1171 | 34.9k | qmf_filter_state_size = QMF_FILTER_STATE_SYN_SIZE; |
1172 | 34.9k | ptr_sbr_qmf->usb = usb; |
1173 | 34.9k | } |
1174 | | |
1175 | 45.5k | ptr_sbr_qmf->ixheaacd_drc_offset = 0; |
1176 | 45.5k | if (audio_object_type != AOT_ER_AAC_ELD && |
1177 | 45.5k | audio_object_type != AOT_ER_AAC_LD) { |
1178 | 28.1k | ptr_sbr_qmf->filter_pos_syn = (WORD16 *)qmf_dec_tables_ptr->qmf_c; |
1179 | 28.1k | ptr_sbr_qmf->p_filter = qmf_dec_tables_ptr->qmf_c; |
1180 | 28.1k | } else { |
1181 | 17.3k | ptr_sbr_qmf->filter_pos_syn = (WORD16 *)qmf_dec_tables_ptr->qmf_c_eld; |
1182 | 17.3k | ptr_sbr_qmf->p_filter = qmf_dec_tables_ptr->qmf_c_eld; |
1183 | 17.3k | } |
1184 | | |
1185 | 45.5k | ptr_sbr_qmf->filter_pos_syn_32 = (WORD32 *)qmf_dec_tables_ptr->esbr_qmf_c; |
1186 | 45.5k | ptr_sbr_qmf->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; |
1187 | | |
1188 | 45.5k | ptr_sbr_qmf->no_channels = L; |
1189 | 45.5k | ptr_sbr_qmf->qmf_filter_state_size = qmf_filter_state_size; |
1190 | 45.5k | ptr_sbr_qmf->num_time_slots = no_bins; |
1191 | 45.5k | ptr_sbr_qmf->lsb = lsb; |
1192 | | |
1193 | 45.5k | ptr_sbr_qmf->filter_states = |
1194 | 45.5k | &sbr_qmf_synth_states[chan ? qmf_filter_state_size : 0]; |
1195 | | |
1196 | 45.5k | memset(ptr_sbr_qmf->filter_states, 0, sizeof(WORD16) * qmf_filter_state_size); |
1197 | | |
1198 | 45.5k | ptr_sbr_qmf->filter_states_32 = |
1199 | 45.5k | &sbr_qmf_synth_states_32[chan ? qmf_filter_state_size : 0]; |
1200 | | |
1201 | 45.5k | memset(ptr_sbr_qmf->filter_states_32, 0, |
1202 | 45.5k | sizeof(WORD32) * qmf_filter_state_size); |
1203 | | |
1204 | 45.5k | if (audio_object_type == AOT_ER_AAC_ELD || |
1205 | 45.5k | audio_object_type == AOT_ER_AAC_LD) { |
1206 | 17.3k | ptr_sbr_qmf->fp1_syn = ptr_sbr_qmf->filter_states; |
1207 | 17.3k | ptr_sbr_qmf->fp2_syn = |
1208 | 17.3k | ptr_sbr_qmf->filter_states + ptr_sbr_qmf->no_channels; |
1209 | 17.3k | ptr_sbr_qmf->sixty4 = NO_SYNTHESIS_CHANNELS; |
1210 | 17.3k | } |
1211 | | |
1212 | 45.5k | return; |
1213 | 45.5k | } |
1214 | | |
1215 | | WORD16 ixheaacd_create_sbrdec(ixheaacd_misc_tables *pstr_common_table, |
1216 | | ia_sbr_channel_struct *ptr_sbr_channel, |
1217 | | ia_sbr_header_data_struct *ptr_header_data, |
1218 | | WORD16 chan, FLAG down_sample_flag, |
1219 | | VOID *sbr_persistent_mem_v, WORD ps_enable, |
1220 | | WORD audio_object_type, WORD32 ldmps_present, |
1221 | | WORD32 ldsbr_present) |
1222 | | |
1223 | 45.5k | { |
1224 | 45.5k | WORD16 err; |
1225 | 45.5k | WORD16 time_slots; |
1226 | 45.5k | WORD16 no_bins; |
1227 | 45.5k | ia_sbr_pers_struct *sbr_persistent_mem = |
1228 | 45.5k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
1229 | 45.5k | ia_sbr_dec_struct *hs = &(ptr_sbr_channel->str_sbr_dec); |
1230 | | |
1231 | 45.5k | time_slots = ptr_header_data->num_time_slots; |
1232 | | |
1233 | 45.5k | no_bins = (WORD16)(time_slots * ptr_header_data->time_step); |
1234 | | |
1235 | 45.5k | hs->str_sbr_scale_fact.ov_lb_scale = INT_BITS - 1; |
1236 | 45.5k | hs->str_sbr_scale_fact.hb_scale = INT_BITS - 1; |
1237 | 45.5k | hs->str_sbr_scale_fact.ov_hb_scale = INT_BITS - 1; |
1238 | 45.5k | hs->str_sbr_scale_fact.st_syn_scale = INT_BITS - 1; |
1239 | | |
1240 | 45.5k | ptr_sbr_channel->pstr_prev_frame_data = |
1241 | 45.5k | sbr_persistent_mem->pstr_prev_frame_data[chan]; |
1242 | | |
1243 | 45.5k | err = ixheaacd_create_sbr_env_calc(pstr_common_table, &hs->str_sbr_calc_env, |
1244 | 45.5k | chan, sbr_persistent_mem, ptr_header_data, |
1245 | 45.5k | audio_object_type); |
1246 | | |
1247 | 45.5k | if (err) { |
1248 | 95 | return (-1); |
1249 | 95 | } |
1250 | | |
1251 | 45.5k | ixheaacd_create_cplx_anal_qmfbank( |
1252 | 45.5k | &hs->str_codec_qmf_bank, &hs->str_sbr_scale_fact, no_bins, |
1253 | 45.5k | ptr_header_data->pstr_freq_band_data->sub_band_start, chan, |
1254 | 45.5k | sbr_persistent_mem->sbr_qmf_analy_states, |
1255 | 45.5k | sbr_persistent_mem->sbr_qmf_analy_states_32, |
1256 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr, |
1257 | 45.5k | audio_object_type, ldmps_present, ldsbr_present); |
1258 | | |
1259 | 45.5k | ixheaacd_create_cplx_synt_qmfbank( |
1260 | 45.5k | &hs->str_synthesis_qmf_bank, no_bins, |
1261 | 45.5k | ptr_header_data->pstr_freq_band_data->sub_band_start, |
1262 | 45.5k | ptr_header_data->pstr_freq_band_data->sub_band_end, chan, |
1263 | 45.5k | down_sample_flag, sbr_persistent_mem->sbr_qmf_synth_states, |
1264 | 45.5k | sbr_persistent_mem->sbr_qmf_synth_states_32, |
1265 | 45.5k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr, |
1266 | 45.5k | audio_object_type); |
1267 | | |
1268 | 45.5k | ixheaacd_init_sbr_prev_framedata(ptr_sbr_channel->pstr_prev_frame_data, |
1269 | 45.5k | time_slots); |
1270 | | |
1271 | 45.5k | ixheaacd_create_hf_generator(&hs->str_hf_generator, |
1272 | 45.5k | hs->str_codec_qmf_bank.num_time_slots, chan, |
1273 | 45.5k | sbr_persistent_mem, ps_enable); |
1274 | | |
1275 | 45.5k | hs->ptr_sbr_overlap_buf = sbr_persistent_mem->ptr_sbr_overlap_buf[chan]; |
1276 | | |
1277 | 45.5k | return 0; |
1278 | 45.5k | } |