/src/libxaac/decoder/ixheaacd_initfuncs.c
Line | Count | Source |
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 "ixheaac_type_def.h" |
22 | | |
23 | | #include "ixheaacd_sbr_common.h" |
24 | | |
25 | | #include "ixheaac_constants.h" |
26 | | #include "ixheaac_basic_ops32.h" |
27 | | #include "ixheaac_basic_ops16.h" |
28 | | #include "ixheaac_basic_ops40.h" |
29 | | #include "ixheaac_basic_ops.h" |
30 | | #include "ixheaacd_bitbuffer.h" |
31 | | |
32 | | #include "ixheaac_basic_op.h" |
33 | | #include "ixheaacd_intrinsics.h" |
34 | | |
35 | | #include "ixheaacd_defines.h" |
36 | | |
37 | | #include "ixheaacd_aac_rom.h" |
38 | | |
39 | | #include "ixheaacd_definitions.h" |
40 | | |
41 | | #include "ixheaacd_error_codes.h" |
42 | | |
43 | | #include "ixheaacd_pulsedata.h" |
44 | | |
45 | | #include "ixheaacd_pns.h" |
46 | | #include "ixheaacd_drc_data_struct.h" |
47 | | |
48 | | #include "ixheaacd_lt_predict.h" |
49 | | #include "ixheaacd_cnst.h" |
50 | | #include "ixheaacd_ec_defines.h" |
51 | | #include "ixheaacd_ec_struct_def.h" |
52 | | |
53 | | #include "ixheaacd_channelinfo.h" |
54 | | #include "ixheaacd_drc_dec.h" |
55 | | |
56 | | #include "ixheaacd_sbrdecoder.h" |
57 | | #include "ixheaacd_block.h" |
58 | | #include "ixheaacd_channel.h" |
59 | | |
60 | | #include "ixheaacd_sbr_payload.h" |
61 | | #include "ixheaacd_common_rom.h" |
62 | | #include "ixheaacd_sbrdecsettings.h" |
63 | | #include "ixheaacd_sbr_scale.h" |
64 | | #include "ixheaacd_env_extr_part.h" |
65 | | #include "ixheaacd_sbr_rom.h" |
66 | | |
67 | | #include "ixheaacd_lpp_tran.h" |
68 | | #include "ixheaacd_hybrid.h" |
69 | | #include "ixheaacd_ps_dec.h" |
70 | | |
71 | | #include "ixheaacd_env_extr.h" |
72 | | #include "ixheaacd_adts.h" |
73 | | #include "ixheaacd_audioobjtypes.h" |
74 | | #include "ixheaacd_memory_standards.h" |
75 | | |
76 | | #include "ixheaacd_latmdemux.h" |
77 | | |
78 | | #include "ixheaacd_aacdec.h" |
79 | | #include "ixheaacd_mps_polyphase.h" |
80 | | #include "ixheaacd_config.h" |
81 | | #include "ixheaacd_qmf_dec.h" |
82 | | #include "ixheaacd_mps_macro_def.h" |
83 | | #include "ixheaacd_mps_struct_def.h" |
84 | | #include "ixheaacd_mps_res_rom.h" |
85 | | #include "ixheaacd_mps_aac_struct.h" |
86 | | #include "ixheaacd_mps_dec.h" |
87 | | |
88 | | #include "ixheaacd_struct_def.h" |
89 | | |
90 | | #include "ixheaacd_multichannel.h" |
91 | | |
92 | 290k | #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) |
93 | | |
94 | | WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v, |
95 | 31.9k | WORD32 num_channel) { |
96 | 31.9k | WORD32 persistent_used; |
97 | | |
98 | 31.9k | struct ia_aac_persistent_struct *aac_persistent_mem = |
99 | 31.9k | (struct ia_aac_persistent_struct *)aac_persistent_mem_v; |
100 | | |
101 | 31.9k | persistent_used = |
102 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8); |
103 | | |
104 | 31.9k | memset(aac_persistent_mem, 0, |
105 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8)); |
106 | 31.9k | aac_persistent_mem->overlap_buffer = |
107 | 31.9k | (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used); |
108 | | |
109 | 31.9k | memset( |
110 | 31.9k | (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, |
111 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED( |
112 | 31.9k | 4 * 512 * num_channel * sizeof(aac_persistent_mem->overlap_buffer[0]), BYTE_ALIGN_8)); |
113 | | |
114 | 31.9k | persistent_used += IXHEAAC_GET_SIZE_ALIGNED( |
115 | 31.9k | 4 * 512 * num_channel * sizeof(aac_persistent_mem->overlap_buffer[0]), BYTE_ALIGN_8); |
116 | | |
117 | 31.9k | aac_persistent_mem->sbr_payload_buffer = |
118 | 31.9k | (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used); |
119 | | |
120 | 31.9k | memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, |
121 | 31.9k | num_channel * |
122 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED( |
123 | 31.9k | MAXSBRBYTES * sizeof(aac_persistent_mem->sbr_payload_buffer[0]), BYTE_ALIGN_8)); |
124 | | |
125 | 31.9k | persistent_used += |
126 | 31.9k | num_channel * |
127 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(aac_persistent_mem->sbr_payload_buffer[0]), |
128 | 31.9k | BYTE_ALIGN_8); |
129 | | |
130 | 31.9k | aac_persistent_mem->prev_sbr_payload_buffer = |
131 | 31.9k | (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used); |
132 | | |
133 | 31.9k | memset((WORD8 *)aac_persistent_mem->prev_sbr_payload_buffer, 0, |
134 | 31.9k | num_channel * IXHEAAC_GET_SIZE_ALIGNED( |
135 | 31.9k | MAXSBRBYTES * sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer)), |
136 | 31.9k | BYTE_ALIGN_8)); |
137 | | |
138 | 31.9k | persistent_used += |
139 | 31.9k | num_channel * |
140 | 31.9k | IXHEAAC_GET_SIZE_ALIGNED( |
141 | 31.9k | MAXSBRBYTES * sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer)), BYTE_ALIGN_8); |
142 | | |
143 | 31.9k | { |
144 | 31.9k | WORD32 i; |
145 | | |
146 | 94.0k | for (i = 0; i < num_channel; i++) { |
147 | 62.1k | aac_persistent_mem->ltp_buf[i] = |
148 | 62.1k | (WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used); |
149 | | |
150 | 62.1k | memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, |
151 | 62.1k | IXHEAAC_GET_SIZE_ALIGNED(ltp_buffer_size * sizeof(aac_persistent_mem->ltp_buf[i][0]), |
152 | 62.1k | BYTE_ALIGN_8)); |
153 | | |
154 | 62.1k | persistent_used += IXHEAAC_GET_SIZE_ALIGNED( |
155 | 62.1k | ltp_buffer_size * sizeof(aac_persistent_mem->ltp_buf[i][0]), BYTE_ALIGN_8); |
156 | | |
157 | 62.1k | aac_persistent_mem->ptr_aac_dec_static_channel_info[i] = |
158 | 62.1k | (ia_aac_dec_channel_info *)((WORD8 *)aac_persistent_mem_v + persistent_used); |
159 | 62.1k | persistent_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_channel_info), BYTE_ALIGN_8); |
160 | | |
161 | 62.1k | aac_persistent_mem->ptr_aac_dec_static_channel_info[i] |
162 | 62.1k | ->overlap_add_data.win_shape = 0; |
163 | 62.1k | aac_persistent_mem->ptr_aac_dec_static_channel_info[i] |
164 | 62.1k | ->overlap_add_data.win_seq = 0; |
165 | | |
166 | 62.1k | aac_persistent_mem->ptr_aac_dec_static_channel_info[i] |
167 | 62.1k | ->overlap_add_data.ptr_overlap_buf = |
168 | 62.1k | &aac_persistent_mem->overlap_buffer[i * OVERLAP_BUFFER_SIZE]; |
169 | 62.1k | } |
170 | 31.9k | } |
171 | | |
172 | 31.9k | return persistent_used; |
173 | 31.9k | } |
174 | | |
175 | 20.1k | VOID ixheaacd_huff_tables_create(ia_aac_dec_tables_struct *ptr_aac_tables) { |
176 | 20.1k | ptr_aac_tables->code_book[0] = 0; |
177 | 20.1k | ptr_aac_tables->code_book[1] = |
178 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb1; |
179 | 20.1k | ptr_aac_tables->code_book[2] = |
180 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb2; |
181 | 20.1k | ptr_aac_tables->code_book[3] = |
182 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb3; |
183 | 20.1k | ptr_aac_tables->code_book[4] = |
184 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb4; |
185 | 20.1k | ptr_aac_tables->code_book[5] = |
186 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb5; |
187 | 20.1k | ptr_aac_tables->code_book[6] = |
188 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb6; |
189 | 20.1k | ptr_aac_tables->code_book[7] = |
190 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb7; |
191 | 20.1k | ptr_aac_tables->code_book[8] = |
192 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb8; |
193 | 20.1k | ptr_aac_tables->code_book[9] = |
194 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb9; |
195 | 20.1k | ptr_aac_tables->code_book[10] = |
196 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; |
197 | 20.1k | ptr_aac_tables->code_book[11] = |
198 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; |
199 | 20.1k | ptr_aac_tables->code_book[12] = |
200 | 20.1k | (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10; |
201 | | |
202 | 20.1k | ptr_aac_tables->index_table[1] = |
203 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf1; |
204 | 20.1k | ptr_aac_tables->index_table[2] = |
205 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf2; |
206 | 20.1k | ptr_aac_tables->index_table[3] = |
207 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf3; |
208 | 20.1k | ptr_aac_tables->index_table[4] = |
209 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf4; |
210 | 20.1k | ptr_aac_tables->index_table[5] = |
211 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf5; |
212 | 20.1k | ptr_aac_tables->index_table[6] = |
213 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf6; |
214 | 20.1k | ptr_aac_tables->index_table[7] = |
215 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf7; |
216 | 20.1k | ptr_aac_tables->index_table[8] = |
217 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf8; |
218 | 20.1k | ptr_aac_tables->index_table[9] = |
219 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf9; |
220 | 20.1k | ptr_aac_tables->index_table[10] = |
221 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; |
222 | 20.1k | ptr_aac_tables->index_table[11] = |
223 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; |
224 | 20.1k | ptr_aac_tables->index_table[12] = |
225 | 20.1k | (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10; |
226 | | |
227 | 20.1k | ptr_aac_tables->scale_factor_bands_short[0] = |
228 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; |
229 | 20.1k | ptr_aac_tables->scale_factor_bands_short[1] = |
230 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; |
231 | 20.1k | ptr_aac_tables->scale_factor_bands_short[2] = |
232 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128; |
233 | 20.1k | ptr_aac_tables->scale_factor_bands_short[3] = |
234 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; |
235 | 20.1k | ptr_aac_tables->scale_factor_bands_short[4] = |
236 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; |
237 | 20.1k | ptr_aac_tables->scale_factor_bands_short[5] = |
238 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128; |
239 | 20.1k | ptr_aac_tables->scale_factor_bands_short[6] = |
240 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128; |
241 | 20.1k | ptr_aac_tables->scale_factor_bands_short[7] = |
242 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128; |
243 | 20.1k | ptr_aac_tables->scale_factor_bands_short[8] = |
244 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; |
245 | 20.1k | ptr_aac_tables->scale_factor_bands_short[9] = |
246 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; |
247 | 20.1k | ptr_aac_tables->scale_factor_bands_short[10] = |
248 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128; |
249 | 20.1k | ptr_aac_tables->scale_factor_bands_short[11] = |
250 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_128; |
251 | | |
252 | 20.1k | ptr_aac_tables->scale_factor_bands_short[12] = |
253 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_120; |
254 | 20.1k | ptr_aac_tables->scale_factor_bands_short[13] = |
255 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_120; |
256 | 20.1k | ptr_aac_tables->scale_factor_bands_short[14] = |
257 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_120; |
258 | 20.1k | ptr_aac_tables->scale_factor_bands_short[15] = |
259 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_120; |
260 | 20.1k | ptr_aac_tables->scale_factor_bands_short[16] = |
261 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_120; |
262 | 20.1k | ptr_aac_tables->scale_factor_bands_short[17] = |
263 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_120; |
264 | 20.1k | ptr_aac_tables->scale_factor_bands_short[18] = |
265 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_120; |
266 | 20.1k | ptr_aac_tables->scale_factor_bands_short[19] = |
267 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_120; |
268 | 20.1k | ptr_aac_tables->scale_factor_bands_short[20] = |
269 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_120; |
270 | 20.1k | ptr_aac_tables->scale_factor_bands_short[21] = |
271 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_120; |
272 | 20.1k | ptr_aac_tables->scale_factor_bands_short[22] = |
273 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_120; |
274 | 20.1k | ptr_aac_tables->scale_factor_bands_short[23] = |
275 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_120; |
276 | | |
277 | 20.1k | ptr_aac_tables->scale_factor_bands_long[0] = |
278 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024; |
279 | 20.1k | ptr_aac_tables->scale_factor_bands_long[1] = |
280 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024; |
281 | 20.1k | ptr_aac_tables->scale_factor_bands_long[2] = |
282 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_64_1024; |
283 | 20.1k | ptr_aac_tables->scale_factor_bands_long[3] = |
284 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024; |
285 | 20.1k | ptr_aac_tables->scale_factor_bands_long[4] = |
286 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024; |
287 | 20.1k | ptr_aac_tables->scale_factor_bands_long[5] = |
288 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_1024; |
289 | 20.1k | ptr_aac_tables->scale_factor_bands_long[6] = |
290 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024; |
291 | 20.1k | ptr_aac_tables->scale_factor_bands_long[7] = |
292 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024; |
293 | 20.1k | ptr_aac_tables->scale_factor_bands_long[8] = |
294 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; |
295 | 20.1k | ptr_aac_tables->scale_factor_bands_long[9] = |
296 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; |
297 | 20.1k | ptr_aac_tables->scale_factor_bands_long[10] = |
298 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024; |
299 | 20.1k | ptr_aac_tables->scale_factor_bands_long[11] = |
300 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_1024; |
301 | | |
302 | 20.1k | ptr_aac_tables->scale_factor_bands_long[12] = |
303 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_960; |
304 | 20.1k | ptr_aac_tables->scale_factor_bands_long[13] = |
305 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_960; |
306 | 20.1k | ptr_aac_tables->scale_factor_bands_long[14] = |
307 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_64_960; |
308 | 20.1k | ptr_aac_tables->scale_factor_bands_long[15] = |
309 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_960; |
310 | 20.1k | ptr_aac_tables->scale_factor_bands_long[16] = |
311 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_960; |
312 | 20.1k | ptr_aac_tables->scale_factor_bands_long[17] = |
313 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_960; |
314 | 20.1k | ptr_aac_tables->scale_factor_bands_long[18] = |
315 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_960; |
316 | 20.1k | ptr_aac_tables->scale_factor_bands_long[19] = |
317 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_960; |
318 | 20.1k | ptr_aac_tables->scale_factor_bands_long[20] = |
319 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_960; |
320 | 20.1k | ptr_aac_tables->scale_factor_bands_long[21] = |
321 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_960; |
322 | 20.1k | ptr_aac_tables->scale_factor_bands_long[22] = |
323 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_960; |
324 | 20.1k | ptr_aac_tables->scale_factor_bands_long[23] = |
325 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_960; |
326 | | |
327 | 20.1k | ptr_aac_tables->scale_fac_bands_512[0] = |
328 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; |
329 | 20.1k | ptr_aac_tables->scale_fac_bands_512[1] = |
330 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; |
331 | 20.1k | ptr_aac_tables->scale_fac_bands_512[2] = |
332 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; |
333 | 20.1k | ptr_aac_tables->scale_fac_bands_512[3] = |
334 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; |
335 | 20.1k | ptr_aac_tables->scale_fac_bands_512[4] = |
336 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512; |
337 | 20.1k | ptr_aac_tables->scale_fac_bands_512[5] = |
338 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_512; |
339 | 20.1k | ptr_aac_tables->scale_fac_bands_512[6] = |
340 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
341 | 20.1k | ptr_aac_tables->scale_fac_bands_512[7] = |
342 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
343 | 20.1k | ptr_aac_tables->scale_fac_bands_512[8] = |
344 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
345 | 20.1k | ptr_aac_tables->scale_fac_bands_512[9] = |
346 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
347 | 20.1k | ptr_aac_tables->scale_fac_bands_512[10] = |
348 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
349 | 20.1k | ptr_aac_tables->scale_fac_bands_512[11] = |
350 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
351 | 20.1k | ptr_aac_tables->scale_fac_bands_512[12] = |
352 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
353 | 20.1k | ptr_aac_tables->scale_fac_bands_512[13] = |
354 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
355 | 20.1k | ptr_aac_tables->scale_fac_bands_512[14] = |
356 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
357 | 20.1k | ptr_aac_tables->scale_fac_bands_512[15] = |
358 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512; |
359 | | |
360 | 20.1k | ptr_aac_tables->scale_fac_bands_480[0] = |
361 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; |
362 | 20.1k | ptr_aac_tables->scale_fac_bands_480[1] = |
363 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; |
364 | 20.1k | ptr_aac_tables->scale_fac_bands_480[2] = |
365 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; |
366 | 20.1k | ptr_aac_tables->scale_fac_bands_480[3] = |
367 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; |
368 | 20.1k | ptr_aac_tables->scale_fac_bands_480[4] = |
369 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480; |
370 | 20.1k | ptr_aac_tables->scale_fac_bands_480[5] = |
371 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_480; |
372 | 20.1k | ptr_aac_tables->scale_fac_bands_480[6] = |
373 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
374 | 20.1k | ptr_aac_tables->scale_fac_bands_480[7] = |
375 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
376 | 20.1k | ptr_aac_tables->scale_fac_bands_480[8] = |
377 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
378 | 20.1k | ptr_aac_tables->scale_fac_bands_480[9] = |
379 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
380 | 20.1k | ptr_aac_tables->scale_fac_bands_480[10] = |
381 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
382 | 20.1k | ptr_aac_tables->scale_fac_bands_480[11] = |
383 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
384 | 20.1k | ptr_aac_tables->scale_fac_bands_480[12] = |
385 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
386 | 20.1k | ptr_aac_tables->scale_fac_bands_480[13] = |
387 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
388 | 20.1k | ptr_aac_tables->scale_fac_bands_480[14] = |
389 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
390 | 20.1k | ptr_aac_tables->scale_fac_bands_480[15] = |
391 | 20.1k | ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480; |
392 | 20.1k | } |
393 | | |
394 | | ia_aac_decoder_struct *ixheaacd_aac_decoder_init( |
395 | | ia_aac_dec_state_struct *p_state_enhaacplus_dec, |
396 | | ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream, WORD channels, |
397 | 145k | VOID *aac_persistent_mem_v, WORD32 frame_length) { |
398 | 145k | WORD i, ch; |
399 | 145k | struct ia_aac_persistent_struct *aac_persistent_mem; |
400 | 145k | aac_persistent_mem = (struct ia_aac_persistent_struct *)aac_persistent_mem_v; |
401 | | |
402 | 145k | aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream = ptr_sbr_bitstream; |
403 | | |
404 | 433k | for (ch = 0; ch < channels; ch++) { |
405 | 288k | ia_aac_decoder_struct *aac_dec_handle = |
406 | 288k | &aac_persistent_mem->str_aac_decoder; |
407 | 288k | aac_dec_handle->pstr_aac_dec_overlap_info[ch] = |
408 | 288k | &aac_persistent_mem->str_aac_dec_overlap_info[ch]; |
409 | 288k | aac_dec_handle->pstr_pns_rand_vec_data = |
410 | 288k | &aac_persistent_mem->str_pns_rand_vec_data; |
411 | | |
412 | 288k | aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_shape = 0; |
413 | 288k | aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_sequence = 0; |
414 | 288k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) |
415 | 60.8k | aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf = |
416 | 60.8k | &aac_persistent_mem->overlap_buffer[ch * 4 * OVERLAP_BUFFER_SIZE]; |
417 | 227k | else |
418 | 227k | aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf = |
419 | 227k | &aac_persistent_mem->overlap_buffer[ch * OVERLAP_BUFFER_SIZE]; |
420 | | |
421 | 288k | { |
422 | 288k | WORD32 *ptr_overlap_buf = |
423 | 288k | aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf; |
424 | 288k | memset(ptr_overlap_buf, 0, |
425 | 288k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ptr_overlap_buf[0]) * 4 * 512, BYTE_ALIGN_8)); |
426 | 288k | } |
427 | 288k | aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] = |
428 | 288k | aac_persistent_mem->ptr_aac_dec_static_channel_info[ch]; |
429 | 288k | aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] |
430 | 288k | ->ltp_buf = aac_persistent_mem->ltp_buf[ch]; |
431 | 288k | } |
432 | | |
433 | 290k | for (i = 0; i < 1; i++) { |
434 | 145k | ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream = |
435 | 145k | &aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream[i]; |
436 | | |
437 | 145k | ptr_sbr_bitstream->no_elements = 0; |
438 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].ptr_sbr_data = |
439 | 145k | &aac_persistent_mem->sbr_payload_buffer[ALIGN_SIZE64(MAXSBRBYTES) * i]; |
440 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].ptr_prev_sbr_data = |
441 | 145k | &aac_persistent_mem->prev_sbr_payload_buffer[ALIGN_SIZE64(MAXSBRBYTES) * i]; |
442 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].sbr_ele_id = ID_SCE; |
443 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].size_payload = 0; |
444 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].prev_size_payload = 0; |
445 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].prev_sbr_ele_id = ID_SCE; |
446 | 145k | ptr_sbr_bitstream->str_sbr_ele[0].size_payload_old = 0; |
447 | 145k | } |
448 | | |
449 | 145k | { |
450 | 145k | ia_aac_dec_tables_struct *ptr_aac_tables = |
451 | 145k | aac_persistent_mem->str_aac_decoder.pstr_aac_tables; |
452 | 145k | ia_aac_dec_huffman_tables_struct *pstr_huffmann_tables = |
453 | 145k | ptr_aac_tables->pstr_huffmann_tables; |
454 | | |
455 | 145k | WORD num_entries = sizeof(pstr_huffmann_tables->str_sample_rate_info) / |
456 | 145k | sizeof(ia_sampling_rate_info_struct); |
457 | | |
458 | 145k | WORD32 sampling_rate = p_state_enhaacplus_dec->sampling_rate; |
459 | 145k | WORD sfidx; |
460 | | |
461 | 145k | i = 0; |
462 | 1.07M | while ((i < num_entries) && |
463 | 1.07M | sampling_rate != ((pstr_huffmann_tables->str_sample_rate_info[i] |
464 | 1.07M | .sampling_frequency))) { |
465 | 928k | i++; |
466 | 928k | } |
467 | 145k | if (i == 12) { |
468 | 1.18k | i = i - 1; |
469 | 1.18k | } |
470 | | |
471 | 145k | if (i == num_entries) { |
472 | 0 | return NULL; |
473 | 0 | } |
474 | 145k | sfidx = i; |
475 | | |
476 | 145k | if (frame_length == 1024 || frame_length == 960) { |
477 | 98.3k | WORD16 *psfb_table_idx[2]; |
478 | 98.3k | const WORD8 *psfb_width[2]; |
479 | 98.3k | WORD width_idx; |
480 | 98.3k | WORD32 j; |
481 | | |
482 | 98.3k | if (frame_length == 960) |
483 | 14.9k | sfidx += 12; |
484 | | |
485 | 98.3k | psfb_table_idx[0] = ptr_aac_tables->sfb_long_table; |
486 | 98.3k | psfb_table_idx[1] = ptr_aac_tables->sfb_short_table; |
487 | | |
488 | 98.3k | psfb_width[0] = ptr_aac_tables->scale_factor_bands_long[sfidx]; |
489 | 98.3k | psfb_width[1] = ptr_aac_tables->scale_factor_bands_short[sfidx]; |
490 | | |
491 | 295k | for (j = 1; j >= 0; j--) { |
492 | 196k | const WORD8 *ptr_width = psfb_width[j]; |
493 | 196k | WORD16 *ptable_idx = psfb_table_idx[j]; |
494 | 196k | width_idx = 0; |
495 | 196k | *ptable_idx++ = width_idx; |
496 | 5.88M | do { |
497 | 5.88M | width_idx += (*ptr_width++); |
498 | 5.88M | *ptable_idx++ = width_idx; |
499 | 5.88M | } while (*ptr_width != -1); |
500 | | |
501 | 196k | aac_persistent_mem->str_aac_decoder.num_swb_window[j] = |
502 | 196k | (WORD8)(ptr_width - psfb_width[j]); |
503 | 196k | } |
504 | | |
505 | 98.3k | { |
506 | 98.3k | ptr_aac_tables->str_aac_sfb_info[0].sfb_index = |
507 | 98.3k | ptr_aac_tables->sfb_long_table; |
508 | 98.3k | ptr_aac_tables->str_aac_sfb_info[1].sfb_index = |
509 | 98.3k | ptr_aac_tables->sfb_long_table; |
510 | 98.3k | ptr_aac_tables->str_aac_sfb_info[3].sfb_index = |
511 | 98.3k | ptr_aac_tables->sfb_long_table; |
512 | | |
513 | 98.3k | ptr_aac_tables->str_aac_sfb_info[2].sfb_index = |
514 | 98.3k | ptr_aac_tables->sfb_short_table; |
515 | | |
516 | 98.3k | ptr_aac_tables->str_aac_sfb_info[0].sfb_width = (WORD8 *)psfb_width[0]; |
517 | 98.3k | ptr_aac_tables->str_aac_sfb_info[1].sfb_width = (WORD8 *)psfb_width[0]; |
518 | 98.3k | ptr_aac_tables->str_aac_sfb_info[3].sfb_width = (WORD8 *)psfb_width[0]; |
519 | | |
520 | 98.3k | ptr_aac_tables->str_aac_sfb_info[2].sfb_width = (WORD8 *)psfb_width[1]; |
521 | 98.3k | } |
522 | 98.3k | } else { |
523 | 46.8k | WORD16 *ptr_sfb_idx[2]; |
524 | 46.8k | const WORD8 *ptr_sfb_width[2] = {0}; |
525 | 46.8k | WORD width_idx; |
526 | 46.8k | WORD32 j; |
527 | | |
528 | 46.8k | ptr_sfb_idx[0] = ptr_aac_tables->sfb_long_table; |
529 | 46.8k | ptr_sfb_idx[1] = ptr_aac_tables->sfb_short_table; |
530 | | |
531 | 46.8k | if (frame_length == 512) |
532 | 27.4k | ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_512[i]; |
533 | 19.3k | else |
534 | 19.3k | ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_480[i]; |
535 | | |
536 | 93.6k | for (j = 0; j >= 0; j--) { |
537 | 46.8k | const WORD8 *ptr_width = ptr_sfb_width[j]; |
538 | 46.8k | WORD16 *ptr_idx = ptr_sfb_idx[j]; |
539 | 46.8k | width_idx = 0; |
540 | 46.8k | *ptr_idx++ = width_idx; |
541 | 1.53M | do { |
542 | 1.53M | width_idx += (*ptr_width++); |
543 | 1.53M | *ptr_idx++ = width_idx; |
544 | 1.53M | } while (*ptr_width != -1); |
545 | | |
546 | 46.8k | aac_persistent_mem->str_aac_decoder.num_swb_window[j] = |
547 | 46.8k | (WORD8)(ptr_width - ptr_sfb_width[j]); |
548 | 46.8k | } |
549 | | |
550 | 46.8k | { |
551 | 46.8k | ptr_aac_tables->str_aac_sfb_info[0].sfb_index = |
552 | 46.8k | ptr_aac_tables->sfb_long_table; |
553 | 46.8k | ptr_aac_tables->str_aac_sfb_info[1].sfb_index = |
554 | 46.8k | ptr_aac_tables->sfb_long_table; |
555 | 46.8k | ptr_aac_tables->str_aac_sfb_info[3].sfb_index = |
556 | 46.8k | ptr_aac_tables->sfb_long_table; |
557 | 46.8k | ptr_aac_tables->str_aac_sfb_info[2].sfb_index = |
558 | 46.8k | ptr_aac_tables->sfb_short_table; |
559 | | |
560 | 46.8k | ptr_aac_tables->str_aac_sfb_info[0].sfb_width = |
561 | 46.8k | (WORD8 *)ptr_sfb_width[0]; |
562 | 46.8k | ptr_aac_tables->str_aac_sfb_info[1].sfb_width = |
563 | 46.8k | (WORD8 *)ptr_sfb_width[0]; |
564 | 46.8k | ptr_aac_tables->str_aac_sfb_info[3].sfb_width = |
565 | 46.8k | (WORD8 *)ptr_sfb_width[0]; |
566 | 46.8k | ptr_aac_tables->str_aac_sfb_info[2].sfb_width = |
567 | 46.8k | (WORD8 *)ptr_sfb_width[1]; |
568 | 46.8k | } |
569 | 46.8k | } |
570 | 145k | { |
571 | 145k | ia_aac_decoder_struct *aac_dec_handle = |
572 | 145k | &aac_persistent_mem->str_aac_decoder; |
573 | 145k | aac_dec_handle->sampling_rate_index = (WORD16)i; |
574 | 145k | aac_dec_handle->sampling_rate = sampling_rate; |
575 | 145k | aac_dec_handle->channels = 1; |
576 | 145k | aac_dec_handle->block_number = 0; |
577 | 145k | aac_dec_handle->samples_per_frame = frame_length; |
578 | 145k | } |
579 | 145k | } |
580 | | |
581 | 0 | return &(aac_persistent_mem->str_aac_decoder); |
582 | 145k | } |