Commit 8785eb25 authored by vaclav's avatar vaclav
Browse files

Merge branch '1885-duplication-of-vad-parameters' into 'main'

Duplication of VAD parameters

Closes #1885

See merge request !2022
parents 7f594642 b4bbcdc3
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ ivas_error acelp_core_enc_fx(
#else
            config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate,
                              st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag,
                              tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx,
                              tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt,
                              tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
        }
@@ -469,7 +469,7 @@ ivas_error acelp_core_enc_fx(
#else
            config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
                              -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag,
                              tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
                              tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif
        }

@@ -527,7 +527,7 @@ ivas_error acelp_core_enc_fx(
#else
                config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame,
                                  -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0,
                                  st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
                                  st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode );
#endif

                /* redo LSF quantization */
+2 −2
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ void acelp_core_switch_enc_fx(
                      GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
#else
    config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
                      GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
                      GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
#endif

    encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
@@ -253,7 +253,7 @@ void acelp_core_switch_enc_ivas_fx(
    config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
#else
    config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot,
                      GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
                      GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_cnt, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ );
#endif

    encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new );
+0 −5
Original line number Diff line number Diff line
@@ -207,11 +207,6 @@ void init_coder_ace_plus_fx(
    move16();
    st->tfa_flag = 0;
    move16();
    /* Initialize DTX */
    IF( st->ini_frame == 0 )
    {
        vad_init_fx( &st->vad_st );
    }

    st->glr = 0;
    move16();
+5 −5
Original line number Diff line number Diff line
@@ -656,7 +656,7 @@ void dtx_fx(
    /* Initialization */
    IF( st_fx->ini_frame == 0 )
    {
        st_fx->active_fr_cnt_fx = CNG_TYPE_HO;
        st_fx->active_cnt = CNG_TYPE_HO;
        move16();

        st_fx->cng_type = FD_CNG;
@@ -756,7 +756,7 @@ void dtx_fx(
        st_fx->fd_cng_reset_flag == 0 )
    {
        /* reset counter */
        st_fx->active_fr_cnt_fx = 0;
        st_fx->active_cnt = 0;
        move16();

        IF( st_fx->Opt_AMR_WB )
@@ -878,7 +878,7 @@ void dtx_fx(
            move16(); /* reset the counter of CNG frames for averaging */
        }
        test();
        IF( GE_16( st_fx->active_fr_cnt_fx, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
        IF( GE_16( st_fx->active_cnt, CNG_TYPE_HO ) && st_fx->Opt_AMR_WB == 0 && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
        {
            IF( EQ_16( st_fx->element_mode, IVAS_SCE ) )
            {
@@ -911,8 +911,8 @@ void dtx_fx(
            st_fx->cng_type = LP_CNG;
            move16();
        }
        st_fx->active_fr_cnt_fx = add( st_fx->active_fr_cnt_fx, 1 );
        st_fx->active_fr_cnt_fx = s_min( st_fx->active_fr_cnt_fx, 200 );
        st_fx->active_cnt = add( st_fx->active_cnt, 1 );
        st_fx->active_cnt = s_min( st_fx->active_cnt, 200 );
    }

    /*------------------------------------------------------------------------*
+33 −42
Original line number Diff line number Diff line
@@ -20,8 +20,11 @@
 *
 * Initialization of state variables
 *-----------------------------------------------------------------------*/

ivas_error init_encoder_fx(
    Encoder_State *st_fx /* i/o: Encoder static variables structure  */
    Encoder_State *st_fx,            /* i/o: Encoder static variables structure  */
    const int16_t var_SID_rate_flag, /* i  : flag for variable SID update rate   */
    const int16_t interval_SID       /* i  : interval for SID update             */
)
{
    Word16 i;
@@ -350,35 +353,6 @@ ivas_error init_encoder_fx(
        }

        wb_vad_init_fx( st_fx->hVAD );
        st_fx->hVAD->prim_act_quick_fx = 0;
        move16();
        st_fx->hVAD->prim_act_slow_fx = 0;
        move16();
        st_fx->hVAD->prim_act_fx = 0;
        move16();
        st_fx->hVAD->prim_act_quick_he_fx = 0;
        move16();
        st_fx->hVAD->prim_act_slow_he_fx = 0;
        move16();
        st_fx->hVAD->prim_act_he_fx = 0;
        move16();
        st_fx->hVAD->hangover_terminate_flag = 0;
        move16();

        st_fx->hVAD->consec_inactive = 0;
        move16();
        st_fx->hVAD->spectral_tilt_reset = 1;
        move16();
        st_fx->hVAD->running_avg_fx = 0;
        move16();
        st_fx->hVAD->ra_deltasum_fx = 0;
        move16();
        st_fx->hVAD->trigger_SID = 0;
        move16();
        st_fx->hVAD->L_snr_sum_vad_fx = 0;
        move32();
        st_fx->hVAD->q_L_snr_sum_vad = Q31;
        move16();
    }
    ELSE
    {
@@ -387,12 +361,22 @@ ivas_error init_encoder_fx(

    st_fx->Pos_relE_cnt = 5120;
    move16(); /*20.0f*/
    st_fx->nb_active_frames_HE_SAD_fx = 0;
    move16();
    st_fx->lp_speech_fx = 11520;
    move16(); /*Q8 (45.0)    */ /* Initialize the long-term active speech level in dB   */

    /* avoid uninitialized memory access */
    /* CLDFB-based VAD */
    IF( st_fx->element_mode == EVS_MONO )
    {
        if ( ( st_fx->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) );
        }

        vad_init_fx( st_fx->hVAD_CLDFB );
    }
    ELSE
    {
        st_fx->hVAD_CLDFB = NULL;
    }


    /*-----------------------------------------------------------------*
     * Noise estimator
@@ -492,7 +476,12 @@ ivas_error init_encoder_fx(
    st_fx->exc_pe_fx = 0;
    move16();

    /* CNG and DTX */
    /*-----------------------------------------------------------------*
     * DTX
     *-----------------------------------------------------------------*/

    st_fx->lp_speech_fx = 11520;
    move16(); /*Q8 (45.0)    */ /* Initialize the long-term active speech level in dB   */
    st_fx->lp_noise_fx = 0;
    move16();

@@ -504,7 +493,7 @@ ivas_error init_encoder_fx(
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX variables\n" ) );
        }
        dtx_enc_init_fx( st_fx, st_fx->var_SID_rate_flag_fx, st_fx->interval_SID_fx );
        dtx_enc_init_fx( st_fx, var_SID_rate_flag, interval_SID );
    }
    ELSE
    {
@@ -518,8 +507,7 @@ ivas_error init_encoder_fx(
    {
        move16();
    }
    st_fx->active_fr_cnt_fx = 0;
    move16();

    st_fx->cng_type = -1;
    move16();

@@ -1494,7 +1482,7 @@ ivas_error init_encoder_ivas_fx(
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for VAD\n" ) );
        }

        wb_vad_init_ivas_fx( st->hVAD );
        wb_vad_init_fx( st->hVAD );
    }
    ELSE
    {
@@ -1506,8 +1494,11 @@ ivas_error init_encoder_ivas_fx(
    /* CLDFB-based VAD */
    IF( st->element_mode == EVS_MONO )
    {
        /* This is done to as in EVS T_CldfbVadState structure is present in Encoder State */
        st->hVAD_CLDFB = &st->vad_st;
        if ( ( st->hVAD_CLDFB = (VAD_CLDFB_HANDLE) malloc( sizeof( T_CldfbVadState ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB VAD\n" ) );
        }

        vad_init_fx( st->hVAD_CLDFB );
    }
    ELSE
Loading