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

cleaned up interpolate_acoustic_data_fx(), interpolate_energies() and cldfb_convolver_state

parent c68d8aa6
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -1093,6 +1093,7 @@ void ivas_reverb_calc_color_levels_fx(
  const Word32 *pT60_filter_coeff, //input in Q31
  Word32 *pTarget_color_L, //output in Q30
  Word32 *pTarget_color_R); //output in Q30

ivas_error ivas_reverb_prepare_cldfb_params(
    const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params,
    const HRTFS_STATISTICS_HANDLE hHrtfStatistics,
@@ -1100,28 +1101,6 @@ ivas_error ivas_reverb_prepare_cldfb_params(
    Word32 *pOutput_t60,
    Word32 *pOutput_ene );

void ivas_reverb_interpolate_acoustic_data_fx(
  const Word16 input_table_size,
  const Word32 *pInput_fc, //input in Q16
  const Word32 *pInput_t60, //input in Q26
  const Word32 *pInput_dsr, //input in Q30
  const Word16 output_table_size,
  const Word32 *pOutput_fc,
  Word32 *pOutput_t60,
  Word32 *pOutput_dsr
);
#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
void ivas_reverb_interpolate_energies_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc, //input in Q16
    const Word32 *pInput_ene_l, //input in Q28
    const Word32 *pInput_ene_r, //input in Q28
    const Word16 output_table_size,
    const Word32 *pOutput_fc,
    Word32 *pOutput_ene_l,  // output in Q28
    Word32 *pOutput_ene_r   // output in Q28
);
#endif
void ivas_reverb_interp_on_freq_grid_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc, //input center frequencies in Q16
+0 −154
Original line number Diff line number Diff line
@@ -838,160 +838,6 @@ void ivas_reverb_calc_color_levels_fx(
    return;
}

/*-------------------------------------------------------------------*
 * ivas_reverb_interpolate_acoustic_data_fx()
 *
 * Interpolates data from the input T60 and DSR tables to the FFT pFilter uniform grid
 * Note: the fc frequencies both for the input and the output must be in the ascending order
 *-------------------------------------------------------------------*/


void ivas_reverb_interpolate_acoustic_data_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc,  // input in Q16
    const Word32 *pInput_t60, // input in Q26
    const Word32 *pInput_dsr, // input in Q30
    const Word16 output_table_size,
    const Word32 *pOutput_fc, // Q16
    Word32 *pOutput_t60,      // pOutput_t60_e // output t60 in Q26
    Word32 *pOutput_dsr       // pOutput_dsr_e // output dsr in Q 30
)
{
    Word16 input_idx, input_idx_next, output_idx;
    Word32 rel_offset;
    Word16 rel_offset_e;
    input_idx = 0;
    input_idx_next = 0;
    move16();
    move16();

    FOR( output_idx = 0; output_idx < output_table_size; output_idx++ )
    {
        /* if the bin frequency is lower than the 1st frequency point in the input table, take this 1st point */
        IF( LT_32( pOutput_fc[output_idx], pInput_fc[0] ) )
        {
            input_idx = 0;
            move16();
            input_idx_next = 0;
            move16();
            rel_offset = 0;
            move32();
            rel_offset_e = 0;
            move16();
        }
        ELSE
        {
            /* if the bin frequency is higher than the last frequency point in the input table, take this last point */
            IF( GT_32( pOutput_fc[output_idx], pInput_fc[input_table_size - 1] ) )
            {
                input_idx = sub( input_table_size, 2 );
                input_idx_next = add( input_idx, 1 );
                rel_offset = ONE_IN_Q15;
                move32();
                rel_offset_e = 1;
                move16();
            }
            /* otherwise use linear interpolation between 2 consecutive points in the input table */
            ELSE
            {
                WHILE( GT_32( pOutput_fc[output_idx], pInput_fc[input_idx + 1] ) )
                {
                    input_idx = add( input_idx, 1 );
                }
                input_idx_next = add( input_idx, 1 );
                rel_offset = BASOP_Util_Divide3232_Scale( L_sub( pOutput_fc[output_idx], pInput_fc[input_idx] ), L_sub( pInput_fc[input_idx + 1], pInput_fc[input_idx] ), &rel_offset_e ); // Q15
                rel_offset = L_shl_sat( rel_offset, add( 16, rel_offset_e ) );
                rel_offset_e = 0;
                move16();
            }
        }

        pOutput_t60[output_idx] = L_add( pInput_t60[input_idx], Mpy_32_32( rel_offset, L_sub( pInput_t60[input_idx_next], pInput_t60[input_idx] ) ) );
        pOutput_dsr[output_idx] = L_add( pInput_dsr[input_idx], Mpy_32_32( rel_offset, L_sub( pInput_dsr[input_idx_next], pInput_dsr[input_idx] ) ) );
    }

    return;
}

#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT
/*-------------------------------------------------------------------*
 * ivas_reverb_interpolate_energies_fx()
 *
 * Interpolates data from the input average energy to the FFT pFilter uniform grid
 * Note: the fc frequencies both for the input and the output must be in the ascending order
 *-------------------------------------------------------------------*/


