Commit 788c1748 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

re-factoring of the fix to keep EVS bit-exactness

parent d5291a66
Loading
Loading
Loading
Loading
Loading
+31 −7
Original line number Diff line number Diff line
@@ -2703,26 +2703,46 @@ void swb_tbe_dec_fx(

    Lscale = root_a_over_b_fx( curr_pow, shl( Q_bwe_exc, 1 ), prev_pow, shl( Q_bwe_exc, 1 ), &exp );


#ifdef FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE
    /* Note, that the code below is identical for both EVS and IVAS codecs. The only difference is the addition of _sat in IVAS functions to avoid the saturation problem. Thus, it's BE for EVS test sequences and legacy implementations. */
    IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
    {
        FOR( i = 0; i < L_SHB_LAHEAD; i++ )
        {
            L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] );     /* Q_bwe_exc + (31-exp) - 15 */
#ifdef FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE
        shaped_shb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */
#else
            shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */
            move16();
        }
    }
    ELSE
    {
#endif
        FOR( i = 0; i < L_SHB_LAHEAD; i++ )
        {
            L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] );             /* Q_bwe_exc + (31-exp) - 15 */
            shaped_shb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */
            move16();
        }
#ifdef FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE
    }
#endif

    IF( exp < 0 )
    {
        Lscale = L_shl( Lscale, exp );
        exp = 0;
        move16();
    }

#ifdef FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE
    /* Note, that the code below is identical for both EVS and IVAS codecs. The only differences are the replacement of i_mult_sat() which has precision issues and the addition of _sat in IVAS functions to avoid the saturation problem. Thus, it's BE for EVS test sequences and legacy implementations. */
#else
    /*
       code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues
       thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations
    */
#endif
    IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
    {
        FOR( ; i < L_SHB_LAHEAD + 10; i++ )
@@ -2745,7 +2765,11 @@ void swb_tbe_dec_fx(
            temp = sub( 32767 /*1.0f Q15*/, temp );
            Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 );
            L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] );     /* Q_bwe_exc + (31-exp) - 15 */
#ifdef FIX_2602_NONBE_SAT_IN_SWB_TBE_SCALE
            shaped_shb_excitation[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */
#else
            shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */
#endif
            move16();
        }
    }