• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CHANNELINFO_H
21 #define IXHEAACD_CHANNELINFO_H
22 
23 #include "ixheaacd_lt_predict.h"
24 
25 #define MAX_SFB_SHORT 16
26 #define MAX_QUANTIZED_VALUE 8191
27 
28 #define OVERLAP_BUFFER_SIZE 512
29 
30 #define JOINT_STEREO_MAX_GROUPS 8
31 #define JOINT_STEREO_MAX_BANDS 64
32 
33 typedef struct {
34   WORD16 window_shape;
35   WORD16 window_sequence;
36   WORD16 max_sfb;
37   WORD16 num_swb_window;
38   WORD16 sampling_rate_index;
39   WORD16 num_window_groups;
40   WORD8 window_group_length[8];
41   WORD16 frame_length;
42   WORD32 frame_size;
43   WORD16 predictor_data_present;
44   ltp_info ltp;
45   ltp_info ltp2;
46   WORD8 qshift_adj;
47 } ia_ics_info_struct;
48 
49 typedef struct {
50   WORD32 aac_sect_data_resil_flag;
51   WORD32 aac_sf_data_resil_flag;
52   WORD32 aac_spect_data_resil_flag;
53   WORD32 ep_config;
54 } ia_aac_err_config_struct;
55 
56 typedef struct {
57   WORD32 ld_sbr_flag_present;
58   WORD32 ld_sbr_samp_rate;
59   WORD32 ld_sbr_crc_flag;
60   WORD32 ldSbrHeaderPresent;
61 
62   WORD32 aac_sect_data_resil_flag;
63   WORD32 aac_sf_data_resil_flag;
64   WORD32 aac_spect_data_resil_flag;
65   WORD32 ep_config;
66 
67 } ia_eld_specific_config_struct;
68 
69 typedef struct {
70   UWORD8 ms_used[JOINT_STEREO_MAX_GROUPS][JOINT_STEREO_MAX_BANDS];
71 } ia_stereo_info_struct;
72 
73 typedef struct {
74   WORD16 start_band;
75   WORD16 stop_band;
76   WORD8 direction;
77   WORD8 resolution;
78   WORD8 order;
79   WORD8 coef[MAX_ORDER];
80 } ia_filter_info_struct;
81 
82 typedef struct {
83   FLAG tns_data_present;
84   WORD8 n_filt[MAX_WINDOWS];
85   ia_filter_info_struct str_filter[MAX_WINDOWS][MAX_FILTERS];
86 } ia_tns_info_aac_struct;
87 
88 typedef struct {
89   const WORD16 *ptr_long_window[2];
90   const WORD16 *ptr_short_window[2];
91   WORD16 window_shape;
92   WORD16 window_sequence;
93   WORD32 *ptr_overlap_buf;
94 
95   WORD16 rvlc_prev_sf[128];
96   WORD16 rvlc_prev_cb[128];
97   WORD8 rvlc_prev_blk_type;
98   WORD8 rvlc_prev_sf_ok;
99 
100 } ia_aac_dec_overlap_info;
101 
102 typedef struct {
103   WORD32 sf_concealment;
104   WORD32 rev_global_gain;
105   WORD16 rvlc_sf_len;
106   WORD32 dpcm_noise_nrg;
107   WORD32 sf_esc_present;
108   WORD16 rvlc_esc_len;
109   WORD32 dpcm_noise_last_pos;
110 
111   WORD32 dpcm_is_last_pos;
112 
113   WORD16 rvlc_sf_fwd_len;
114   WORD16 rvlc_sf_bwd_len;
115 
116   WORD16 *ptr_rvl_bit_cnt;
117   UWORD16 *ptr_rvl_bit_str_idx;
118 
119   WORD16 num_wind_grps;
120   WORD16 max_sfb_transmitted;
121   UWORD8 first_noise_group;
122   UWORD8 first_noise_band;
123   UWORD8 direction;
124 
125   UWORD16 rvl_fwd_bit_str_idx;
126   UWORD16 rvl_bwd_bit_str_idx;
127   UWORD16 esc_bit_str_idx;
128 
129   const UWORD32 *ptr_huff_tree_rvl_cw;
130   const UWORD32 *ptr_huff_tree_rvl_esc;
131 
132   UWORD8 num_fwd_esc_words_decoded;
133   UWORD8 num_bwd_esc_words_decoded;
134   UWORD8 num_esc_words_decoded;
135 
136   WORD8 noise_used;
137   WORD8 intensity_used;
138   WORD8 sf_used;
139 
140   WORD16 firt_scale_fac;
141   WORD16 last_scale_fac;
142   WORD16 first_nrg;
143   WORD16 last_nrg;
144   WORD16 is_first;
145   WORD16 is_last;
146 
147   UWORD32 rvlc_err_log;
148   WORD16 conceal_min;
149   WORD16 conceal_max;
150   WORD16 conceal_min_esc;
151   WORD16 conceal_max_esc;
152 } ia_rvlc_info_struct;
153 
154 #define LINES_PER_UNIT 4
155 
156 #define MAX_SFB_HCR (((1024 / 8) / LINES_PER_UNIT) * 8)
157 #define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8)
158 #define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS)
159 
160 #define FROM_LEFT_TO_RIGHT 0
161 #define FROM_RIGHT_TO_LEFT 1
162 
163 #define MAX_CB_PAIRS 23
164 #define MAX_HCR_SETS 14
165 
166 #define ESCAPE_VALUE 16
167 #define POSITION_OF_FLAG_A 21
168 #define POSITION_OF_FLAG_B 20
169 
170 #define MAX_CB 32
171 
172 #define MAX_CB_CHECK 32
173 #define WORD_BITS 32
174 
175 #define THIRTYTWO_LOG_DIV_TWO_LOG 5
176 #define EIGHT_LOG_DIV_TWO_LOG 3
177 #define FOUR_LOG_DIV_TWO_LOG 2
178 
179 #define CPE_TOP_LENGTH 12288
180 #define SCE_TOP_LENGTH 6144
181 #define LEN_OF_LONGEST_CW_TOP_LENGTH 49
182 #define Q_VALUE_INVALID 8192
183 #define NODE_MASK 0x400
184 
185 #define ERROR_POS 0x00000001
186 #define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC
187 
188 typedef enum { PCW, PCW_SIGN, PCW_ESC_SIGN } ia_pcw_type_struct;
189 
190 typedef struct {
191   UWORD32 err_log;
192   WORD32 *ptr_quant_spec_coeff_base;
193   WORD32 quant_spec_coeff_idx;
194   WORD16 reordered_spec_data_len;
195   WORD16 num_sect;
196   WORD16 *ptr_num_line_in_sect;
197   UWORD16 bit_str_idx;
198   WORD8 longest_cw_len;
199   UWORD8 *ptr_cb;
200 } ia_huff_code_reorder_io_struct;
201 
202 typedef struct {
203   const UWORD8 *ptr_min_cb_pair_tbl;
204   const UWORD8 *ptr_max_cb_pair_tbl;
205 } ia_huff_code_reorder_cb_pairs_struct;
206 
207 typedef struct {
208   const UWORD16 *ptr_lav_tbl;
209   const UWORD8 *ptr_max_cw_len_tbl;
210   const UWORD8 *ptr_cb_dimension_tbl;
211   const UWORD8 *ptr_cb_dim_shift_tbl;
212   const UWORD8 *ptr_cb_sign_tbl;
213   const UWORD8 *ptr_cb_priority;
214 } ia_huff_code_reorder_tbl_struct;
215 
216 typedef struct {
217   WORD32 num_segment;
218   UWORD32 segment_offset;
219   WORD32 arr_temp_values[1024];
220   UWORD16 arr_seg_start_l[1024 >> 1];
221   UWORD16 arr_seg_start_r[1024 >> 1];
222   WORD8 p_remaining_bits_in_seg[1024 >> 1];
223   WORD32 code[512];
224   WORD32 code_extra[512];
225   WORD8 p_num_bits[512];
226   UWORD8 read_direction;
227   WORD32 is_decoded[512];
228 } ia_huff_code_reord_seg_info_struct;
229 
230 typedef struct {
231   UWORD32 num_code_word;
232   UWORD32 current_codeword;
233   UWORD32 num_sorted_section;
234   UWORD16 ptr_num_cw_in_sect[MAX_SFB_HCR];
235   UWORD16 ptr_num_sorted_cw_in_sect[MAX_SFB_HCR];
236   UWORD16 ptr_num_ext_sorted_cw_in_sect[MAX_SFB_HCR + MAX_HCR_SETS];
237   WORD32 num_ext_sorted_cw_in_sect_idx;
238   UWORD16 ptr_num_ext_sorted_sect_in_sets[MAX_HCR_SETS];
239   WORD32 num_ext_sorted_sect_in_sets_idx;
240   UWORD16 ptr_reorder_offset[MAX_SFB_HCR];
241   UWORD8 ptr_sorted_cb[MAX_SFB_HCR];
242 
243   UWORD8 ptr_ext_sorted_cw[MAX_SFB_HCR + MAX_HCR_SETS];
244   WORD32 ext_sorted_cw_idx;
245   UWORD8 ptr_ext_sorted_sect_max_cb_len[MAX_SFB_HCR + MAX_HCR_SETS];
246   WORD32 ext_sorted_sect_max_cb_len_idx;
247   UWORD8 ptr_cb_switch[MAX_SFB_HCR];
248 } ia_huff_code_reord_sect_info_struct;
249 
250 typedef UWORD32 (*ixheaacd_ptr_state_func)(ia_bit_buf_struct *, pVOID);
251 
252 typedef struct {
253   WORD32 *ptr_result_base;
254   UWORD16 res_ptr_idx[1024 >> 2];
255   UWORD32 cw_offset;
256   UWORD8 ptr_cb[1024 >> 2];
257 } ia_hcr_non_pcw_sideinfo_struct;
258 
259 typedef struct {
260   ia_huff_code_reorder_io_struct str_dec_io;
261   ia_huff_code_reorder_cb_pairs_struct codebook_pairs;
262   ia_huff_code_reorder_tbl_struct table_info;
263   ia_huff_code_reord_seg_info_struct str_segment_info;
264   ia_huff_code_reord_sect_info_struct sect_info;
265   ia_hcr_non_pcw_sideinfo_struct str_non_pcw_side_info;
266 
267   WORD32 global_hcr_type;
268 } ia_hcr_info_struct;
269 
270 typedef struct {
271   WORD16 scale_factor[MAX_WINDOWS * MAX_SFB_SHORT];
272   WORD8 code_book[MAX_WINDOWS * MAX_SFB_SHORT];
273 } ia_aac_sfb_code_book_struct;
274 
275 typedef struct {
276   ia_stereo_info_struct str_stereo_info;
277   ia_pns_correlation_info_struct str_pns_corr_info;
278 } ia_pns_stereo_data_struct;
279 
280 typedef struct {
281   WORD16 win_shape;
282   WORD16 win_seq;
283 
284   WORD32 *ptr_overlap_buf;
285 
286 } ia_aac_dec_ola_data;
287 
288 typedef struct {
289   const WORD16 *ptr_long_window[2];
290   const WORD16 *ptr_short_window[2];
291 
292   ia_aac_dec_ola_data overlap_add_data;
293 
294   WORD16 *ltp_buf;
295   UWORD16 ltp_lag;
296   ia_ec_state_str str_ec_state;
297 } ia_aac_dec_channel_info;
298 
299 typedef struct {
300   WORD16 *ptr_scale_factor;
301   WORD8 *ptr_code_book;
302   WORD32 *ptr_spec_coeff;
303   ia_stereo_info_struct *pstr_stereo_info;
304   ia_pns_correlation_info_struct *pstr_pns_corr_info;
305   ia_pns_rand_vec_struct *pstr_pns_rand_vec_data;
306   ia_ics_info_struct str_ics_info;
307   ia_tns_info_aac_struct str_tns_info;
308   ia_pulse_info_struct str_pulse_info;
309   ia_pns_info_struct str_pns_info;
310   WORD16 common_window;
311   WORD16 element_instance_tag;
312   WORD16 global_gain;
313   WORD32 *scratch_buf_ptr;
314   WORD32 *pulse_scratch;
315   ia_rvlc_info_struct ptr_rvlc_info;
316   ia_hcr_info_struct str_hcr_info;
317   WORD16 reorder_spect_data_len;
318   WORD8 longest_cw_len;
319   WORD16 rvlc_scf_esc_arr[128];
320   WORD16 rvlc_scf_fwd_arr[128];
321   WORD16 rvlc_scf_bwd_arr[128];
322   WORD8 rvlc_intensity_used;
323   WORD16 num_line_in_sec4_hcr_arr[32 * 8];
324   UWORD8 cb4_hcr_arr[32 * 8];
325   WORD32 number_sect;
326   WORD32 granule_len;
327   WORD16 rvlc_curr_sf_flag;
328   WORD16 *ltp_buf;
329   UWORD16 ltp_lag;
330 } ia_aac_dec_channel_info_struct;
331 WORD16 ixheaacd_ics_read(ia_bit_buf_struct *it_bit_buff,
332                          ia_ics_info_struct *ptr_ics_info,
333                          WORD8 num_swb_window[2], WORD32 object_type,
334                          WORD32 common_window, WORD32 frame_size);
335 
336 IA_ERRORCODE ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff,
337                                  ia_ics_info_struct *ptr_ics_info,
338                                  WORD32 object_type, WORD32 frame_size,
339                                  WORD32 ch);
340 
341 #endif /* #ifndef IXHEAACD_CHANNELINFO_H */
342