Commit 1fec57a9 authored by vaillancour's avatar vaillancour
Browse files

High layer replacement

parent 76262b6d
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -108,12 +108,23 @@
#define REUSE_EVS_BE_GAINQ_LBR   // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed


#define EVS_NONBE_REUSAGE_1905
#ifdef EVS_NONBE_REUSAGE_1905
    #define REUSE_EVS_ACELP_corr_xh_fx    // this one could be non-bit-exact on very low level signal, as summation is initialized with 1 instead of 0
    #define REUSE_EVS_GAUSS_L2  // The gain is computed slightly differently, gauss_L2_ivas_fx was actually not using the right scaling, might not be BE  (this cause non BE and high ampl diff, but mld diff about 0.004)
    //#define REUSE_EVS_ACELP_PITCH_NORM_CORR // -> computation slightly different, but the impact is huge on the difference signal 
#endif

#define EVS_NONBE_REUSAGE_1906
#ifdef EVS_NONBE_REUSAGE_1906
    #define REUSE_EVS_ACELP_SHIFT    // Add shift parameter as expected by EVS acelp subfunctions
    #define REUSE_EVS_ACELP_HL_AVQ   // Replace ACELP high layers by EVS
    //#define REUSE_EVS_ACELP_TC       // Replace TC by EVS TC
#endif

//#define REUSE_EVS_ACELP_PITCH_NORM_CORR // -> computation slightly different, make the pitch not BE, could be harmonized but won't be BE

#endif

#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW  /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define FIX_1844_MISSING_FREE                                /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */

+17 −1
Original line number Diff line number Diff line
@@ -790,7 +790,9 @@ ivas_error acelp_core_enc_ivas_fx(

    Word16 att_fx;
    Word16 tmpF_fx;

#if defined EVS_NONBE_REUSAGE_1906 
    Word16 shift = 0;
#endif
    test();
    IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL )
    {
@@ -1313,7 +1315,21 @@ ivas_error acelp_core_enc_ivas_fx(

        calc_residu_fx( st, inp, res_fx, Aq );
        calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
#ifdef REUSE_EVS_ACELP_SHIFT 
        /* This could be moved outside of ACELP and compute on wsp or can be estimated on residual, idea is to prevent correlation to saturate, and from here they are all derived from residual*/
        {
            Word16 loc_max;
            loc_max = 0;
            move16();
            FOR( i = 0; i < st->L_frame; i++ )
            {
                loc_max = s_max( loc_max, s_max( abs_s( res_fx[i] ), abs_s( inp[i] ) ) );
            }

            shift = sub( norm_s( loc_max ), 3 );
            shift = s_min( shift, 0 );
        }
#endif
        IF( NE_16( att_fx, 32767 /* ONE_IN_Q15 */ ) )
        {
            v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame );
+10 −0
Original line number Diff line number Diff line
@@ -665,8 +665,13 @@ void encod_gen_voic_ivas_fx(
        test();
        IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) )
        {
#ifndef REUSE_EVS_ACELP_HL_AVQ
            transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
                                     xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
#else
            transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx,
                                     xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
#endif
        }

        /*-----------------------------------------------------------------*
@@ -747,8 +752,13 @@ void encod_gen_voic_ivas_fx(
        test();
        IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) )
        {
#ifndef REUSE_EVS_ACELP_HL_AVQ
            transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
                                     Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
#else
            transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
                                     Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
#endif
        }

        /*-----------------------------------------------------------------*
+25 −0
Original line number Diff line number Diff line
@@ -326,7 +326,30 @@ void transf_cdbk_enc_fx(
    }
    st_fx->last_nq_preQ = nq[7];
    move16();
#ifdef REUSE_EVS_ACELP_HL_AVQ
    /* TD pre-quantizer: in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */
    test();
    test();
    test();
    test();
    test();
    IF( GT_16( st_fx->element_mode, EVS_MONO ) && NE_16( st_fx->coder_type, INACTIVE ) && GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && !harm_flag_acelp && code_preQ[0] != 0 )
    {
        IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 4 ) ) )
        {
            st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 4 );
            move16();
        }
        ELSE IF( GT_16( abs_s( st_fx->last_code_preq ), shl_sat( abs_s( code_preQ[0] ), 3 ) ) )
        {
            st_fx->mem_preemp_preQ_fx = shr( st_fx->mem_preemp_preQ_fx, 3 );
            move16();
        }
    }

    st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0
    move16();
#endif
    PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) );

    /*--------------------------------------------------------------*
@@ -372,6 +395,7 @@ void transf_cdbk_enc_fx(

    return;
}
#ifndef REUSE_EVS_ACELP_HL_AVQ
void transf_cdbk_enc_ivas_fx(
    Encoder_State *st_fx,         /* i/o: encoder state structure                         */
    const Word16 harm_flag_acelp, /* i  : harmonic flag for higher rates ACELP            Q0*/
@@ -754,6 +778,7 @@ void transf_cdbk_enc_ivas_fx(

    return;
}
#endif
/*-------------------------------------------------------------------*
 * Find target in residual domain - cn[]
 *-------------------------------------------------------------------*/
+5 −0
Original line number Diff line number Diff line
@@ -563,8 +563,13 @@ Word16 encod_tran_ivas_fx(

        IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {
#ifndef REUSE_EVS_ACELP_HL_AVQ
            transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
                                     &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
#else
            transf_cdbk_enc_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
                                     &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
#endif
        }

        /*-----------------------------------------------------------------*
Loading