Commit 3c5aa0b3 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

cleaned up comments + latest merge from main

parent 8f7a40d8
Loading
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -1278,27 +1278,27 @@ static void set_reverb_acoustic_data_fx(

    FOR( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ )
    {
        L_tmp = Mpy_32_32( pRt60_fx[bin_idx], ln_1e6_inverted_fx ); // L_tmp in Q26
        L_tmp = Mpy_32_32( pRt60_fx[bin_idx], ln_1e6_inverted_fx ); //Q26

        // exp_argument_fx = BASOP_Util_Divide3232_Scale( delay_diff_fx, L_tmp, &exp_argument_e );//
        exp_argument_fx = BASOP_Util_Divide3232_Scale_newton( delay_diff_fx, L_tmp, &exp_argument_e );
        exp_argument_fx = L_shr_sat( exp_argument_fx, sub( 6, exp_argument_e ) ); // exp_argument_fx in Q26 - verified
        exp_argument_fx = L_shr_sat( exp_argument_fx, sub( 6, exp_argument_e ) ); //Q26

        /* Limit exponent to approx +/-100 dB in case of incoherent value of delay_diff, to prevent overflow */
        IF( GT_32( exp_argument_fx, 1543503872 ) ) //23 in Q26
        {
            exp_argument_fx = 1543503872;
        }
        IF( LT_32( exp_argument_fx, -1543503872 ) ) //-23 in Q26
        IF( LT_32( exp_argument_fx, -1543503872 ) ) //23 in Q26
        {
            exp_argument_fx = -1543503872;
        }

        tmp = Mpy_32_32( 96817114, exp_argument_fx ); // Q21 -> multiplication of Q26 by Q26 // x * 1/ln(2) it is ensured that exp_argument_fx is always in Q26
        tmp = Mpy_32_32( 96817114, exp_argument_fx ); //Q21

        L_tmp = BASOP_util_Pow2( tmp, 10, &pow_exp );  // Q28 -> not always, because pow_exp is not fixed
        L_tmp = Mpy_32_32( L_tmp, pDsr_fx[bin_idx] );  // Q27 if result of previous step is in Q28
        L_tmp = L_shl_sat( L_tmp, add( 1, pow_exp ) ); // L_tmp in Q31
        L_tmp = BASOP_util_Pow2( tmp, 10, &pow_exp );
        L_tmp = Mpy_32_32( L_tmp, pDsr_fx[bin_idx] );
        L_tmp = L_shl_sat( L_tmp, add( 1, pow_exp ) ); //Q31

        pDsr_fx[bin_idx] = L_tmp;
        move32();
@@ -1550,8 +1550,8 @@ ivas_error ivas_reverb_open_fx(
        return error;
    }
    /* Compute target levels (gains) for the coloration filters */
    Word32 *pHrtf_avg_pwr_response_l_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); // not required
    Word32 *pHrtf_avg_pwr_response_r_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); // not required
    Word32 *pHrtf_avg_pwr_response_l_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) );
    Word32 *pHrtf_avg_pwr_response_r_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) );
    Word16 lenT60_filter_coeff = add( params.t60_filter_order, 1 );
    lenT60_filter_coeff = add( i_mult( shl( lenT60_filter_coeff, 1 ), sub( params.nr_loops, 1 ) ), add( lenT60_filter_coeff, 2 ) );
    Word32 *pT60_filter_coeff = (Word32 *) malloc( ( lenT60_filter_coeff ) * sizeof( Word32 * ) );
