• 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_MAIN_H
21 #define IXHEAACD_MAIN_H
22 
23 VOID ixheaacd_imdct_flt(FLOAT32 in_data[], FLOAT32 out_data[], WORD32 len);
24 
25 VOID usac_tw_imdct(FLOAT32 in_data[], FLOAT32 out_data[], WORD32 len);
26 
27 WORD32 ixheaacd_window_calc(FLOAT32 window[], WORD32 len, WORD32 wfun_select);
28 
29 VOID calc_window_ratio(FLOAT32 window[], WORD32 len, WORD32 prev_len,
30                        WORD32 wfun_select, WORD32 prev_wfun_select);
31 
32 WORD32 ixheaacd_tw_window_calc(FLOAT32 window[], WORD32 len,
33                                WORD32 wfun_select);
34 
35 typedef struct ia_usac_lpd_decoder {
36   WORD32 mode_prev;
37   float synth_prev[MAX_PITCH + SYNTH_DELAY_LMAX];
38   float xcitation_prev[MAX_PITCH + INTER_LP_FIL_ORDER + 1];
39   int pitch_prev[NUM_SUBFR_SUPERFRAME_BY2 - 1];
40   float gain_prev[NUM_SUBFR_SUPERFRAME_BY2 - 1];
41 
42   float lp_flt_coeff_a_prev[2 * (ORDER + 1)];
43 
44   FLOAT32 exc_prev[1 + (2 * FAC_LENGTH)];
45 
46   FLOAT32 bpf_prev[FILTER_DELAY + LEN_SUBFR];
47 
48   WORD32 ilspold[ORDER];
49 
50   FLOAT32 fac_gain;
51   FLOAT32 fac_fd_data[FAC_LENGTH / 4];
52 
53   FLOAT32 lsf_prev[ORDER];
54   FLOAT32 lspold[ORDER];
55   WORD32 lsfold_first[ORDER];
56 
57   FLOAT32 gain_threshold;
58 
59   WORD32 fscale;
60 
61   FLOAT32 fd_synth_buf[3 * LEN_FRAME + 1 + ORDER];
62   FLOAT32 *fd_synth;
63   WORD32 bpf_active_prev;
64 
65 } ia_usac_lpd_decoder, *ia_usac_lpd_decoder_handle;
66 
67 typedef struct ia_usac_data_main_struct {
68   FLOAT32 time_sample_vector[MAX_NUM_CHANNELS][4096];
69   WORD32 input_data_ptr[MAX_NUM_CHANNELS][4096];
70   WORD32 overlap_data_ptr[MAX_NUM_CHANNELS][4096];
71   WORD32 output_data_ptr[MAX_NUM_CHANNELS][4096];
72 
73   WORD32 window_shape[MAX_NUM_CHANNELS];
74   WORD32 window_shape_prev[MAX_NUM_CHANNELS];
75   WORD32 window_sequence[MAX_NUM_CHANNELS];
76   WORD32 window_sequence_last[MAX_NUM_CHANNELS];
77 
78   WORD32 output_samples;
79   WORD32 sbr_ratio_idx;
80   WORD32 usac_independency_flg;
81 
82   WORD32 sampling_rate_idx;
83   WORD32 audio_object_type;
84 
85   WORD32 down_samp_sbr;
86   WORD32 sbr_mode;
87 
88   WORD32 tw_mdct[MAX_ELEMENTS];
89   WORD32 mps_pseudo_lr[MAX_ELEMENTS];
90   WORD32 td_frame_prev[MAX_NUM_CHANNELS];
91 
92   FLOAT32 warp_sum[MAX_NUM_CHANNELS][2];
93   FLOAT32 warp_cont_mem[MAX_NUM_CHANNELS][3 * 1024];
94   FLOAT32 prev_sample_pos[MAX_NUM_CHANNELS][3 * 1024];
95   FLOAT32 prev_tw_trans_len[MAX_NUM_CHANNELS][2];
96   WORD32 prev_tw_start_stop[MAX_NUM_CHANNELS][2];
97   FLOAT32 prev_warped_time_sample_vector[MAX_NUM_CHANNELS][3 * 1024];
98 
99   FLOAT32 lpc_prev[MAX_NUM_CHANNELS][ORDER + 1];
100   FLOAT32 acelp_in[MAX_NUM_CHANNELS][1 + (2 * FAC_LENGTH)];
101 
102   WORD32 alpha_q_re[MAX_SHORT_WINDOWS][SFB_NUM_MAX];
103   WORD32 alpha_q_im[MAX_SHORT_WINDOWS][SFB_NUM_MAX];
104   UWORD8 cplx_pred_used[MAX_SHORT_WINDOWS][SFB_NUM_MAX];
105 
106   WORD32 alpha_q_re_prev[SFB_NUM_MAX];
107   WORD32 alpha_q_im_prev[SFB_NUM_MAX];
108   WORD32 dmx_re_prev[BLOCK_LEN_LONG];
109 
110   VOID *sbr_scratch_mem_base;
111 
112   WORD32 *coef_fix[MAX_NUM_CHANNELS];
113   FLOAT32 *coef[MAX_NUM_CHANNELS];
114   UWORD8 *ms_used[MAX_NUM_CHANNELS];
115   WORD32 *coef_save[chans];
116 
117   WORD16 *factors[MAX_NUM_CHANNELS];
118   UWORD8 *group_dis[MAX_NUM_CHANNELS];
119 
120   WORD32 tw_data_present[MAX_NUM_CHANNELS];
121   WORD32 *tw_ratio[MAX_NUM_CHANNELS];
122   ia_tns_frame_info_struct *pstr_tns[MAX_NUM_CHANNELS];
123 
124   ia_usac_lpd_decoder_handle str_tddec[MAX_NUM_CHANNELS];
125 
126   WORD32 arith_prev_n[MAX_NUM_CHANNELS];
127   WORD8 c_prev[MAX_NUM_CHANNELS][1024 / 2 + 4];
128   WORD8 c[MAX_NUM_CHANNELS][1024 / 2 + 4];
129 
130   WORD32 noise_filling_config[MAX_NUM_ELEMENTS];
131   UWORD32 seed_value[MAX_NUM_CHANNELS];
132   WORD32 present_chan;
133 
134   WORD32 fac_data_present[MAX_NUM_CHANNELS];
135   WORD32 fac_data[MAX_NUM_CHANNELS][FAC_LENGTH + 1];
136 
137   ia_sfb_info_struct *pstr_sfb_info[MAX_NUM_CHANNELS];
138   ia_sfb_info_struct str_only_long_info;
139   ia_sfb_info_struct str_eight_short_info;
140   ia_sfb_info_struct *pstr_usac_winmap[NUM_WIN_SEQ];
141   WORD16 sfb_width_short[(1 << LEN_MAX_SFBS)];
142 
143   WORD32 ccfl;
144   WORD32 len_subfrm;
145   WORD32 num_subfrm;
146 
147   ia_handle_sbr_dec_inst_struct pstr_esbr_dec;
148   ia_aac_dec_sbr_bitstream_struct esbr_bit_str[2];
149 
150   WORD32 x_ac_dec[1024];
151   WORD32 scratch_buffer[1024];
152 
153   FLOAT32 synth_buf[1883];
154   FLOAT32 exc_buf[1453];
155   FLOAT32 lp_flt_coff[290];
156   WORD32 pitch[25];
157   FLOAT32 pitch_gain[25];
158 
159   UWORD16 *huffman_code_book_scl;
160   UWORD32 *huffman_code_book_scl_index;
161 
162   WORD32 *tns_coeff3_32;
163 
164   WORD32 *tns_coeff4_32;
165 
166   WORD32 (*tns_max_bands_tbl_usac)[16][2];
167 
168   WORD16 sfb_width_long[(1 << LEN_MAX_SFBL)];
169   WORD32 usac_flag;
170 
171   WORD32 arr_coef_fix[MAX_NUM_CHANNELS][(LN2 + LN2 / 8)];
172   FLOAT32 arr_coef[MAX_NUM_CHANNELS][(LN2 + LN2 / 8)];
173   WORD32 arr_coef_save[chans][(LN2 + LN2 / 8)];
174   WORD16 arr_factors[MAX_NUM_CHANNELS][MAXBANDS];
175   UWORD8 arr_group_dis[MAX_NUM_CHANNELS][NSHORT];
176   WORD32 arr_tw_ratio[MAX_NUM_CHANNELS][NUM_TW_NODES];
177   UWORD8 arr_ms_used[MAX_NUM_CHANNELS][MAXBANDS];
178   ia_usac_lpd_decoder arr_str_tddec[MAX_NUM_CHANNELS];
179   ia_tns_frame_info_struct arr_str_tns[MAX_NUM_CHANNELS];
180 
181 } ia_usac_data_struct;
182 
183 IA_ERRORCODE ixheaacd_tns_apply(ia_usac_data_struct *usac_data, WORD32 *spec,
184                                 WORD32 nbands,
185                                 ia_sfb_info_struct *pstr_sfb_info,
186                                 ia_tns_frame_info_struct *pstr_tns);
187 
188 WORD32 ixheaacd_calc_max_spectral_line_dec(WORD32 *ptr_tmp, WORD32 size);
189 
190 WORD32 ixheaacd_calc_max_spectral_line_armv7(WORD32 *ptr_tmp, WORD32 size);
191 
192 WORD32 ixheaacd_calc_max_spectral_line_armv8(WORD32 *ptr_tmp, WORD32 size);
193 
194 WORD32 ixheaacd_tw_buff_update(ia_usac_data_struct *usac_data, WORD32 i,
195                                ia_usac_lpd_decoder_handle st);
196 
197 VOID ixheaacd_fix2flt_data(ia_usac_data_struct *usac_data,
198                            ia_usac_lpd_decoder_handle st, WORD32 k);
199 
200 VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k, WORD32 mod0);
201 
202 WORD32 ixheaacd_tw_frame_dec(ia_usac_data_struct *usac_data, WORD32 i_ch,
203                              FLOAT32 sample_pos[], FLOAT32 tw_trans_len[],
204                              WORD32 tw_start_stop[]);
205 
206 WORD32 ixheaacd_fd_frm_dec(ia_usac_data_struct *usac_data, WORD32 i_ch);
207 
208 WORD32 ixheaacd_acelp_mdct(WORD32 *ptr_in, WORD32 *ptr_out, WORD32 *preshift,
209                            WORD32 length, WORD32 *ptr_scratch);
210 
211 WORD32 ixheaacd_acelp_mdct_main(ia_usac_data_struct *usac_data, WORD32 *x,
212                                 WORD32 *y, WORD32 l, WORD32 m,
213                                 WORD32 *preshift);
214 
215 WORD32 ixheaacd_fr_alias_cnx_fix(WORD32 *x_in, WORD32 len_subfr, WORD32 lfac,
216                                  WORD32 *iaq, WORD32 *izir, WORD32 *ifacdec,
217                                  WORD8 *qshift1, WORD8 qshift2, WORD8 qshift3,
218                                  WORD32 *preshift, WORD32 *ptr_scratch);
219 
220 WORD32 ixheaacd_fwd_alias_cancel_tool(
221     ia_usac_data_struct *usac_data, ia_td_frame_data_struct *pstr_td_frame_data,
222     WORD32 fac_length, FLOAT32 *iaq, WORD32 gain);
223 
224 WORD32 ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short,
225                             FLOAT32 out_buffer[],
226                             ia_usac_lpd_decoder_handle st);
227 
228 VOID ixheaacd_reset_acelp_data_fix(ia_usac_data_struct *usac_data,
229                                    ia_usac_lpd_decoder_handle st,
230                                    WORD32 *ptr_ola_buff, WORD32 last_was_short,
231                                    WORD32 tw_mdct);
232 #endif
233