From d58e455c00c98061192f6826a2d8b74dbbb3a431 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 20 Nov 2025 13:51:46 +0200 Subject: [PATCH 1/2] Fix issue 1452 by refactoring the default reverb setting into earlier step in renderer init. --- apps/renderer.c | 59 ++++++++++++++++++++++------ lib_rend/lib_rend.c | 94 +-------------------------------------------- 2 files changed, 48 insertions(+), 105 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 753a116c15..9c6168490e 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1101,6 +1101,53 @@ int main( fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); goto cleanup; } +#ifdef FIX_1318_ROOM_SIZE_CMD_LINE + + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + /* Set reverb room size if specified or select based automatically based on default per input formats */ + IVAS_ROOM_SIZE_T selectedReverbRoomSize = args.reverbRoomSize; + if ( selectedReverbRoomSize == IVAS_ROOM_SIZE_AUTO ) + { + bool combinedFormat = false; + selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM; + + /* ISM present with MASA/SBA inputs; treat as combined format */ + if ( args.inConfig.numAudioObjects > 0 && ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 ) ) + { + combinedFormat = true; + } + + if ( combinedFormat ) + { + selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM; + } + else + { + /* Only set large if ISM is present alone, MASA and Ambisonic have been checked above */ + if ( args.inConfig.numAudioObjects > 0 && args.inConfig.numMultiChannelBuses == 0 ) + { + selectedReverbRoomSize = IVAS_ROOM_SIZE_LARGE; + } + /* if only MC is present, set medium; Will not be overridden by the subsequent block */ + else if ( args.inConfig.numMultiChannelBuses > 0 ) + { + selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM; + } + else if ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 ) + { + selectedReverbRoomSize = IVAS_ROOM_SIZE_SMALL; + } + } + } + + if ( ( IVAS_REND_SetReverbRoomSize( hIvasRend, selectedReverbRoomSize ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError setting reverb room size\n" ); + goto cleanup; + } + } +#endif if ( args.renderConfigFilePath[0] != '\0' ) { @@ -1176,18 +1223,6 @@ int main( fprintf( stderr, "\nError in IVAS_REND_SetOrientationTrackingMode(): %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE - - /* Set reverb room size if specified */ - if ( args.reverbRoomSize != IVAS_ROOM_SIZE_AUTO ) - { - if ( ( IVAS_REND_SetReverbRoomSize( hIvasRend, args.reverbRoomSize ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError setting reverb room size\n" ); - goto cleanup; - } - } -#endif /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5f1af59a95..36a6e2ddc8 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3809,85 +3809,6 @@ static ivas_error isar_pre_rend_init( return IVAS_ERR_OK; } -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE -static IVAS_ROOM_SIZE_T getDefaultReverbSize( - input_ism *ismInputs, - input_masa *masaInputs, - input_mc *mcInputs, - input_sba *sbaInputs ) -{ - bool combinedFormat; - int16_t i; - int16_t nActiveInputsIsm, nActiveInputsMasa, nActiveInputsSba, nActiveInputsMc; - IVAS_ROOM_SIZE_T selectedReverb; - selectedReverb = IVAS_ROOM_SIZE_MEDIUM; - - combinedFormat = false; - nActiveInputsIsm = 0; - nActiveInputsMasa = 0; - nActiveInputsMc = 0; - nActiveInputsSba = 0; - - for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ ) - { - if ( ismInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) - { - nActiveInputsIsm++; - } - } - for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ ) - { - if ( masaInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) - { - nActiveInputsMasa++; - } - } - for ( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ ) - { - if ( mcInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) - { - nActiveInputsMc++; - } - } - for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ ) - { - if ( sbaInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) - { - nActiveInputsSba++; - } - } - - /* ISM present with MASA/SBA inputs; treat as combined format */ - if ( nActiveInputsIsm && ( nActiveInputsMasa || nActiveInputsSba ) ) - { - combinedFormat = true; - } - - if ( combinedFormat ) - { - selectedReverb = IVAS_ROOM_SIZE_MEDIUM; - } - else - { - /* Only set large if ISM is present alone */ - if ( nActiveInputsIsm && !nActiveInputsMc ) - { - selectedReverb = IVAS_ROOM_SIZE_LARGE; - } - /* if only MC is present, set medium; Will not be overridden by the subsequent block */ - else if ( nActiveInputsMc ) - { - selectedReverb = IVAS_ROOM_SIZE_MEDIUM; - } - else if ( nActiveInputsMasa || nActiveInputsSba ) - { - selectedReverb = IVAS_ROOM_SIZE_SMALL; - } - } - - return selectedReverb; -} -#endif /*-------------------------------------------------------------------* @@ -3987,18 +3908,6 @@ ivas_error IVAS_REND_AddInput( /* set global maximum delay after adding an input */ setMaxGlobalDelayNs( hIvasRend ); -#ifdef FIX_1318_ROOM_SIZE_CMD_LINE - - /* select default reverb size after adding an input */ - if ( hIvasRend->selectedRoomReverbSize == DEFAULT_REVERB_UNSET ) - { - IVAS_REND_SetReverbRoomSize( hIvasRend, - getDefaultReverbSize( hIvasRend->inputsIsm, - hIvasRend->inputsMasa, - hIvasRend->inputsMc, - hIvasRend->inputsSba ) ); - } -#endif return IVAS_ERR_OK; } @@ -5289,8 +5198,7 @@ ivas_error IVAS_REND_SetReverbRoomSize( break; case IVAS_ROOM_SIZE_AUTO: default: - hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET; - break; /* will be setup in IVAS_REND_AddInput() */ + assert( 0 && "Room size is not set"); } if ( hIvasRend->hRendererConfig != NULL ) -- GitLab From c26312beae18edba53e52ce92cf77bb44786a4fb Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 20 Nov 2025 13:56:58 +0200 Subject: [PATCH 2/2] Clang format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 36a6e2ddc8..c0c97f0bed 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5198,7 +5198,7 @@ ivas_error IVAS_REND_SetReverbRoomSize( break; case IVAS_ROOM_SIZE_AUTO: default: - assert( 0 && "Room size is not set"); + assert( 0 && "Room size is not set" ); } if ( hIvasRend->hRendererConfig != NULL ) -- GitLab