Commit 43748b0d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Integration of few common functions

[x] updt_common_enc, RunTransientDetection integration
[x] ivas_core_pre_proc_front and pre_proc_ivas cleanup
parent e6f00a28
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1959,6 +1959,7 @@ typedef enum _DCTTYPE
#define TOD_NSPEC                           80                      /* number of spectral bins of the tonal detector */
#define TOD_NSPEC_INV_Q31                   26843546                /* inverse of number of spectral bins of the tonal detector */
#define TOD_THR_MASS                        0.86f                   /* initial value for the adaptive threshold of the tonal detector */
#define TOD_THR_MASS_FX_Q22                 3607101                 /* initial value for the adaptive threshold of the tonal detector */
#define P2A_FACT                            0.9f                    /* long-term averaging factor for peak-to-average ratio */
#define P2A_FACT_FX_Q15                     29491                   /* long-term averaging factor for peak-to-average ratio */
#define THR_P2A_HIGH                        95.0f                   /* higher threshold to detect strongly peaky signals at low bitrates*/
+1 −1
Original line number Diff line number Diff line
@@ -833,7 +833,7 @@ void ivas_updt_dec_common_fx(
    Decoder_State *st_fx,              /* i/o: decoder state structure     */
    Word16 hq_core_type_fx,            /* i  : HQ core type                */
    const Word16 concealWholeFrameTmp, /* i  : concealWholeFrameTmp flag   */
    const Word32 *synth,               /* i  : decoded synthesis           */
    const Word32 *synth,               /* i  : decoded synthesis          Q(Qpostd) */
    const Word16 Qpostd                /* i  : Synthesis Q value           */

)
+77 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@
#include "prot.h"
#include "wmc_auto.h"

#ifdef IVAS_FLOAT_FIXED
#include "prot_fx.h"
#endif

