Loading lib_com/ivas_cnst.h +0 −4 Original line number Diff line number Diff line Loading @@ -1663,15 +1663,11 @@ typedef enum #define RV_FILTER_MAX_FFT_SIZE ( 512 ) #define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */ #define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 #endif #define IVAS_REVERB_DEFAULT_N_BANDS 31 #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) #endif /*----------------------------------------------------------------------------------* Loading lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -160,7 +160,6 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ #define NONBE_FIX_AVG_IAC_CLDFB_REVERB /* Orange: Add computation avg energy and iac tables for rom and binaural binary file */ #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define NONBE_FIX_935_SBA_REVERB /* FhG: issue 935: fix MSAN error for SBA related to BINAURAL_ROOM_REVERB */ Loading lib_rend/ivas_reverb_filter_design.c +0 −4 Original line number Diff line number Diff line Loading @@ -714,14 +714,12 @@ void ivas_reverb_get_hrtf_set_properties( const float norm_freq = out_freq_step * out_bin_idx; /* Computing the bin index in the source data */ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( in_freq_count == out_freq_count ) { base_idx = out_bin_idx; } else { #endif const float tbl_index = ( norm_freq - inp_freq_offset ) / inp_freq_step; if ( tbl_index <= 0.0f ) /* In case of extrapolation (below 1st bin), choose nearest */ Loading @@ -739,9 +737,7 @@ void ivas_reverb_get_hrtf_set_properties( relative_pos = 1.0f; } } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB } #endif /* Computing 2 bins data for later interpolation */ Loading lib_util/hrtf_file_reader.c +0 −26 Original line number Diff line number Diff line Loading @@ -448,32 +448,24 @@ static ivas_error set_default_reverb_iac_energy( ) { int16_t i; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; #endif if ( HrFiltSet_p == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB lr_iac_len = LR_IAC_LENGTH_NR_FC; if ( HrFiltSet_p->SampleRate == 16000 ) { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif if ( HrFiltSet_p->ModelParams.modelROM == 0 ) { for ( i = 0; i < 3; i++ ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( lr_iac_len * sizeof( float ) ); #else HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); #endif if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); Loading @@ -492,15 +484,9 @@ static ivas_error set_default_reverb_iac_energy( mvr2r( defaultHRIR_coherence_32kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], LR_IAC_LENGTH_NR_FC ); break; case 16000: #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB mvr2r( defaultHRIR_left_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[0], lr_iac_len ); mvr2r( defaultHRIR_right_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[1], lr_iac_len ); mvr2r( defaultHRIR_coherence_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], lr_iac_len ); #else mvr2r( defaultHRIR_left_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[0], LR_IAC_LENGTH_NR_FC ); mvr2r( defaultHRIR_right_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[1], LR_IAC_LENGTH_NR_FC ); mvr2r( defaultHRIR_coherence_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], LR_IAC_LENGTH_NR_FC ); #endif break; } } Loading Loading @@ -557,7 +543,6 @@ static ivas_error load_reverb_from_binary( ivas_hrtfs_header_t hrtf_header; int32_t hrtf_data_size_max; char *hrtf_data; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES Loading @@ -578,7 +563,6 @@ static ivas_error load_reverb_from_binary( { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif header_check_result = IVAS_ERR_OK; Loading Loading @@ -650,7 +634,6 @@ static ivas_error load_reverb_from_binary( /* left/right energy and interaural coherence for late reverb */ for ( i = 0; i < 3; i++ ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( lr_iac_len * sizeof( float ) ); if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { Loading @@ -658,15 +641,6 @@ static ivas_error load_reverb_from_binary( } fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), lr_iac_len, f_hrtf ); HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #else HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf ); HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #endif } #endif } Loading scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +0 −79 Original line number Diff line number Diff line Loading @@ -1316,7 +1316,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define IVAS_REVERB_FFT_SIZE_48K ( 512 ) #define IVAS_REVERB_FFT_SIZE_32K ( 512 ) Loading Loading @@ -1351,7 +1350,6 @@ static uint16_t get_fft_size( return 0; } #endif /*-------------------------------------------------------------------* * ivas_reverb_get_hrtf_set_properties() Loading Loading @@ -1412,14 +1410,12 @@ void ivas_reverb_get_hrtf_set_properties( const float norm_freq = out_freq_step * out_bin_idx; /* Computing the bin index in the source data */ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( in_freq_count == out_freq_count ) { base_idx = out_bin_idx; } else { #endif const float tbl_index = ( norm_freq - inp_freq_offset ) / inp_freq_step; if ( tbl_index <= 0.0f ) /* In case of extrapolation (below 1st bin), choose nearest */ Loading @@ -1437,9 +1433,7 @@ void ivas_reverb_get_hrtf_set_properties( relative_pos = 1.0f; } } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB } #endif /* Computing 2 bins data for later interpolation */ /* Zeroing before accumalation for average value computing */ Loading Loading @@ -1744,9 +1738,7 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) if ( frame_len_ms == 5 ) frame_len = frame_len >> 2; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB frame_len = get_fft_size( frame_len ); #endif data_IR_current = sofa_data_IR_val_48k; sofa_N = sofa_N_48k; Loading Loading @@ -1788,7 +1780,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) float **pHrtf_set_r_im = NULL; float *pTemp = NULL; int16_t nr_fc_fft_filter = LR_IAC_LENGTH_NR_FC; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB nr_fc_fft_filter = ( frame_len >> 1 ) + 1; float *p_avg_lr = NULL; float *pCoherence = NULL; Loading @@ -1796,10 +1787,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) pCoherence = (float *) malloc( sizeof( float * ) * nr_fc_fft_filter ); memset( p_avg_lr, 0, sizeof( float ) * nr_fc_fft_filter * 2 ); memset( pCoherence, 0, sizeof( float ) * nr_fc_fft_filter ); #else float p_avg_lr[LR_IAC_LENGTH_NR_FC * 2] = { 0 }; float pCoherence[LR_IAC_LENGTH_NR_FC] = { 0 }; #endif pHrtf_set_l_re = (float **) malloc( sizeof( float * ) * sofa_M ); pHrtf_set_l_im = (float **) malloc( sizeof( float * ) * sofa_M ); Loading @@ -1818,14 +1805,10 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) { pTemp[n] = (float) ( data_IR_current[size * i + n] * (double) mdft_scale_fact ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB memcpy( pHrtf_set_l_re[i], pTemp, frame_len ); memset( pHrtf_set_l_im[i], 0, frame_len ); DoRTFTn( pHrtf_set_l_re[i], pHrtf_set_l_im[i], frame_len ); #else ivas_mdft( pTemp, pHrtf_set_l_re[i], pHrtf_set_l_im[i], frame_len, frame_len ); #endif pHrtf_set_r_re[i] = (float *) malloc( sizeof( float ) * ( frame_len ) ); memset( pHrtf_set_r_re[i], 0, sizeof( float ) * frame_len ); Loading @@ -1836,22 +1819,14 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) { pTemp[n] = (float) ( data_IR_current[size * i + sofa_N + n] * (double) mdft_scale_fact ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB memcpy( pHrtf_set_r_re[i], pTemp, frame_len ); memset( pHrtf_set_r_im[i], 0, frame_len ); DoRTFTn( pHrtf_set_r_re[i], pHrtf_set_r_im[i], frame_len ); #else ivas_mdft( pTemp, pHrtf_set_r_re[i], pHrtf_set_r_im[i], frame_len, frame_len ); #endif } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, IVAS_AUDIO_CONFIG_5_1, sofa_M, nr_fc_fft_filter, nr_fc_fft_filter, p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence ); #else ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, IVAS_AUDIO_CONFIG_5_1, sofa_M, frame_len, nr_fc_fft_filter, p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence ); #endif update_h_file_with_reverb( sample_rates[indSR] ); update_c_file_with_reverb( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], nr_fc_fft_filter ); Loading Loading @@ -1889,7 +1864,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) free( pTemp ); pTemp = NULL; } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( pCoherence ) { free( pCoherence ); Loading @@ -1900,7 +1874,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) free( p_avg_lr ); p_avg_lr = NULL; } #endif } /* close the file */ Loading Loading @@ -2021,13 +1994,11 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 *---------------------------------------------------------------------*/ void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate, const int16_t len ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB char len_str[26] = "LR_IAC_LENGTH_NR_FC"; if ( samplerate == 16000 ) { strcpy( len_str, "LR_IAC_LENGTH_NR_FC_16KHZ" ); } #endif if ( c_file_path == NULL ) return; Loading Loading @@ -2055,29 +2026,17 @@ void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherenc fprintf( fp, "\n/* Sample Rate = %ld */\n", (long) samplerate ); /* float *defaultHRIR_right_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_coherence_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_coherence_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pCoherence, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); /* float *defaultHRIR_left_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_left_avg_power_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_left_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pEner_l, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); /* float *defaultHRIR_right_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_right_avg_power_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_right_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pEner_r, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); Loading Loading @@ -2308,13 +2267,11 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int *---------------------------------------------------------------------*/ void update_h_file_with_reverb( int32_t samplerate ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB char len_str[26] = "LR_IAC_LENGTH_NR_FC"; if ( samplerate == 16000 ) { strcpy( len_str, "LR_IAC_LENGTH_NR_FC_16KHZ" ); } #endif if ( h_file_path == NULL ) return; Loading @@ -2334,22 +2291,10 @@ void update_h_file_with_reverb( int32_t samplerate ) fprintf( fp, "\n/* Sample Rate = %ld */\n", (long) samplerate ); /* float *defaultHRIR_coherence_[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_coherence_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_coherence_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif /* float *defaultHRIR_left_avg_power[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_left_avg_power_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_left_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif /* float *defaultHRIR_right_avg_power[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_right_avg_power_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_right_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif if ( samplerate == LAST_SAMPLERATE ) { Loading Loading @@ -2869,13 +2814,11 @@ void write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCohere char *binary_file_full_path = NULL; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t len = LR_IAC_LENGTH_NR_FC; if ( samplerate == 16000 ) { len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif if ( pEner_l == NULL ) return; Loading @@ -2890,53 +2833,31 @@ void write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCohere return; hrtf_bin = NULL; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_data_size = sizeof( float ) * 3 * len; #else hrtf_data_size = sizeof( float ) * 3 * LR_IAC_LENGTH_NR_FC; #endif hrtf_bin = (char *) malloc( hrtf_data_size ); if ( hrtf_bin == NULL ) return; memset( hrtf_bin, 0x00, hrtf_data_size ); hrtf_bin_wptr = hrtf_bin; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB for ( iTap = 0; iTap < len; iTap++ ) #else for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pEner_l[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; for ( iTap = 0; iTap < len; iTap++ ) #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pEner_r[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; for ( iTap = 0; iTap < len; iTap++ ) #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pCoherence[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; #endif binary_file_full_path = (char *) malloc( sizeof( char ) * ( strlen( binary_file_path ) + 1 + strlen( "Reverb" ) + 1 + 5 + 3 + 4 ) ); sprintf( binary_file_full_path, "%s_%s_%ikHz.bin", binary_file_path, "Reverb", samplerate / 1000 ); Loading Loading
lib_com/ivas_cnst.h +0 −4 Original line number Diff line number Diff line Loading @@ -1663,15 +1663,11 @@ typedef enum #define RV_FILTER_MAX_FFT_SIZE ( 512 ) #define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */ #define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 #endif #define IVAS_REVERB_DEFAULT_N_BANDS 31 #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) #endif /*----------------------------------------------------------------------------------* Loading
lib_com/options.h +0 −1 Original line number Diff line number Diff line Loading @@ -160,7 +160,6 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ #define NONBE_FIX_AVG_IAC_CLDFB_REVERB /* Orange: Add computation avg energy and iac tables for rom and binaural binary file */ #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define NONBE_FIX_935_SBA_REVERB /* FhG: issue 935: fix MSAN error for SBA related to BINAURAL_ROOM_REVERB */ Loading
lib_rend/ivas_reverb_filter_design.c +0 −4 Original line number Diff line number Diff line Loading @@ -714,14 +714,12 @@ void ivas_reverb_get_hrtf_set_properties( const float norm_freq = out_freq_step * out_bin_idx; /* Computing the bin index in the source data */ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( in_freq_count == out_freq_count ) { base_idx = out_bin_idx; } else { #endif const float tbl_index = ( norm_freq - inp_freq_offset ) / inp_freq_step; if ( tbl_index <= 0.0f ) /* In case of extrapolation (below 1st bin), choose nearest */ Loading @@ -739,9 +737,7 @@ void ivas_reverb_get_hrtf_set_properties( relative_pos = 1.0f; } } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB } #endif /* Computing 2 bins data for later interpolation */ Loading
lib_util/hrtf_file_reader.c +0 −26 Original line number Diff line number Diff line Loading @@ -448,32 +448,24 @@ static ivas_error set_default_reverb_iac_energy( ) { int16_t i; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; #endif if ( HrFiltSet_p == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB lr_iac_len = LR_IAC_LENGTH_NR_FC; if ( HrFiltSet_p->SampleRate == 16000 ) { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif if ( HrFiltSet_p->ModelParams.modelROM == 0 ) { for ( i = 0; i < 3; i++ ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( lr_iac_len * sizeof( float ) ); #else HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); #endif if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); Loading @@ -492,15 +484,9 @@ static ivas_error set_default_reverb_iac_energy( mvr2r( defaultHRIR_coherence_32kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], LR_IAC_LENGTH_NR_FC ); break; case 16000: #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB mvr2r( defaultHRIR_left_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[0], lr_iac_len ); mvr2r( defaultHRIR_right_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[1], lr_iac_len ); mvr2r( defaultHRIR_coherence_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], lr_iac_len ); #else mvr2r( defaultHRIR_left_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[0], LR_IAC_LENGTH_NR_FC ); mvr2r( defaultHRIR_right_avg_power_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[1], LR_IAC_LENGTH_NR_FC ); mvr2r( defaultHRIR_coherence_16kHz, HrFiltSet_p->lr_energy_and_iac_dyn[2], LR_IAC_LENGTH_NR_FC ); #endif break; } } Loading Loading @@ -557,7 +543,6 @@ static ivas_error load_reverb_from_binary( ivas_hrtfs_header_t hrtf_header; int32_t hrtf_data_size_max; char *hrtf_data; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES Loading @@ -578,7 +563,6 @@ static ivas_error load_reverb_from_binary( { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif header_check_result = IVAS_ERR_OK; Loading Loading @@ -650,7 +634,6 @@ static ivas_error load_reverb_from_binary( /* left/right energy and interaural coherence for late reverb */ for ( i = 0; i < 3; i++ ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( lr_iac_len * sizeof( float ) ); if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { Loading @@ -658,15 +641,6 @@ static ivas_error load_reverb_from_binary( } fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), lr_iac_len, f_hrtf ); HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #else HrFiltSet_p->lr_energy_and_iac_dyn[i] = (float *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); if ( HrFiltSet_p->lr_energy_and_iac_dyn[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( HrFiltSet_p->lr_energy_and_iac_dyn[i], sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf ); HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #endif } #endif } Loading
scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +0 −79 Original line number Diff line number Diff line Loading @@ -1316,7 +1316,6 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define IVAS_REVERB_FFT_SIZE_48K ( 512 ) #define IVAS_REVERB_FFT_SIZE_32K ( 512 ) Loading Loading @@ -1351,7 +1350,6 @@ static uint16_t get_fft_size( return 0; } #endif /*-------------------------------------------------------------------* * ivas_reverb_get_hrtf_set_properties() Loading Loading @@ -1412,14 +1410,12 @@ void ivas_reverb_get_hrtf_set_properties( const float norm_freq = out_freq_step * out_bin_idx; /* Computing the bin index in the source data */ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( in_freq_count == out_freq_count ) { base_idx = out_bin_idx; } else { #endif const float tbl_index = ( norm_freq - inp_freq_offset ) / inp_freq_step; if ( tbl_index <= 0.0f ) /* In case of extrapolation (below 1st bin), choose nearest */ Loading @@ -1437,9 +1433,7 @@ void ivas_reverb_get_hrtf_set_properties( relative_pos = 1.0f; } } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB } #endif /* Computing 2 bins data for later interpolation */ /* Zeroing before accumalation for average value computing */ Loading Loading @@ -1744,9 +1738,7 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) if ( frame_len_ms == 5 ) frame_len = frame_len >> 2; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB frame_len = get_fft_size( frame_len ); #endif data_IR_current = sofa_data_IR_val_48k; sofa_N = sofa_N_48k; Loading Loading @@ -1788,7 +1780,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) float **pHrtf_set_r_im = NULL; float *pTemp = NULL; int16_t nr_fc_fft_filter = LR_IAC_LENGTH_NR_FC; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB nr_fc_fft_filter = ( frame_len >> 1 ) + 1; float *p_avg_lr = NULL; float *pCoherence = NULL; Loading @@ -1796,10 +1787,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) pCoherence = (float *) malloc( sizeof( float * ) * nr_fc_fft_filter ); memset( p_avg_lr, 0, sizeof( float ) * nr_fc_fft_filter * 2 ); memset( pCoherence, 0, sizeof( float ) * nr_fc_fft_filter ); #else float p_avg_lr[LR_IAC_LENGTH_NR_FC * 2] = { 0 }; float pCoherence[LR_IAC_LENGTH_NR_FC] = { 0 }; #endif pHrtf_set_l_re = (float **) malloc( sizeof( float * ) * sofa_M ); pHrtf_set_l_im = (float **) malloc( sizeof( float * ) * sofa_M ); Loading @@ -1818,14 +1805,10 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) { pTemp[n] = (float) ( data_IR_current[size * i + n] * (double) mdft_scale_fact ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB memcpy( pHrtf_set_l_re[i], pTemp, frame_len ); memset( pHrtf_set_l_im[i], 0, frame_len ); DoRTFTn( pHrtf_set_l_re[i], pHrtf_set_l_im[i], frame_len ); #else ivas_mdft( pTemp, pHrtf_set_l_re[i], pHrtf_set_l_im[i], frame_len, frame_len ); #endif pHrtf_set_r_re[i] = (float *) malloc( sizeof( float ) * ( frame_len ) ); memset( pHrtf_set_r_re[i], 0, sizeof( float ) * frame_len ); Loading @@ -1836,22 +1819,14 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) { pTemp[n] = (float) ( data_IR_current[size * i + sofa_N + n] * (double) mdft_scale_fact ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB memcpy( pHrtf_set_r_re[i], pTemp, frame_len ); memset( pHrtf_set_r_im[i], 0, frame_len ); DoRTFTn( pHrtf_set_r_re[i], pHrtf_set_r_im[i], frame_len ); #else ivas_mdft( pTemp, pHrtf_set_r_re[i], pHrtf_set_r_im[i], frame_len, frame_len ); #endif } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, IVAS_AUDIO_CONFIG_5_1, sofa_M, nr_fc_fft_filter, nr_fc_fft_filter, p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence ); #else ivas_reverb_get_hrtf_set_properties( pHrtf_set_l_re, pHrtf_set_l_im, pHrtf_set_r_re, pHrtf_set_r_im, IVAS_AUDIO_CONFIG_5_1, sofa_M, frame_len, nr_fc_fft_filter, p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence ); #endif update_h_file_with_reverb( sample_rates[indSR] ); update_c_file_with_reverb( p_avg_lr, &p_avg_lr[nr_fc_fft_filter], pCoherence, sample_rates[indSR], nr_fc_fft_filter ); Loading Loading @@ -1889,7 +1864,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) free( pTemp ); pTemp = NULL; } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( pCoherence ) { free( pCoherence ); Loading @@ -1900,7 +1874,6 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) free( p_avg_lr ); p_avg_lr = NULL; } #endif } /* close the file */ Loading Loading @@ -2021,13 +1994,11 @@ void write_array_uint16_to_file( FILE *fp, uint16_t *vec, int32_t size_vec, int3 *---------------------------------------------------------------------*/ void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherence, const int32_t samplerate, const int16_t len ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB char len_str[26] = "LR_IAC_LENGTH_NR_FC"; if ( samplerate == 16000 ) { strcpy( len_str, "LR_IAC_LENGTH_NR_FC_16KHZ" ); } #endif if ( c_file_path == NULL ) return; Loading Loading @@ -2055,29 +2026,17 @@ void update_c_file_with_reverb( float *pEner_l, float *pEner_r, float *pCoherenc fprintf( fp, "\n/* Sample Rate = %ld */\n", (long) samplerate ); /* float *defaultHRIR_right_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_coherence_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_coherence_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pCoherence, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); /* float *defaultHRIR_left_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_left_avg_power_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_left_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pEner_l, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); /* float *defaultHRIR_right_avg_power_[LR_IAC_LENGTH_NR_FC];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nconst float defaultHRIR_right_avg_power_%dkHz[%s] = \n", samplerate / 1000, len_str ); #else fprintf( fp, "\nconst float defaultHRIR_right_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC] = \n", samplerate / 1000 ); #endif write_array_float_to_file( fp, pEner_r, len, NUM_SAMPLES_PER_LINES_REVERB, FORMAT_FLOAT, 2, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";\n" ); Loading Loading @@ -2308,13 +2267,11 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int *---------------------------------------------------------------------*/ void update_h_file_with_reverb( int32_t samplerate ) { #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB char len_str[26] = "LR_IAC_LENGTH_NR_FC"; if ( samplerate == 16000 ) { strcpy( len_str, "LR_IAC_LENGTH_NR_FC_16KHZ" ); } #endif if ( h_file_path == NULL ) return; Loading @@ -2334,22 +2291,10 @@ void update_h_file_with_reverb( int32_t samplerate ) fprintf( fp, "\n/* Sample Rate = %ld */\n", (long) samplerate ); /* float *defaultHRIR_coherence_[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_coherence_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_coherence_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif /* float *defaultHRIR_left_avg_power[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_left_avg_power_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_left_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif /* float *defaultHRIR_right_avg_power[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS];*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fprintf( fp, "\nextern float defaultHRIR_right_avg_power_%dkHz[%s];", samplerate / 1000, len_str ); #else fprintf( fp, "\nextern float defaultHRIR_right_avg_power_%dkHz[LR_IAC_LENGTH_NR_FC];", samplerate / 1000 ); #endif if ( samplerate == LAST_SAMPLERATE ) { Loading Loading @@ -2869,13 +2814,11 @@ void write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCohere char *binary_file_full_path = NULL; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t len = LR_IAC_LENGTH_NR_FC; if ( samplerate == 16000 ) { len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif if ( pEner_l == NULL ) return; Loading @@ -2890,53 +2833,31 @@ void write_reverb_to_binary_file( float *pEner_l, float *pEner_r, float *pCohere return; hrtf_bin = NULL; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_data_size = sizeof( float ) * 3 * len; #else hrtf_data_size = sizeof( float ) * 3 * LR_IAC_LENGTH_NR_FC; #endif hrtf_bin = (char *) malloc( hrtf_data_size ); if ( hrtf_bin == NULL ) return; memset( hrtf_bin, 0x00, hrtf_data_size ); hrtf_bin_wptr = hrtf_bin; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB for ( iTap = 0; iTap < len; iTap++ ) #else for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pEner_l[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; for ( iTap = 0; iTap < len; iTap++ ) #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pEner_r[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; for ( iTap = 0; iTap < len; iTap++ ) #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; for ( iTap = 0; iTap < LR_IAC_LENGTH_NR_FC; iTap++ ) #endif { sprintf( tmpStr, FORMAT_FLOAT, pCoherence[iTap] ); sscanf( tmpStr, "%f", &( ( (float *) hrtf_bin_wptr )[iTap] ) ); } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB hrtf_bin_wptr += sizeof( float ) * len; #else hrtf_bin_wptr += sizeof( float ) * LR_IAC_LENGTH_NR_FC; #endif binary_file_full_path = (char *) malloc( sizeof( char ) * ( strlen( binary_file_path ) + 1 + strlen( "Reverb" ) + 1 + 5 + 3 + 4 ) ); sprintf( binary_file_full_path, "%s_%s_%ikHz.bin", binary_file_path, "Reverb", samplerate / 1000 ); Loading