Commit f64d3dd4 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Core coder functions: acelp_core, stere_tcx_core and other sub-functions

[x] cng exc syn12k8, cng energy integration
[x] wb_tbe_extras_reset, InitSWBencBufferStates, swb_tbe_reset, TBEreset_enc, fb_tbe_reset_enc integration
[x] Converted kernel_switch_update_transforms function and its subfunctions in ivas_mdct_core_whitening_enc() call stack
[x] ivas_decision_matrix_enc and sub-functions converted and integrated
[x] Ported encod_gen2sbfr and its sub functions
[x] FEC_encode, non_linearity, updt_enc, cng_params_upd integration
[x] Converted QuantizeSpectrum and InternalTCXDecoder
parent 92a13f5d
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1425,6 +1425,7 @@ enum
#define NB_LEADER                           36
#define NB_LDQ4                             27
#define FAC_LOG2                            3.321928095f
#define FAC_LOG2_BY10_Q16                   21771                   

#define NSV_MAX                             34                      /* maximal number of sub-vectors used by the AVQ */

+1 −1
Original line number Diff line number Diff line
@@ -746,7 +746,7 @@ void edxt_fx(
                move32();
            }

            y[sub( Nm1, imult1616( Nm1, shl( kernelType, 1 ) ) )] = L_shr( re[0], 1 );
            y[sub( Nm1, imult1616( Nm1, shr( kernelType, 1 ) ) )] = L_shr( re[0], 1 );
            move32();
        }
        ELSE /* inverse II = III */
