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 #ifndef IXHEAACD_AACDEC_H
21 #define IXHEAACD_AACDEC_H
22 
23 #define AAC_DEC_OK IA_ENHAACPLUS_DEC_API_NONFATAL_NO_ERROR
24 
25 #define IA_ENHAACPDEC_NUM_MEMTABS (4)
26 
27 #define FRAME_SIZE 1024
28 
29 #define ADTS_BSFORMAT 2
30 #define LOAS_BSFORMAT 3
31 
32 typedef struct ia_aac_decoder_struct {
33   FLAG frame_status;
34   WORD32 byte_align_bits;
35   ia_aac_dec_sbr_bitstream_struct *pstr_sbr_bitstream;
36   ia_aac_dec_channel_info_struct *pstr_aac_dec_ch_info[CHANNELS];
37 
38   ia_aac_dec_channel_info *ptr_aac_dec_static_channel_info[CHANNELS];
39 
40   ia_aac_dec_overlap_info *pstr_aac_dec_overlap_info[CHANNELS];
41   ia_pns_rand_vec_struct *pstr_pns_rand_vec_data;
42   void *p_ind_channel_info;
43   WORD32 block_number;
44   WORD16 sampling_rate_index;
45   WORD32 sampling_rate;
46   WORD32 samples_per_frame;
47   WORD16 channels;
48   WORD8 num_swb_window[2];
49   ia_aac_dec_tables_struct *pstr_aac_tables;
50   ixheaacd_misc_tables *pstr_common_tables;
51 } ia_aac_decoder_struct;
52 
53 struct ia_aac_persistent_struct {
54   WORD32 *overlap_buffer;
55   ia_aac_dec_overlap_info str_aac_dec_overlap_info[CHANNELS];
56   ia_pns_rand_vec_struct str_pns_rand_vec_data;
57   struct ia_aac_decoder_struct str_aac_decoder;
58   WORD8 *sbr_payload_buffer;
59 
60   ia_aac_dec_channel_info *ptr_aac_dec_static_channel_info[CHANNELS];
61   WORD16 *ltp_buf[CHANNELS];
62 };
63 
64 typedef struct {
65   VOID *base_scr_8k;
66   VOID *extra_scr_4k[4];
67 
68   WORD32 *in_data;
69   WORD32 *out_data;
70 
71 } ia_aac_dec_scratch_struct;
72 
73 WORD16 ixheaacd_individual_ch_stream(
74     ia_bit_buf_struct *it_bit_buff, ia_aac_decoder_struct *aac_dec_handle,
75     WORD32 num_ch, WORD32 frame_size, WORD32 total_channels, WORD32 object_type,
76     ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type);
77 
78 VOID ixheaacd_huff_tables_create(ia_aac_dec_tables_struct *);
79 
80 WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v,
81                                            WORD32 channels);
82 
83 VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len,
84                              const UWORD16 *input_table,
85                              const UWORD32 *idx_table);
86 
87 #endif /* #ifndef IXHEAACD_AACDEC_H */
88