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

activated binary hrtf compiler switch + changes in ivas_reverb_fx.c

parent f928d386
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@
#define FIX_1372_ISAR_POST_REND
#define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM   /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */

//#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#define USE_NEW_HRTF_BINARY_FILE_FORMAT                 /* Orange: to activate when decided to change the hrtf binary file format */
#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT
#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES       /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers	*/
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format*/
+105 −9
Original line number Diff line number Diff line
@@ -145,10 +145,10 @@ typedef struct ivas_reverb_params_t
    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                               */
#endif
    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                               */
#endif

    Word16 do_corr_filter; /* Flag indicating whether correlation filters should be used.                          */
                           /*        Correlation only supported and needed for binaural playback (i.e.             */
@@ -1499,7 +1499,9 @@ ivas_error ivas_reverb_open_fx(
{
    ivas_error error;
#ifdef FIX_1053_REVERB_RECONFIGURATION

    REVERB_HANDLE pState = *hReverb;
    UWord16 nr_coefs, branch_idx;
    Word16 *pCoef_a, *pCoef_b;
#else
    REVERB_HANDLE pState = NULL;
#endif
@@ -1521,17 +1523,44 @@ ivas_error ivas_reverb_open_fx(
    move16();
    nr_fc_input = hRenderConfig->roomAcoustics.nBands;

#ifdef FIX_1053_REVERB_RECONFIGURATION
    IF( *hReverb == NULL )
    {
        IF( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" );
        }
    }
#else
    /* Allocate main reverb. handle */
    IF( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Reverberator " );
    }

#endif
    IF( NE_32( ( error = set_base_config_fx( &params, output_Fs ) ), IVAS_ERR_OK ) )
    {
        return error;
    }
#ifdef FIX_1053_REVERB_RECONFIGURATION
    IF( *hReverb == NULL )
    {
        /* Allocate memory for feedback delay lines */
        FOR( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ )
        {
            IF( ( pState->loop_delay_buffer_fx[loop_idx] = (Word32 *) malloc( params.pLoop_delays[loop_idx] * sizeof( Word32 ) ) ) == NULL );
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" );
            }
        }

        /* Allocate memory for the pre-delay line */
        IF( ( pState->pPredelay_buffer_fx = (Word32 *) malloc( output_frame * sizeof( Word32 ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" );
        }
    }
#else
    /* Allocate memory for feedback delay lines */
    FOR( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ )
    {
@@ -1546,21 +1575,26 @@ ivas_error ivas_reverb_open_fx(
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" );
    }

#endif
    pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES;
    move16();
    set_fft_and_datablock_sizes_fx( pState, subframe_len );

    nr_fc_fft_filter = add( extract_l( L_shr( pState->fft_size, 1 ) ), 1 );

    /* === '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.                             */
#ifndef FIX_1053_REVERB_RECONFIGURATION
    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;
#endif
    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];
#ifndef FIX_1053_REVERB_RECONFIGURATION
    params.pHrtf_inter_aural_coherence_fx = &pState->fft_filter_color_1.fft_spectrum_fx[0];
#endif
    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(...) */
@@ -1619,8 +1653,15 @@ ivas_error ivas_reverb_open_fx(
        move32();
    }

#ifdef FIX_1053_REVERB_RECONFIGURATION
    IF( *hReverb == NULL )
    {
        pState->dmx_gain_fx = calc_dmx_gain_fx();
    }
#else
    /*  set up input downmix  */
    pState->dmx_gain_fx = calc_dmx_gain_fx();
#endif

    /*  set up predelay - must be after set_base_config() and before compute_t60_coeffs() */
    calc_predelay_fx( &params, hRenderConfig->roomAcoustics.acousticPreDelay_fx, output_Fs );
@@ -1668,6 +1709,25 @@ ivas_error ivas_reverb_open_fx(

    /* Compute the window used for FFT filters */
    ivas_reverb_define_window_fft_fx( pTime_window_fx, transition_start, transition_length, nr_fc_fft_filter );

#ifdef FIX_1053_REVERB_RECONFIGURATION
    /* === Copy parameters from ivas_reverb_params_t into DSP blocks   === */
    /* === to be used for subsequent audio signal processing           === */
    if ( *hReverb == NULL )
    {
        pState->do_corr_filter = params.do_corr_filter;
        move16();

        /* clear & init jot reverb fft filters */
        IF( NE_32( ( error = initialize_reverb_filters_fx( pState ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
        Word16 q_pFft_wf_filter_ch0_fx = 23, q_pFft_wf_filter_ch1_fx = 23;
        move16();
        move16();
    }
#else
    /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks   === */
    /* === to be used for subsequent audio signal processing                === */

@@ -1682,6 +1742,8 @@ ivas_error ivas_reverb_open_fx(
    Word16 q_pFft_wf_filter_ch0_fx = 23, q_pFft_wf_filter_ch1_fx = 23;
    move16();
    move16();
#endif

    IF( pState->do_corr_filter )
    {
        /* Computing correlation filters on the basis of target IA coherence */
@@ -1744,8 +1806,11 @@ ivas_error ivas_reverb_open_fx(
        pFft_wf_filter_ch1_fx[i][1] = L_shl( pFft_wf_filter_ch1_fx[i][1], sub( 31, q_pFft_wf_filter_ch1_fx ) );
        move32();
    }

#ifndef FIX_1053_REVERB_RECONFIGURATION
    Scale_sig32( params.pHrtf_inter_aural_coherence_fx, nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/
#else
    Scale_sig32( params.pHrtf_inter_aural_coherence_const_fx, nr_fc_fft_filter, 4 ); /*Scaling ( *hReverb )->fft_filter_color_0.fft_spectrum_fx to Q31*/
#endif
    Scale_sig32( params.pFc_fx, 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 */
@@ -1759,6 +1824,36 @@ ivas_error ivas_reverb_open_fx(
        return error;
    }

#ifdef FIX_1053_REVERB_RECONFIGURATION
    if ( *hReverb == NULL )
    {
        /* init predelay */
        ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer_fx, params.pre_delay, predelay_bf_len );

        /* set up feedback delay network */
        if ( ( error = setup_FDN_branches( pState, &params ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
    else
    {
        pState->predelay_line.Delay = params.pre_delay;
    }

    nr_coefs = params.t60_filter_order + 1;

    for ( branch_idx = 0; branch_idx < params.nr_loops; branch_idx++ )
    {
        pCoef_a = &params.pT60_filter_coeff_fx[2 * nr_coefs * branch_idx + nr_coefs];
        pCoef_b = &params.pT60_filter_coeff_fx[2 * nr_coefs * branch_idx];

        if ( ( error = set_t60_filter( pState, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#else
    /* init predelay */
    ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer_fx, params.pre_delay, predelay_bf_len );

@@ -1767,6 +1862,7 @@ ivas_error ivas_reverb_open_fx(
    {
        return error;
    }
#endif
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    free( pDsr_e );
    free( pRt60_e );