+17 −4
Original line number Diff line number Diff line
@@ -317,8 +317,8 @@ ivas_error pre_proc_ivas(
    const int16_t loc_harm,                                     /* i  : harmonicity flag                        */
    const float cor_map_sum,                                    /* i  : speech/music clasif. parameter          */
    const int16_t vad_flag_dtx,                                 /* i  : HE-SAD flag with additional DTX HO      */
    const float enerBuffer[CLDFB_NO_CHANNELS_MAX],              /* i  : energy buffer                           */
    const float fft_buff[2 * L_FFT],                            /* i  : FFT buffer                              */
    /*const*/ float enerBuffer[CLDFB_NO_CHANNELS_MAX],              /* i  : energy buffer                           */
    /*const*/ float fft_buff[2 * L_FFT],                            /* i  : FFT buffer                              */
    const int16_t MCT_flag,                                     /* i  : hMCT handle allocated (1) or not (0)    */
    const int16_t vad_hover_flag,                               /* i  : VAD hangover flag                       */
    const int16_t flag_16k_smc                                  /* i  : flag to indicate if the OL SMC is run at 16 kHz */
@@ -635,6 +635,7 @@ ivas_error ivas_core_dec(
#endif


#ifndef IVAS_FLOAT_FIXED
void encod_gen_2sbfr(
    Encoder_State *st,                                          /* i/o: state structure                         */
    const float speech[],                                       /* i  : input speech                            */
@@ -650,6 +651,7 @@ void encod_gen_2sbfr(
    const int16_t tdm_Pitch_reuse_flag,                         /* i  : primary channel pitch reuse flag        */
    const float tdm_Pri_pitch_buf[]                             /* i  : pitch values for primary channel        */
);
#endif

void decod_gen_2sbfr(
    Decoder_State *st,                                          /* i/o: decoder static memory                   */
@@ -799,6 +801,7 @@ int16_t ivas_acelp_tcx20_switching(
    const int16_t flag_16k_smc                                  /* i  : flag to indicate if the OL SMC is run at 16 kHz */
);

#ifndef IVAS_FLOAT_FIXED
void ivas_decision_matrix_enc(
    Encoder_State *st,                                          /* i/o: encoder state structure                 */
    const int32_t element_brate,                                /* i  : element bitrate                         */
@@ -806,6 +809,16 @@ void ivas_decision_matrix_enc(
    const float enerBuffer[],                                   /* i  : energy buffer                           */
    const int16_t last_element_mode                             /* i  : last element mode                       */
);
#else
void ivas_decision_matrix_enc_fx(
    Encoder_State *st,          /* i  : encoder state structure                 */
    const Word32 element_brate, /* i  : element bitrate                         */
    const Word16 fft_buff[],    /* i  : FFT buffer                              */
    const Word32 enerBuffer[],  /* i  : energy buffer                           */
    Word16 enerBuffer_exp,
    const Word16 last_element_mode /* i  : last element mode                       */
);
#endif

#ifdef IVAS_FLOAT_FIXED
void ivas_signaling_enc_fx(
@@ -8001,8 +8014,8 @@ void ivas_omasa_dirac_rend_jbm(
#ifdef IVAS_FLOAT_FIXED
void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx(
    Decoder_Struct *st_ivas,
    Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],
    Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/
    Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/
    Word16 *cldfb_buf_q,
    const Word16 nBins,
    const Word16 subframe
+78 −11
Original line number Diff line number Diff line
@@ -2653,6 +2653,14 @@ void ivas_param_mc_metadata_open_fx(
    HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* o  : handle for the Parametric MC parameter coding state */
);

Word16 mdct_classifier_ivas_fx(
    Encoder_State *st,         /* i/o: Encoder state variable                  */
    const Word16 *fft_buff,    /* i  : FFT spectrum from fft_rel               */
    const Word32 enerBuffer[], /* i  : energy buffer                           */
    Word16 enerBuffer_exp,     /* i: enenrgy buffer exponent                   */
    const Word32 brate         /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
);

/*----------------------------------------------------------------------------------*
 * Range Coder prototypes
 *----------------------------------------------------------------------------------*/
@@ -2723,6 +2731,38 @@ void core_switching_pre_enc_ivas_fx(
    const Word16 active_cnt,       /* i  : active frame counter              */
    const Word16 last_element_mode /* i  : last_element_mode                 */
);

void encod_gen_2sbfr(
    Encoder_State *st,                 /* i/o: state structure                         */
    const Word16 speech[],             /* i  : input speech                            */
    const Word16 Aw[],                 /* i  : weighted A(z) unquantized for subframes */
    const Word16 Aq[],                 /* i  : LP coefficients                         */
    const Word16 *res,                 /* i  : residual signal                         */
    Word16 *syn,                       /* i/o: core synthesis                          */
    Word16 *exc,                       /* i/o: current non-enhanced excitation         */
    Word16 *exc2,                      /* i/o: current enhanced excitation             */
    Word16 *pitch_buf,                 /* i/o: floating pitch values for each subframe */
    Word16 *voice_factors,             /* o  : voicing factors                         */
    Word16 *bwe_exc,                   /* o  : excitation for SWB TBE                  */
    const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag        */
    const Word16 tdm_Pri_pitch_buf[],  /* i  : pitch values for primary channel        */
    Word16 *Q_new );

void acelp_fast_fx(
    BSTR_ENC_HANDLE hBstr,  /* i/o: encoder bitstream handle                      */
    const Word16 cdk_index, /* i  : codebook index                                */
    const Word16 dn_orig[L_SUBFR],
    /* i  : corr. between target and h[].                 */ // Q_new + 1
    Word16 Q_dn,
    const Word16 cn[L_SUBFR],
    /* i  : residual after long term prediction           */ // Q_new + 1
    const Word16 H[L_SUBFR],
    /* i  : impulse response of weighted synthesis filter */ // e(norm_s(H[0])+1)
    Word16 code[L_SUBFR],                                    /* o  : algebraic (fixed) codebook excitation         */
    Word16 y[],                                              /* o  : filtered fixed codebook excitation            */
    const Word16 L_subfr                                     /* i  : subframe length                               */
);

#endif

void ivas_mdct_quant_coder_fx(
@@ -2741,15 +2781,42 @@ void ivas_mdct_tcx10_bit_distribution_fx(

void QuantizeSpectrum_ivas_fx(
    Encoder_State *st,          /* i/o: encoder state structure                         */
    const float A[],             /* i  : quantized coefficients NxAz_q[M+1]              */
    const Word16 A_fx[],        /* i  : quantized coefficients NxAz_q[M+1]              */
    const Word16 Aqind[],       /* i  : frame-independent quantized coefficients (M+1)  */
    float gainlpc[],             /* i  : MDCT gains of the previous frame                */
    float synth[],               /* o  : synthesis buffer                                */
    const int16_t nb_bits,       /* i  : bit budget                                      */
    const int16_t tnsSize,       /* i  : number of tns parameters put into prm           */
    int16_t prm[],               /* o  : tcx parameters                                  */
    const int16_t frame_cnt,     /* i  : frame counter in the super_frame                */
    Word16 gainlpc_fx[],        /* i  : MDCT gains of the previous frame                */
    Word16 gainlpc_e[],         /* i  : exponents of MDCT gains of the previous frame                */
    Word16 synth[],             /* o  : synthesis buffer, Q0                                */
    const Word16 nb_bits,       /* i  : bit budget                                      */
    const Word16 tnsSize,       /* i  : number of tns parameters put into prm           */
    Word16 prm[],               /* o  : tcx parameters                                  */
    const Word16 frame_cnt,     /* i  : frame counter in the super_frame                */
    CONTEXT_HM_CONFIG *hm_cfg,  /* i  : HM configuration                             */
    const int16_t vad_hover_flag /* i  : VAD hangover flag                               */
    const Word16 vad_hover_flag /* i  : VAD hangover flag                            */
);

void InternalTCXDecoder_fx(
    Encoder_State *st,               /* i/o: state handle                            */
    const Word16 frame_cnt,          /* i  : frame counter in the super_frame        */
    const Word16 L_frameTCX,         /* i  : full frame length                       */
    const Word16 L_frame,            /* i  : frame length                            */
    const Word16 L_spec,             /* i  : length of the coded spectrum            */
    const Word16 tcx_offset,         /* i  : folding point offset relative to the end of the previous frame */
    const Word16 noiseFillingBorder, /* i  : noise filling border                    */
    const Word32 *x_quant_fx,        /* i  : quantized spectrum                      */
    const Word32 ener_fx,            /* i  : energy of the quantized spectrum        */
    const Word16 ener_e,             /* i  : energy of the quantized spectrum exponent        */
    Word16 lf_deemph_fact_fx[],      /* i/o: low frequency deemphasis factors        */
    const Word16 fac_ns_fx,          /* i  : noise filling level, Q15                     */
    const Word16 nf_seed,            /* i  : noise filling random seed, Q0               */
    const Word16 *A_fx,              /* i  : LPC representation of the FDNS gains    */
    Word16 gainlpc_fx[],             /* i/o: FDNS gains                              */
    Word16 gainlpc_e[],              /* i/o: FDNS gains exponent                              */
    const Word16 hm_active,          /* i  : flag indicating if the harmonic model is active */
    Word16 gain_tcx_fx,              /* i/o: global gain / quantized global gain             */
    Word16 *gain_tcx_e,              /* i/o: global gain / quantized global gain exponent             */
    Word32 spectrum_fx[],            /* o  : dequantized spectrum                    */
    Word16 *spectrum_e,              /* o  : dequantized spectrum                    */
    Word16 synth[],                  /* o  : time domain signal                      */
    Word16 *gain_tcx_q               /* o  : quantized global gain (at low bitrates) */
);
#endif
+39 −0
Original line number Diff line number Diff line
@@ -1746,6 +1746,17 @@ void wtda_fx(
    const Word16 L           /* i  : length                              */
);
#ifdef IVAS_FLOAT_FIXED
void wtda_ext_fx(
    const Word16 *new_audio,  /* i  : input audio (Q_in)                  */
    Word16 *wtda_audio,       /* o  : windowed audio (Q_in)               */
    const Word16 left_mode,   /* i  : window overlap of previous frame (0: full, 2: none, or 3: half) */
    const Word16 right_mode,  /* i  : window overlap of current frame (0: full, 2: none, or 3: half) */
    const Word16 L,           /* i  : length                              */
    const UWord16 kernel_type /* i  : transform kernel type (0 - 3)       */
);
#endif
/*========================================================================================================/
swb_bwe_com_lr_fx.c
/========================================================================================================*/
@@ -3947,6 +3958,19 @@ void mdct_window_aldo(
// tcx_utils.c
Word16 getInvFrameLen( const Word16 L_frame ); /* returns 1/L_frame in Q21 format */
#ifdef IVAS_FLOAT_FIXED
void tcx_get_windows(
    TCX_CONFIG_HANDLE hTcxCfg, /* i  : TCX configuration                   */
    const Word16 left_mode,    /* i: overlap mode of left window half          */
    const Word16 right_mode,   /* i: overlap mode of right window half         */
    Word16 *left_overlap,      /* o: left overlap length                       */
    const PWord16 **left_win,  /* o: left overlap window                       */
    Word16 *right_overlap,     /* o: right overlap length                      */
    const PWord16 **right_win, /* o: right overlap window                      */
    const Word8 fullband       /* i: fullband flag                             */
);
#endif
void WindowSignal(
    TCX_CONFIG_HANDLE hTcxCfg,      /* i  :   configuration of TCX              */
    Word16 offset,                  /* i  :   left folding point offset relative to the i   signal pointer */
@@ -7479,6 +7503,7 @@ void HQ_nbfec_init_fx(
    HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle  */
);
void GetAttackForTCXDecision_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex );
// FEC_HQ_phase_ecu_fx.c
void hq_ecu_fx(
@@ -10770,4 +10795,18 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
    Word32 *dist_ptr_fx,              /* i/o: updated  MSE vector for stage1         */
    Word16 *dist_ptr_e                /* i/o: exp for updated  MSE vector for stage1 */
);
void FEC_encode_ivas_fx(
    BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                        */
    const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP                      */
    const Word16 *synth,          /* i  : pointer to synthesized speech for E computation */
    const Word16 coder_type,      /* i  : type of coder                                   */
    Word16 clas,                  /* i  : signal clas for current frame                   */
    const Word16 *fpit,           /* i  : close loop fractional pitch buffer      Q6      */
    const Word16 *res,            /* i  : LP residual signal frame                        */
    Word16 *last_pulse_pos,       /* i/o: Position of the last pulse                      */
    const Word16 L_frame,         /* i  : Frame length                                    */
    const Word32 total_brate,     /* i  : total codec bitrate                             */
    const Word16 Q_synth          /* i  : input scaling                                   */
);
#endif
Loading