void ivas_reverb_interpolate_energies_fx(
    const Word16 input_table_size,
    const Word32 *pInput_fc,    // input in Q16
    const Word32 *pInput_ene_l, // input in Q28
    const Word32 *pInput_ene_r, // input in Q28
    const Word16 output_table_size,
    const Word32 *pOutput_fc, // Q16
    Word32 *pOutput_ene_l,    // output in Q28
    Word32 *pOutput_ene_r )   // output in Q28
{
    Word16 input_idx, input_idx_next, output_idx;
    Word32 rel_offset;
    Word16 rel_offset_e;
    input_idx = 0;
    input_idx_next = 0;
    move16();
    move16();

    FOR( output_idx = 0; output_idx < output_table_size; output_idx++ )
    {
        /* if the bin frequency is lower than the 1st frequency point in the input table, take this 1st point */
        IF( LT_32( pOutput_fc[output_idx], pInput_fc[0] ) )
        {
            input_idx = 0;
            move16();
            input_idx_next = 0;
            move16();
            rel_offset = 0;
            move32();
            rel_offset_e = 0;
            move16();
        }
        ELSE
        {
            /* if the bin frequency is higher than the last frequency point in the input table, take this last point */
            IF( GT_32( pOutput_fc[output_idx], pInput_fc[input_table_size - 1] ) )
            {
                input_idx = sub( input_table_size, 2 );
                move16();
                input_idx_next = add( input_idx, 1 );
                move16();
                rel_offset = ONE_IN_Q15;
                move32();
                rel_offset_e = 1;
                move16();
            }
            /* otherwise use linear interpolation between 2 consecutive points in the input table */
            ELSE
            {
                WHILE( GT_32( pOutput_fc[output_idx], pInput_fc[input_idx + 1] ) )
                {
                    input_idx = add( input_idx, 1 );
                }
                input_idx_next = add( input_idx, 1 );
                // Rel_offset
                rel_offset = BASOP_Util_Divide3232_Scale( L_sub( pOutput_fc[output_idx], pInput_fc[input_idx] ), L_sub( pInput_fc[input_idx + 1], pInput_fc[input_idx] ), &rel_offset_e ); // Q15
                rel_offset = L_shl_sat( rel_offset, add( 16, rel_offset_e ) );
                rel_offset_e = 0;
                move16();
            }
        }

        pOutput_ene_l[output_idx] = L_add( pInput_ene_l[input_idx], Mpy_32_32( rel_offset, L_sub( pInput_ene_l[input_idx_next], pInput_ene_l[input_idx] ) ) );
        pOutput_ene_r[output_idx] = L_add( pInput_ene_r[input_idx], Mpy_32_32( rel_offset, L_sub( pInput_ene_r[input_idx_next], pInput_ene_r[input_idx] ) ) );
    }

    return;
}
#endif

/*-------------------------------------------------------------------*
 * ivas_reverb_interp_on_freq_grid_fx()
 *
+4 −3
Original line number Diff line number Diff line
@@ -1277,8 +1277,9 @@ static void set_reverb_acoustic_data_fx(
    Word16 *pDsr_e = pParams->pDsr_e;

    /* interpolate input table data for T60 and DSR to the FFT filter grid */
    ivas_reverb_interpolate_acoustic_data_fx( nr_fc_input, pFc_input_fx, pAcoustic_rt60_fx, pAcoustic_dsr_fx,
                                              nr_fc_fft_filter, pFc_fx, pRt60_fx, pDsr_fx );

    ivas_reverb_interp_on_freq_grid_fx( nr_fc_input, pFc_input_fx, pAcoustic_rt60_fx, nr_fc_fft_filter, pFc_fx, pRt60_fx );
    ivas_reverb_interp_on_freq_grid_fx( nr_fc_input, pFc_input_fx, pAcoustic_dsr_fx, nr_fc_fft_filter, pFc_fx, pDsr_fx );

    /* adjust DSR for the delay difference */

+0 −13
Original line number Diff line number Diff line
@@ -54,16 +54,6 @@
 * Local function prototypes
 *-----------------------------------------------------------------------------------------*/

//typedef struct cldfb_convolver_state
//{
//    const float *filter_taps_left_re[CLDFB_NO_CHANNELS_MAX];
//    const float *filter_taps_left_im[CLDFB_NO_CHANNELS_MAX];
//    const float *filter_taps_right_re[CLDFB_NO_CHANNELS_MAX];
//    const float *filter_taps_right_im[CLDFB_NO_CHANNELS_MAX];
//    float filter_states_re[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX];
//    float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX];
//} cldfb_convolver_state;

static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const Word32 sampling_rate, Word32 *avg_pwr_l_out, Word32 *avg_pwr_r_out );

/*-----------------------------------------------------------------------------------------*
@@ -226,9 +216,6 @@ static void ivas_reverb_set_energies(
    //Avg Energy Right
    ivas_reverb_interp_on_freq_grid_fx( avg_pwr_len, input_fc_fx, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_right_fx );

#else
    ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r,
                                              CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e );
#endif

    FOR( int i = 0; i < 60; i++ )