/src/libxaac/decoder/ixheaacd_common_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 "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 "ixheaacd_bitbuffer.h" |
29 | | #include "ixheaacd_defines.h" |
30 | | #include "ixheaacd_aac_rom.h" |
31 | | #include "ixheaacd_pulsedata.h" |
32 | | |
33 | | #include "ixheaacd_pns.h" |
34 | | #include "ixheaacd_drc_data_struct.h" |
35 | | |
36 | | #include "ixheaacd_lt_predict.h" |
37 | | |
38 | | #include "ixheaacd_cnst.h" |
39 | | #include "ixheaacd_ec_defines.h" |
40 | | #include "ixheaacd_ec_struct_def.h" |
41 | | #include "ixheaacd_channelinfo.h" |
42 | | #include "ixheaacd_drc_dec.h" |
43 | | #include "ixheaacd_sbrdecoder.h" |
44 | | |
45 | | #include "ixheaacd_audioobjtypes.h" |
46 | | #include "ixheaacd_sbrdecsettings.h" |
47 | | #include "ixheaacd_memory_standards.h" |
48 | | #include "ixheaacd_error_codes.h" |
49 | | |
50 | | #include "ixheaacd_defines.h" |
51 | | |
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 | | |
57 | | #include "ixheaacd_hybrid.h" |
58 | | #include "ixheaacd_ps_dec.h" |
59 | | #include "ixheaacd_ps_bitdec.h" |
60 | | |
61 | | #include "ixheaacd_pulsedata.h" |
62 | | |
63 | | #include "ixheaacd_env_extr.h" |
64 | | #include "ixheaacd_common_rom.h" |
65 | | #include "ixheaacd_block.h" |
66 | | #include "ixheaacd_channel.h" |
67 | | |
68 | | #include "ixheaacd_audioobjtypes.h" |
69 | | #include "ixheaacd_latmdemux.h" |
70 | | |
71 | | #include "ixheaacd_aacdec.h" |
72 | | #include "ixheaacd_hybrid.h" |
73 | | #include "ixheaacd_ps_dec.h" |
74 | | #include "ixheaacd_mps_polyphase.h" |
75 | | #include "ixheaacd_config.h" |
76 | | #include "ixheaacd_qmf_dec.h" |
77 | | #include "ixheaacd_mps_macro_def.h" |
78 | | #include "ixheaacd_mps_struct_def.h" |
79 | | #include "ixheaacd_mps_res_rom.h" |
80 | | #include "ixheaacd_mps_aac_struct.h" |
81 | | #include "ixheaacd_mps_dec.h" |
82 | | #include "ixheaacd_struct_def.h" |
83 | | #include "ixheaacd_headerdecode.h" |
84 | | |
85 | | #include "ixheaacd_multichannel.h" |
86 | | |
87 | | #include "ixheaac_basic_op.h" |
88 | | #include "ixheaacd_adts_crc_check.h" |
89 | | #include "ixheaacd_function_selector.h" |
90 | | |
91 | | VOID ixheaacd_allocate_mem_persistent( |
92 | | ia_exhaacplus_dec_api_struct *p_obj_enhaacplus_dec, |
93 | | ia_aac_dec_state_struct *p_state_enhaacplus_dec, WORD channels, |
94 | 11.4k | WORD *persistent_used_total, WORD *sbr_persistent_start, WORD ps_enable) { |
95 | 11.4k | WORD persistent_used; |
96 | 11.4k | WORD8 **temp_persistent = |
97 | 11.4k | (WORD8 **)&(p_state_enhaacplus_dec->aac_persistent_mem_v); |
98 | 11.4k | *temp_persistent += *persistent_used_total; |
99 | | |
100 | 11.4k | persistent_used = ixheaacd_set_aac_persistent_buffers( |
101 | 11.4k | p_state_enhaacplus_dec->aac_persistent_mem_v, channels); |
102 | | |
103 | 11.4k | *persistent_used_total += persistent_used; |
104 | | |
105 | 11.4k | *sbr_persistent_start = *persistent_used_total; |
106 | | |
107 | 11.4k | p_state_enhaacplus_dec->sbr_persistent_mem_v = |
108 | 11.4k | (pVOID)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + |
109 | 11.4k | IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); |
110 | | |
111 | 11.4k | persistent_used = ixheaacd_getsize_sbr_persistent(); |
112 | | |
113 | 11.4k | ixheaacd_set_sbr_persistent_buffers( |
114 | 11.4k | p_state_enhaacplus_dec->sbr_persistent_mem_v, &persistent_used, channels, |
115 | 11.4k | ps_enable); |
116 | | |
117 | 11.4k | *persistent_used_total += persistent_used; |
118 | | |
119 | 11.4k | { |
120 | 11.4k | struct ia_aac_persistent_struct *aac_persistent_mem = |
121 | 11.4k | (struct ia_aac_persistent_struct *) |
122 | 11.4k | p_obj_enhaacplus_dec->p_state_aac->aac_persistent_mem_v; |
123 | 11.4k | aac_persistent_mem->str_aac_decoder.pstr_aac_tables = |
124 | 11.4k | &p_obj_enhaacplus_dec->aac_tables; |
125 | 11.4k | aac_persistent_mem->str_aac_decoder.pstr_common_tables = |
126 | 11.4k | p_obj_enhaacplus_dec->common_tables; |
127 | 11.4k | } |
128 | | |
129 | 11.4k | ixheaacd_set_sbr_persistent_table_pointer( |
130 | 11.4k | p_obj_enhaacplus_dec->p_state_aac->sbr_persistent_mem_v, |
131 | 11.4k | &p_obj_enhaacplus_dec->str_sbr_tables, |
132 | 11.4k | p_obj_enhaacplus_dec->common_tables); |
133 | 11.4k | } |
134 | | |
135 | | ia_bit_buf_struct *ixheaacd_create_bit_buf(ia_bit_buf_struct *it_bit_buff, |
136 | | UWORD8 *ptr_bit_buf_base, |
137 | 1.13M | WORD32 bit_buf_size) { |
138 | 1.13M | it_bit_buff->ptr_bit_buf_base = ptr_bit_buf_base; |
139 | 1.13M | it_bit_buff->ptr_bit_buf_end = ptr_bit_buf_base + bit_buf_size - 1; |
140 | | |
141 | 1.13M | it_bit_buff->ptr_read_next = ptr_bit_buf_base; |
142 | 1.13M | it_bit_buff->bit_pos = 7; |
143 | | |
144 | 1.13M | it_bit_buff->cnt_bits = 0; |
145 | 1.13M | it_bit_buff->size = bit_buf_size << 3; |
146 | | |
147 | 1.13M | it_bit_buff->adts_header_present = 0; |
148 | 1.13M | it_bit_buff->protection_absent = 0; |
149 | 1.13M | it_bit_buff->pstr_adts_crc_info = &it_bit_buff->str_adts_crc_info; |
150 | | |
151 | 1.13M | it_bit_buff->max_size = it_bit_buff->size; |
152 | | |
153 | 1.13M | ixheaacd_adts_crc_open(it_bit_buff->pstr_adts_crc_info); |
154 | | |
155 | 1.13M | return it_bit_buff; |
156 | 1.13M | } |
157 | | |
158 | | VOID ixheaacd_create_init_bit_buf(ia_bit_buf_struct *it_bit_buff, |
159 | | UWORD8 *ptr_bit_buf_base, |
160 | 356k | WORD32 bit_buf_size) { |
161 | 356k | ixheaacd_create_bit_buf(it_bit_buff, ptr_bit_buf_base, bit_buf_size); |
162 | 356k | it_bit_buff->cnt_bits = (bit_buf_size << 3); |
163 | 356k | return; |
164 | 356k | } |
165 | | |
166 | | VOID ixheaacd_read_bidirection(ia_bit_buf_struct *it_bit_buff, |
167 | 3.23M | WORD32 ixheaacd_drc_offset) { |
168 | 3.23M | if (ixheaacd_drc_offset != 0) { |
169 | 3.23M | WORD32 byte_offset; |
170 | 3.23M | if ((it_bit_buff->cnt_bits < 0) || |
171 | 3.23M | (it_bit_buff->cnt_bits - ixheaacd_drc_offset < 0) || |
172 | 3.23M | (it_bit_buff->cnt_bits - ixheaacd_drc_offset > it_bit_buff->size)) { |
173 | 8 | longjmp(*(it_bit_buff->xaac_jmp_buf), |
174 | 8 | IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); |
175 | 8 | } |
176 | 3.23M | it_bit_buff->cnt_bits = it_bit_buff->cnt_bits - ixheaacd_drc_offset; |
177 | 3.23M | it_bit_buff->bit_pos = it_bit_buff->bit_pos - ixheaacd_drc_offset; |
178 | 3.23M | byte_offset = it_bit_buff->bit_pos >> 3; |
179 | 3.23M | it_bit_buff->bit_pos = it_bit_buff->bit_pos - (byte_offset << 3); |
180 | | |
181 | 3.23M | if (byte_offset) { |
182 | 757k | UWORD8 *ptr_read_next; |
183 | | |
184 | 757k | ptr_read_next = it_bit_buff->ptr_read_next; |
185 | | |
186 | 757k | ptr_read_next = ptr_read_next - (byte_offset); |
187 | | |
188 | 757k | it_bit_buff->ptr_read_next = ptr_read_next; |
189 | 757k | } |
190 | 3.23M | } |
191 | 3.23M | } |