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_type_def.h"
22
23 #include "ixheaacd_sbr_common.h"
24
25 #include "ixheaacd_constants.h"
26 #include "ixheaacd_basic_ops32.h"
27 #include "ixheaacd_basic_ops16.h"
28 #include "ixheaacd_basic_ops40.h"
29 #include "ixheaacd_basic_ops.h"
30 #include "ixheaacd_bitbuffer.h"
31
32 #include "ixheaacd_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
50 #include "ixheaacd_channelinfo.h"
51 #include "ixheaacd_drc_dec.h"
52
53 #include "ixheaacd_sbrdecoder.h"
54 #include "ixheaacd_block.h"
55 #include "ixheaacd_channel.h"
56
57 #include "ixheaacd_sbr_payload.h"
58 #include "ixheaacd_common_rom.h"
59 #include "ixheaacd_sbrdecsettings.h"
60 #include "ixheaacd_sbr_scale.h"
61 #include "ixheaacd_env_extr_part.h"
62 #include "ixheaacd_sbr_rom.h"
63
64 #include "ixheaacd_lpp_tran.h"
65 #include "ixheaacd_hybrid.h"
66 #include "ixheaacd_ps_dec.h"
67
68 #include "ixheaacd_env_extr.h"
69 #include "ixheaacd_adts.h"
70 #include "ixheaacd_audioobjtypes.h"
71 #include "ixheaacd_memory_standards.h"
72
73 #include "ixheaacd_latmdemux.h"
74
75 #include "ixheaacd_aacdec.h"
76 #include "ixheaacd_mps_polyphase.h"
77 #include "ixheaacd_config.h"
78 #include "ixheaacd_mps_dec.h"
79
80 #include "ixheaacd_struct_def.h"
81
82 #include "ixheaacd_multichannel.h"
83
84 #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3)
85
ixheaacd_set_aac_persistent_buffers(VOID * aac_persistent_mem_v,WORD32 num_channel)86 WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v,
87 WORD32 num_channel) {
88 WORD32 persistent_used;
89
90 struct ia_aac_persistent_struct *aac_persistent_mem =
91 (struct ia_aac_persistent_struct *)aac_persistent_mem_v;
92
93 persistent_used = sizeof(struct ia_aac_persistent_struct);
94
95 memset(aac_persistent_mem, 0, sizeof(struct ia_aac_persistent_struct));
96 aac_persistent_mem->overlap_buffer =
97 (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used);
98
99 memset((WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0,
100 4 * 512 * num_channel * sizeof(WORD32));
101
102 persistent_used += 4 * 512 * num_channel * sizeof(WORD32);
103
104 aac_persistent_mem->sbr_payload_buffer =
105 (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used);
106
107 memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0,
108 ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8));
109
110 persistent_used += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8);
111
112 {
113 WORD32 i;
114
115 for (i = 0; i < num_channel; i++) {
116 aac_persistent_mem->ltp_buf[i] =
117 (WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used);
118
119 memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0,
120 ltp_buffer_size * sizeof(WORD16));
121
122 persistent_used += (ltp_buffer_size * sizeof(WORD16));
123
124 aac_persistent_mem->ptr_aac_dec_static_channel_info[i] =
125 (ia_aac_dec_channel_info *)((WORD8 *)aac_persistent_mem_v +
126 persistent_used);
127 persistent_used += sizeof(ia_aac_dec_channel_info);
128
129 aac_persistent_mem->ptr_aac_dec_static_channel_info[i]
130 ->overlap_add_data.win_shape = 0;
131 aac_persistent_mem->ptr_aac_dec_static_channel_info[i]
132 ->overlap_add_data.win_seq = 0;
133
134 aac_persistent_mem->ptr_aac_dec_static_channel_info[i]
135 ->overlap_add_data.ptr_overlap_buf =
136 &aac_persistent_mem->overlap_buffer[i * OVERLAP_BUFFER_SIZE];
137 }
138 }
139
140 return persistent_used;
141 }
142
ixheaacd_huff_tables_create(ia_aac_dec_tables_struct * ptr_aac_tables)143 VOID ixheaacd_huff_tables_create(ia_aac_dec_tables_struct *ptr_aac_tables) {
144 ptr_aac_tables->code_book[0] = 0;
145 ptr_aac_tables->code_book[1] =
146 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb1;
147 ptr_aac_tables->code_book[2] =
148 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb2;
149 ptr_aac_tables->code_book[3] =
150 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb3;
151 ptr_aac_tables->code_book[4] =
152 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb4;
153 ptr_aac_tables->code_book[5] =
154 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb5;
155 ptr_aac_tables->code_book[6] =
156 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb6;
157 ptr_aac_tables->code_book[7] =
158 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb7;
159 ptr_aac_tables->code_book[8] =
160 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb8;
161 ptr_aac_tables->code_book[9] =
162 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb9;
163 ptr_aac_tables->code_book[10] =
164 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10;
165 ptr_aac_tables->code_book[11] =
166 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10;
167 ptr_aac_tables->code_book[12] =
168 (UWORD16 *)ptr_aac_tables->pstr_huffmann_tables->input_table_cb10;
169
170 ptr_aac_tables->index_table[1] =
171 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf1;
172 ptr_aac_tables->index_table[2] =
173 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf2;
174 ptr_aac_tables->index_table[3] =
175 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf3;
176 ptr_aac_tables->index_table[4] =
177 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf4;
178 ptr_aac_tables->index_table[5] =
179 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf5;
180 ptr_aac_tables->index_table[6] =
181 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf6;
182 ptr_aac_tables->index_table[7] =
183 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf7;
184 ptr_aac_tables->index_table[8] =
185 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf8;
186 ptr_aac_tables->index_table[9] =
187 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf9;
188 ptr_aac_tables->index_table[10] =
189 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10;
190 ptr_aac_tables->index_table[11] =
191 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10;
192 ptr_aac_tables->index_table[12] =
193 (UWORD32 *)ptr_aac_tables->pstr_huffmann_tables->idx_table_hf10;
194
195 ptr_aac_tables->scale_factor_bands_short[0] =
196 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128;
197 ptr_aac_tables->scale_factor_bands_short[1] =
198 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128;
199 ptr_aac_tables->scale_factor_bands_short[2] =
200 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_128;
201 ptr_aac_tables->scale_factor_bands_short[3] =
202 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128;
203 ptr_aac_tables->scale_factor_bands_short[4] =
204 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128;
205 ptr_aac_tables->scale_factor_bands_short[5] =
206 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_128;
207 ptr_aac_tables->scale_factor_bands_short[6] =
208 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128;
209 ptr_aac_tables->scale_factor_bands_short[7] =
210 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_128;
211 ptr_aac_tables->scale_factor_bands_short[8] =
212 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128;
213 ptr_aac_tables->scale_factor_bands_short[9] =
214 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128;
215 ptr_aac_tables->scale_factor_bands_short[10] =
216 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_128;
217 ptr_aac_tables->scale_factor_bands_short[11] =
218 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_128;
219
220 ptr_aac_tables->scale_factor_bands_long[0] =
221 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024;
222 ptr_aac_tables->scale_factor_bands_long[1] =
223 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_96_1024;
224 ptr_aac_tables->scale_factor_bands_long[2] =
225 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_64_1024;
226 ptr_aac_tables->scale_factor_bands_long[3] =
227 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024;
228 ptr_aac_tables->scale_factor_bands_long[4] =
229 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_1024;
230 ptr_aac_tables->scale_factor_bands_long[5] =
231 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_1024;
232 ptr_aac_tables->scale_factor_bands_long[6] =
233 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024;
234 ptr_aac_tables->scale_factor_bands_long[7] =
235 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_1024;
236 ptr_aac_tables->scale_factor_bands_long[8] =
237 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024;
238 ptr_aac_tables->scale_factor_bands_long[9] =
239 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024;
240 ptr_aac_tables->scale_factor_bands_long[10] =
241 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_16_1024;
242 ptr_aac_tables->scale_factor_bands_long[11] =
243 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_8_1024;
244
245 ptr_aac_tables->scale_fac_bands_512[0] =
246 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512;
247 ptr_aac_tables->scale_fac_bands_512[1] =
248 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512;
249 ptr_aac_tables->scale_fac_bands_512[2] =
250 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512;
251 ptr_aac_tables->scale_fac_bands_512[3] =
252 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512;
253 ptr_aac_tables->scale_fac_bands_512[4] =
254 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_512;
255 ptr_aac_tables->scale_fac_bands_512[5] =
256 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_512;
257 ptr_aac_tables->scale_fac_bands_512[6] =
258 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
259 ptr_aac_tables->scale_fac_bands_512[7] =
260 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
261 ptr_aac_tables->scale_fac_bands_512[8] =
262 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
263 ptr_aac_tables->scale_fac_bands_512[9] =
264 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
265 ptr_aac_tables->scale_fac_bands_512[10] =
266 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
267 ptr_aac_tables->scale_fac_bands_512[11] =
268 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
269 ptr_aac_tables->scale_fac_bands_512[12] =
270 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
271 ptr_aac_tables->scale_fac_bands_512[13] =
272 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
273 ptr_aac_tables->scale_fac_bands_512[14] =
274 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
275 ptr_aac_tables->scale_fac_bands_512[15] =
276 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_512;
277
278 ptr_aac_tables->scale_fac_bands_480[0] =
279 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480;
280 ptr_aac_tables->scale_fac_bands_480[1] =
281 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480;
282 ptr_aac_tables->scale_fac_bands_480[2] =
283 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480;
284 ptr_aac_tables->scale_fac_bands_480[3] =
285 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480;
286 ptr_aac_tables->scale_fac_bands_480[4] =
287 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_48_480;
288 ptr_aac_tables->scale_fac_bands_480[5] =
289 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_32_480;
290 ptr_aac_tables->scale_fac_bands_480[6] =
291 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
292 ptr_aac_tables->scale_fac_bands_480[7] =
293 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
294 ptr_aac_tables->scale_fac_bands_480[8] =
295 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
296 ptr_aac_tables->scale_fac_bands_480[9] =
297 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
298 ptr_aac_tables->scale_fac_bands_480[10] =
299 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
300 ptr_aac_tables->scale_fac_bands_480[11] =
301 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
302 ptr_aac_tables->scale_fac_bands_480[12] =
303 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
304 ptr_aac_tables->scale_fac_bands_480[13] =
305 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
306 ptr_aac_tables->scale_fac_bands_480[14] =
307 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
308 ptr_aac_tables->scale_fac_bands_480[15] =
309 ptr_aac_tables->pstr_huffmann_tables->ixheaacd_sfb_24_480;
310 }
311
ixheaacd_aac_decoder_init(ia_aac_dec_state_struct * p_state_enhaacplus_dec,ia_aac_dec_sbr_bitstream_struct * ptr_sbr_bitstream,WORD channels,VOID * aac_persistent_mem_v,WORD32 frame_length)312 ia_aac_decoder_struct *ixheaacd_aac_decoder_init(
313 ia_aac_dec_state_struct *p_state_enhaacplus_dec,
314 ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream, WORD channels,
315 VOID *aac_persistent_mem_v, WORD32 frame_length) {
316 WORD i, ch;
317 struct ia_aac_persistent_struct *aac_persistent_mem;
318 aac_persistent_mem = (struct ia_aac_persistent_struct *)aac_persistent_mem_v;
319
320 aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream = ptr_sbr_bitstream;
321
322 for (ch = 0; ch < channels; ch++) {
323 ia_aac_decoder_struct *aac_dec_handle =
324 &aac_persistent_mem->str_aac_decoder;
325 aac_dec_handle->pstr_aac_dec_overlap_info[ch] =
326 &aac_persistent_mem->str_aac_dec_overlap_info[ch];
327 aac_dec_handle->pstr_pns_rand_vec_data =
328 &aac_persistent_mem->str_pns_rand_vec_data;
329
330 aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_shape = 0;
331 aac_dec_handle->pstr_aac_dec_overlap_info[ch]->window_sequence = 0;
332 if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD)
333 aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf =
334 &aac_persistent_mem->overlap_buffer[ch * 4 * OVERLAP_BUFFER_SIZE];
335 else
336 aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf =
337 &aac_persistent_mem->overlap_buffer[ch * OVERLAP_BUFFER_SIZE];
338
339 {
340 WORD32 *ptr_overlap_buf =
341 aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf;
342 memset(ptr_overlap_buf, 0, sizeof(WORD32) * 4 * 512);
343 }
344 aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] =
345 aac_persistent_mem->ptr_aac_dec_static_channel_info[ch];
346 aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch]
347 ->ltp_buf = aac_persistent_mem->ltp_buf[ch];
348 }
349
350 for (i = 0; i < 1; i++) {
351 ia_aac_dec_sbr_bitstream_struct *ptr_sbr_bitstream =
352 &aac_persistent_mem->str_aac_decoder.pstr_sbr_bitstream[i];
353
354 ptr_sbr_bitstream->no_elements = 0;
355 ptr_sbr_bitstream->str_sbr_ele[0].ptr_sbr_data =
356 &aac_persistent_mem->sbr_payload_buffer[ALIGN_SIZE64(MAXSBRBYTES) * i];
357 ptr_sbr_bitstream->str_sbr_ele[0].sbr_ele_id = ID_SCE;
358 ptr_sbr_bitstream->str_sbr_ele[0].size_payload = 0;
359 }
360
361 {
362 ia_aac_dec_tables_struct *ptr_aac_tables =
363 aac_persistent_mem->str_aac_decoder.pstr_aac_tables;
364 ia_aac_dec_huffman_tables_struct *pstr_huffmann_tables =
365 ptr_aac_tables->pstr_huffmann_tables;
366
367 WORD num_entries = sizeof(pstr_huffmann_tables->str_sample_rate_info) /
368 sizeof(ia_sampling_rate_info_struct);
369
370 WORD32 sampling_rate = p_state_enhaacplus_dec->sampling_rate;
371
372 i = 0;
373 while ((i < num_entries) &&
374 sampling_rate != ((pstr_huffmann_tables->str_sample_rate_info[i]
375 .sampling_frequency))) {
376 i++;
377 }
378 if (i == 12) {
379 i = i - 1;
380 }
381
382 if (i == num_entries) {
383 return NULL;
384 }
385
386 if (frame_length == 1024) {
387 WORD16 *psfb_table_idx[2];
388 const WORD8 *psfb_width[2];
389 WORD width_idx;
390 WORD32 j;
391
392 psfb_table_idx[0] = ptr_aac_tables->sfb_long_table;
393 psfb_table_idx[1] = ptr_aac_tables->sfb_short_table;
394
395 psfb_width[0] = ptr_aac_tables->scale_factor_bands_long[i];
396 psfb_width[1] = ptr_aac_tables->scale_factor_bands_short[i];
397
398 for (j = 1; j >= 0; j--) {
399 const WORD8 *ptr_width = psfb_width[j];
400 WORD16 *ptable_idx = psfb_table_idx[j];
401 width_idx = 0;
402 *ptable_idx++ = width_idx;
403 do {
404 width_idx += (*ptr_width++);
405 *ptable_idx++ = width_idx;
406 } while (*ptr_width != -1);
407
408 aac_persistent_mem->str_aac_decoder.num_swb_window[j] =
409 (WORD8)(ptr_width - psfb_width[j]);
410 }
411
412 {
413 ptr_aac_tables->str_aac_sfb_info[0].sfb_index =
414 ptr_aac_tables->sfb_long_table;
415 ptr_aac_tables->str_aac_sfb_info[1].sfb_index =
416 ptr_aac_tables->sfb_long_table;
417 ptr_aac_tables->str_aac_sfb_info[3].sfb_index =
418 ptr_aac_tables->sfb_long_table;
419
420 ptr_aac_tables->str_aac_sfb_info[2].sfb_index =
421 ptr_aac_tables->sfb_short_table;
422
423 ptr_aac_tables->str_aac_sfb_info[0].sfb_width = (WORD8 *)psfb_width[0];
424 ptr_aac_tables->str_aac_sfb_info[1].sfb_width = (WORD8 *)psfb_width[0];
425 ptr_aac_tables->str_aac_sfb_info[3].sfb_width = (WORD8 *)psfb_width[0];
426
427 ptr_aac_tables->str_aac_sfb_info[2].sfb_width = (WORD8 *)psfb_width[1];
428 }
429 } else {
430 WORD16 *ptr_sfb_idx[2];
431 const WORD8 *ptr_sfb_width[2];
432 WORD width_idx;
433 WORD32 j;
434
435 ptr_sfb_idx[0] = ptr_aac_tables->sfb_long_table;
436 ptr_sfb_idx[1] = ptr_aac_tables->sfb_short_table;
437
438 if (frame_length == 512)
439 ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_512[i];
440 else
441 ptr_sfb_width[0] = ptr_aac_tables->scale_fac_bands_480[i];
442
443 for (j = 0; j >= 0; j--) {
444 const WORD8 *ptr_width = ptr_sfb_width[j];
445 WORD16 *ptr_idx = ptr_sfb_idx[j];
446 width_idx = 0;
447 *ptr_idx++ = width_idx;
448 do {
449 width_idx += (*ptr_width++);
450 *ptr_idx++ = width_idx;
451 } while (*ptr_width != -1);
452
453 aac_persistent_mem->str_aac_decoder.num_swb_window[j] =
454 (WORD8)(ptr_width - ptr_sfb_width[j]);
455 }
456
457 {
458 ptr_aac_tables->str_aac_sfb_info[0].sfb_index =
459 ptr_aac_tables->sfb_long_table;
460 ptr_aac_tables->str_aac_sfb_info[1].sfb_index =
461 ptr_aac_tables->sfb_long_table;
462 ptr_aac_tables->str_aac_sfb_info[3].sfb_index =
463 ptr_aac_tables->sfb_long_table;
464 ptr_aac_tables->str_aac_sfb_info[2].sfb_index =
465 ptr_aac_tables->sfb_short_table;
466
467 ptr_aac_tables->str_aac_sfb_info[0].sfb_width =
468 (WORD8 *)ptr_sfb_width[0];
469 ptr_aac_tables->str_aac_sfb_info[1].sfb_width =
470 (WORD8 *)ptr_sfb_width[0];
471 ptr_aac_tables->str_aac_sfb_info[3].sfb_width =
472 (WORD8 *)ptr_sfb_width[0];
473 ptr_aac_tables->str_aac_sfb_info[2].sfb_width =
474 (WORD8 *)ptr_sfb_width[1];
475 }
476 }
477 {
478 ia_aac_decoder_struct *aac_dec_handle =
479 &aac_persistent_mem->str_aac_decoder;
480 aac_dec_handle->sampling_rate_index = (WORD16)i;
481 aac_dec_handle->sampling_rate = sampling_rate;
482 aac_dec_handle->channels = 1;
483 aac_dec_handle->block_number = 0;
484 aac_dec_handle->samples_per_frame = frame_length;
485 }
486 }
487
488 return &(aac_persistent_mem->str_aac_decoder);
489 }
490