@@ -1559,14 +1559,14 @@ ivas_error ivas_reverb_open_fx(

    FOR( i = 0; i < nr_fc_fft_filter; i++ )
    {
        pHrtf_avg_pwr_response_l_const[i] = params.pHrtf_avg_pwr_response_l_const_fx[i]; /*Q28*/ // Not required - contamination
        pHrtf_avg_pwr_response_l_const[i] = params.pHrtf_avg_pwr_response_l_const_fx[i]; /*Q28*/
        move32();
        pHrtf_avg_pwr_response_r_const[i] = params.pHrtf_avg_pwr_response_r_const_fx[i]; /*Q23+5*/ // Not required - contamination
        pHrtf_avg_pwr_response_r_const[i] = params.pHrtf_avg_pwr_response_r_const_fx[i]; /*Q23+5*/
        move32();
    }
    FOR( i = 0; i < lenT60_filter_coeff; i++ )
    {
        pT60_filter_coeff[i] = L_shl_sat( params.pT60_filter_coeff_fx[i], 17 ); // needed because calc_color_levels() uses 32-bit representaion of T60_filter_coefficients
        pT60_filter_coeff[i] = L_shl_sat( params.pT60_filter_coeff_fx[i], 17 );
        move32();
    }
    ivas_reverb_calc_color_levels_fx( output_Fs, nr_fc_fft_filter, params.nr_loops, params.pFc_fx, params.pDsr_fx, pHrtf_avg_pwr_response_l_const, pHrtf_avg_pwr_response_r_const,
+9 −12
Original line number Diff line number Diff line
@@ -94,10 +94,10 @@ ivas_error ivas_reverb_prepare_cldfb_params(

    FOR( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
    {
        L_tmp = Mpy_32_32( output_t60_fx[idx], ln_1e6_inverted_fx ); // L_tmp in Q26
        L_tmp = Mpy_32_32( output_t60_fx[idx], ln_1e6_inverted_fx ); // Q26

        exp_argument_fx = BASOP_Util_Divide3232_Scale_newton( delay_diff_fx, L_tmp, &tmp_exp ); // exp_argument_L_fx in Q30 (not alwys, because tmp_exp values are not constant)
        exp_argument_fx = L_shr_sat( exp_argument_fx, sub( 6, tmp_exp ) );                      // exp_argument_L_fx in Q26
        exp_argument_fx = BASOP_Util_Divide3232_Scale_newton( delay_diff_fx, L_tmp, &tmp_exp );
        exp_argument_fx = L_shr_sat( exp_argument_fx, sub( 6, tmp_exp ) );                      //Q26

        /* Limit exponent to approx +/-100 dB in case of incoherent value of delay_diff, to prevent overflow */
        IF( GT_32( exp_argument_fx, 1543503872 ) ) // 23 in Q26
@@ -109,21 +109,19 @@ ivas_error ivas_reverb_prepare_cldfb_params(
            exp_argument_fx = -1543503872;
        }

        tmp = Mpy_32_32( 96817114, exp_argument_fx ); // Q21 -> multiplication of Q26 by Q26 // x * 1/ln(2) it is ensured that exp_argument_fx is always in Q26
        tmp = Mpy_32_32( 96817114, exp_argument_fx ); //Q21

        L_tmp = BASOP_util_Pow2( tmp, 10, &pow_exp );   // Q28 -> not always, because pow_exp is not fixed
        L_tmp = Mpy_32_32( L_tmp, output_ene_fx[idx] ); // Q27 if result of previous step is in Q28
        L_tmp = L_shl_sat( L_tmp, add( 1, pow_exp ) );  // L_tmp in Q31
        L_tmp = BASOP_util_Pow2( tmp, 10, &pow_exp );
        L_tmp = Mpy_32_32( L_tmp, output_ene_fx[idx] );
        L_tmp = L_shl_sat( L_tmp, add( 1, pow_exp ) ); //Q31

        // Assign energy to output pointer
        pOutput_ene[idx] = L_tmp;
        pOutput_ene[idx] = L_tmp; //Q31
        move32();

        // Assign t60 to output pointer
        pOutput_t60[idx] = output_t60_fx[idx]; // Q26
    }

    ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_fx, avg_pwr_right_fx ); // This function returns avg powers for left and right in Q28 -> why?? how??
    ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_fx, avg_pwr_right_fx ); //Q28

    FOR( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ )
    {
@@ -132,7 +130,6 @@ ivas_error ivas_reverb_prepare_cldfb_params(
        tmp_ene = L_shr( L_add( avg_pwr_left_fx[idx], avg_pwr_right_fx[idx] ), 1 ); // Q28
        tmp_ene = Mpy_32_32( tmp_ene, dmx_gain_2_fx );                              // Q13
        pOutput_ene[idx] = Mpy_32_32( pOutput_ene[idx], tmp_ene );                  // Q13
        // Scale final output to Q31 for compatibility with further computations
        pOutput_ene[idx] = L_shl_sat( pOutput_ene[idx], 18 ); // Q31
    }