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