Commit 90a372d1 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Fixed bug : cosine value dropoff in cal_color_levels_fx() + cleaned up debugging comments

parent e4ce3d17
Loading
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -671,7 +671,7 @@ void ivas_reverb_calc_color_levels_fx(
    const Word32 output_Fs,
    const Word16 freq_count,
    const Word16 loop_count,
    const Word32 *pFc,             // input in Q14
    const Word32 *pFc,             // input in Q14 //Input is actually in Q16
    const Word32 *pAcoustic_dsr,   // input in Q31
    const Word32 *pHrtf_avg_pwr_L, // input in Q28
    const Word32 *pHrtf_avg_pwr_R, // input in Q28
@@ -741,12 +741,8 @@ void ivas_reverb_calc_color_levels_fx(
            Word32 temp_32;
            move16();
            move16();
            //cos_w calculation has a bug. Values of cosine start at 1, but drop off very fast compared to the floating point variant.
            //Cosine multiplicaiton factor is 2*PI in floating point. In this code, it is left shift by 3, which is multiplicaiton by 8.
            Word32 PI_2_fx = 1684125261; // 2*PI in Q28 // 1686629713
            temp_32 = Mpy_32_32(fs_inverted, PI_2_fx);//Q26
            //cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) );                                                                                                                 // q = 15 
            cos_w = getCosWord16R2( (Word16) L_abs( Mpy_32_32( pFc[freq_idx], temp_32 ) ) );

            cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 1 ) ) );                                                                                                                 // q = 15 
            H_filter = L_add( L_shr( L_add( L_shr( Mpy_32_32( coefB[0], coefB[0] ), 1 ), L_shr( Mpy_32_32( coefB[1], coefB[1] ), 1 ) ), 2 ), L_shr( Mpy_32_32( coefB[0], Mpy_32_32( coefB[1], L_shl( cos_w, 15 ) ) ), 1 ) ); // q = 28
            H_filter = BASOP_Util_Divide3232_Scale_newton( H_filter, L_add( ONE_IN_Q28, L_shr( L_add( L_shr( Mpy_32_32( coefA[1], coefA[1] ), 2 ), Mpy_32_32( coefA[1], L_shl( cos_w, 15 ) ) ), 1 ) ), &temp );
            H_filter = Sqrt32( H_filter, &temp );
+1 −1
Original line number Diff line number Diff line
@@ -1447,7 +1447,7 @@ ivas_error ivas_reverb_open_fx(
    freq_step_fx = L_mult0( extract_l( L_shr( output_Fs, 2 ) ), div_s( 1, ( nr_fc_fft_filter - 1 ) ) ); /*Q14:0.5f * output_Fs / ( nr_fc_fft_filter - 1 )*/
    FOR( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ )
    {
        params.pFc_fx[bin_idx] = W_extract_l( W_mult0_32_32( freq_step_fx, bin_idx ) ); /*Q14*/
        params.pFc_fx[bin_idx] = W_extract_l( W_mult0_32_32( freq_step_fx, bin_idx ) ); /*Q14*/ //Initial comment says Q14, but these values align with floating point only if they are considered to be in Q16
    }

    test();