diff --git a/apps/decoder.c b/apps/decoder.c index 7c13aa693f58fbc5c129c804c1126879c296858e..760021ea7fc5d237e4d14b60dbd6cec29699d1fb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -797,6 +797,29 @@ int main( #ifdef NONBE_FIX_BINARY_BINAURAL_READING if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { +#ifdef FIX_OLD_BINARY_FORMAT + cleanup_SetOfHRTF( hSetOfHRTF ); + hrtfFileReader_close( &hrtfReader ); + strcat( arg.hrtfFileName, "new" ); + + if ( hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } + if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } + else + { + destroy_SetOfHRTF( hSetOfHRTF ); + } + } +#else if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); @@ -806,6 +829,7 @@ int main( { destroy_SetOfHRTF( hSetOfHRTF ); } +#endif } #else if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) diff --git a/apps/renderer.c b/apps/renderer.c index 449df94dca4331cd388f12002c5f245adca44564..07222e33cdcc1b2e198d672b566e4dbe94c39efc 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1094,6 +1094,28 @@ int main( if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) { +#ifdef FIX_OLD_BINARY_FORMAT + cleanup_SetOfHRTF( hSetOfHRTF ); + hrtfFileReader_close( &hrtfFileReader ); + strcat( args.customHrtfFilePath, "new" ); + if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); + goto cleanup; + } + if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); + goto cleanup; + } + else + { + destroy_SetOfHRTF( hSetOfHRTF ); + } + } +#else if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); @@ -1103,6 +1125,7 @@ int main( { destroy_SetOfHRTF( hSetOfHRTF ); } +#endif } if ( ( error = IVAS_REND_GetHrtfFastConvHandle( hIvasRend, &hHrtfFastConv ) ) != IVAS_ERR_OK ) diff --git a/lib_com/options.h b/lib_com/options.h index 8ff5ac61340ada342f8ea24172a9157aa249afb3..820383e905426866979a7b35c7cec77558c5f3b1 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,9 +152,12 @@ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define FIX_954_OTR_REF_VEC /* FhG: Fix forward vector direction for OTR REF VEC mode */ -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange : Missing left/right and coherence late reverb tables in binary format*/ #define FIX_OLD_BINARY_FORMAT /* Orange: temporary to maintain bitexactness */ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ +#define FIX_WARNING_SPLIT_RENDER /* Orange: fix warning on windows build vscode */ +#define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural reverb*/ +#define FIX_20_MS_FRAME_LEN_TABLES_CONVERTER /* Orange : generate_tables_converter tools can generate rom for 5 and 20 ms frame length */ #define FIX_958_667_DISABLE_INITIAL_PLC_SUPPRESSION /* Ericsson: Fix related to issue 667 in IVAS BASOP. Handling of initial lost frame in IVAS causes non-BE on EVS BASOP 26.444 */ #define FIX_957_REMOVE_PANNING_DEAD_CODE /* VA: Remove obsolete non-diegetic panning related code. */ #define FIX_956_DECODER_COMMAND_LINE_FIX /* VA: Output correct error message when the decoder command-line has too many mandatory arguments. */ diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index abdc527c737b6f79bb8cbe3272e8ea0927237e86..26462c3a246f6009bf216c6142faabcb7dd4fe36 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -69,12 +69,20 @@ ivas_error ivas_hrtf_init( hHrtf->max_num_iterations = 0; hHrtf->gain_lfe = 0; hHrtf->index_frequency_max_diffuse = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->same_inv_diffuse_weight = 1; +#endif for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = 0; +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = 0; +#endif hHrtf->num_iterations[i][j] = 0; hHrtf->pIndex_frequency_max[i][j] = NULL; hHrtf->pOut_to_bin_re[i][j] = NULL; @@ -364,6 +372,7 @@ static ivas_error ivas_rend_initCrend( if ( output_Fs == 48000 ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[tmp]; @@ -372,11 +381,14 @@ static ivas_error ivas_rend_initCrend( { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[tmp]; } - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_48kHz[tmp][j]; @@ -384,6 +396,9 @@ static ivas_error ivas_rend_initCrend( } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_48kHz[tmp][j]; @@ -393,6 +408,7 @@ static ivas_error ivas_rend_initCrend( } else if ( output_Fs == 32000 ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[tmp]; @@ -401,11 +417,14 @@ static ivas_error ivas_rend_initCrend( { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[tmp]; } - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_32kHz[tmp][j]; @@ -413,6 +432,9 @@ static ivas_error ivas_rend_initCrend( } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_32kHz[tmp][j]; @@ -422,6 +444,7 @@ static ivas_error ivas_rend_initCrend( } else if ( output_Fs == 16000 ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[tmp]; @@ -430,11 +453,14 @@ static ivas_error ivas_rend_initCrend( { hHrtf->inv_diffuse_weight[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[tmp]; } - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_BRIR_coeff_re_16kHz[tmp][j]; @@ -442,6 +468,9 @@ static ivas_error ivas_rend_initCrend( } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[j][tmp]; +#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_Combined_HRIR_coeff_re_16kHz[tmp][j]; @@ -467,10 +496,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_48kHz[i][j]; @@ -493,10 +526,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_32kHz[i][j]; @@ -520,10 +557,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA3_HRIR_coeff_re_16kHz[i][j]; @@ -554,10 +595,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_48kHz[i][j]; @@ -580,10 +625,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_32kHz[i][j]; @@ -607,10 +656,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz[i][j]; @@ -641,10 +694,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_48kHz[i][j]; @@ -667,10 +724,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_32kHz[i][j]; @@ -694,10 +755,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[j][i]; +#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[i][j]; hHrtf->pOut_to_bin_re[i][j] = CRendBin_FOA_HRIR_coeff_re_16kHz[i][j]; @@ -807,7 +872,7 @@ static ivas_error ivas_rend_initCrend( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); } - +#ifndef FIX_INV_DIFFUSE_WEIGHT if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { hHrtf->inv_diffuse_weight[i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[tmp]; @@ -816,11 +881,15 @@ static ivas_error ivas_rend_initCrend( { hHrtf->inv_diffuse_weight[i] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight[tmp]; } +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[j][tmp]; +#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_re[tmp][j]; @@ -828,6 +897,9 @@ static ivas_error ivas_rend_initCrend( } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight[j][tmp]; +#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max[tmp][j]; hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re[tmp][j]; @@ -852,10 +924,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight[j][i]; +#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max[i][j]; hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pOut_to_bin_re[i][j]; @@ -884,10 +960,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight[j][i]; +#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max[i][j]; hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pOut_to_bin_re[i][j]; @@ -916,10 +996,14 @@ static ivas_error ivas_rend_initCrend( for ( i = 0; i < hHrtf->max_num_ir; i++ ) { +#ifndef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight[i] = hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight[i]; - +#endif for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight[j][i]; +#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max[i][j]; hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pOut_to_bin_re[i][j]; @@ -941,6 +1025,20 @@ static ivas_error ivas_rend_initCrend( } } +#ifdef FIX_INV_DIFFUSE_WEIGHT + hHrtf->same_inv_diffuse_weight = 1; + for ( i = 0; i < hHrtf->max_num_ir; i++ ) + { + if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + if ( hHrtf->inv_diffuse_weight[0][i] != hHrtf->inv_diffuse_weight[1][i] ) + { + hHrtf->same_inv_diffuse_weight = 0; + } + } + } +#endif + pCrend->hHrtfCrend = hHrtf; return IVAS_ERR_OK; @@ -1225,8 +1323,15 @@ ivas_error ivas_rend_initCrendWrapper( hCrend->prev_out_buffer[i] = NULL; } +#ifdef FIX_INV_DIFFUSE_WEIGHT + hCrend->freq_buffer_re_diffuse[0] = NULL; + hCrend->freq_buffer_re_diffuse[1] = NULL; + hCrend->freq_buffer_im_diffuse[0] = NULL; + hCrend->freq_buffer_im_diffuse[1] = NULL; +#else hCrend->freq_buffer_re_diffuse = NULL; hCrend->freq_buffer_im_diffuse = NULL; +#endif hCrend->hReverb = NULL; hCrend->reflections = NULL; hCrend->delay_line_rw_index = 0; @@ -1370,22 +1475,81 @@ ivas_error ivas_rend_openCrend( if ( max_total_ir_len > 0 ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( ( hCrend->freq_buffer_re_diffuse[0] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + if ( hHrtf->same_inv_diffuse_weight == 0 ) + { + if ( ( hCrend->freq_buffer_re_diffuse[1] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + } + else + { + hCrend->freq_buffer_re_diffuse[1] = NULL; + } +#else if ( ( hCrend->freq_buffer_re_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#endif +#ifdef FIX_INV_DIFFUSE_WEIGHT + set_zero_l( hCrend->freq_buffer_re_diffuse[0], max_total_ir_len ); + if ( hCrend->freq_buffer_re_diffuse[1] != NULL ) + { + set_zero_l( hCrend->freq_buffer_re_diffuse[1], max_total_ir_len ); + } +#else set_zero_l( hCrend->freq_buffer_re_diffuse, max_total_ir_len ); +#endif +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( ( hCrend->freq_buffer_im_diffuse[0] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + if ( hHrtf->same_inv_diffuse_weight == 0 ) + { + if ( ( hCrend->freq_buffer_im_diffuse[1] = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + } + else + { + hCrend->freq_buffer_im_diffuse[1] = NULL; + } +#else if ( ( hCrend->freq_buffer_im_diffuse = (float *) malloc( sizeof( float ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } +#endif +#ifdef FIX_INV_DIFFUSE_WEIGHT + set_zero_l( hCrend->freq_buffer_im_diffuse[0], max_total_ir_len ); + if ( hCrend->freq_buffer_im_diffuse[1] != NULL ) + { + set_zero_l( hCrend->freq_buffer_im_diffuse[1], max_total_ir_len ); + } +#else set_zero_l( hCrend->freq_buffer_im_diffuse, max_total_ir_len ); +#endif } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + hCrend->freq_buffer_re_diffuse[0] = NULL; + hCrend->freq_buffer_im_diffuse[0] = NULL; + hCrend->freq_buffer_re_diffuse[1] = NULL; + hCrend->freq_buffer_im_diffuse[1] = NULL; +#else hCrend->freq_buffer_re_diffuse = NULL; hCrend->freq_buffer_im_diffuse = NULL; +#endif } max_total_ir_len = (int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length; @@ -1533,7 +1697,31 @@ void ivas_rend_closeCrend( free( hCrend->lfe_delay_line ); hCrend->lfe_delay_line = NULL; } +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( hCrend->freq_buffer_re_diffuse[0] != NULL ) + { + free( hCrend->freq_buffer_re_diffuse[0] ); + hCrend->freq_buffer_re_diffuse[0] = NULL; + } + if ( hCrend->freq_buffer_im_diffuse[0] != NULL ) + { + free( hCrend->freq_buffer_im_diffuse[0] ); + hCrend->freq_buffer_im_diffuse[0] = NULL; + } + + if ( hCrend->freq_buffer_re_diffuse[1] != NULL ) + { + free( hCrend->freq_buffer_re_diffuse[1] ); + hCrend->freq_buffer_re_diffuse[1] = NULL; + } + + if ( hCrend->freq_buffer_im_diffuse[1] != NULL ) + { + free( hCrend->freq_buffer_im_diffuse[1] ); + hCrend->freq_buffer_im_diffuse[1] = NULL; + } +#else if ( hCrend->freq_buffer_re_diffuse != NULL ) { free( hCrend->freq_buffer_re_diffuse ); @@ -1545,6 +1733,7 @@ void ivas_rend_closeCrend( free( hCrend->freq_buffer_im_diffuse ); hCrend->freq_buffer_im_diffuse = NULL; } +#endif if ( hCrend->hTrack != NULL ) { @@ -1642,6 +1831,9 @@ static ivas_error ivas_rend_crendConvolver( int16_t nchan_in, nchan_out; const float *pIn; float *pFreq_buf_re, *pFreq_buf_im; +#ifdef FIX_INV_DIFFUSE_WEIGHT + float *pFreq_buf2_re, *pFreq_buf2_im; +#endif const float *pFreq_filt_re, *pFreq_filt_im; float pOut[L_FRAME48k * 2]; float tmp_out_re[L_FRAME48k], tmp_out_im[L_FRAME48k]; @@ -1684,8 +1876,18 @@ static ivas_error ivas_rend_crendConvolver( if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + set_zero( &hCrend->freq_buffer_re_diffuse[0][offset_diffuse], subframe_length ); + set_zero( &hCrend->freq_buffer_im_diffuse[0][offset_diffuse], subframe_length ); + if ( pCrend->hHrtfCrend->same_inv_diffuse_weight == 0 ) + { + set_zero( &hCrend->freq_buffer_re_diffuse[1][offset_diffuse], subframe_length ); + set_zero( &hCrend->freq_buffer_im_diffuse[1][offset_diffuse], subframe_length ); + } +#else set_zero( &hCrend->freq_buffer_re_diffuse[offset_diffuse], subframe_length ); set_zero( &hCrend->freq_buffer_im_diffuse[offset_diffuse], subframe_length ); +#endif } i = 0; @@ -1694,6 +1896,41 @@ static ivas_error ivas_rend_crendConvolver( pIn = &pcm_in[idx_in][i_ts * subframe_length]; if ( idx_in != lfe_idx_in ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) + { + if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) + { + pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; + pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; + pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; + pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; + + for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ ) + { + pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i]; + pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i]; + } + } + else + { + pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; + pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; + pFreq_buf2_re = &hCrend->freq_buffer_re_diffuse[1][offset_diffuse]; + pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse[1][offset_diffuse]; + pFreq_filt_re = &hCrend->freq_buffer_re[i][offset]; + pFreq_filt_im = &hCrend->freq_buffer_im[i][offset]; + + for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ ) + { + pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i]; + pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[0][i]; + pFreq_buf2_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight[1][i]; + pFreq_buf2_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[1][i]; + } + } + } +#else if ( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[offset_diffuse]; @@ -1707,6 +1944,7 @@ static ivas_error ivas_rend_crendConvolver( pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight[i]; } } +#endif pFreq_buf_re = &hCrend->freq_buffer_re[i][offset]; pFreq_buf_im = &hCrend->freq_buffer_im[i][offset]; @@ -1754,8 +1992,21 @@ static ivas_error ivas_rend_crendConvolver( offset_diffuse = ( hCrend->diffuse_delay_line_rw_index + m + 1 ); offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0]; offset_diffuse = offset_diffuse * subframe_length; +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) + { + pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[0][offset_diffuse]; + pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[0][offset_diffuse]; + } + else + { + pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[j][offset_diffuse]; + pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[j][offset_diffuse]; + } +#else pFreq_buf_re = &hCrend->freq_buffer_re_diffuse[offset_diffuse]; pFreq_buf_im = &hCrend->freq_buffer_im_diffuse[offset_diffuse]; +#endif pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re[j][offset]; pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im[j][offset]; diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index c5574e73608d0569139977f416d97db48299995b..6cb087fa301997ca988e0794dc19162540b8ea67 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -62,7 +62,11 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[HRTF_LS_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_Combined_HRIR_coeff_re_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]={ { @@ -318,7 +322,11 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[HRTF_LS_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_Combined_HRIR_coeff_re_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]={ { @@ -514,7 +522,11 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[HRTF_LS_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_Combined_HRIR_coeff_re_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]={ { @@ -656,7 +668,11 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[FOA_CHANNELS][BINAURAL_CHA const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][FOA_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[FOA_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_FOA_HRIR_coeff_re_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][240]={ { @@ -736,7 +752,11 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[FOA_CHANNELS][BINAURAL_CHA const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][FOA_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[FOA_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_FOA_HRIR_coeff_re_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][160]={ { @@ -800,7 +820,11 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[FOA_CHANNELS][BINAURAL_CHA const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][FOA_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[FOA_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_FOA_HRIR_coeff_re_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][80]={ { @@ -854,7 +878,11 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[HOA2_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[HOA2_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA2_HRIR_coeff_re_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][240]={ { @@ -1014,7 +1042,11 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[HOA2_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[HOA2_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA2_HRIR_coeff_re_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][160]={ { @@ -1138,7 +1170,11 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[HOA2_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[HOA2_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA2_HRIR_coeff_re_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][80]={ { @@ -1232,7 +1268,11 @@ const uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[HOA3_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[HOA3_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA3_HRIR_coeff_re_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][240]={ { @@ -1504,7 +1544,11 @@ const uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[HOA3_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[HOA3_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA3_HRIR_coeff_re_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][160]={ { @@ -1712,7 +1756,11 @@ const uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[HOA3_CHANNELS][BINAURAL_C const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f},{0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}}; +#else const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[HOA3_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; +#endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float CRendBin_HOA3_HRIR_coeff_re_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][80]={ { @@ -1862,7 +1910,11 @@ const uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f},{0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}}; +#else const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[HRTF_LS_CHANNELS]={0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}; +#endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; const float CRendBin_Combined_BRIR_coeff_re_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]={ { @@ -3898,7 +3950,11 @@ const uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 136, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 136, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 138, 132, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 138, 132, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 127, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 127, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 122, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 124, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 122, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 124, 160}},{{115, 115, 115, 119, 121, 119, 124, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 139, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 124, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 139, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 128, 123, 128, 125, 130, 129, 131, 131, 130, 134, 133, 148, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 128, 123, 128, 125, 130, 129, 131, 131, 130, 134, 133, 148, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 123, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 123, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 125, 131, 122, 127, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 125, 131, 122, 127, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 126, 136, 128, 126, 127, 132, 132, 129, 125, 121, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 126, 136, 128, 126, 127, 132, 132, 129, 125, 121, 160}},{{99, 100, 111, 117, 114, 113, 118, 116, 121, 123, 124, 121, 125, 130, 127, 132, 132, 129, 133, 128, 131, 160},{99, 100, 111, 117, 114, 113, 118, 116, 121, 123, 124, 121, 125, 130, 127, 132, 132, 129, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 135, 127, 129, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 135, 127, 129, 160}},{{105, 100, 112, 114, 115, 108, 116, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 138, 154, 116, 160},{105, 100, 112, 114, 115, 108, 116, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 138, 154, 116, 160}},{{110, 106, 113, 110, 122, 116, 118, 125, 123, 127, 125, 127, 128, 127, 133, 129, 132, 132, 142, 147, 127, 160},{110, 106, 113, 110, 122, 116, 118, 125, 123, 127, 125, 127, 128, 127, 133, 129, 132, 132, 142, 147, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 134, 126, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 134, 126, 160}},{{110, 117, 106, 118, 118, 115, 121, 124, 128, 125, 122, 121, 126, 130, 124, 130, 133, 131, 137, 133, 131, 160},{110, 117, 106, 118, 118, 115, 121, 124, 128, 125, 122, 121, 126, 130, 124, 130, 133, 131, 137, 133, 131, 160}}}; const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.224196f, 0.227460f, 0.241819f, 0.207160f, 0.218132f, 0.222950f, 0.232154f, 0.248179f, 0.249232f, 0.261592f, 0.246334f, 0.279153f, 0.285801f, 0.262550f, 0.271878f},{0.224196f, 0.227460f, 0.241819f, 0.207160f, 0.218132f, 0.222950f, 0.232154f, 0.248179f, 0.249232f, 0.261592f, 0.246334f, 0.279153f, 0.285801f, 0.262550f, 0.271878f}}; +#else const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[HRTF_LS_CHANNELS]={0.224196f, 0.227460f, 0.241819f, 0.207160f, 0.218132f, 0.222950f, 0.232154f, 0.248179f, 0.249232f, 0.261592f, 0.246334f, 0.279153f, 0.285801f, 0.262550f, 0.271878f}; +#endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 62, 62, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 62, 62, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; const float CRendBin_Combined_BRIR_coeff_re_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2818]={ { @@ -5854,7 +5910,11 @@ const uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BIN const uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][23]={{{77, 77, 77, 79, 77, 78, 79, 79, 79, 77, 78, 77, 78, 78, 77, 79, 79, 79, 79, 78, 79, 77, 80},{77, 77, 77, 79, 77, 78, 79, 79, 79, 77, 78, 77, 78, 78, 77, 79, 79, 79, 79, 78, 79, 77, 80}},{{78, 77, 78, 78, 79, 79, 78, 78, 79, 79, 77, 79, 78, 79, 76, 79, 78, 78, 76, 79, 79, 78, 80},{78, 77, 78, 78, 79, 79, 78, 78, 79, 79, 77, 79, 78, 79, 76, 79, 78, 78, 76, 79, 79, 78, 80}},{{77, 76, 74, 79, 74, 77, 77, 77, 76, 79, 77, 78, 76, 78, 76, 78, 79, 78, 79, 79, 78, 78, 80},{77, 76, 74, 79, 74, 77, 77, 77, 76, 79, 77, 78, 76, 78, 76, 78, 79, 78, 79, 79, 78, 78, 80}},{{76, 78, 78, 78, 78, 79, 76, 77, 79, 78, 77, 79, 79, 79, 78, 79, 78, 77, 78, 79, 78, 78, 80},{76, 78, 78, 78, 78, 79, 76, 77, 79, 78, 77, 79, 79, 79, 78, 79, 78, 77, 78, 79, 78, 78, 80}},{{78, 77, 77, 76, 79, 77, 79, 78, 76, 78, 78, 78, 79, 79, 78, 78, 79, 78, 78, 79, 78, 77, 80},{78, 77, 77, 76, 79, 77, 79, 78, 76, 78, 78, 78, 79, 79, 78, 78, 79, 78, 78, 79, 78, 77, 80}},{{78, 76, 78, 77, 78, 78, 78, 78, 79, 78, 79, 79, 78, 78, 78, 77, 79, 77, 78, 79, 78, 78, 80},{78, 76, 78, 77, 78, 78, 78, 78, 79, 78, 79, 79, 78, 78, 78, 77, 79, 77, 78, 79, 78, 78, 80}},{{78, 76, 75, 78, 76, 78, 79, 77, 79, 78, 77, 77, 79, 79, 78, 77, 78, 79, 78, 79, 76, 78, 80},{78, 76, 75, 78, 76, 78, 79, 77, 79, 78, 77, 77, 79, 79, 78, 77, 78, 79, 78, 79, 76, 78, 80}},{{78, 76, 78, 77, 75, 77, 77, 79, 79, 79, 78, 79, 78, 79, 79, 78, 78, 79, 79, 79, 79, 76, 80},{78, 76, 78, 77, 75, 77, 77, 79, 79, 79, 78, 79, 78, 79, 79, 78, 78, 79, 79, 79, 79, 76, 80}},{{78, 79, 78, 76, 77, 78, 77, 77, 78, 78, 79, 79, 76, 78, 78, 79, 79, 79, 78, 79, 78, 77, 80},{78, 79, 78, 76, 77, 78, 77, 77, 78, 78, 79, 79, 76, 78, 78, 79, 79, 79, 78, 79, 78, 77, 80}},{{75, 75, 78, 78, 78, 79, 78, 78, 78, 78, 78, 79, 76, 78, 78, 78, 79, 79, 78, 79, 79, 76, 80},{75, 75, 78, 78, 78, 79, 78, 78, 78, 78, 78, 79, 76, 78, 78, 78, 79, 79, 78, 79, 79, 76, 80}},{{76, 76, 77, 76, 79, 79, 76, 79, 76, 77, 79, 77, 79, 77, 78, 75, 78, 79, 78, 79, 78, 79, 80},{76, 76, 77, 76, 79, 79, 76, 79, 76, 77, 79, 77, 79, 77, 78, 75, 78, 79, 78, 79, 78, 79, 80}},{{76, 79, 76, 74, 78, 78, 77, 77, 78, 79, 78, 78, 77, 77, 79, 77, 79, 78, 79, 79, 77, 78, 80},{76, 79, 76, 74, 78, 78, 77, 77, 78, 79, 78, 78, 77, 77, 79, 77, 79, 78, 79, 79, 77, 78, 80}},{{76, 78, 79, 78, 76, 78, 78, 78, 77, 78, 74, 77, 79, 78, 78, 79, 79, 79, 79, 79, 77, 79, 80},{76, 78, 79, 78, 76, 78, 78, 78, 77, 78, 74, 77, 79, 78, 78, 79, 79, 79, 79, 79, 77, 79, 80}},{{75, 78, 78, 76, 78, 77, 78, 78, 77, 78, 78, 79, 79, 79, 75, 77, 79, 79, 79, 76, 79, 77, 80},{75, 78, 78, 76, 78, 77, 78, 78, 77, 78, 78, 79, 79, 79, 75, 77, 79, 79, 79, 76, 79, 77, 80}},{{78, 77, 77, 78, 76, 78, 78, 76, 78, 79, 79, 79, 79, 79, 76, 79, 79, 79, 79, 76, 78, 79, 80},{78, 77, 77, 78, 76, 78, 78, 76, 78, 79, 79, 79, 79, 79, 76, 79, 79, 79, 79, 76, 78, 79, 80}}}; const uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; +#ifdef FIX_INV_DIFFUSE_WEIGHT +const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.222851f, 0.226528f, 0.249241f, 0.208677f, 0.219855f, 0.219498f, 0.230603f, 0.248624f, 0.251270f, 0.263876f, 0.243763f, 0.281177f, 0.282748f, 0.261662f, 0.273417f},{0.222851f, 0.226528f, 0.249241f, 0.208677f, 0.219855f, 0.219498f, 0.230603f, 0.248624f, 0.251270f, 0.263876f, 0.243763f, 0.281177f, 0.282748f, 0.261662f, 0.273417f}}; +#else const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[HRTF_LS_CHANNELS]={0.222851f, 0.226528f, 0.249241f, 0.208677f, 0.219855f, 0.219498f, 0.230603f, 0.248624f, 0.251270f, 0.263876f, 0.243763f, 0.281177f, 0.282748f, 0.261662f, 0.273417f}; +#endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 54, 54, 59, 59, 59, 65, 65, 65, 65, 65, 65, 65, 65, 71, 71, 71, 71, 72, 73, 73, 73, 73, 73, 73, 73, 73, 73, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 54, 54, 59, 59, 59, 65, 65, 65, 65, 65, 65, 65, 65, 71, 71, 71, 71, 72, 73, 73, 73, 73, 73, 73, 73, 73, 73, 77}}; const float CRendBin_Combined_BRIR_coeff_re_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1799]={ { diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 9a1920f992d7da8edc75934be178249133507a7f..4c9f3587f54f149f895e8ae4cc26517e8c4af78f 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -60,7 +60,11 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern float CRendBin_Combined_HRIR_coeff_re_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; extern float CRendBin_Combined_HRIR_coeff_im_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; @@ -74,7 +78,11 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern float CRendBin_Combined_HRIR_coeff_re_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; extern float CRendBin_Combined_HRIR_coeff_im_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; @@ -88,7 +96,11 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern float CRendBin_Combined_HRIR_coeff_re_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; extern float CRendBin_Combined_HRIR_coeff_im_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; @@ -108,7 +120,11 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[FOA_CHANNELS][BINAURAL_CH extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][FOA_CHANNELS]; +#else extern float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[FOA_CHANNELS]; +#endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern float CRendBin_FOA_HRIR_coeff_re_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][240]; extern float CRendBin_FOA_HRIR_coeff_im_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][240]; @@ -122,7 +138,11 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[FOA_CHANNELS][BINAURAL_CH extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][FOA_CHANNELS]; +#else extern float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[FOA_CHANNELS]; +#endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern float CRendBin_FOA_HRIR_coeff_re_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][160]; extern float CRendBin_FOA_HRIR_coeff_im_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][160]; @@ -136,7 +156,11 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[FOA_CHANNELS][BINAURAL_CH extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][FOA_CHANNELS]; +#else extern float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[FOA_CHANNELS]; +#endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern float CRendBin_FOA_HRIR_coeff_re_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][80]; extern float CRendBin_FOA_HRIR_coeff_im_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][80]; @@ -156,7 +180,11 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[HOA2_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]; +#else extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[HOA2_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA2_HRIR_coeff_re_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; extern float CRendBin_HOA2_HRIR_coeff_im_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; @@ -170,7 +198,11 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[HOA2_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]; +#else extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[HOA2_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA2_HRIR_coeff_re_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][160]; extern float CRendBin_HOA2_HRIR_coeff_im_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][160]; @@ -184,7 +216,11 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[HOA2_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HOA2_CHANNELS]; +#else extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[HOA2_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA2_HRIR_coeff_re_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; extern float CRendBin_HOA2_HRIR_coeff_im_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; @@ -204,7 +240,11 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[HOA3_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]; +#else extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[HOA3_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA3_HRIR_coeff_re_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; extern float CRendBin_HOA3_HRIR_coeff_im_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; @@ -218,7 +258,11 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[HOA3_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]; +#else extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[HOA3_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA3_HRIR_coeff_re_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; extern float CRendBin_HOA3_HRIR_coeff_im_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; @@ -232,7 +276,11 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[HOA3_CHANNELS][BINAURAL_ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]; +#else extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[HOA3_CHANNELS]; +#endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern float CRendBin_HOA3_HRIR_coeff_re_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][80]; extern float CRendBin_HOA3_HRIR_coeff_im_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][80]; @@ -252,7 +300,11 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; extern float CRendBin_Combined_BRIR_coeff_re_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; extern float CRendBin_Combined_BRIR_coeff_im_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; @@ -266,7 +318,11 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; extern float CRendBin_Combined_BRIR_coeff_re_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2818]; extern float CRendBin_Combined_BRIR_coeff_im_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2818]; @@ -280,7 +336,11 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BI extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][23]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; +#ifdef FIX_INV_DIFFUSE_WEIGHT +extern float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; +#else extern float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[HRTF_LS_CHANNELS]; +#endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; extern float CRendBin_Combined_BRIR_coeff_re_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1799]; extern float CRendBin_Combined_BRIR_coeff_im_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1799]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ec5d5efa4a775e8825e4bebfb3833c079237c16c..108476754c8d47216cb56d05cc3ddea7a54a86ba 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1201,7 +1201,12 @@ typedef struct ivas_hrtfs_structure #ifdef NONBE_FIX_BINARY_BINAURAL_READING int16_t init_from_rom; #endif +#ifdef FIX_INV_DIFFUSE_WEIGHT + float inv_diffuse_weight[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ + int16_t same_inv_diffuse_weight; +#else float inv_diffuse_weight[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ +#endif float gain_lfe; } HRTFS_DATA, *HRTFS_HANDLE; @@ -1212,8 +1217,13 @@ typedef struct ivas_crend_state_t { float *freq_buffer_re[MAX_INTERN_CHANNELS]; float *freq_buffer_im[MAX_INTERN_CHANNELS]; +#ifdef FIX_INV_DIFFUSE_WEIGHT + float *freq_buffer_re_diffuse[BINAURAL_CHANNELS]; + float *freq_buffer_im_diffuse[BINAURAL_CHANNELS]; +#else float *freq_buffer_re_diffuse; float *freq_buffer_im_diffuse; +#endif float *prev_out_buffer[BINAURAL_CHANNELS]; float *lfe_delay_line; float m_fYaw; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index fd0f7193fbe689afee48947df7ccf71a00b4dfa3..0cf92c5a33512a20b497bab6d4104e16095161fd 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2880,7 +2880,13 @@ static ivas_error setRendInputActiveSplitPostRend( #ifdef NONBE_FIX_BINARY_BINAURAL_READING , #if defined _MSC_VER && !defined __clang__ +#ifdef _MSC_VER +#pragma warning( disable : 4100 ) +#endif hrtf_handles *hrtfs +#ifdef _MSC_VER +#pragma warning( default : 4100 ) +#endif #else hrtf_handles *hrtfs __attribute__( ( unused ) ) /* avoid unused parameter warning when compiling with clang */ #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 25b9c21a73a0a7654a1e7ec531e9de4a14499f9f..76a2b0351e4a0b40344c7a325d029398a282bab2 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -929,7 +929,7 @@ static void HRTF_energy_sections_precalc( #ifdef NONBE_FIX_BINARY_BINAURAL_READING /*---------------------------------------------------------------------* - * dealloc_HRTF_binary() + * destroy_td_hrtf() * * Deallocated memory allocated by load_HRTF_binary *---------------------------------------------------------------------*/ @@ -1190,11 +1190,36 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( uint16_t ); /* inv_diffuse_weight */ +#ifdef FIX_INV_DIFFUSE_WEIGHT + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + ( *hHRTF )->inv_diffuse_weight[0][i] = *( (float *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( float ); + } + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + ( *hHRTF )->inv_diffuse_weight[1][i] = *( (float *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( float ); + } +#else for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( float ); } +#endif + +#ifdef FIX_OLD_BINARY_FORMAT +#ifdef FIX_INV_DIFFUSE_WEIGHT + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + if ( ( *hHRTF )->inv_diffuse_weight[1][i] != ( *hHRTF )->inv_diffuse_weight[0][i] ) + { + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file format not compliant (BINAURAL_CHANNELS)" ); + } + } +#endif +#endif /* max_total_num_fsamp_per_iteration */ max_total_num_fsamp_per_iteration = *( (uint16_t *) ( hrtf_data_rptr ) ); @@ -1302,14 +1327,14 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ #else - RENDERER_TYPE rend_type, /* i : Renderer type */ + RENDERER_TYPE rend_type, /* i : Renderer type */ #endif - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j; @@ -2004,6 +2029,7 @@ ivas_error create_SetOfHRTF_from_binary( { if ( read_hrtf_binary_header( &hrtf_header, f_hrtf ) != IVAS_ERR_OK ) { + free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } @@ -2048,6 +2074,7 @@ ivas_error create_SetOfHRTF_from_binary( if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { + free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -2056,6 +2083,7 @@ ivas_error create_SetOfHRTF_from_binary( /* Create the HRTF reading the raw data from the binary file */ if ( ( create_HRTF_from_rawdata( hHRTF, hrtf_data ) ) != IVAS_ERR_OK ) { + free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create HRTF from binary file" ); } } @@ -2144,13 +2172,36 @@ static ivas_error destroy_HRTF( } +#ifdef NONBE_FIX_BINARY_BINAURAL_READING /*---------------------------------------------------------------------* * destroy_SetOfHRTF() * * Destroy the HRTF data set. *---------------------------------------------------------------------*/ +#ifdef FIX_OLD_BINARY_FORMAT +/*---------------------------------------------------------------------* + * cleanup_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +void cleanup_SetOfHRTF( + HRTFS_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +) +{ + if ( ( hSetOfHRTF != NULL ) && ( *hSetOfHRTF != NULL ) ) + { + destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_combined ) ); + destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa3 ) ); + destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa2 ) ); + destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_foa ) ); + destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_brir_combined ) ); + } + + return; +} +#endif -#ifdef NONBE_FIX_BINARY_BINAURAL_READING void destroy_SetOfHRTF( HRTFS_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ ) diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 22deacdca301bc3ef1076d8ae89e5f30bd7787b8..4befc9f2dce04e64ec6d0b3039238fbca2100c97 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -117,6 +117,17 @@ ivas_error create_SetOfHRTF_from_binary( int32_t output_Fs /* i : Output sampling frequency */ ); +#ifdef FIX_OLD_BINARY_FORMAT +/*---------------------------------------------------------------------* + * cleanup_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +void cleanup_SetOfHRTF( + IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +); +#endif /*---------------------------------------------------------------------* * destroy_SetOfHRTF() diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 1a08a69297ab1380a7c87c04aaa0b190f5f36c7a..8ed9736a5982d5e6ba8841aef8042f4d78068f66 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -298,7 +298,11 @@ ivas_error split_rend_read_bits_from_file( return IVAS_ERR_FAILED_FILE_READ; } +#ifdef FIX_WARNING_SPLIT_RENDER + header_len = (int32_t) strlen( header ); +#else header_len = strlen( header ); +#endif /* read frame header */ for ( i = 0; i < header_len; i++ ) diff --git a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c index 3a22c25ffe60b6ff5da98dce3f492aea512fd329..f53365a33844f62764da946bdd3f355aceac6de7 100644 --- a/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c +++ b/scripts/binauralRenderer_interface/Table_Format_Converter/generate_tables_from_rom_to_bin.c @@ -1397,7 +1397,7 @@ char *create_hrtf_parametric( int32_t *hrtf_size ) parametricReverberationTimes => float[CLDFB_NO_CHANNELS_MAX]; parametricReverberationEneCorrections => float[CLDFB_NO_CHANNELS_MAX]; parametricEarlyPartEneCorrection => float[CLDFB_NO_CHANNELS_MAX]; - */ +*/ // Compute total size of data to write // CLDFB SH domain HRTF-data @@ -2346,7 +2346,11 @@ int16_t check_hrtf_data( RENDERER_TYPE rend_type, BINAURAL_INPUT_AUDIO_CONFIG in hrtf_data_in_rptr += sizeof( uint16_t ); // inv_diffuse_weight +#ifdef FIX_INV_DIFFUSE_WEIGHT + ctrl_size = tabs_dims.max_num_ir * BINAURAL_CHANNELS * sizeof( float ); +#else ctrl_size = tabs_dims.max_num_ir * sizeof( float ); +#endif if ( memcmp( tabs_ptrs.inv_diffuse_weight, hrtf_data_in_rptr, ctrl_size ) != 0 ) { fprintf( stderr, "check_hrtf_data of binary file failed: bad inv_diffuse_weight!\n\n" ); diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin index 9a988eb588c1be259b9c7ce01c3bbc872cf3b1e9..ecf077ad831255d5b9fa31c237f8c1eac3529e24 100644 --- a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a263c5498fc7ec0407c4f448e78e1f0aaf97163234ef44f2f79a1dfcb5adc37f -size 1968026 +oid sha256:4ad61e24a0be84cd5c9506b1b1b24bd9efffad1cbdedb5fb399b2599ea8b515c +size 1971738 diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.binnew b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.binnew index f092780ab5b9c8b0996bab38cca74f8649554ff4..1a072328c7841f63a35b8d2b1469c267e52426bd 100644 Binary files a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.binnew and b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.binnew differ diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin index 73f151217e89352c910668206ef00200577543d8..b8351278177a34e1f9e06336a0c9c123ca15f48a 100644 --- a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8622b0f7969a3126f8ab147c10392916b5e9cbe8d8bd9c04798abd3836e36c76 -size 2431246 +oid sha256:e3cd94b6325244546f888fd1e6a703619c8c8f952fbfc477e45ab915214504db +size 2430542 diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.binnew b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.binnew index f492e437292be2ba3f254b5d05b58ac8f714abc7..e0a97fca3a1771ab07be982e3f8835978403743a 100644 Binary files a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.binnew and b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.binnew differ diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin index d847e746131f589ddf50882fec0caf5b1da2724b..4751e031a79817feb43f96c987eba293051dd18c 100644 --- a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin +++ b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:30bcf48f0c851d4e676d5b92be7eb3032442f5106a1072ef8fc9b335d60d0fbf -size 2673694 +oid sha256:879ad86ab39e789500ad973a2ae8f5e5350bd28eb57823619804e66085710fe0 +size 2673710 diff --git a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.binnew b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.binnew index ff9593323a3523749980af7f462ce653ec522b04..e556de6e58f0b9b315a2be410ddc688168f9d314 100644 Binary files a/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.binnew and b/scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.binnew differ diff --git a/scripts/binauralRenderer_interface/config_reader.c b/scripts/binauralRenderer_interface/config_reader.c index c345a9e6114f01290e3d9905094d9b9093c1691c..cfff0669fd5066a09b2cb255a11b35e795895782 100644 --- a/scripts/binauralRenderer_interface/config_reader.c +++ b/scripts/binauralRenderer_interface/config_reader.c @@ -60,7 +60,7 @@ *-----------------------------------------------------------------------------------------*/ static ivas_error read_txt_bool( const char *pLine, /* i : String to read from */ - int32_t *pTarget /* o : Output pointer */ + int32_t *pTarget /* o : Output pointer */ ) { char value[8 + 1]; @@ -104,6 +104,27 @@ static ivas_error read_txt_float( return IVAS_ERR_OK; } +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER +/*-----------------------------------------------------------------------------------------* + * Function read_txt_uint32() + * Reads a float value from a line + *-----------------------------------------------------------------------------------------*/ +static ivas_error read_txt_int32( + const char *pLine, /* i : String to read from */ + int32_t *pTarget /* o : Output pointer */ +) +{ + int32_t val = 0; + if ( sscanf( pLine, "%d", &val ) != 1 ) + { + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + + *pTarget = val; + + return IVAS_ERR_OK; +} +#endif /*-----------------------------------------------------------------------------------------* * Function read_txt_vector() @@ -273,6 +294,10 @@ ivas_error ConfigReader_read( hRenderConfig->diffuseEnergyThreshold = DEFAULT_DIFFUSE_ENERGY_THRESHOLD; hRenderConfig->diffuseCutOffFreqThreshold = DEFAULT_DIFFUSE_CUT_OFF_FREQ_THRESHOLD; hRenderConfig->directCutOffFreqThreshold = DEFAULT_DIRECT_CUT_OFF_FREQ_THRESHOLD; +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + hRenderConfig->maxNumDirectBlocks = DEFAULT_MAX_NUM_DIRECT_BLOCKS; + hRenderConfig->maxNumDiffuseBlocks = DEFAULT_MAX_NUM_DIFFUSE_BLOCKS; +#endif /* read file line by line */ while ( fgets( pConfig_str, file_size, pConfigFile ) != NULL ) { @@ -391,6 +416,24 @@ ivas_error ConfigReader_read( return IVAS_ERR_INVALID_RENDER_CONFIG; } } +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + else if ( strcmp( item, "MAXNUMDIRECTBLOCKS" ) == 0 ) + { + if ( read_txt_int32( pValue, &hRenderConfig->maxNumDirectBlocks ) != IVAS_ERR_OK ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } + else if ( strcmp( item, "MAXNUMDIFFUSEBLOCKS" ) == 0 ) + { + if ( read_txt_int32( pValue, &hRenderConfig->maxNumDiffuseBlocks ) != IVAS_ERR_OK ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + return IVAS_ERR_INVALID_RENDER_CONFIG; + } + } +#endif } free( pValue ); } diff --git a/scripts/binauralRenderer_interface/config_reader.h b/scripts/binauralRenderer_interface/config_reader.h index fc9de4ee2d2468879f86e1fd08d0a32dc203693c..58c4b4fbb5ec7b4cfecb3e6e0d840d986c887db5 100644 --- a/scripts/binauralRenderer_interface/config_reader.h +++ b/scripts/binauralRenderer_interface/config_reader.h @@ -44,6 +44,10 @@ #define DEFAULT_DIFFUSE_ENERGY_THRESHOLD ( -25.f ) #define DEFAULT_DIFFUSE_CUT_OFF_FREQ_THRESHOLD ( -20.f ) #define DEFAULT_DIRECT_CUT_OFF_FREQ_THRESHOLD ( -20.f ) +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER +#define DEFAULT_MAX_NUM_DIRECT_BLOCKS ( 40 ) +#define DEFAULT_MAX_NUM_DIFFUSE_BLOCKS ( 40 ) +#endif typedef struct ConfigReader @@ -57,6 +61,10 @@ typedef struct ConfigReader float diffuseEnergyThreshold; /* use to find the time end limit of the diffuse part (te). diffuse part. It is a ratio in dB between diffuse part after te and complete diffuse HRIR/BRIR energies. The more the value is near zero the smallest is te, complexity decrease. */ float diffuseCutOffFreqThreshold; /* threshold in dB to determine the cut off (fcdiff) frequency for each slice of the diffuse IR. ratio in dB between the energy after fcdiff and the total energy. The more the value is near zero the smallest is fcdiff, complexity decrease */ float directCutOffFreqThreshold; /* threshold in dB to determine the cut off (fcdirect) frequency for each slice of the direct IR. Do not applied to first slice. ratio in dB between the energy after fcdirect and the total energy. The more the value is near zero the smallest is fcdirect, complexity decrease */ +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + int32_t maxNumDirectBlocks; /* max number of direct blocks */ + int32_t maxNumDiffuseBlocks; /* max number of diffuse blocks */ +#endif } ConfigReader, *ConfigReaderHandle; typedef enum diff --git a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c index b6ed0bf1238d4a3f862873c60313ea83146d0027..cdf5501e9d5e3776a4f5ec9e5aabdba7314bf1d0 100644 --- a/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c +++ b/scripts/binauralRenderer_interface/generate_crend_ivas_tables_from_sofa.c @@ -276,6 +276,10 @@ int main( int argc, char *argv[] ) cfgBrirOptim.endEnergyThreshold = DEFAULT_END_ENERGY_THRESHOLD; cfgBrirOptim.harmonizeLateReverbBinauralGain = 1; cfgBrirOptim.optimize = 1; +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + cfgBrirOptim.maxNumDirectBlocks = DEFAULT_MAX_NUM_DIRECT_BLOCKS; + cfgBrirOptim.maxNumDiffuseBlocks = DEFAULT_MAX_NUM_DIFFUSE_BLOCKS; +#endif for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { @@ -345,6 +349,27 @@ int main( int argc, char *argv[] ) strcpy( binary_common_file_name, argv[i] ); i++; } +#ifdef FIX_INV_DIFFUSE_WEIGHT + else if ( strcmp( to_upper( argv[i] ), "-BRIR_OPTIM_CONFIG_PATH" ) == 0 ) + { + i++; + if ( strlen( argv[i] ) == 0 ) + { + fprintf( stderr, "Wrong file path: %s\n\n", argv[i] ); + usage_gen_crend_tables(); + return -1; + } + brir_optim_config_path = malloc( strlen( argv[i] ) + 1 ); + strcpy( brir_optim_config_path, argv[i] ); + if ( ConfigReader_read( brir_optim_config_path, &cfgBrirOptim ) != IVAS_ERR_OK ) + { + fprintf( stderr, "cannot read file : %s\n\n", argv[i] ); + usage_gen_crend_tables(); + return -1; + } + i++; + } +#endif else if ( strcmp( to_upper( argv[i] ), "-ADD_DEFINE" ) == 0 ) { add_define = true; @@ -1118,6 +1143,9 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c { uint16_t frame_len = L_FRAME48k; int32_t maxDel = maxDel48kHz * DEFAULT_SAMPLERATE / sample_rates[indSR]; +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + float mdft_scale_fact; +#endif switch ( sample_rates[indSR] ) { case 8000: @@ -1134,29 +1162,35 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c frame_len = L_FRAME48k; break; } +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + mdft_scale_fact = (float) L_FRAME48k / (float) frame_len; +#endif if ( frame_len_ms == 5 ) { frame_len = frame_len >> 2; +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + mdft_scale_fact = (float) ( L_FRAME48k * 0.25f ) / (float) frame_len; +#endif } data_IR_current = sofa_data_IR_val_48k; sofa_N = sofa_N_48k; - switch ( sample_rates[indSR] ) - { - case 32000: - data_IR_current = sofa_data_IR_val_32k; - sofa_N = (int32_t) ceil( 32000.f * sofa_N_48k / 48000.f ); - break; - case 16000: - data_IR_current = sofa_data_IR_val_16k; - sofa_N = (int32_t) ceil( 16000.f * sofa_N_48k / 48000.f ); - break; - default: - data_IR_current = sofa_data_IR_val_48k; - sofa_N = sofa_N_48k; - break; - } + switch ( sample_rates[indSR] ) + { + case 32000: + data_IR_current = sofa_data_IR_val_32k; + sofa_N = (int32_t) ceil( 32000.f * sofa_N_48k / 48000.f ); + break; + case 16000: + data_IR_current = sofa_data_IR_val_16k; + sofa_N = (int32_t) ceil( 16000.f * sofa_N_48k / 48000.f ); + break; + default: + data_IR_current = sofa_data_IR_val_48k; + sofa_N = sofa_N_48k; + break; + } struct ivas_hrtf_t *ivas_hrtf = NULL; ivas_hrtf = malloc( sizeof( ivas_hrtf_t ) ); @@ -1252,11 +1286,19 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c { ivas_crend_binaural_filter_design_compute_filters_params( ivas_hrtf, frame_len, &hrtf_data, &index_start, &index_end, &max_ir_len, cfgReader ); ivas_crend_binaural_filter_design_set_hrtf_fr( ivas_hrtf, frame_len, +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + mdft_scale_fact, +#endif &hrtf_data, index_start, index_end, &max_ir_len, cfgReader ); } else { - ivas_set_hrtf_fr( &hrtf_data, ivas_hrtf, frame_len ); + ivas_set_hrtf_fr( &hrtf_data, ivas_hrtf, frame_len +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + , + mdft_scale_fact +#endif + ); } hrtf_data.latency_s += 0.000000001f; @@ -1754,21 +1796,21 @@ int generate_reverb_ivas_tables_from_sofa( const char *file_path ) data_IR_current = sofa_data_IR_val_48k; sofa_N = sofa_N_48k; - switch ( sample_rates[indSR] ) - { - case 32000: - data_IR_current = sofa_data_IR_val_32k; - sofa_N = (int32_t) ceil( 32000.f * sofa_N_48k / 48000.f ); - break; - case 16000: - data_IR_current = sofa_data_IR_val_16k; - sofa_N = (int32_t) ceil( 16000.f * sofa_N_48k / 48000.f ); - break; - default: - data_IR_current = sofa_data_IR_val_48k; - sofa_N = sofa_N_48k; - break; - } + switch ( sample_rates[indSR] ) + { + case 32000: + data_IR_current = sofa_data_IR_val_32k; + sofa_N = (int32_t) ceil( 32000.f * sofa_N_48k / 48000.f ); + break; + case 16000: + data_IR_current = sofa_data_IR_val_16k; + sofa_N = (int32_t) ceil( 16000.f * sofa_N_48k / 48000.f ); + break; + default: + data_IR_current = sofa_data_IR_val_48k; + sofa_N = sofa_N_48k; + break; + } if ( frame_len < sofa_N ) { @@ -2206,10 +2248,27 @@ void update_c_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int /* uint16_t index_frequency_max_diffuse; */ fprintf( fp, "\nconst uint16_t %s_%s_index_frequency_max_diffuse_%2dkHz = %d;", DECLARATION_NAME, lscfg.name, samplerate / 1000, hrtf->index_frequency_max_diffuse ); +#ifdef FIX_INV_DIFFUSE_WEIGHT + /* float inv_diffuse_weight[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; */ + fprintf( fp, "\n#ifdef FIX_INV_DIFFUSE_WEIGHT" ); + fprintf( fp, "\nconst float %s_%s_inv_diffuse_weight_%2dkHz[BINAURAL_CHANNELS][%s]=", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); + fprintf( fp, "{" ); + write_array_float_to_file( fp, hrtf->inv_diffuse_weight[0], hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "," ); + write_array_float_to_file( fp, hrtf->inv_diffuse_weight[1], hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, "}" ); + fprintf( fp, ";" ); + fprintf( fp, "\n#else" ); + fprintf( fp, "\nconst float %s_%s_inv_diffuse_weight_%2dkHz[%s]=", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); + write_array_float_to_file( fp, hrtf->inv_diffuse_weight[0], hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0, TAB_WITH_SPACE_OR_NOT ); + fprintf( fp, ";" ); + fprintf( fp, "\n#endif" ); +#else /* float inv_diffuse_weight[MAX_INTERN_CHANNELS]; */ fprintf( fp, "\nconst float %s_%s_inv_diffuse_weight_%2dkHz[%s]=", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); write_array_float_to_file( fp, hrtf->inv_diffuse_weight, hrtf->max_num_ir, hrtf->max_num_ir, FORMAT_FLOAT, 0, TAB_WITH_SPACE_OR_NOT ); fprintf( fp, ";" ); +#endif /* uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];*/ if ( hrtf->pIndex_frequency_max_diffuse[0] == NULL ) @@ -2447,8 +2506,17 @@ void update_h_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const int /* uint16_t index_frequency_max_diffuse; */ fprintf( fp, "\nextern uint16_t %s_%s_index_frequency_max_diffuse_%2dkHz;", DECLARATION_NAME, lscfg.name, samplerate / 1000 ); +#ifdef FIX_INV_DIFFUSE_WEIGHT + /* float inv_diffuse_weight[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; */ + fprintf( fp, "\n#ifdef FIX_INV_DIFFUSE_WEIGHT" ); + fprintf( fp, "\nextern float %s_%s_inv_diffuse_weight_%2dkHz[BINAURAL_CHANNELS][%s];", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); + fprintf( fp, "\n#else" ); + fprintf( fp, "\nextern float %s_%s_inv_diffuse_weight_%2dkHz[%s];", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); + fprintf( fp, "\n#endif" ); +#else /* float inv_diffuse_weight[MAX_INTERN_CHANNELS]; */ fprintf( fp, "\nextern float %s_%s_inv_diffuse_weight_%2dkHz[%s];", DECLARATION_NAME, lscfg.name, samplerate / 1000, lscfg.output_config_num_channel_name ); +#endif /* uint16_t *pIndex_frequency_max_diffuse[BINAURAL_CHANNELS];*/ if ( hrtf->pIndex_frequency_max_diffuse[0] == NULL ) { @@ -2582,8 +2650,12 @@ uint32_t compute_binary_size( HRTFS_DATA *hrtf, crend_hrtf_tables_dimensions *hr } } - hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse + hrtf_data_size += sizeof( uint16_t ); // index_frequency_max_diffuse +#ifdef FIX_INV_DIFFUSE_WEIGHT + hrtf_data_size += hrtf->max_num_ir * sizeof( float ) * BINAURAL_CHANNELS; // inv_diffuse_weight +#else hrtf_data_size += hrtf->max_num_ir * sizeof( float ); // inv_diffuse_weight +#endif hrtf_data_size += sizeof( uint16_t ); // max_total_num_fsamp_per_iteration @@ -2730,12 +2802,26 @@ void write_binary_file( HRTFS_DATA *hrtf, struct ivas_layout_config lscfg, const memcpy( hrtf_bin_wptr, &( hrtf->index_frequency_max_diffuse ), sizeof( uint16_t ) ); // index_frequency_max_diffuse hrtf_bin_wptr += sizeof( uint16_t ); +#ifdef FIX_INV_DIFFUSE_WEIGHT + for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) + { + sprintf( tmpStr, FORMAT_FLOAT, hrtf->inv_diffuse_weight[0][iIR] ); + sscanf( tmpStr, "%f", &( (float *) hrtf_bin_wptr )[iIR] ); + } + for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) + { + sprintf( tmpStr, FORMAT_FLOAT, hrtf->inv_diffuse_weight[1][iIR] ); + sscanf( tmpStr, "%f", &( (float *) hrtf_bin_wptr )[hrtf->max_num_ir + iIR] ); + } + data_size_tmp = hrtf->max_num_ir * sizeof( float ) * BINAURAL_CHANNELS; +#else for ( iIR = 0; iIR < hrtf->max_num_ir; iIR++ ) { sprintf( tmpStr, FORMAT_FLOAT, hrtf->inv_diffuse_weight[iIR] ); sscanf( tmpStr, "%f", &( (float *) hrtf_bin_wptr )[iIR] ); } data_size_tmp = hrtf->max_num_ir * sizeof( float ); +#endif hrtf_bin_wptr += data_size_tmp; memcpy( hrtf_bin_wptr, &( hrtf_table_dims.max_total_num_fsamp_per_iteration ), sizeof( uint16_t ) ); // max_total_num_fsamp_per_iteration diff --git a/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.c b/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.c index 99fdbdb7ec154126a4207fa696078bfafaeaf138..7a1c698ad2fcbe35f12fa7c8de242d63f3ead41d 100644 --- a/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.c +++ b/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.c @@ -146,7 +146,12 @@ static void printfAudioBufferOutFilterParams( printf( "\nmax Diffuse Fc : %u", pParam->index_frequency_max_diffuse ); printf( "\n" ); printf( "\nInverse Diffuse Weights :" ); +#ifdef FIX_INV_DIFFUSE_WEIGHT + printBuf_float32( pParam->inv_diffuse_weight[0], pParam->max_num_ir ); + printBuf_float32( pParam->inv_diffuse_weight[1], pParam->max_num_ir ); +#else printBuf_float32( pParam->inv_diffuse_weight, pParam->max_num_ir ); +#endif printf( "\n" ); /*if (pParam->numDiffuseBlock > 0) @@ -558,11 +563,20 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params( { pParam->num_iterations[i_chan][0]++; } +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + /* max MAX_LENGTH_DIRECT_FILTER */ + if ( pParam->num_iterations[i_chan][0] > cfgReader->maxNumDirectBlocks ) + { + pParam->num_iterations[i_chan][0] = cfgReader->maxNumDirectBlocks; + } + pParam->num_iterations[i_chan][1] = pParam->num_iterations[i_chan][0]; +#else pParam->num_iterations[i_chan][1] = pParam->num_iterations[i_chan][0]; if ( pParam->num_iterations[i_chan][0] > IVAS_MAX_NUM_DIRECT_BLOCKS ) { pParam->num_iterations[i_chan][0] = IVAS_MAX_NUM_DIRECT_BLOCKS; } +#endif } pParam->max_num_iterations = 0; @@ -652,10 +666,17 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params( } /* max MAX_NUM_DIFFUSE_BLOCKS */ +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + if ( numDiffuseBlock > cfgReader->maxNumDiffuseBlocks ) + { + numDiffuseBlock = cfgReader->maxNumDiffuseBlocks; + } +#else if ( numDiffuseBlock > IVAS_MAX_NUM_DIFFUSE_BLOCKS ) { numDiffuseBlock = IVAS_MAX_NUM_DIFFUSE_BLOCKS; } +#endif for ( i_ear = 0; i_ear < 2; ++i_ear ) { @@ -685,6 +706,9 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params( ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr( ivas_hrtf_t *pFirData, const int16_t frame_len, +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + float mdft_scale_fact, +#endif HRTFS_DATA *pParam, int32_t index_start, int32_t index_end, @@ -712,7 +736,9 @@ ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr( float ppEnergyDiffuseFilter[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS] = { { 0 } }; /* diffuse filter energies ( ppEnergyDiffuseFilter[ear][channel] ) */ float ppDiffuseWeight[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS] = { { 0 } }; /* diffuse weights ( ppDiffuseWeight[ear][channel] ) */ float delayf; +#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER float mdft_scale_fact = ( (float) L_FRAME48k * 0.25f ) / frame_len; +#endif if ( cfgReader != NULL ) { @@ -1071,11 +1097,37 @@ ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr( { if ( ppDiffuseWeight[i_chan][0] != -1 && ppDiffuseWeight[i_chan][1] != -1 ) { +#ifdef FIX_INV_DIFFUSE_WEIGHT + if ( cfgReader != NULL ) + { + if ( cfgReader->harmonizeLateReverbBinauralGain ) + { + pParam->inv_diffuse_weight[0][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] ); + pParam->inv_diffuse_weight[1][i_chan] = pParam->inv_diffuse_weight[0][i_chan]; + } + else + { + pParam->inv_diffuse_weight[0][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 1.f / ppDiffuseWeight[i_chan][0]; + pParam->inv_diffuse_weight[1][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 1.f / ppDiffuseWeight[i_chan][1]; + } + } + else + { + pParam->inv_diffuse_weight[0][i_chan] = 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] ); + pParam->inv_diffuse_weight[1][i_chan] = pParam->inv_diffuse_weight[0][i_chan]; + } +#else pParam->inv_diffuse_weight[i_chan] = 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] ); +#endif } else { +#ifdef FIX_INV_DIFFUSE_WEIGHT + pParam->inv_diffuse_weight[0][i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */ + pParam->inv_diffuse_weight[1][i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */ +#else pParam->inv_diffuse_weight[i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */ +#endif } } @@ -1285,13 +1337,19 @@ ivas_error ivas_set_hrtf_fr( HRTFS_DATA *crend_hrtf, ivas_hrtf_t *hrtf, const int16_t output_frame +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + , + float mdft_scale_fact +#endif ) { int32_t i, j, m, n; float data_ir_flt[L_FRAME48k] = { 0.0f }; int32_t tmp_ir_len, in_len, k; +#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER float mdft_scale_fact = ( (float) L_FRAME48k * 0.25f ) / output_frame; +#endif crend_hrtf->max_num_ir = (int16_t) hrtf->m; diff --git a/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.h b/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.h index 21e0bb37c0d7a32b50ceb5683ed4f89d5f0e4cd5..3cab89cdfdfbdec65a4f21390bb87ddbb8891f83 100644 --- a/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.h +++ b/scripts/binauralRenderer_interface/ivas_crend_binaural_filter_design.h @@ -40,8 +40,10 @@ #define IVAS_SOFA_MAX_VAL_R ( 2 ) #define IVAS_SOFA_MAX_VAL_N ( 48000 ) #define IVAS_SOFA_MAX_VAL_I ( 1 ) +#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER #define IVAS_MAX_NUM_DIRECT_BLOCKS ( 40 ) /* max number of direct blocks */ #define IVAS_MAX_NUM_DIFFUSE_BLOCKS ( 40 ) /* max number of diffuse blocks */ +#endif #define IVAS_MAX_HRTF_LATENCY_MS ( 0.1 ) /* max hrtf latency */ typedef struct ivas_hrtf_t @@ -61,10 +63,17 @@ typedef struct ivas_hrtf_t ivas_error ivas_get_hrtf_lens( ivas_hrtf_t *hrtf, HRTFS_DATA *crend_hrtf, const int16_t frame_len ); ivas_error ivas_set_hrtf_fr( HRTFS_DATA *crend_hrtf, ivas_hrtf_t *hrtf, const int16_t frame_len +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + , + float mdft_scale_fact +#endif ); ivas_error ivas_crend_binaural_filter_design_compute_filters_params( ivas_hrtf_t *pFirData, const int16_t framelen, HRTFS_DATA *pParam, int32_t *index_start, int32_t *index_end, int32_t *max_ir_len, ConfigReader *cfgReader ); ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr( ivas_hrtf_t *pFirData, const int16_t frame_len, +#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER + float mdft_scale_fact, +#endif HRTFS_DATA *pParam, int32_t index_start, int32_t index_end,