Commit aa0c4f58 authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Correct shb_ener_fx calculation in shb_DTX_fx()

parent e79176c8
Loading
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -1649,6 +1649,9 @@ static Word16 shb_DTX_fx(
    Word16 *shb_new_speech_fx;
    Word32 wb_ener_fx;
    Word32 shb_ener_fx;
#ifdef NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT
    Word16 shb_ener_q;
#endif
    Word16 log_wb_ener_fx;
    Word16 log_shb_ener_fx;
    Word16 tmp;
@@ -1673,13 +1676,22 @@ static Word16 shb_DTX_fx(
#endif

    shb_ener_fx = L_deposit_l( 0 );
#ifdef NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT
    FOR( i = 0; i < L_FRAME16k; i++ )
    {
        shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); // ( 2 * hBWE_TD->old_speech_shb_q + Q1 ) --> Q1 due to left shift in L_mac
    }
    shb_ener_q = add( shl( hBWE_TD->old_speech_shb_q, 1 ), 1 );

    shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in shb_ener_q */
#else
    FOR( i = 0; i < L_FRAME16k; i++ )
    {
        shb_ener_fx = L_mac_sat( shb_ener_fx, shb_old_speech_fx[i], shb_old_speech_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac
    }

    shb_ener_fx = L_add( Mpy_32_16_1( shb_ener_fx, 102 ), 1 ); /* ( 1 / L_FRAME16K ) -> 102 in Q15, shb_ener_fx in Q1 */

#endif
    wb_ener_fx = L_deposit_l( 0 );
    FOR( i = 0; i < st->L_frame; i++ )
    {
@@ -1696,7 +1708,11 @@ static Word16 shb_DTX_fx(
    log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */
    exp = norm_l( shb_ener_fx );
    fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
#ifdef NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT
    exp = sub( sub( 30, shb_ener_q ), exp );
#else
    exp = sub( 30 - 1, exp );
#endif
    shb_ener_fx = Mpy_32_16( exp, fra, LG10 );

    test();