Commit e4ce3d17 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

debugging code + struct ivas_reverb_params_t cleanup

parent af338a7d
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -689,8 +689,8 @@ void ivas_reverb_calc_color_levels_fx(

    /* Pre-computing inverse values for optimisation (to avoid divisions in inner loops) */
    Word16 fs_inverted_q;
    const Word32 fs_inverted = BASOP_Util_Divide3232_Scale( ONE_IN_Q11, L_shl( output_Fs, 11 ), &fs_inverted_q ); // q= 15 - fs_inverted_q = 29
    const Word32 loop_count_inverted = divide3232( ONE_IN_Q27, L_shl( loop_count, 27 ) );                         // q= 15;
    const Word32 fs_inverted = BASOP_Util_Divide3232_Scale( ONE_IN_Q11, L_shl( output_Fs, 11 ), &fs_inverted_q ); // q= 15 - fs_inverted_q = 29//Q29
    const Word32 loop_count_inverted = divide3232( ONE_IN_Q27, L_shl( loop_count, 27 ) );                         // q= 15;Q15

    const Word32 log__0_001 = -1854286438; // logf( 0.001f ) in q28
    move32();
@@ -738,9 +738,15 @@ void ivas_reverb_calc_color_levels_fx(
            Word32 H_filter;
            Word32 T60_est;
            Word16 temp = 0, result_e = 0;
            Word32 temp_32;
            move16();
            move16();
            cos_w = getCosWord16R2( (Word16) L_abs( L_shl( Mpy_32_32( pFc[freq_idx], fs_inverted ), 3 ) ) );                                                                                                                 // q = 15
            //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 ) ) );
            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 );
+2 −8
Original line number Diff line number Diff line
@@ -125,9 +125,6 @@ typedef struct ivas_reverb_params_t
    Word32 *pRt60_fx;                                                                                                                                                     /* RT60 values at these frequencies                                                     */
    Word32 *pDsr_fx;                                                                                                                                                      /* DSR values at these frequencies                                                      */

    Word32 *pHrtf_avg_pwr_response_l_fx;                /* The HRTF set's average left  ear power response                                      */
    Word32 *pHrtf_avg_pwr_response_r_fx;                /* The HRTF set's average right ear power response                                      */
    Word32 *pHrtf_inter_aural_coherence_fx;             /* The HRTF set's inter-aural coherence for diffuse sound                               */
    const Word32 *pHrtf_avg_pwr_response_l_const_fx;    /* The HRTF set's average left  ear power response                                      */
    const Word32 *pHrtf_avg_pwr_response_r_const_fx;    /* The HRTF set's average right ear power response                                      */
    const Word32 *pHrtf_inter_aural_coherence_const_fx; /* The HRTF set's inter-aural coherence for diffuse sound                               */
@@ -1439,12 +1436,9 @@ ivas_error ivas_reverb_open_fx(
    /* === 'Control logic': compute the reverb processing parameters from the              === */
    /* === room, source and listener acoustic information provided in the reverb config    === */
    /* Setting up shared temporary buffers for fc, RT60, DSR, etc.                             */
    params.pHrtf_avg_pwr_response_l_fx = &pFft_wf_filter_ch0_fx[0][0];
    params.pHrtf_avg_pwr_response_r_fx = params.pHrtf_avg_pwr_response_l_fx + nr_fc_fft_filter;
    params.pRt60_fx = &pFft_wf_filter_ch1_fx[0][0];
    params.pDsr_fx = params.pRt60_fx + nr_fc_fft_filter;
    params.pFc_fx = &pState->fft_filter_color_0.fft_spectrum_fx[0];
    params.pHrtf_inter_aural_coherence_fx = &pState->fft_filter_color_1.fft_spectrum_fx[0];
    set32_fx( pState->fft_filter_color_1.fft_spectrum_fx, 0, RV_FILTER_MAX_FFT_SIZE );
    /* Note: these temp buffers can only be used before the final step of the FFT filter design :     */
    /* before calls to ivas_reverb_calc_correl_filters(...) or to ivas_reverb_calc_color_filters(...) */
@@ -1606,8 +1600,8 @@ ivas_error ivas_reverb_open_fx(
        move32();
    }

    Scale_sig32( params.pHrtf_inter_aural_coherence_fx, nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/
    Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 17 );                        /*Scaling  ( *hReverb )->fft_filter_color_1.fft_spectrum_fx to Q31*/
    //Scale_sig32( pFft_wf_filter_ch1_fx[0][0], nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/
    //Scale_sig32( pFft_wf_filter_ch1_fx[0][0], nr_fc_fft_filter, 17 ); /*Scaling  ( *hReverb )->fft_filter_color_1.fft_spectrum_fx to Q31*/

    /* Copying the computed FFT colorations filters to the fft_filter components */
    IF( NE_32( ( error = set_color_fft_filter_fx( pState, 0, pFft_wf_filter_ch0_fx ) ), IVAS_ERR_OK ) )