From 825c504686805cfb1992097dba96cdc7a982e58b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 15:09:11 +0100 Subject: [PATCH 01/14] fix issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed; under FIX_1226_FASTCONV_HRTF_LOADING_OPTIM --- apps/decoder.c | 23 +++++++++++++++++ apps/renderer.c | 4 +++ lib_com/options.h | 2 +- lib_dec/lib_dec.c | 50 +++++++++++++++++++++++++++++++------ lib_dec/lib_dec.h | 4 +++ lib_util/hrtf_file_reader.c | 24 +++++++++++++++--- lib_util/hrtf_file_reader.h | 10 +++++--- 7 files changed, 101 insertions(+), 16 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 31d34ee4f0..660a71c4a9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -170,8 +170,12 @@ typedef struct IVAS_BIN_RENDERER_TYPE binaural_renderer_sec; IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + IVAS_AUDIO_CONFIG fastConv_set_cfg; +#else IVAS_AUDIO_CONFIG intern_audio_config; int16_t room_reverb_flag; +#endif } IVAS_DEC_HRTF_BINARY_WRAPPER; @@ -728,8 +732,12 @@ int main( hHrtfBinary.hrtfFileName = arg.hrtfFileName; hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + hHrtfBinary.fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; +#else hHrtfBinary.room_reverb_flag = 0; hHrtfBinary.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID; +#endif } /*------------------------------------------------------------------------------------------* @@ -2366,7 +2374,11 @@ static ivas_error decodeG192( /* Read main parameters from the bitstream to set-up the decoder */ hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer; hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->fastConv_set_cfg ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->room_reverb_flag, &hHrtfBinary->intern_audio_config ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3273,7 +3285,11 @@ static ivas_error decodeVoIP( /* Read main parameters from the bitstream to set-up the decoder */ hHrtf->binaural_renderer_old = hHrtf->binaural_renderer; hHrtf->binaural_renderer_sec_old = hHrtf->binaural_renderer_sec; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->fastConv_set_cfg ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->room_reverb_flag, &hHrtf->intern_audio_config ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -3787,7 +3803,11 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( return error; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3797,6 +3817,9 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( else { destroy_fastconv_hrtf( hHrtfFastConv ); +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + return error; +#endif } } } diff --git a/apps/renderer.c b/apps/renderer.c index 3aa0a47428..544dd283f1 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -945,7 +945,11 @@ int main( goto cleanup; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 0, IVAS_AUDIO_CONFIG_INVALID, hrtfFileReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { diff --git a/lib_com/options.h b/lib_com/options.h index 1ab8d2b425..05f342d284 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,7 +163,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ - +#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* VA: issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9fe3a8132e..a56d0999cf 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -912,11 +912,15 @@ ivas_error IVAS_DEC_FeedFrame_Serial( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_ReadFormat( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ - IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o : secondary binaural renderer type */ - int16_t *room_reverb_flag, /* o : room reverb flag */ - IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ + IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o : secondary binaural renderer type */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend.*/ +#else + int16_t *room_reverb_flag, /* o : room reverb flag */ + IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ +#endif ) { ivas_error error; @@ -972,16 +976,18 @@ ivas_error IVAS_DEC_ReadFormat( break; case RENDERER_BINAURAL_FASTCONV: *binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; - +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { *room_reverb_flag = 1; } - +#endif break; case RENDERER_BINAURAL_FASTCONV_ROOM: *binaural_renderer = IVAS_BIN_RENDERER_TYPE_FASTCONV; +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM *room_reverb_flag = 1; +#endif break; case RENDERER_BINAURAL_PARAMETRIC: case RENDERER_BINAURAL_PARAMETRIC_ROOM: @@ -998,7 +1004,35 @@ ivas_error IVAS_DEC_ReadFormat( *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; + if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) + { + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + } + else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + } + } + } +#else *intern_audio_config = st_ivas->intern_config; +#endif if ( ( renderer_type_old != st_ivas->renderer_type && renderer_type_old != RENDERER_DISABLE ) || ( st_ivas->ini_active_frame > 0 && ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) ) @@ -1052,7 +1086,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } /* If TSM is generally enabled, we have to wait for the first good frame. - Otherwise, we directly decode the first frame in any case. */ + Otherwise, we directly decode the first frame in any case. */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { uint16_t l_ts, nTimeScalerOutSamples; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 1345602dee..ecd7c2d02c 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -159,8 +159,12 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec,/* o: secondary binaural renderer type */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend. */ +#else int16_t *room_reverb_flag, /* o : room reverb flag */ IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ +#endif ); /*! r: decoder error code */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 5979e0a251..3c24371ce8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1886,10 +1886,14 @@ static ivas_error create_parambin_HRTF_from_rawdata( *---------------------------------------------------------------------*/ ivas_error load_fastconv_HRTF_from_binary( - IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ - const int16_t room_reverb_flag, /* i : room reverb flag */ - const IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ - const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + const IVAS_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ +#else + const int16_t room_reverb_flag, /* i : room reverb flag */ + const IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ +#endif + const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ) { FILE *f_hrtf; @@ -1937,6 +1941,14 @@ ivas_error load_fastconv_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && + ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) || + ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) +#else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA2 ) || @@ -1944,6 +1956,7 @@ ivas_error load_fastconv_HRTF_from_binary( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) ) ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && room_reverb_flag == 1 ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && intern_audio_config == IVAS_AUDIO_CONFIG_INVALID ) ) +#endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) { @@ -1957,6 +1970,9 @@ ivas_error load_fastconv_HRTF_from_binary( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Could not create FastConv HRTF from binary file" ); } asFastconv = 1; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + continue; /* read just one set */ +#endif } else { diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index b98cbbd03a..e9295e8442 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -132,9 +132,13 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ - const int16_t room_reverb_flag, /* i : room reverb flag */ - IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ - const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + const IVAS_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ +#else + const int16_t room_reverb_flag, /* i : room reverb flag */ + IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ +#endif + const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); /*---------------------------------------------------------------------* -- GitLab From ab64436d145eb4dfc6b35b9336c98956aca79694 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 15:21:24 +0100 Subject: [PATCH 02/14] build warning --- lib_dec/ivas_binRenderer_internal.c | 5 +++++ lib_util/hrtf_file_reader.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 587f2c7b2b..a1e6ac1c16 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -780,6 +780,11 @@ static ivas_error ivas_binaural_hrtf_open( HrtfFastConv->rightHRIRImag_HOA3[i][j] = rightHRIRImag_HOA3[i][j]; } } + +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer + as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ +#endif if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { for ( j = 0; j < HOA2_CHANNELS; j++ ) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3c24371ce8..868e9be4c7 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1942,11 +1942,11 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) || + if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && + ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || + ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && -- GitLab From 7934240801bfb28a452ee6354d705c19667ac82d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 15:59:51 +0100 Subject: [PATCH 03/14] comment --- lib_dec/ivas_binRenderer_internal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a1e6ac1c16..49ba69f8f8 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -393,6 +393,10 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3[bandIdx][chIdx]; hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3[bandIdx][chIdx]; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer + as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ +#endif else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { /* HOA2 filter coefficients */ @@ -782,7 +786,7 @@ static ivas_error ivas_binaural_hrtf_open( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer + /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ #endif if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) -- GitLab From dafeeebedf0a9431cf3a2355b017ad21e7ff02a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 16:10:23 +0100 Subject: [PATCH 04/14] fix MC_MODE_PARAMUPMIX --- lib_dec/lib_dec.c | 5 +++++ lib_util/hrtf_file_reader.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a56d0999cf..1241d4dd6e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1027,6 +1027,11 @@ ivas_error IVAS_DEC_ReadFormat( if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + + if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + } } } } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 868e9be4c7..c05e53ab95 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1942,12 +1942,16 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM +#if 1 + if ( hrtf_id == 4 ) +#else if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) +#endif #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || -- GitLab From 00dc70ac2850b57b1a2bc6ed0ff03b753e5a3ebe Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 16:59:37 +0100 Subject: [PATCH 05/14] remove debugging code --- lib_util/hrtf_file_reader.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index c05e53ab95..868e9be4c7 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1942,16 +1942,12 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM -#if 1 - if ( hrtf_id == 4 ) -#else if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) -#endif #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || -- GitLab From 6e6a12806092df902d43fbbc98f7b990f5e1e4e2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 21 Nov 2024 23:19:10 +0100 Subject: [PATCH 06/14] - removal of multiplied code; so far under FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 - fixes --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal.c | 190 +++++++++++++++++++++++++++- lib_dec/lib_dec.c | 28 +++- lib_rend/ivas_stat_rend.h | 13 ++ lib_util/hrtf_file_reader.c | 84 +++++++++++- 5 files changed, 307 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 05f342d284..be1eaa946f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ #define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* VA: issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed */ +#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 /* removal of multiplied code */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 49ba69f8f8..7b9a47e2bf 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -165,10 +165,16 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenderer->nInChannels = ( audioCfg2channels( input_config ) - isLoudspeaker ); } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + hBinRenConvModule->numTaps = hHrtf->ntaps; +#endif + if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 hBinRenConvModule->numTaps = hHrtf->ntaps_brir; +#endif /* Use variable order filtering */ bandIdx = 0; for ( ; bandIdx < 5; bandIdx++ ) @@ -194,6 +200,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } else { +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 if ( hBinRenderer->ivas_format == SBA_FORMAT ) { if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) @@ -218,6 +225,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenConvModule->numTaps = hHrtf->ntaps_hrir; } +#endif /* Use fixed order filtering */ bandIdx = 0; for ( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) @@ -326,6 +334,9 @@ static ivas_error ivas_binRenderer_convModuleOpen( { int16_t tmp = 0; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + tmp = chIdx; +#endif if ( isLoudspeaker ) { if ( input_config == IVAS_AUDIO_CONFIG_5_1 ) @@ -356,6 +367,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( #endif } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftReal[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftImag[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightReal[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightImag[bandIdx][tmp]; +#else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { @@ -419,6 +436,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } +#endif } } @@ -453,6 +471,17 @@ void ivas_init_binaural_hrtf( { int16_t i; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal = NULL; + HrtfFastConv->leftImag = NULL; + HrtfFastConv->rightReal = NULL; + HrtfFastConv->rightImag = NULL; + HrtfFastConv->FASTCONV_latency_s = 0x00; + + HrtfFastConv->n_channels = 0; + HrtfFastConv->allocate_init_flag = 0x00; + HrtfFastConv->ntaps = 0; +#else HrtfFastConv->leftHRIRReal_HOA3 = NULL; HrtfFastConv->leftHRIRImag_HOA3 = NULL; HrtfFastConv->rightHRIRReal_HOA3 = NULL; @@ -489,6 +518,7 @@ void ivas_init_binaural_hrtf( HrtfFastConv->ntaps_hrir_hoa2 = BINAURAL_NTAPS_SBA; HrtfFastConv->ntaps_hrir_hoa3 = BINAURAL_NTAPS_SBA; HrtfFastConv->ntaps_brir = BINAURAL_NTAPS_MAX; +#endif for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { @@ -559,6 +589,57 @@ ivas_error ivas_allocate_binaural_hrtf( const int16_t allocate_init_flag /* i : Memory allocation flag */ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + int16_t n_channels = 0; + + if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) || + ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) ) + { + n_channels = HRTF_LS_CHANNELS; + } + + if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( input_config == IVAS_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + { + n_channels = HOA3_CHANNELS; + } + else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) + { + n_channels = HOA2_CHANNELS; + } + else if ( input_config == IVAS_AUDIO_CONFIG_FOA || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) + { + n_channels = FOA_CHANNELS; + } + } + + HrtfFastConv->n_channels = n_channels; + + if ( ( HrtfFastConv->leftReal != NULL ) && ( HrtfFastConv->leftImag != NULL ) && ( HrtfFastConv->rightReal != NULL ) && ( HrtfFastConv->rightImag != NULL ) ) + { + return IVAS_ERR_OK; + } + else + { + if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftReal, BINAURAL_CONVBANDS, n_channels, HrtfFastConv->ntaps, allocate_init_flag ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HrtfFastConv->leftReal" ); + } + if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->leftImag, BINAURAL_CONVBANDS, n_channels, HrtfFastConv->ntaps, allocate_init_flag ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HrtfFastConv->leftImag" ); + } + if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightReal, BINAURAL_CONVBANDS, n_channels, HrtfFastConv->ntaps, allocate_init_flag ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HrtfFastConv->rightReal" ); + } + if ( IVAS_ERR_OK != ivas_alloc_pppMem( &HrtfFastConv->rightImag, BINAURAL_CONVBANDS, n_channels, HrtfFastConv->ntaps, allocate_init_flag ) ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HrtfFastConv->rightImag" ); + } + } +#else if ( input_config == IVAS_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) { if ( ( HrtfFastConv->leftHRIRReal_HOA3 != NULL ) && ( HrtfFastConv->leftHRIRImag_HOA3 != NULL ) && ( HrtfFastConv->rightHRIRReal_HOA3 != NULL ) && ( HrtfFastConv->rightHRIRImag_HOA3 != NULL ) ) @@ -685,6 +766,7 @@ ivas_error ivas_allocate_binaural_hrtf( } } } +#endif return IVAS_ERR_OK; } @@ -725,23 +807,48 @@ static ivas_error ivas_binaural_hrtf_open( if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->FASTCONV_latency_s = FASTCONV_HRIR_latency_s; + HrtfFastConv->ntaps = BINAURAL_NTAPS; +#else HrtfFastConv->FASTCONV_HRIR_latency_s = FASTCONV_HRIR_latency_s; +#endif } if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA2_latency_s; + HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; +#else HrtfFastConv->FASTCONV_HOA2_latency_s = FASTCONV_HOA2_latency_s; +#endif } if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA3_latency_s; + HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; +#else HrtfFastConv->FASTCONV_HOA3_latency_s = FASTCONV_HOA3_latency_s; +#endif } if ( input_config == IVAS_AUDIO_CONFIG_FOA ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->FASTCONV_latency_s = FASTCONV_FOA_latency_s; + HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; +#else HrtfFastConv->FASTCONV_FOA_latency_s = FASTCONV_FOA_latency_s; +#endif } if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->FASTCONV_latency_s = FASTCONV_BRIR_latency_s; + HrtfFastConv->ntaps = BINAURAL_NTAPS_MAX; +#else HrtfFastConv->FASTCONV_BRIR_latency_s = FASTCONV_BRIR_latency_s; +#endif } HrtfFastConv->allocate_init_flag = 1; @@ -753,60 +860,116 @@ static ivas_error ivas_binaural_hrtf_open( for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + if ( renderer_type == RENDERER_BINAURAL_FASTCONV && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) +#else if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) +#endif { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal[i][j] = leftHRIRReal[i][j]; + HrtfFastConv->leftImag[i][j] = leftHRIRImag[i][j]; + HrtfFastConv->rightReal[i][j] = rightHRIRReal[i][j]; + HrtfFastConv->rightImag[i][j] = rightHRIRImag[i][j]; +#else HrtfFastConv->leftHRIRReal[i][j] = leftHRIRReal[i][j]; HrtfFastConv->leftHRIRImag[i][j] = leftHRIRImag[i][j]; HrtfFastConv->rightHRIRReal[i][j] = rightHRIRReal[i][j]; HrtfFastConv->rightHRIRImag[i][j] = rightHRIRImag[i][j]; +#endif } } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) +#else else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) +#endif { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal[i][j] = leftBRIRReal[i][j]; + HrtfFastConv->leftImag[i][j] = leftBRIRImag[i][j]; + HrtfFastConv->rightReal[i][j] = rightBRIRReal[i][j]; + HrtfFastConv->rightImag[i][j] = rightBRIRImag[i][j]; +#else HrtfFastConv->leftBRIRReal[i][j] = leftBRIRReal[i][j]; HrtfFastConv->leftBRIRImag[i][j] = leftBRIRImag[i][j]; HrtfFastConv->rightBRIRReal[i][j] = rightBRIRReal[i][j]; HrtfFastConv->rightBRIRImag[i][j] = rightBRIRImag[i][j]; +#endif } } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + if ( input_config == IVAS_AUDIO_CONFIG_HOA3 && HrtfFastConv->n_channels == HOA3_CHANNELS ) +#else if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) +#endif { for ( j = 0; j < HOA3_CHANNELS; j++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA3[i][j]; + HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA3[i][j]; + HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA3[i][j]; + HrtfFastConv->rightImag[i][j] = rightHRIRImag_HOA3[i][j]; +#else HrtfFastConv->leftHRIRReal_HOA3[i][j] = leftHRIRReal_HOA3[i][j]; HrtfFastConv->leftHRIRImag_HOA3[i][j] = leftHRIRImag_HOA3[i][j]; HrtfFastConv->rightHRIRReal_HOA3[i][j] = rightHRIRReal_HOA3[i][j]; HrtfFastConv->rightHRIRImag_HOA3[i][j] = rightHRIRImag_HOA3[i][j]; +#endif } } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ #endif +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + if ( input_config == IVAS_AUDIO_CONFIG_HOA2 && HrtfFastConv->n_channels == HOA2_CHANNELS ) +#else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) +#endif { for ( j = 0; j < HOA2_CHANNELS; j++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA2[i][j]; + HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA2[i][j]; + HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA2[i][j]; + HrtfFastConv->rightImag[i][j] = rightHRIRImag_HOA2[i][j]; +#else HrtfFastConv->leftHRIRReal_HOA2[i][j] = leftHRIRReal_HOA2[i][j]; HrtfFastConv->leftHRIRImag_HOA2[i][j] = leftHRIRImag_HOA2[i][j]; HrtfFastConv->rightHRIRReal_HOA2[i][j] = rightHRIRReal_HOA2[i][j]; HrtfFastConv->rightHRIRImag_HOA2[i][j] = rightHRIRImag_HOA2[i][j]; +#endif } } + +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + if ( input_config == IVAS_AUDIO_CONFIG_FOA && HrtfFastConv->n_channels == FOA_CHANNELS ) +#else if ( input_config == IVAS_AUDIO_CONFIG_FOA ) +#endif { for ( j = 0; j < FOA_CHANNELS; j++ ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + HrtfFastConv->leftReal[i][j] = leftHRIRReal_FOA[i][j]; + HrtfFastConv->leftImag[i][j] = leftHRIRImag_FOA[i][j]; + HrtfFastConv->rightReal[i][j] = rightHRIRReal_FOA[i][j]; + HrtfFastConv->rightImag[i][j] = rightHRIRImag_FOA[i][j]; +#else HrtfFastConv->leftHRIRReal_FOA[i][j] = leftHRIRReal_FOA[i][j]; HrtfFastConv->leftHRIRImag_FOA[i][j] = leftHRIRImag_FOA[i][j]; HrtfFastConv->rightHRIRReal_FOA[i][j] = rightHRIRReal_FOA[i][j]; HrtfFastConv->rightHRIRImag_FOA[i][j] = rightHRIRImag_FOA[i][j]; +#endif } } } @@ -1045,6 +1208,9 @@ ivas_error ivas_rend_openCldfbRend( return error; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); +#else if ( inConfig == IVAS_AUDIO_CONFIG_FOA ) { pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_FOA_latency_s * 1000000000.f ); @@ -1062,6 +1228,8 @@ ivas_error ivas_rend_openCldfbRend( /* should never happen for SBA */ return IVAS_ERR_INVALID_OUTPUT_FORMAT; } +#endif + hBinRenderer->hReverb = NULL; hBinRenderer->hEFAPdata = NULL; @@ -1183,7 +1351,11 @@ ivas_error ivas_binRenderer_open( } hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); +#else st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s * 1000000000.f ); +#endif } else { @@ -1193,6 +1365,9 @@ ivas_error ivas_binRenderer_open( return error; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); +#else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { if ( hBinRenderer->ivas_format == MC_FORMAT ) @@ -1224,6 +1399,7 @@ ivas_error ivas_binRenderer_open( /* same value for MC or HOA both use MC BRIR*/ st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s * 1000000000.f ); } +#endif } /* Allocate memories needed for reverb module */ @@ -1445,6 +1621,9 @@ void ivas_binaural_hrtf_close( ) { int16_t allocate_init_flag; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + int16_t n_channels; +#endif if ( hHrtfFastConv == NULL || *hHrtfFastConv == NULL ) { @@ -1452,6 +1631,14 @@ void ivas_binaural_hrtf_close( } allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + n_channels = ( *hHrtfFastConv )->n_channels; + + ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftReal, n_channels, allocate_init_flag ); + ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftImag, n_channels, allocate_init_flag ); + ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightReal, n_channels, allocate_init_flag ); + ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightImag, n_channels, allocate_init_flag ); +#else ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRReal, HRTF_LS_CHANNELS, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag, HRTF_LS_CHANNELS, allocate_init_flag ); @@ -1477,6 +1664,7 @@ void ivas_binaural_hrtf_close( ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftHRIRImag_FOA, FOA_CHANNELS, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRReal_FOA, FOA_CHANNELS, allocate_init_flag ); ivas_free_pppHrtfMem( &( *hHrtfFastConv )->rightHRIRImag_FOA, FOA_CHANNELS, allocate_init_flag ); +#endif return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 1241d4dd6e..e78cb650b0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -929,7 +929,11 @@ ivas_error IVAS_DEC_ReadFormat( ISM_MODE ism_mode_old; MC_MODE mc_mode_old; int16_t nchan_transport_old; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + AUDIO_CONFIG intern_config_old, transport_config_old, output_config; +#else AUDIO_CONFIG intern_config_old, transport_config_old; +#endif RENDERER_TYPE renderer_type_old; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -946,6 +950,11 @@ ivas_error IVAS_DEC_ReadFormat( transport_config_old = st_ivas->transport_config; renderer_type_old = st_ivas->renderer_type; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + output_config = st_ivas->hDecoderConfig->output_config; + +#endif + if ( st_ivas->ivas_format == MONO_FORMAT ) { return IVAS_ERR_OK; @@ -999,23 +1008,27 @@ ivas_error IVAS_DEC_ReadFormat( } *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) +#endif { *binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_TDREND; } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; - if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) + if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || + output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; } @@ -1024,11 +1037,16 @@ ivas_error IVAS_DEC_ReadFormat( { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_LS_CUSTOM; /* hack to signal BINAURAL_INPUT_AUDIO_CONFIG_COMBINED coefs. without ROOM effect */ + } + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; - if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f1d777699c..b4c50f6069 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1257,6 +1257,14 @@ typedef struct ivas_hrtfs_crend_structure /* Fastconv binaural data structure */ typedef struct ivas_hrtfs_fastconv_struct { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + float FASTCONV_latency_s; + float ***leftReal; + float ***leftImag; + float ***rightReal; + float ***rightImag; + int16_t n_channels; +#else float FASTCONV_HOA3_latency_s; float ***leftHRIRReal_HOA3; float ***leftHRIRImag_HOA3; @@ -1286,13 +1294,18 @@ typedef struct ivas_hrtfs_fastconv_struct float ***rightHRIRReal_FOA; float ***rightHRIRImag_FOA; float FASTCONV_FOA_latency_s; +#endif int16_t allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + uint16_t ntaps; +#else uint16_t ntaps_hrir; uint16_t ntaps_hrir_hoa3; uint16_t ntaps_hrir_hoa2; uint16_t ntaps_hrir_foa; uint16_t ntaps_brir; +#endif float fastconvReverberationTimes[CLDFB_NO_CHANNELS_MAX]; float fastconvReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 868e9be4c7..3c9fd8f67d 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1369,14 +1369,23 @@ static ivas_error create_fastconv_HRTF_from_rawdata( ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + ( *hHRTF )->ntaps = ntaps; + ( *hHRTF )->FASTCONV_latency_s = latency_s; + + ( *hHRTF )->n_channels = nbchan; +#endif + if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { if ( HRTF_LS_CHANNELS != nbchan ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 ( *hHRTF )->ntaps_hrir = ntaps; ( *hHRTF )->FASTCONV_HRIR_latency_s = latency_s; +#endif } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) { @@ -1384,8 +1393,10 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); } +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 ( *hHRTF )->ntaps_hrir_hoa3 = ntaps; ( *hHRTF )->FASTCONV_HOA3_latency_s = latency_s; +#endif } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) { @@ -1393,8 +1404,10 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); } +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 ( *hHRTF )->ntaps_hrir_hoa2 = ntaps; ( *hHRTF )->FASTCONV_HOA2_latency_s = latency_s; +#endif } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) { @@ -1402,8 +1415,10 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); } +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 ( *hHRTF )->ntaps_hrir_foa = ntaps; ( *hHRTF )->FASTCONV_FOA_latency_s = latency_s; +#endif } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { @@ -1411,8 +1426,10 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 ( *hHRTF )->ntaps_brir = ntaps; ( *hHRTF )->FASTCONV_BRIR_latency_s = latency_s; +#endif } else { @@ -1438,6 +1455,65 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + /* HRIR/BRIR Q factor*/ + factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( Word16 ); + scaleFactor = powf( 2.f, -1.f * factorQ ); + + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < nbchan; j++ ) + { + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ntaps; k++ ) + { + ( *hHRTF )->leftReal[i][j][k] = ptW16[k] * scaleFactor; + } + hrtf_data_rptr += ntaps * sizeof( Word16 ); + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < nbchan; j++ ) + { + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ntaps; k++ ) + { + ( *hHRTF )->leftImag[i][j][k] = ptW16[k] * scaleFactor; + } + hrtf_data_rptr += ntaps * sizeof( Word16 ); + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < nbchan; j++ ) + { + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ntaps; k++ ) + { + ( *hHRTF )->rightReal[i][j][k] = ptW16[k] * scaleFactor; + } + hrtf_data_rptr += ntaps * sizeof( Word16 ); + } + } + for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) + { + for ( j = 0; j < nbchan; j++ ) + { + ptW16 = (Word16 *) hrtf_data_rptr; + for ( k = 0; k < ntaps; k++ ) + { + ( *hHRTF )->rightImag[i][j][k] = ptW16[k] * scaleFactor; + } + hrtf_data_rptr += ntaps * sizeof( Word16 ); + } + } + + /* BRIR */ + if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + { +#else /* HRIR */ if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) { @@ -1724,6 +1800,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( hrtf_data_rptr += ( *hHRTF )->ntaps_brir * sizeof( Word16 ); } } +#endif /* Reverb Parameters */ if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) @@ -1942,11 +2019,12 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || + if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && + ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_LS_CUSTOM ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || + ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && @@ -1971,7 +2049,7 @@ ivas_error load_fastconv_HRTF_from_binary( } asFastconv = 1; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - continue; /* read just one set */ + break; /* read just one set */ #endif } else -- GitLab From 72cbfa0ba4d072b4177005cb57cbb3a1601b5621 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 25 Nov 2024 11:02:56 +0100 Subject: [PATCH 07/14] change hack of IVAS_AUDIO_CONFIG_LS_CUSTOM to IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB --- lib_dec/lib_dec.c | 2 +- lib_util/hrtf_file_reader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e78cb650b0..5a51798b24 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1039,7 +1039,7 @@ ivas_error IVAS_DEC_ReadFormat( if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_LS_CUSTOM; /* hack to signal BINAURAL_INPUT_AUDIO_CONFIG_COMBINED coefs. without ROOM effect */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB; } if ( st_ivas->hDecoderConfig->Opt_Headrotation ) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3c9fd8f67d..1e85842f33 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2020,7 +2020,7 @@ ivas_error load_fastconv_HRTF_from_binary( #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_LS_CUSTOM ) || + ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || -- GitLab From 84f8f5d50aabf560e1f229404fbc989611368e29 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 25 Nov 2024 17:14:28 +0100 Subject: [PATCH 08/14] change enum value used for selecting regular HRIRs for FastConv --- lib_dec/lib_dec.c | 8 +++++++- lib_util/hrtf_file_reader.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5a51798b24..3ed3ab09d4 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1026,28 +1026,34 @@ ivas_error IVAS_DEC_ReadFormat( if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { + /* SHD transformed HRIRs */ *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; } else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { + /* BRIRs */ *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; } } else if ( st_ivas->ivas_format == MC_FORMAT ) { + /* BRIRs */ *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB; + /* HRIRs */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL; } if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { + /* SHD transformed HRIRs for low complexity rotation */ *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { + /* BRIRs */ *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; } } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 1e85842f33..518d2c353a 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2020,7 +2020,7 @@ ivas_error load_fastconv_HRTF_from_binary( #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || + ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || -- GitLab From 120067b19fc487476e760d89bc64db6c7a68a605 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Nov 2024 13:58:17 +0100 Subject: [PATCH 09/14] adopt logic simplification; under FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY --- apps/decoder.c | 19 ++++++ apps/renderer.c | 4 ++ lib_com/ivas_cnst.h | 2 + lib_com/ivas_prot.h | 6 +- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal.c | 37 +++++++++++- lib_dec/lib_dec.c | 26 +++++++++ lib_util/hrtf_file_reader.c | 91 +++++++++++++++++++++++++++-- lib_util/hrtf_file_reader.h | 3 + 9 files changed, 180 insertions(+), 9 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 660a71c4a9..605fcfda5f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -188,7 +188,11 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); +#else static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs ); +#endif #ifdef DEBUGGING static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); @@ -2389,7 +2393,11 @@ static ivas_error decodeG192( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3300,7 +3308,11 @@ static ivas_error decodeVoIP( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3700,6 +3712,9 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + const IVAS_AUDIO_CONFIG OutputConfig, +#endif const int32_t output_Fs ) { ivas_error error; @@ -3804,7 +3819,11 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif diff --git a/apps/renderer.c b/apps/renderer.c index 544dd283f1..37c9a5ce82 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -946,7 +946,11 @@ int main( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 0, IVAS_AUDIO_CONFIG_INVALID, hrtfFileReader ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4a56f13237..89abf62dc9 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1499,6 +1499,7 @@ typedef enum #define BINAURAL_COHERENCE_DIFFERENCE_BINS 9 /* Number of bins for direction-dependent diffuse-field binaural coherence */ +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY typedef enum { BINAURAL_INPUT_AUDIO_CONFIG_INVALID, @@ -1510,6 +1511,7 @@ typedef enum } BINAURAL_INPUT_AUDIO_CONFIG; +#endif #define HEADROT_ORDER 3 #define HEADROT_SHMAT_DIM ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) ) #define HEADROT_SHMAT_DIM2 ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 418d49267f..2e7c6eb80a 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5135,10 +5135,14 @@ void ivas_init_binaural_hrtf( ); ivas_error ivas_allocate_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + const int16_t n_channels, /* i : number of input channels */ +#else const AUDIO_CONFIG input_config, /* i : input audio configuration */ const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ const RENDERER_TYPE renderer_type, /* i : renderer type */ +#endif const int16_t allocate_init_flag /* i : Memory allocation flag */ ); diff --git a/lib_com/options.h b/lib_com/options.h index be1eaa946f..881ce10f7d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -165,6 +165,7 @@ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ #define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* VA: issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed */ #define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 /* removal of multiplied code */ +#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 7b9a47e2bf..e30355bbb3 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -582,14 +582,19 @@ static ivas_error ivas_alloc_pppMem( *-------------------------------------------------------------------------*/ ivas_error ivas_allocate_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + const int16_t n_channels, /* i : number of input channels */ +#else const AUDIO_CONFIG input_config, /* i : input audio configuration */ const BINAURAL_INPUT_AUDIO_CONFIG bin_input_config, /* i : binaural input audio config */ const RENDERER_TYPE renderer_type, /* i : renderer type */ - const int16_t allocate_init_flag /* i : Memory allocation flag */ +#endif + const int16_t allocate_init_flag /* i : Memory allocation flag */ ) { #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY int16_t n_channels = 0; if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) || @@ -613,6 +618,7 @@ ivas_error ivas_allocate_binaural_hrtf( n_channels = FOA_CHANNELS; } } +#endif HrtfFastConv->n_channels = n_channels; @@ -853,7 +859,34 @@ static ivas_error ivas_binaural_hrtf_open( HrtfFastConv->allocate_init_flag = 1; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + int16_t n_channels = 0; + + if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) + { + n_channels = HRTF_LS_CHANNELS; + } + + if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) + { + if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) + { + n_channels = HOA3_CHANNELS; + } + else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) + { + n_channels = HOA2_CHANNELS; + } + else if ( input_config == IVAS_AUDIO_CONFIG_FOA ) + { + n_channels = FOA_CHANNELS; + } + } + + if ( ( error = ivas_allocate_binaural_hrtf( HrtfFastConv, n_channels, HrtfFastConv->allocate_init_flag ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_allocate_binaural_hrtf( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3ed3ab09d4..aea51695c0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1021,6 +1021,31 @@ ivas_error IVAS_DEC_ReadFormat( *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + { + /* SHD HRIRs */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + /* BRIRs */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_7_1_4; + } + } + else if ( st_ivas->ivas_format == MC_FORMAT ) + { + /* HRIRs */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_7_1_4; + + if ( ( st_ivas->hDecoderConfig->Opt_Headrotation ) && + !( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + /* SHD HRIRs for low complexity rotation */ + *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + } + } +#else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || @@ -1058,6 +1083,7 @@ ivas_error IVAS_DEC_ReadFormat( } } } +#endif } #else *intern_audio_config = st_ivas->intern_config; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 518d2c353a..ee1b80ba20 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -56,6 +56,19 @@ typedef struct ivas_hrtfs_file_header_t } ivas_hrtfs_file_header_t; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +typedef enum +{ + BINAURAL_INPUT_AUDIO_CONFIG_INVALID, + BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */ + BINAURAL_INPUT_AUDIO_CONFIG_HOA3, /* HOA3 */ + BINAURAL_INPUT_AUDIO_CONFIG_HOA2, /* HOA2 */ + BINAURAL_INPUT_AUDIO_CONFIG_FOA, /* FOA */ + BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */ + +} BINAURAL_INPUT_AUDIO_CONFIG; + +#endif /*---------------------------------------------------------------------* * hrtfFileReader_open() @@ -238,6 +251,40 @@ static ivas_error read_hrtf_binary_header( return IVAS_ERR_END_OF_FILE; } +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + +/*-------------------------------------------------------------------* + * audio_cfg_2_binaural_cfg() + * + * Convert audio config. to HRTF binaural config + --------------------------------------------------------------------*/ + +static BINAURAL_INPUT_AUDIO_CONFIG audio_cfg_2_binaural_cfg( + const IVAS_AUDIO_CONFIG fastConv_set_cfg ) +{ + BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; + + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED; + + switch ( fastConv_set_cfg ) + { + case IVAS_AUDIO_CONFIG_7_1_4: + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED; + break; + case IVAS_AUDIO_CONFIG_FOA: + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_FOA; + break; + case IVAS_AUDIO_CONFIG_HOA2: + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA2; + break; + case IVAS_AUDIO_CONFIG_HOA3: + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3; + break; + } + + return hrtf_set_binaural_cfg; +} +#endif /*-------------------------------------------------------------------* * LoadBSplineBinaryITD() @@ -1324,10 +1371,10 @@ 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 */ - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + const BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j, k; @@ -1438,14 +1485,22 @@ static ivas_error create_fastconv_HRTF_from_rawdata( if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, nbchan, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) { - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, nbchan, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1964,6 +2019,9 @@ static ivas_error create_parambin_HRTF_from_rawdata( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ +#endif #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM const IVAS_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ #else @@ -1981,6 +2039,13 @@ ivas_error load_fastconv_HRTF_from_binary( ivas_hrtfs_file_header_t hrtfs_file_header; int16_t hrtf_id; int16_t asFastconv = 0; +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + bool load = false; + BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; + + /* convert audio config. to HRTF binaural config */ + hrtf_set_binaural_cfg = audio_cfg_2_binaural_cfg( fastConv_set_cfg ); +#endif if ( hrtfReader == NULL || hrtfReader->file == NULL ) { @@ -2019,6 +2084,19 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ + ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || + ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && /* BRIRs */ + OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + load = ( (BINAURAL_INPUT_AUDIO_CONFIG) hrtf_header.input_cfg == hrtf_set_binaural_cfg ) ? true : false; + } + + /* TBD: condition for external renderer */ + + if ( load ) +#else if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL ) || ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || @@ -2026,6 +2104,7 @@ ivas_error load_fastconv_HRTF_from_binary( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) +#endif #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index e9295e8442..70620cb00e 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -132,6 +132,9 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ +#endif #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM const IVAS_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ #else -- GitLab From 578ed6f3a9f5ed8c3a72a7f6b388f6814229c0da Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Nov 2024 14:11:14 +0100 Subject: [PATCH 10/14] fix build --- lib_util/hrtf_file_reader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index ee1b80ba20..fb195279c8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -280,6 +280,9 @@ static BINAURAL_INPUT_AUDIO_CONFIG audio_cfg_2_binaural_cfg( case IVAS_AUDIO_CONFIG_HOA3: hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3; break; + default: + hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_INVALID; + break; } return hrtf_set_binaural_cfg; -- GitLab From 59a3eba67b38c3a06bd60eb95a123cab7a9fe9ea Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Nov 2024 14:25:13 +0100 Subject: [PATCH 11/14] fix instrumented build --- lib_dec/ivas_binRenderer_internal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index e30355bbb3..59a67c6f29 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -792,7 +792,9 @@ static ivas_error ivas_binaural_hrtf_open( { int16_t i, j; ivas_error error; - +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + int16_t n_channels; +#endif if ( hHrtfFastConv != NULL && *hHrtfFastConv != NULL ) { @@ -860,8 +862,7 @@ static ivas_error ivas_binaural_hrtf_open( HrtfFastConv->allocate_init_flag = 1; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - int16_t n_channels = 0; - + n_channels = 0; if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) { n_channels = HRTF_LS_CHANNELS; -- GitLab From 4fb2209dceb062e52a4f80fcc54e343d99f1247f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Nov 2024 09:37:47 +0100 Subject: [PATCH 12/14] fix external renderer set-up --- apps/renderer.c | 2 +- lib_rend/lib_rend.c | 3 +++ lib_util/hrtf_file_reader.c | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 37c9a5ce82..4c0bdb1638 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -947,7 +947,7 @@ int main( #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, args.inConfig.ambisonicsBuses->audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3c19a8c268..a67bf004ae 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7652,6 +7652,9 @@ void IVAS_REND_Close( for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { clearInputSba( &hIvasRend->inputsSba[i] ); +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 + hIvasRend->hHrtfs.hHrtfFastConv = NULL; +#endif } for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index fb195279c8..1f55b81e5e 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2091,13 +2091,12 @@ ivas_error load_fastconv_HRTF_from_binary( if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && /* BRIRs */ - OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || + ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) { load = ( (BINAURAL_INPUT_AUDIO_CONFIG) hrtf_header.input_cfg == hrtf_set_binaural_cfg ) ? true : false; } - /* TBD: condition for external renderer */ - if ( load ) #else if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && -- GitLab From da0084e19545259c323b199f4ccf81d7865fa19d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Nov 2024 16:29:04 +0100 Subject: [PATCH 13/14] merge switches into one --- apps/decoder.c | 18 ++---- apps/renderer.c | 4 -- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_prot.h | 2 +- lib_com/options.h | 3 +- lib_dec/ivas_binRenderer_internal.c | 92 ++++++++++------------------- lib_dec/lib_dec.c | 40 ------------- lib_rend/ivas_stat_rend.h | 4 +- lib_rend/lib_rend.c | 4 +- lib_util/hrtf_file_reader.c | 38 ++++-------- lib_util/hrtf_file_reader.h | 4 +- 11 files changed, 56 insertions(+), 155 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index dfc86d7207..2849d39db5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -186,7 +186,7 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); #else static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs ); @@ -2380,7 +2380,7 @@ static ivas_error decodeG192( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( error = load_hrtf_from_file( hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) @@ -3295,7 +3295,7 @@ static ivas_error decodeVoIP( /* Load HRTF binary file data */ if ( arg.hrtfReaderEnabled ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( error = load_hrtf_from_file( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK ) @@ -3690,7 +3690,7 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( #endif -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /*---------------------------------------------------------------------* * load_hrtf_from_file() * @@ -3713,9 +3713,6 @@ static ivas_error load_hrtf_from_file( static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - const IVAS_AUDIO_CONFIG OutputConfig, -#endif const int32_t output_Fs ) #endif { @@ -3821,11 +3818,7 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) -#endif #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif @@ -3838,9 +3831,6 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( else { destroy_fastconv_hrtf( hHrtfFastConv ); -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - return error; -#endif } } } diff --git a/apps/renderer.c b/apps/renderer.c index 4c0bdb1638..dc779ada5a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -946,11 +946,7 @@ int main( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, args.inConfig.ambisonicsBuses->audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK ) -#else - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK ) -#endif #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 0, IVAS_AUDIO_CONFIG_INVALID, hrtfFileReader ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1309cdf79a..786a6d436b 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1495,7 +1495,7 @@ typedef enum #define BINAURAL_COHERENCE_DIFFERENCE_BINS 9 /* Number of bins for direction-dependent diffuse-field binaural coherence */ -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM typedef enum { BINAURAL_INPUT_AUDIO_CONFIG_INVALID, diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2e7c6eb80a..3513df00a4 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5136,7 +5136,7 @@ void ivas_init_binaural_hrtf( ivas_error ivas_allocate_binaural_hrtf( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM const int16_t n_channels, /* i : number of input channels */ #else const AUDIO_CONFIG input_config, /* i : input audio configuration */ diff --git a/lib_com/options.h b/lib_com/options.h index 811fa4e782..3228086c64 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,8 +161,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* VA: issue 1226: for FastConv binaural renderer in decoder, load only HTRT coefficient set that is needed */ -#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 /* removal of multiplied code */ -#define FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY + /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 59a67c6f29..a9075b1f0d 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -165,13 +165,13 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenderer->nInChannels = ( audioCfg2channels( input_config ) - isLoudspeaker ); } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM hBinRenConvModule->numTaps = hHrtf->ntaps; #endif if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM hBinRenConvModule->numTaps = hHrtf->ntaps_brir; #endif @@ -200,7 +200,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } else { -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( hBinRenderer->ivas_format == SBA_FORMAT ) { if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) @@ -334,7 +334,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( { int16_t tmp = 0; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM tmp = chIdx; #endif if ( isLoudspeaker ) @@ -367,7 +367,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( #endif } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM hBinRenConvModule->filterTapsLeftReal[bandIdx][chIdx] = hHrtf->leftReal[bandIdx][tmp]; hBinRenConvModule->filterTapsLeftImag[bandIdx][chIdx] = hHrtf->leftImag[bandIdx][tmp]; hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightReal[bandIdx][tmp]; @@ -410,10 +410,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( hBinRenConvModule->filterTapsRightReal[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3[bandIdx][chIdx]; hBinRenConvModule->filterTapsRightImag[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3[bandIdx][chIdx]; } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer - as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ -#endif else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { /* HOA2 filter coefficients */ @@ -471,7 +467,7 @@ void ivas_init_binaural_hrtf( { int16_t i; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal = NULL; HrtfFastConv->leftImag = NULL; HrtfFastConv->rightReal = NULL; @@ -583,7 +579,7 @@ static ivas_error ivas_alloc_pppMem( ivas_error ivas_allocate_binaural_hrtf( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM const int16_t n_channels, /* i : number of input channels */ #else const AUDIO_CONFIG input_config, /* i : input audio configuration */ @@ -593,33 +589,7 @@ ivas_error ivas_allocate_binaural_hrtf( const int16_t allocate_init_flag /* i : Memory allocation flag */ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - int16_t n_channels = 0; - - if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) || - ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) ) - { - n_channels = HRTF_LS_CHANNELS; - } - - if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) - { - if ( input_config == IVAS_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) - { - n_channels = HOA3_CHANNELS; - } - else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) - { - n_channels = HOA2_CHANNELS; - } - else if ( input_config == IVAS_AUDIO_CONFIG_FOA || bin_input_config == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) - { - n_channels = FOA_CHANNELS; - } - } -#endif - +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->n_channels = n_channels; if ( ( HrtfFastConv->leftReal != NULL ) && ( HrtfFastConv->leftImag != NULL ) && ( HrtfFastConv->rightReal != NULL ) && ( HrtfFastConv->rightImag != NULL ) ) @@ -792,7 +762,7 @@ static ivas_error ivas_binaural_hrtf_open( { int16_t i, j; ivas_error error; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM int16_t n_channels; #endif @@ -815,7 +785,7 @@ static ivas_error ivas_binaural_hrtf_open( if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->FASTCONV_latency_s = FASTCONV_HRIR_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS; #else @@ -824,7 +794,7 @@ static ivas_error ivas_binaural_hrtf_open( } if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA2_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; #else @@ -833,7 +803,7 @@ static ivas_error ivas_binaural_hrtf_open( } if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->FASTCONV_latency_s = FASTCONV_HOA3_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; #else @@ -842,7 +812,7 @@ static ivas_error ivas_binaural_hrtf_open( } if ( input_config == IVAS_AUDIO_CONFIG_FOA ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->FASTCONV_latency_s = FASTCONV_FOA_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_SBA; #else @@ -851,7 +821,7 @@ static ivas_error ivas_binaural_hrtf_open( } if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->FASTCONV_latency_s = FASTCONV_BRIR_latency_s; HrtfFastConv->ntaps = BINAURAL_NTAPS_MAX; #else @@ -861,7 +831,7 @@ static ivas_error ivas_binaural_hrtf_open( HrtfFastConv->allocate_init_flag = 1; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM n_channels = 0; if ( ( renderer_type == RENDERER_BINAURAL_FASTCONV || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && input_config != IVAS_AUDIO_CONFIG_INVALID ) { @@ -894,7 +864,7 @@ static ivas_error ivas_binaural_hrtf_open( for ( i = 0; i < BINAURAL_CONVBANDS; i++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( renderer_type == RENDERER_BINAURAL_FASTCONV && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) #else if ( renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -902,7 +872,7 @@ static ivas_error ivas_binaural_hrtf_open( { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal[i][j] = leftHRIRReal[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal[i][j]; @@ -915,7 +885,7 @@ static ivas_error ivas_binaural_hrtf_open( #endif } } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && HrtfFastConv->n_channels == HRTF_LS_CHANNELS ) #else else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) @@ -923,7 +893,7 @@ static ivas_error ivas_binaural_hrtf_open( { for ( j = 0; j < HRTF_LS_CHANNELS; j++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal[i][j] = leftBRIRReal[i][j]; HrtfFastConv->leftImag[i][j] = leftBRIRImag[i][j]; HrtfFastConv->rightReal[i][j] = rightBRIRReal[i][j]; @@ -937,7 +907,7 @@ static ivas_error ivas_binaural_hrtf_open( } } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( input_config == IVAS_AUDIO_CONFIG_HOA3 && HrtfFastConv->n_channels == HOA3_CHANNELS ) #else if ( input_config == IVAS_AUDIO_CONFIG_HOA3 ) @@ -945,7 +915,7 @@ static ivas_error ivas_binaural_hrtf_open( { for ( j = 0; j < HOA3_CHANNELS; j++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA3[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA3[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA3[i][j]; @@ -959,11 +929,11 @@ static ivas_error ivas_binaural_hrtf_open( } } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* Note: IVAS_AUDIO_CONFIG_HOA2 and IVAS_AUDIO_CONFIG_FOA input configs. are not relevant in internal renderer as SBA to binaural always synthesizes HOA3 output for binauralization. However, the external renderer can use them. */ #endif -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( input_config == IVAS_AUDIO_CONFIG_HOA2 && HrtfFastConv->n_channels == HOA2_CHANNELS ) #else if ( input_config == IVAS_AUDIO_CONFIG_HOA2 ) @@ -971,7 +941,7 @@ static ivas_error ivas_binaural_hrtf_open( { for ( j = 0; j < HOA2_CHANNELS; j++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal[i][j] = leftHRIRReal_HOA2[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_HOA2[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_HOA2[i][j]; @@ -985,7 +955,7 @@ static ivas_error ivas_binaural_hrtf_open( } } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( input_config == IVAS_AUDIO_CONFIG_FOA && HrtfFastConv->n_channels == FOA_CHANNELS ) #else if ( input_config == IVAS_AUDIO_CONFIG_FOA ) @@ -993,7 +963,7 @@ static ivas_error ivas_binaural_hrtf_open( { for ( j = 0; j < FOA_CHANNELS; j++ ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM HrtfFastConv->leftReal[i][j] = leftHRIRReal_FOA[i][j]; HrtfFastConv->leftImag[i][j] = leftHRIRImag_FOA[i][j]; HrtfFastConv->rightReal[i][j] = rightHRIRReal_FOA[i][j]; @@ -1242,7 +1212,7 @@ ivas_error ivas_rend_openCldfbRend( return error; } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); #else if ( inConfig == IVAS_AUDIO_CONFIG_FOA ) @@ -1385,7 +1355,7 @@ ivas_error ivas_binRenderer_open( } hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); #else st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s * 1000000000.f ); @@ -1399,7 +1369,7 @@ ivas_error ivas_binRenderer_open( return error; } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM st_ivas->binaural_latency_ns = (int32_t) ( st_ivas->hHrtfFastConv->FASTCONV_latency_s * 1000000000.f ); #else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) @@ -1655,7 +1625,7 @@ void ivas_binaural_hrtf_close( ) { int16_t allocate_init_flag; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM int16_t n_channels; #endif @@ -1665,7 +1635,7 @@ void ivas_binaural_hrtf_close( } allocate_init_flag = ( *hHrtfFastConv )->allocate_init_flag; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM n_channels = ( *hHrtfFastConv )->n_channels; ivas_free_pppHrtfMem( &( *hHrtfFastConv )->leftReal, n_channels, allocate_init_flag ); diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4a159dddd5..70c021228d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1015,7 +1015,6 @@ ivas_error IVAS_DEC_ReadFormat( *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { /* SHD HRIRs */ @@ -1039,45 +1038,6 @@ ivas_error IVAS_DEC_ReadFormat( *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; } } -#else - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) - { - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || - output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - /* SHD transformed HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; - } - else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; - } - } - else if ( st_ivas->ivas_format == MC_FORMAT ) - { - /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; - - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - /* HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL; - } - - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) - { - /* SHD transformed HRIRs for low complexity rotation */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; - - if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; - } - } - } -#endif } #else *intern_audio_config = st_ivas->intern_config; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b4c50f6069..f24ff2ca3f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1257,7 +1257,7 @@ typedef struct ivas_hrtfs_crend_structure /* Fastconv binaural data structure */ typedef struct ivas_hrtfs_fastconv_struct { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM float FASTCONV_latency_s; float ***leftReal; float ***leftImag; @@ -1297,7 +1297,7 @@ typedef struct ivas_hrtfs_fastconv_struct #endif int16_t allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM uint16_t ntaps; #else uint16_t ntaps_hrir; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a67bf004ae..f866cff06b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7501,7 +7501,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, @@ -7652,7 +7652,7 @@ void IVAS_REND_Close( for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) { clearInputSba( &hIvasRend->inputsSba[i] ); -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM hIvasRend->hHrtfs.hHrtfFastConv = NULL; #endif } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 1f55b81e5e..8c20814f50 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -56,7 +56,7 @@ typedef struct ivas_hrtfs_file_header_t } ivas_hrtfs_file_header_t; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM typedef enum { BINAURAL_INPUT_AUDIO_CONFIG_INVALID, @@ -251,7 +251,7 @@ static ivas_error read_hrtf_binary_header( return IVAS_ERR_END_OF_FILE; } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /*-------------------------------------------------------------------* * audio_cfg_2_binaural_cfg() @@ -1419,7 +1419,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( uint16_t ); -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps = ntaps; ( *hHRTF )->FASTCONV_latency_s = latency_s; @@ -1432,7 +1432,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps_hrir = ntaps; ( *hHRTF )->FASTCONV_HRIR_latency_s = latency_s; #endif @@ -1443,7 +1443,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA3_CHANNELS)" ); } -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps_hrir_hoa3 = ntaps; ( *hHRTF )->FASTCONV_HOA3_latency_s = latency_s; #endif @@ -1454,7 +1454,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HOA2_CHANNELS)" ); } -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps_hrir_hoa2 = ntaps; ( *hHRTF )->FASTCONV_HOA2_latency_s = latency_s; #endif @@ -1465,7 +1465,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (FOA_CHANNELS)" ); } -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps_hrir_foa = ntaps; ( *hHRTF )->FASTCONV_FOA_latency_s = latency_s; #endif @@ -1476,7 +1476,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_LS_CHANNELS)" ); } -#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifndef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM ( *hHRTF )->ntaps_brir = ntaps; ( *hHRTF )->FASTCONV_BRIR_latency_s = latency_s; #endif @@ -1488,7 +1488,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, nbchan, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) @@ -1499,7 +1499,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) { -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, nbchan, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, IVAS_AUDIO_CONFIG_INVALID, input_cfg, RENDERER_BINAURAL_FASTCONV_ROOM, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) @@ -1513,7 +1513,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_2 +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM /* HRIR/BRIR Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); @@ -2022,10 +2022,8 @@ static ivas_error create_parambin_HRTF_from_rawdata( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ -#endif #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ #else const int16_t room_reverb_flag, /* i : room reverb flag */ @@ -2042,7 +2040,7 @@ ivas_error load_fastconv_HRTF_from_binary( ivas_hrtfs_file_header_t hrtfs_file_header; int16_t hrtf_id; int16_t asFastconv = 0; -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY +#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM bool load = false; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; @@ -2087,7 +2085,6 @@ ivas_error load_fastconv_HRTF_from_binary( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && /* HRIRs */ ( OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL || OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && /* BRIRs */ @@ -2098,15 +2095,6 @@ ivas_error load_fastconv_HRTF_from_binary( } if ( load ) -#else - if ( ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && - ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA3 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 && fastConv_set_cfg == IVAS_AUDIO_CONFIG_HOA2 ) || - ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA && fastConv_set_cfg == IVAS_AUDIO_CONFIG_FOA ) ) ) || - ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED && fastConv_set_cfg == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || - ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV || hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && fastConv_set_cfg == IVAS_AUDIO_CONFIG_EXTERNAL ) ) -#endif #else if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && ( ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 && intern_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) || diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 70620cb00e..fae6eb25cf 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -132,10 +132,8 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ -#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM_SIMPLIFY - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ -#endif #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ #else const int16_t room_reverb_flag, /* i : room reverb flag */ -- GitLab From f55b22e5132aa67fe83bf1f1ec7001abf098ed53 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 28 Nov 2024 16:44:39 +0100 Subject: [PATCH 14/14] rename 'fastConv_set_cfg' to 'hrtf_set_audio_cfg' --- apps/decoder.c | 12 ++++++------ lib_dec/lib_dec.c | 12 ++++++------ lib_dec/lib_dec.h | 2 +- lib_rend/lib_rend.c | 2 +- lib_util/hrtf_file_reader.c | 18 +++++++++--------- lib_util/hrtf_file_reader.h | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2849d39db5..2b18205f87 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -169,7 +169,7 @@ typedef struct IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG fastConv_set_cfg; + IVAS_AUDIO_CONFIG hrtf_set_audio_cfg; #else IVAS_AUDIO_CONFIG intern_audio_config; int16_t room_reverb_flag; @@ -720,7 +720,7 @@ int main( } /*------------------------------------------------------------------------------------------* - * Load HRTF binary file data + * Initialize HRTF binary file data *------------------------------------------------------------------------------------------*/ if ( arg.hrtfReaderEnabled ) @@ -730,7 +730,7 @@ int main( hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE; hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - hHrtfBinary.fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; + hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; #else hHrtfBinary.room_reverb_flag = 0; hHrtfBinary.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID; @@ -2366,7 +2366,7 @@ static ivas_error decodeG192( hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer; hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->fastConv_set_cfg ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->room_reverb_flag, &hHrtfBinary->intern_audio_config ) ) != IVAS_ERR_OK ) #endif @@ -3281,7 +3281,7 @@ static ivas_error decodeVoIP( hHrtf->binaural_renderer_old = hHrtf->binaural_renderer; hHrtf->binaural_renderer_sec_old = hHrtf->binaural_renderer_sec; #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->fastConv_set_cfg ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->room_reverb_flag, &hHrtf->intern_audio_config ) ) != IVAS_ERR_OK ) #endif @@ -3818,7 +3818,7 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 70c021228d..baa70ce54a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -910,7 +910,7 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o : secondary binaural renderer type */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend.*/ + IVAS_AUDIO_CONFIG *hrtf_set_audio_cfg /* o : HRTF set audio config. */ #else int16_t *room_reverb_flag, /* o : room reverb flag */ IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ @@ -1012,30 +1012,30 @@ ivas_error IVAS_DEC_ReadFormat( } #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID; + *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID; if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { /* SHD HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_HOA3; if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { /* BRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_7_1_4; + *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4; } } else if ( st_ivas->ivas_format == MC_FORMAT ) { /* HRIRs */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_7_1_4; + *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4; if ( ( st_ivas->hDecoderConfig->Opt_Headrotation ) && !( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { /* SHD HRIRs for low complexity rotation */ - *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3; + *hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_HOA3; } } } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d2dfa10c8a..48794851a8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -158,7 +158,7 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_BIN_RENDERER_TYPE *binaural_renderer, /* o : binaural renderer type */ IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec,/* o: secondary binaural renderer type */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o : HRTF set audio config. for FastConv rend. */ + IVAS_AUDIO_CONFIG *hrtf_set_audio_cfg /* o : HRTF set audio config. */ #else int16_t *room_reverb_flag, /* o : room reverb flag */ IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f866cff06b..7cb6c67257 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7501,7 +7501,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8c20814f50..f8816b75e9 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -260,13 +260,13 @@ static ivas_error read_hrtf_binary_header( --------------------------------------------------------------------*/ static BINAURAL_INPUT_AUDIO_CONFIG audio_cfg_2_binaural_cfg( - const IVAS_AUDIO_CONFIG fastConv_set_cfg ) + const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg ) { BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED; - switch ( fastConv_set_cfg ) + switch ( hrtf_set_audio_cfg ) { case IVAS_AUDIO_CONFIG_7_1_4: hrtf_set_binaural_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED; @@ -2021,15 +2021,15 @@ static ivas_error create_parambin_HRTF_from_rawdata( *---------------------------------------------------------------------*/ ivas_error load_fastconv_HRTF_from_binary( - IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ - const IVAS_AUDIO_CONFIG fastConv_set_cfg, /* i : HRTF set audio config. for FastConv rend. */ + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ + const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ #else - const int16_t room_reverb_flag, /* i : room reverb flag */ - const IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ + const int16_t room_reverb_flag, /* i : room reverb flag */ + const IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ #endif - const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ + const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ) { FILE *f_hrtf; @@ -2045,7 +2045,7 @@ ivas_error load_fastconv_HRTF_from_binary( BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; /* convert audio config. to HRTF binaural config */ - hrtf_set_binaural_cfg = audio_cfg_2_binaural_cfg( fastConv_set_cfg ); + hrtf_set_binaural_cfg = audio_cfg_2_binaural_cfg( hrtf_set_audio_cfg ); #endif if ( hrtfReader == NULL || hrtfReader->file == NULL ) diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index fae6eb25cf..c8507f4900 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -133,8 +133,8 @@ void destroy_SetOfHRTF( ivas_error load_fastconv_HRTF_from_binary( IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ #ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM - const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ - const IVAS_AUDIO_CONFIG hrtf_set_config, /* i : HRTF set audio config. for FastConv rend. */ + const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ + const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ #else const int16_t room_reverb_flag, /* i : room reverb flag */ IVAS_AUDIO_CONFIG intern_audio_config, /* i : internal audio configuration */ -- GitLab