Home | History | Annotate | Download | only in decoder
      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_PS_DEC_H
     21 #define IXHEAACD_PS_DEC_H
     22 
     23 #define MAX_NUM_COLUMNS 32
     24 #define NUM_OF_QUAD_MIRROR_FILTER_CHNLS 64
     25 #define NUM_OF_ALL_PASS_CHNLS 23
     26 #define NUM_OF_DEL_CHNLS \
     27   (NUM_OF_QUAD_MIRROR_FILTER_CHNLS - NUM_OF_ALL_PASS_CHNLS)
     28 #define DEL_ALL_PASS 2
     29 #define SMALL_DEL_STRT 12
     30 #define SMALL_DEL 1
     31 #define HIGH_DEL 14
     32 #define NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS \
     33   (NUM_OF_ALL_PASS_CHNLS - NO_QMF_CHANNELS_IN_HYBRID)
     34 #define NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS \
     35   (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + NUM_OF_DEL_CHNLS)
     36 #define PEAK_DECAYING_FACT 0x620a
     37 #define NUM_SER_AP_LINKS 3
     38 #define MAXIM_NUM_OF_PS_ENVLOPS 5
     39 #define PSC_SQRT05F (0x5a82)
     40 #define NUM_OF_BINS (20)
     41 #define NUM_BANDS_FINE (34)
     42 
     43 typedef WORD16((*REVERB_BUFFERS_RI)[NUM_SER_AP_LINKS])[32 * 2];
     44 typedef WORD16((REVERB_BUFFERS_CH_RI[5])[NUM_SER_AP_LINKS])[16 * 2];
     45 
     46 typedef struct {
     47   WORD16 (*delay_buf_qmf_ap_re_im)[32 * 2];
     48 
     49   WORD16 (*delay_buf_qmf_ld_re_im)[SMALL_DEL_STRT * 2];
     50 
     51   WORD16 (*delay_buf_qmf_sd_re_im)[2 * 32];
     52 
     53   WORD16 delay_buf_idx_ser[NUM_SER_AP_LINKS];
     54   WORD16 delay_sample_ser[NUM_SER_AP_LINKS];
     55 
     56   REVERB_BUFFERS_RI delay_buf_qmf_ser_re_im;
     57   WORD16 delay_buf_idx;
     58   WORD16 delay_buf_idx_long;
     59 
     60   WORD32 *peak_decay_diff;
     61   WORD32 *energy_prev;
     62   WORD32 *peak_decay_diff_prev;
     63 
     64   WORD32 *ptr_hyb_left_re;
     65   WORD32 *ptr_hyb_left_im;
     66   WORD32 *ptr_hyb_right_re;
     67   WORD32 *ptr_hyb_right_im;
     68 
     69   WORD16 delay_buf_qmf_sub_re_im[DEL_ALL_PASS][16 * 2];
     70   REVERB_BUFFERS_CH_RI delay_buf_qmf_sub_ser_re_im;
     71 
     72   WORD16 h11_h12_vec[2 * 24];
     73   WORD16 h21_h22_vec[2 * 24];
     74 
     75   WORD16 H11_H12[2 * 24];
     76   WORD16 H21_H22[2 * 24];
     77 
     78   WORD16 delta_h11_h12[2 * 24];
     79   WORD16 delta_h21_h22[2 * 24];
     80 
     81   FLAG force_mono;
     82 
     83   WORD16 delay_buffer_scale;
     84   WORD16 usb;
     85 
     86   WORD16 iid_par_prev[NUM_BANDS_FINE];
     87   WORD16 icc_par_prev[NUM_BANDS_FINE];
     88 
     89   FLAG ps_data_present;
     90 
     91   FLAG enable_iid;
     92   FLAG enable_icc;
     93 
     94   FLAG enable_ext;
     95 
     96   WORD16 iid_mode;
     97   WORD16 icc_mode;
     98   FLAG iid_quant;
     99 
    100   FLAG frame_class;
    101   WORD16 num_env;
    102   WORD16 border_position[MAXIM_NUM_OF_PS_ENVLOPS + 2];
    103 
    104   FLAG iid_dt[MAXIM_NUM_OF_PS_ENVLOPS];
    105   FLAG icc_dt[MAXIM_NUM_OF_PS_ENVLOPS];
    106 
    107   WORD16 iid_par_table[MAXIM_NUM_OF_PS_ENVLOPS + 2][NUM_BANDS_FINE];
    108   WORD16 icc_par_table[MAXIM_NUM_OF_PS_ENVLOPS + 2][NUM_BANDS_FINE];
    109 
    110   ia_hybrid_struct str_hybrid;
    111 } ia_ps_dec_struct;
    112 
    113 WORD32 ixheaacd_create_psdec(ia_ps_dec_struct *ptr_ps_dec,
    114                              VOID *sbr_persistent_mem, WORD32 *ptr_overlap_buf);
    115 
    116 VOID ixheaacd_decorr_filter1_dec(ia_ps_dec_struct *ptr_ps_dec,
    117                                  ia_ps_tables_struct *ps_tables_ptr,
    118                                  WORD16 *transient_ratio);
    119 
    120 VOID ixheaacd_decorr_filter1_armv7(ia_ps_dec_struct *ptr_ps_dec,
    121                                    ia_ps_tables_struct *ps_tables_ptr,
    122                                    WORD16 *transient_ratio);
    123 
    124 VOID ixheaacd_decorr_filter2_dec(
    125     ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real,
    126     WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag,
    127     ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio);
    128 
    129 VOID ixheaacd_decorr_filter2_armv7(
    130     ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real,
    131     WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag,
    132     ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio);
    133 
    134 WORD32 ixheaacd_divide16_pos_dec(WORD32 op1, WORD32 op2);
    135 
    136 WORD32 ixheaacd_divide16_pos_armv7(WORD32 op1, WORD32 op2);
    137 
    138 VOID ixheaacd_decorrelation_dec(ia_ps_dec_struct *ptr_ps_dec,
    139                                 WORD32 *p_buf_left_real,
    140                                 WORD32 *p_buf_left_imag,
    141                                 WORD32 *p_buf_right_real,
    142                                 WORD32 *p_buf_right_imag,
    143                                 ia_ps_tables_struct *ps_tables_ptr);
    144 
    145 VOID ixheaacd_decorrelation_armv7(ia_ps_dec_struct *ptr_ps_dec,
    146                                   WORD32 *p_buf_left_real,
    147                                   WORD32 *p_buf_left_imag,
    148                                   WORD32 *p_buf_right_real,
    149                                   WORD32 *p_buf_right_imag,
    150                                   ia_ps_tables_struct *ps_tables_ptr);
    151 
    152 VOID ixheaacd_init_ps_scale(ia_ps_dec_struct *ptr_ps_dec,
    153                             ia_sbr_scale_fact_struct *sbr_scale_factor);
    154 
    155 VOID ixheaacd_init_rot_env(ia_ps_dec_struct *ptr_ps_dec, WORD16 env, WORD16 usb,
    156                            ia_sbr_tables_struct *sbr_tables_ptr,
    157                            const WORD16 *cos_sin_lookup_tab);
    158 
    159 VOID ixheaacd_apply_ps(ia_ps_dec_struct *ptr_ps_dec, WORD32 **real_buf_left,
    160                        WORD32 **imag_buf_left, WORD32 *real_buf_right,
    161                        WORD32 *imag_buf_right,
    162                        ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 slot,
    163                        ia_sbr_tables_struct *sbr_tables_ptr);
    164 
    165 VOID ixheaacd_apply_rot_dec(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re,
    166                             WORD32 *p_qmf_left_im, WORD32 *p_qmf_right_re,
    167                             WORD32 *p_qmf_right_im,
    168                             ia_sbr_tables_struct *sbr_tables_ptr,
    169                             const WORD16 *ptr_res);
    170 
    171 VOID ixheaacd_apply_rot_armv7(ia_ps_dec_struct *ptr_ps_dec,
    172                               WORD32 *qmf_left_real, WORD32 *qmf_left_imag,
    173                               WORD32 *qmf_right_real, WORD32 *qmf_right_imag,
    174                               ia_sbr_tables_struct *sbr_tables_ptr,
    175                               const WORD16 *ptr_resol);
    176 
    177 VOID ixheaacd_scale_ps_states(ia_ps_dec_struct *ptr_ps_dec, WORD16 scale);
    178 
    179 extern WORD16 ixheaacd_divideby2(WORD32 op);
    180 extern WORD16 ixheaacd_divideby3(WORD32 op);
    181 
    182 #endif
    183