Commit 2f8b3639 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Float to fixed point conversion for binary hrtf data + compiler switch bug fixes

parent 7c54695c
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -100,12 +100,6 @@
#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	*/
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#define	FIX_638_ENERGIE_IAC_ROM_TABLES						  /* Orange: Missing left/right and coherence late reverb tables in binary format */
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#define NONBE_FIX_AVG_IAC_CLDFB_REVERB
#endif
#endif
#define FIX_638_ENERGIE_IAC_ROM_TABLES                  /* Orange: Missing left/right and coherence late reverb tables in binary format*/
#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES
#define NONBE_FIX_AVG_IAC_CLDFB_REVERB
+1 −1
Original line number Diff line number Diff line
@@ -2345,7 +2345,7 @@ ivas_error ivas_init_decoder_fx(
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
        IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
                                                  st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ),
                                                  st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ),
                   IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config,
+7 −5
Original line number Diff line number Diff line
@@ -1284,8 +1284,6 @@ static void set_reverb_acoustic_data_fx(
    Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp;
    Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e;
    Word16 pow_exp;
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#else
    Word32 *pHrtf_set_l_re_fx[MAX_INTERN_CHANNELS];
    Word32 *pHrtf_set_l_im_fx[MAX_INTERN_CHANNELS];
    Word32 *pHrtf_set_r_re_fx[MAX_INTERN_CHANNELS];
@@ -1300,6 +1298,8 @@ static void set_reverb_acoustic_data_fx(
    Word16 *pRt60_e = pParams->pRt60_e;
    Word32 *pDsr_fx = pParams->pDsr_fx;
    Word16 *pDsr_e = pParams->pDsr_e;
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#else

    /* use crend hrtf filters */
    IF( hHrtf != NULL )
@@ -1558,9 +1558,9 @@ ivas_error ivas_reverb_open_fx(

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    set_reverb_acoustic_data( &params, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter );
    params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l;
    params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r;
    params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence;
    params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l;
    params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r;
    params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence;
#else
    IF( hHrtf == NULL && lr_energy_and_iac_fx != NULL )
    {
@@ -1749,8 +1749,10 @@ ivas_error ivas_reverb_open_fx(
    {
        return error;
    }
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    free( pDsr_e );
    free( pRt60_e );
#endif
    *hReverb = pState;

    return error;
+6 −3
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies(
    float avg_pwr_right_fft[FFT_SPECTRUM_SIZE];
#endif
    float input_fc[FFT_SPECTRUM_SIZE];
    float output_fc[CLDFB_NO_CHANNELS_MAX];
#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    ivas_error error;
#endif
@@ -326,10 +327,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies(
    }
#endif

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right );
#else

    if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK )
    {
        return error;
    }

    Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) );
    Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) );
    Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) );
@@ -352,9 +358,6 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies(
        output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16;
    }

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right );
#else
    ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_left_fft_fx, avg_pwr_right_fft_fx,
                                              CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e );
    for ( int i = 0; i < 257; i++ )
+38 −34
Original line number Diff line number Diff line
@@ -722,7 +722,9 @@ static ivas_error load_reverb_from_binary(
    char *hrtf_data;
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
    int16_t lr_iac_len;
#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES
    float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC];
#endif

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
    if ( hHrtfStatistics == NULL )
@@ -800,8 +802,9 @@ static ivas_error load_reverb_from_binary(
        hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
        hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
        hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) );
        float *hrtf_prop_local = (float *) malloc( lr_iac_len * sizeof( float ) );

        if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL )
        if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL || hrtf_prop_local == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" );
        }
@@ -809,17 +812,17 @@ static ivas_error load_reverb_from_binary(
        hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn;
        hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn;

        fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hHrtfStatistics->average_energy_l_dyn, hHrtfStatistics->average_energy_l, Q27, lr_iac_len );
        fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_l, Q27, lr_iac_len );

        fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hHrtfStatistics->average_energy_r_dyn, hHrtfStatistics->average_energy_r, Q27, lr_iac_len );

        fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hHrtfStatistics->inter_aural_coherence_dyn, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len );
        fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_r, Q27, lr_iac_len );

        fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf );
        floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len );

        hHrtfStatistics->fromROM = FALSE;
        free( hrtf_prop_local );
#else
        /* left/right energy and interaural coherence for late reverb */
        FOR( i = 0; i < 3; i++ )
@@ -1168,7 +1171,6 @@ void destroy_td_hrtf(
        {
            free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] );
        }
#endif
    }
#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB
    else
@@ -1182,6 +1184,9 @@ void destroy_td_hrtf(
        }
    }
#endif
#else
    }
#endif

    ivas_HRTF_binary_close_fx( hHrtf );

@@ -2394,7 +2399,6 @@ void destroy_hrtf_statistics(
        {
            free( ( *hHrtfStatistics )->inter_aural_coherence_dyn );
        }

    }
    ivas_HRTF_statistics_close( hHrtfStatistics );
}