#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
@@ -519,7 +522,81 @@ void amr_wb_enc(
    updt_enc( st, old_exc_flt, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );

    /* update main codec paramaters */
#ifdef IVAS_FLOAT_FIXED
#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
    f2me_buf_16( st->buf_speech_enc_pe_flt, st->buf_speech_enc_pe, &st->exp_buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    f2me_buf_16( st->buf_speech_enc_flt, st->buf_speech_enc, &st->exp_buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    f2me_buf_16( st->buf_synth_flt, st->buf_synth, &st->exp_buf_synth, OLD_SYNTH_SIZE_ENC + L_FRAME32k );
    IF( st->hTcxEnc != NULL )
    {
        f2me_buf_16( st->buf_wspeech_enc_flt, st->buf_wspeech_enc, &st->exp_buf_wspeech_enc, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k );
        f2me_buf_16( st->hTcxEnc->buf_speech_ltp_flt, st->hTcxEnc->buf_speech_ltp, &st->hTcxEnc->exp_buf_speech_ltp, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    }
    IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
    {
        st->hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( st->hTcxEnc->tcxltp_norm_corr_past_flt, 15 );
    }
#endif

    updt_enc_common_ivas_fx( st );

#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
    me2f_buf_16( st->buf_speech_enc_pe, st->exp_buf_speech_enc_pe, st->buf_speech_enc_pe_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    me2f_buf_16( st->buf_speech_enc, st->exp_buf_speech_enc, st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    me2f_buf_16( st->buf_synth, st->exp_buf_synth, st->buf_synth_flt, OLD_SYNTH_SIZE_ENC + L_FRAME32k );
    IF( st->hTcxEnc != NULL )
    {
        me2f_buf_16( st->buf_wspeech_enc, st->exp_buf_wspeech_enc, st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k );
        me2f_buf_16( st->hTcxEnc->buf_speech_ltp, st->hTcxEnc->exp_buf_speech_ltp, st->hTcxEnc->buf_speech_ltp_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
    }

    IF( ( st->Opt_DTX_ON && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) || ( st->tcxonly && ( EQ_16( st->codec_mode, MODE2 ) || GT_16( st->element_mode, EVS_MONO ) ) ) )
    {
        set_zero( st->mem_MA, M );
        mvr2r( GEWB_Ave, st->mem_AR, M );
    }

    IF( st->hTcxEnc != NULL )
    {
        IF( st->element_mode != IVAS_CPE_MDCT )
        {
            st->hTcxEnc->kernel_switch_corr_past_flt = 0.f;
        }
    }

    IF( st->element_mode > EVS_MONO && st->hTcxEnc != NULL )
    {
        st->hTcxEnc->tcxltp_norm_corr_mem_flt = fixedToFloat( st->hTcxEnc->tcxltp_norm_corr_mem, 31 );
    }

    IF( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->mdct_sw, MODE2 ) )
    {
        IF( EQ_32( st->sr_core, INT_FS_12k8 ) )
        {
            st->preemph_fac_flt = PREEMPH_FAC_FLT;
            st->gamma_flt = GAMMA1_FLT;
        }
        ELSE
        {
            st->preemph_fac_flt = PREEMPH_FAC_16k_FLT;
            st->gamma_flt = GAMMA16k_FLT;
        }
    }

    IF( st->Opt_DTX_ON && st->hTdCngEnc != NULL )
    {
        IF( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->hDtxEnc->first_CNG, 1 ) )
        {
            IF( ( EQ_16( st->element_mode, IVAS_SCE ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && GE_16( st->hTdCngEnc->act_cnt2, MIN_ACT_CNG_UPD ) )
            {
                st->hTdCngEnc->CNG_att = fix16_to_float( st->hTdCngEnc->CNG_att_fx, Q7 );
            }
        }
    }
#endif
#else
    updt_enc_common( st );
#endif

    pop_wmops();

+4 −1
Original line number Diff line number Diff line
@@ -479,6 +479,9 @@ ivas_error init_encoder(
        }

        speech_music_clas_init( st->hSpMusClas );
#if 1
        speech_music_clas_init_ivas_fx( st->hSpMusClas );
#endif

        st->sp_aud_decision0 = 0;
        st->sp_aud_decision1 = 0;
@@ -1595,7 +1598,7 @@ ivas_error init_encoder_ivas_fx(
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Speech/music classifier\n" ) );
        }

        speech_music_clas_init_fx( st->hSpMusClas );
        speech_music_clas_init_ivas_fx( st->hSpMusClas );
#if 1
        speech_music_clas_init( st->hSpMusClas );
#endif
+4 −30
Original line number Diff line number Diff line
@@ -2383,8 +2383,6 @@ ivas_error pre_proc_front_ivas_fx(
        L_Extract( epsP_fx[j], &epsP_h[j], &epsP_l[j] );
    }

    st->hSpMusClas->mean_avr_dyn_fx = float_to_fix16( st->hSpMusClas->mean_avr_dyn, Q7 );
    st->hSpMusClas->last_sw_dyn_fx = float_to_fix16( st->hSpMusClas->last_sw_dyn, Q7 );

    floatToFixed_arr16( st->hSpMusClas->past_log_enr, st->hSpMusClas->past_log_enr_fx, Q8, NB_BANDS_SPMUS );

@@ -2572,9 +2570,6 @@ ivas_error pre_proc_front_ivas_fx(
    fixedToFloat_arrL32( st->hNoiseEst->ave_enr2_fx, st->hNoiseEst->ave_enr2, q_fr_bands, NB_BANDS );

    fixedToFloat_arr( st->hSpMusClas->past_log_enr_fx, st->hSpMusClas->past_log_enr, Q8, NB_BANDS_SPMUS );
    st->hSpMusClas->ener_RAT = fixedToFloat_16( st->hSpMusClas->ener_RAT_fx, Q15 );
    st->hSpMusClas->mean_avr_dyn = fixedToFloat_16( st->hSpMusClas->mean_avr_dyn_fx, Q7 );
    st->hSpMusClas->last_sw_dyn = fixedToFloat_16( st->hSpMusClas->last_sw_dyn_fx, Q7 );

    fixedToFloat_arr( st->hNoiseEst->old_S_fx, st->hNoiseEst->old_S, Q7, 128 );
    fixedToFloat_arr( st->hNoiseEst->cor_map_fx, st->hNoiseEst->cor_map, Q15, 128 );
@@ -2792,8 +2787,6 @@ ivas_error pre_proc_front_ivas_fx(
    hSpMusClas->wrise_fx = float_to_fix16( hSpMusClas->wrise, 9 );
    relE_fx = float_to_fix16( *relE, 8 );
    floatToFixed_arr16( st->voicing, st->voicing_fx, 15, 3 );
    hSpMusClas->prev_relE_fx = float_to_fix16( hSpMusClas->prev_relE, 8 );
    hSpMusClas->relE_attack_sum_fx = float_to_fix16( hSpMusClas->relE_attack_sum, 8 );
    Word16 Qfact_PS = Q_factor_arrL( PS, 128 );
    floatToFixed_arr32( PS, PS_fx, Qfact_PS, 128 );
    Word16 e_esp;
@@ -2813,18 +2806,13 @@ ivas_error pre_proc_front_ivas_fx(
    fixedToFloat_arr( hSpMusClas->past_dlp_fx, hSpMusClas->past_dlp, Q9, HANG_LEN - 1 );
    hSpMusClas->lpm = fixedToFloat( hSpMusClas->lpm_fx, Q7 );     // Q7
    hSpMusClas->lps = fixedToFloat( hSpMusClas->lps_fx, Q7 );     // Q7
    hSpMusClas->lpn = fixedToFloat( hSpMusClas->lpn_fx, Q7 );                   // Q7
    hSpMusClas->wdrop = fixedToFloat( hSpMusClas->wdrop_fx, Q9 ); // Q8
    hSpMusClas->wrise = fixedToFloat( hSpMusClas->wrise_fx, Q9 ); // Q8
    hSpMusClas->lt_dec_thres = fixedToFloat( hSpMusClas->lt_dec_thres_fx, Q9 ); // Q8
    hSpMusClas->wdlp_0_95_sp = fixedToFloat( hSpMusClas->wdlp_0_95_sp_32fx, Q24 );
    hSpMusClas->dlp_mean_LT = fixedToFloat_32( hSpMusClas->dlp_mean_LT_fx, Q19 );
    hSpMusClas->wdlp_xtalk = fixedToFloat( hSpMusClas->wdlp_xtalk_fx, Q19 );
    hSpMusClas->dlp_var_LT = fixedToFloat_32( hSpMusClas->dlp_var_LT_fx, Q19 );
    hSpMusClas->prev_relE = fixedToFloat( hSpMusClas->prev_relE_fx, Q8 );
    hSpMusClas->prev_Etot = fixedToFloat( hSpMusClas->prev_Etot_fx, Q8 );
    fixedToFloat_arrL32( hSpMusClas->past_PS_fx, hSpMusClas->past_PS, Qfact_PS_past, 67 );
    hSpMusClas->relE_attack_sum = fixedToFloat( hSpMusClas->relE_attack_sum_fx, Q8 );
    fixedToFloat_arrL32( hSpMusClas->FV_st_fx, hSpMusClas->FV_st, Q20, 15 );
    fixedToFloat_arrL32( hSpMusClas->prev_FV_fx, hSpMusClas->prev_FV, Q20, 15 );
    fixedToFloat_arrL32( hSpMusClas->past_dlp_mean_ST_fx, hSpMusClas->past_dlp_mean_ST, Q19, 7 );
@@ -3138,18 +3126,10 @@ ivas_error pre_proc_front_ivas_fx(
        st->hSpMusClas->gsc_mem_etot_fx = float_to_fix16( st->hSpMusClas->gsc_mem_etot, Q8 );
        floatToFixed_arr( st->hSpMusClas->gsc_thres, st->hSpMusClas->gsc_thres_fx, Q11, 4 );
        st->old_corr_fx = float_to_fix16( st->old_corr, Q15 );
        floatToFixed_arr( st->hSpMusClas->var_cor_t, st->hSpMusClas->var_cor_t_fx, Q11, VAR_COR_LEN );
        floatToFixed_arrL( st->hSpMusClas->finc_prev, st->hSpMusClas->finc_prev_fx, 2 * Q_new, ATT_NSEG );
        st->hSpMusClas->lt_finc_fx = floatToFixed( st->hSpMusClas->lt_finc, 2 * Q_new );
        st->lp_noise_fx = float_to_fix16( st->lp_noise, Q8 );
        st->hSpMusClas->wdlp_0_95_sp_fx = float_to_fix16( st->hSpMusClas->wdlp_0_95_sp, Q8 );
        st->hSpMusClas->ener_RAT_fx = float_to_fix16( st->hSpMusClas->ener_RAT, Q8 );
        st->hSpMusClas->lt_dec_thres_fx = float_to_fix16( st->hSpMusClas->lt_dec_thres, Q9 );
        st->hSpMusClas->tod_S_mass_lt_fx = float_to_fix( st->hSpMusClas->tod_S_mass_lt, Q22 );
        st->hSpMusClas->tod_S_mass_prev_fx = float_to_fix( st->hSpMusClas->tod_S_mass_prev, Q22 );
        st->hSpMusClas->tod_thr_lt_fx = float_to_fix( st->hSpMusClas->tod_thr_lt, Q22 );
        floatToFixed_arrL( st->hSpMusClas->tod_S_map_lt, st->hSpMusClas->tod_S_map_lt_fx, Q22, TOD_NSPEC );
        st->hSpMusClas->tod_weight_fx = float_to_fix16( st->hSpMusClas->tod_weight, Q15 );
        st->hSpMusClas->mold_corr_fx = float_to_fix16( st->hSpMusClas->mold_corr, Q15 );
#endif // IVAS_FLOAT_FIXED_CONVERSIONS

@@ -3163,12 +3143,6 @@ ivas_error pre_proc_front_ivas_fx(
        st->hSpMusClas->lt_finc = fixedToFloat( st->hSpMusClas->lt_finc_fx, 2 * Q_new );
        fixedToFloat_arrL( st->hSpMusClas->tod_lt_Bin_E_fx, st->hSpMusClas->tod_lt_Bin_E, Q_new + Q_SCALE - 2, TOD_NSPEC );
        st->hSpMusClas->mold_corr = fix16_to_float( st->hSpMusClas->mold_corr_fx, Q15 );
        st->hSpMusClas->tod_S_mass_lt = fix_to_float( st->hSpMusClas->tod_S_mass_lt_fx, Q22 );
        st->hSpMusClas->tod_S_mass_prev = fix_to_float( st->hSpMusClas->tod_S_mass_prev_fx, Q22 );
        st->hSpMusClas->tod_thr_lt = fix_to_float( st->hSpMusClas->tod_thr_lt_fx, Q22 );
        fixedToFloat_arrL( st->hSpMusClas->tod_S_map_lt_fx, st->hSpMusClas->tod_S_map_lt, Q22, TOD_NSPEC );
        st->hSpMusClas->tod_weight = fix16_to_float( st->hSpMusClas->tod_weight_fx, Q15 );
        fixedToFloat_arr( st->hSpMusClas->var_cor_t_fx, st->hSpMusClas->var_cor_t, Q11, VAR_COR_LEN );
#endif // IVAS_FLOAT_FIXED_CONVERSIONS

#else
Loading