Commit 235156bb authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Added sanity check for 120dB in Q8

parent 5d8fa7e8
Loading
Loading
Loading
Loading
+41 −23
Original line number Diff line number Diff line
@@ -632,11 +632,12 @@ static ivas_error compute_t60_coeffs_fx(

    Word16 loop_delay_sec_fx, tmp;
    Word32 freq_Nyquist_fx = L_shr( output_Fs, 1 );
    Word16 target_gains_db_fx[RV_LENGTH_NR_FC];
    Word16 target_gains_db_fx[RV_LENGTH_NR_FC]; // Q8
    Word16 norm_f_fx[RV_LENGTH_NR_FC];
    Word32 *targetT60_fx, *pFc_fx;
    Word16 *pCoeffs_a_fx, *pCoeffs_b_fx;
    Word16 e;
    const Word16 min120q8 = -30720; // -120 in Q8

    error = IVAS_ERR_OK;
    move32();
@@ -658,13 +659,32 @@ static ivas_error compute_t60_coeffs_fx(

        Word16 loop_delay_sec_fx_exp;
        loop_delay_sec_fx = BASOP_Util_Divide3232_Scale( pParams->pLoop_delays[loop_idx], output_Fs, &e );
        loop_delay_sec_fx = shl( loop_delay_sec_fx, e );
        loop_delay_sec_fx = shl( loop_delay_sec_fx, e ); // Q15

        FOR( bin_idx = 0; bin_idx < tf_T60_len; bin_idx++ )
        {
            IF( EQ_16( pParams->pRt60_fx[bin_idx], 0 ) )
            {
                target_gains_db_fx[bin_idx] == min120q8;
            }
            ELSE
            {
                tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e );
                IF( LT_16( e, -1 ) )
                {
                    target_gains_db_fx[bin_idx] == min120q8;
                }
                ELSE
                {
                    tmp = shr( tmp, add( e, 1 ) );
            target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 //targetgains is in Q9
                    target_gains_db_fx[bin_idx] = mult( shr( min120q8, 1 ), tmp );  // Q8
                }
            }
            // TODO: check for RT60 not 0, in case of 0, target gain is simply -120 dB
            //tmp = BASOP_Util_Divide3232_Scale( L_deposit_h( loop_delay_sec_fx ), pParams->pRt60_fx[bin_idx], &e );
            // TODO: check for positive e, otherwise make it -120 dB
            //tmp = shr( tmp, add( e, 1 ) );
            //target_gains_db_fx[bin_idx] = mult( -30720, tmp ); // -60 in Q9 -> -30720 //targetgains is in Q9

            // tmp = BASOP_Util_Cmp_Mant32Exp( L_deposit_h( target_gains_db_fx[bin_idx] ), target_gains_db_exp[bin_idx], -2013265920, 7 );
            IF( tmp < 0 )
@@ -1308,7 +1328,6 @@ static void set_reverb_acoustic_data_fx(

        pDsr_fx[bin_idx] = L_tmp;
        move32();

    }
    return;
}
@@ -2418,7 +2437,6 @@ ivas_error ivas_binaural_reverb_init(
#else
        preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX );
#endif

    }
    else
    {