From 00bd7ed643d4eae70aedec725c7b22dd196b0d44 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 22 Apr 2026 09:02:56 +0200 Subject: [PATCH 1/8] Range check refactoring --- apps/decoder.c | 20 +++++ apps/renderer.c | 12 +++ lib_com/options.h | 1 + lib_util/render_config_reader.c | 151 ++++++++++++++++++++++++++++++++ lib_util/render_config_reader.h | 6 ++ 5 files changed, 190 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index cc437dfe8..a68ea3c18 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -615,6 +615,14 @@ int main( goto cleanup; } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + goto cleanup; + } +#endif + aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); if ( aeCount > 0 ) { @@ -696,11 +704,13 @@ int main( { if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); goto cleanup; } +#endif } else { @@ -2340,6 +2350,14 @@ static ivas_error decodeG192( fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } + +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + goto cleanup; + } +#endif } for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -2541,11 +2559,13 @@ static ivas_error decodeG192( arg.aeSequence.frameCounter = 0; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); goto cleanup; } +#endif } else { diff --git a/apps/renderer.c b/apps/renderer.c index 2c6d6fed6..cc47ac8b7 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1126,6 +1126,14 @@ int main( goto cleanup; } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + goto cleanup; + } +#endif + if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, args.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", args.directivityPatternId[0], args.directivityPatternId[1], args.directivityPatternId[2], args.directivityPatternId[3] ); @@ -1143,11 +1151,13 @@ int main( aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : IVAS_DEFAULT_AEID; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid room acoustics configuration parameters\n\n" ); goto cleanup; } +#endif } else { @@ -1562,11 +1572,13 @@ int main( args.aeSequence.frameCounter = 0; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid acoustic environment configuration parameters\n\n" ); goto cleanup; } +#endif } else { diff --git a/lib_com/options.h b/lib_com/options.h index 694e97ef9..78d614fef 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,7 @@ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ +#define FIX_2500_ISM4_BIN_REVERB_DISTORTION /* FhG: Basop issue #2500: Move RenderConfigReader_checkValues() to operate on RenderConfigReader float values before fixed-point conversion. */ #define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Basop issue 2023: Distance attenuation scaling, synch with BASOP updates and adding clamping of distance att input and listener position */ #define FIX_1574_EFAP_CODE_LINT /* FhG: issue 1574: Code quality fixes in ivas_efap.c */ #define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS /* Nokia: float issue 1569: fix render config checks in renderer */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 789c0358a..29e94d6ca 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1230,6 +1230,156 @@ static int32_t errorHandler( * Verifies if the configuration parameters lie within acceptable limits *------------------------------------------------------------------------------------------*/ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +ivas_error RenderConfigReader_checkValues( + RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ +) +{ + int16_t band_idx, tab_value_err_count; + int16_t wall_idx; + uint32_t n, i; + + tab_value_err_count = 0; + + /* Verify all acoustic environments */ + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + AcousticEnv *pAE = &pRenderConfigReader->pAE[n]; + int16_t nBands = (int16_t) pAE->pFG->nrBands; + + /* Verify the number of frequency bands in the config input data */ + if ( ( nBands > N_BANDS_MAX ) || ( nBands < N_BANDS_MIN ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + /* Verify input pre-delay value */ + if ( ( pAE->preDelay > INPUTPREDELAY_MAX ) || ( pAE->preDelay < INPUTPREDELAY_MIN ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + /* Verify data per band in the acoustic properties table */ + for ( band_idx = 0; band_idx < nBands; band_idx++ ) + { + /* Verify if the frequencies are in the ascending order (required for interpolation) */ + if ( band_idx != 0 ) + { + if ( pAE->pFG->pFc[band_idx] <= pAE->pFG->pFc[band_idx - 1] ) + { + tab_value_err_count++; + } + } + + /* Check the input frequencies */ + if ( ( pAE->pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( pAE->pFG->pFc[band_idx] < FC_INPUT_MIN ) ) + { + tab_value_err_count++; + } + + /* Check the input RT60 values */ + if ( ( pAE->pRT60[band_idx] > ACOUSTIC_RT60_MAX ) || ( pAE->pRT60[band_idx] < ACOUSTIC_RT60_MIN ) ) + { + tab_value_err_count++; + } + + /* Check the input DSR values */ + if ( ( pAE->pDSR[band_idx] > ACOUSTIC_DSR_MAX ) || ( pAE->pDSR[band_idx] < ACOUSTIC_DSR_MIN ) ) + { + tab_value_err_count++; + } + + /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ + if ( pAE->pDSR[band_idx] <= 0.0f ) + { + pAE->pDSR[band_idx] = ACOUSTIC_DSR_EPSILON; + } + } + + if ( tab_value_err_count != 0 ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + /* Early reflections parameter clamping */ + if ( pAE->pEarlyReflections != NULL && pAE->pEarlyReflections->use_er == 1 ) + { + /* Room dimensions */ + if ( pAE->pEarlyReflections->dimensions.x < ER_MIN_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.x = ER_MIN_ROOM_DIMENSION; + } + if ( pAE->pEarlyReflections->dimensions.x > ER_MAX_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.x = ER_MAX_ROOM_DIMENSION; + } + if ( pAE->pEarlyReflections->dimensions.y < ER_MIN_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.y = ER_MIN_ROOM_DIMENSION; + } + if ( pAE->pEarlyReflections->dimensions.y > ER_MAX_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.y = ER_MAX_ROOM_DIMENSION; + } + if ( pAE->pEarlyReflections->dimensions.z < ER_MIN_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.z = ER_MIN_ROOM_DIMENSION; + } + if ( pAE->pEarlyReflections->dimensions.z > ER_MAX_ROOM_DIMENSION ) + { + pAE->pEarlyReflections->dimensions.z = ER_MAX_ROOM_DIMENSION; + } + + /* Abs Coeff */ + for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) + { + if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) + { + pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; + } + if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) + { + pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; + } + } + } + } + + /* Apply default distance attenuation if not specified in config */ + if ( pRenderConfigReader->distAtt[0] == -1 ) + { + pRenderConfigReader->distAtt[0] = 15.75f; + pRenderConfigReader->distAtt[1] = 1.0f; + pRenderConfigReader->distAtt[2] = 1.0f; + } + + /* Verify range of distance attenuation parameters */ +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION + /* refDist: 0.0 <= distAtt[1] <= 6.3 */ + /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ + /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ + pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); + pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); + pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); +#else + /* 0.1 <= distAtt[0] <= distAtt[1] */ + /* 0.0 <= distAtt[2] <= 10.0 */ + pRenderConfigReader->distAtt[0] = max( 0.1f, pRenderConfigReader->distAtt[0] ); + pRenderConfigReader->distAtt[1] = max( pRenderConfigReader->distAtt[0], pRenderConfigReader->distAtt[1] ); + pRenderConfigReader->distAtt[2] = max( 0.0f, min( 10.0f, pRenderConfigReader->distAtt[2] ) ); +#endif + + /* Verify range of directivity patterns */ + for ( i = 0; i < pRenderConfigReader->nDP; i++ ) + { + pRenderConfigReader->pDP[i].pDirectivity[0] = max( 0.0f, min( 360.0f, pRenderConfigReader->pDP[i].pDirectivity[0] ) ); + pRenderConfigReader->pDP[i].pDirectivity[1] = max( 0.0f, min( 360.0f, pRenderConfigReader->pDP[i].pDirectivity[1] ) ); + pRenderConfigReader->pDP[i].pDirectivity[2] = max( 0.0f, min( 1.0f, pRenderConfigReader->pDP[i].pDirectivity[2] ) ); + } + + return IVAS_ERR_OK; +} +#else /* !FIX_2500_ISM4_BIN_REVERB_DISTORTION */ ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ ) @@ -1364,6 +1514,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } +#endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ /*------------------------------------------------------------------------------------------* diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 105d5d194..9db24cc32 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -79,9 +79,15 @@ ivas_error RenderConfigReader_getDistanceAttenuation( float *distAtt /* o : Distance attenuation */ ); /* Verifies configuration parameters */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +ivas_error RenderConfigReader_checkValues( + RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ +); +#else ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ ); +#endif /* Reads a configuration */ ivas_error RenderConfigReader_read( -- GitLab From 5957044e87d84f8b20ea146b8a6390b9dd66fac6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 13:57:00 +0200 Subject: [PATCH 2/8] Cleanup --- apps/decoder.c | 8 ++++---- apps/renderer.c | 6 +++--- lib_com/options.h | 2 +- lib_util/render_config_reader.c | 6 +++--- lib_util/render_config_reader.h | 8 +++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index a68ea3c18..58ac7fa08 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -615,7 +615,7 @@ int main( goto cleanup; } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); @@ -704,7 +704,7 @@ int main( { if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); @@ -2351,7 +2351,7 @@ static ivas_error decodeG192( goto cleanup; } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); @@ -2559,7 +2559,7 @@ static ivas_error decodeG192( arg.aeSequence.frameCounter = 0; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); diff --git a/apps/renderer.c b/apps/renderer.c index cc47ac8b7..e33bbbd25 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1126,7 +1126,7 @@ int main( goto cleanup; } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); @@ -1151,7 +1151,7 @@ int main( aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : IVAS_DEFAULT_AEID; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid room acoustics configuration parameters\n\n" ); @@ -1572,7 +1572,7 @@ int main( args.aeSequence.frameCounter = 0; if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid acoustic environment configuration parameters\n\n" ); diff --git a/lib_com/options.h b/lib_com/options.h index 78d614fef..e3c00e825 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,7 @@ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ #define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API /* Expose Payload Type setting in RTP Header */ -#define FIX_2500_ISM4_BIN_REVERB_DISTORTION /* FhG: Basop issue #2500: Move RenderConfigReader_checkValues() to operate on RenderConfigReader float values before fixed-point conversion. */ +#define FIX_2500_RENDCONF_REFACTOR /* Eri: Basop issue #2500: Renderer configuration range check before conversion to fixed point. Harmonize between BASOP/float */ #define FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Eri: Basop issue 2023: Distance attenuation scaling, synch with BASOP updates and adding clamping of distance att input and listener position */ #define FIX_1574_EFAP_CODE_LINT /* FhG: issue 1574: Code quality fixes in ivas_efap.c */ #define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS /* Nokia: float issue 1569: fix render config checks in renderer */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 29e94d6ca..4c8ce1fbe 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1230,7 +1230,7 @@ static int32_t errorHandler( * Verifies if the configuration parameters lie within acceptable limits *------------------------------------------------------------------------------------------*/ -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifdef FIX_2500_RENDCONF_REFACTOR ivas_error RenderConfigReader_checkValues( RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ ) @@ -1379,7 +1379,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } -#else /* !FIX_2500_ISM4_BIN_REVERB_DISTORTION */ +#else ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ ) @@ -1514,7 +1514,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } -#endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ +#endif /*------------------------------------------------------------------------------------------* diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 9db24cc32..89f7c58d6 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -79,15 +79,13 @@ ivas_error RenderConfigReader_getDistanceAttenuation( float *distAtt /* o : Distance attenuation */ ); /* Verifies configuration parameters */ -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION ivas_error RenderConfigReader_checkValues( - RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ -); +#ifdef FIX_2500_RENDCONF_REFACTOR + RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ #else -ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ -); #endif +); /* Reads a configuration */ ivas_error RenderConfigReader_read( -- GitLab From 5cad16d375cfa16146472d37d0d71a7dd1daca52 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 14:09:19 +0200 Subject: [PATCH 3/8] Align RenderConfigReader_checkValues between BASOP/float --- lib_util/render_config_reader.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 003911e6d..73b048ca7 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1237,7 +1237,7 @@ ivas_error RenderConfigReader_checkValues( { int16_t band_idx, tab_value_err_count; int16_t wall_idx; - uint32_t n, i; + int16_t n, i; tab_value_err_count = 0; @@ -1353,21 +1353,12 @@ ivas_error RenderConfigReader_checkValues( pRenderConfigReader->distAtt[2] = 1.0f; } - /* Verify range of distance attenuation parameters */ -#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION - /* refDist: 0.0 <= distAtt[1] <= 6.3 */ - /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ - /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ + /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ + /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ + /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); -#else - /* 0.1 <= distAtt[0] <= distAtt[1] */ - /* 0.0 <= distAtt[2] <= 10.0 */ - pRenderConfigReader->distAtt[0] = max( 0.1f, pRenderConfigReader->distAtt[0] ); - pRenderConfigReader->distAtt[1] = max( pRenderConfigReader->distAtt[0], pRenderConfigReader->distAtt[1] ); - pRenderConfigReader->distAtt[2] = max( 0.0f, min( 10.0f, pRenderConfigReader->distAtt[2] ) ); -#endif /* Verify range of directivity patterns */ for ( i = 0; i < pRenderConfigReader->nDP; i++ ) -- GitLab From ffb173538a652d058dab38bcef1aae1c27330c93 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 14:22:10 +0200 Subject: [PATCH 4/8] Fix type on counter --- lib_util/render_config_reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 73b048ca7..03fd0fe67 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1237,7 +1237,7 @@ ivas_error RenderConfigReader_checkValues( { int16_t band_idx, tab_value_err_count; int16_t wall_idx; - int16_t n, i; + uint32_t n, i; tab_value_err_count = 0; -- GitLab From 9baff5a3b322766bd4cfa6cc16c52806a6c59728 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 27 Apr 2026 22:44:46 +0200 Subject: [PATCH 5/8] Cleanup under FIX_2500_RENDCONF_REFACTOR --- apps/decoder.c | 24 +++++++++++++----- apps/renderer.c | 22 +++++++++++++---- lib_util/render_config_reader.c | 43 ++++++++++++++++++++------------- lib_util/render_config_reader.h | 2 +- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 44fe25c4f..71933ddeb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -624,7 +624,7 @@ int main( #ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + fprintf( stderr, "Invalid renderer configuration parameters\n\n" ); goto cleanup; } #endif @@ -708,21 +708,27 @@ int main( if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); + goto cleanup; + } +#else if ( ( error = IVAS_DEC_GetAcousticEnvironment( hIvasDec, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid reverberation configuration parameters\n\n" ); goto cleanup; } -#endif } else { fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); goto cleanup; } +#endif } /* ISAR frame size is set from command line, not renderer config file. @@ -2364,7 +2370,7 @@ static ivas_error decodeG192( #ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + fprintf( stderr, "Invalid renderer configuration parameters\n\n" ); goto cleanup; } #endif @@ -2567,21 +2573,27 @@ static ivas_error decodeG192( arg.aeSequence.selected = 0; } arg.aeSequence.frameCounter = 0; +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to get acoustic environment with ID %d\n\n", arg.aeSequence.pID[arg.aeSequence.selected] ); + goto cleanup; + } +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); goto cleanup; } -#endif } else { fprintf( stderr, "Failed to get acoustic environment with ID %d\n\n", arg.aeSequence.pID[arg.aeSequence.selected] ); goto cleanup; } +#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/apps/renderer.c b/apps/renderer.c index b37646f6f..6e2f6cb15 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1176,7 +1176,7 @@ int main( #ifdef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nInvalid render configuration parameters\n\n" ); + fprintf( stderr, "Invalid renderer configuration parameters\n\n" ); goto cleanup; } #endif @@ -1196,21 +1196,27 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : IVAS_DEFAULT_AEID; +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", aeID ); + goto cleanup; + } +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid room acoustics configuration parameters\n\n" ); goto cleanup; } -#endif } else { fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", aeID ); goto cleanup; } +#endif } /* ISAR frame size is set from command line, not renderer config file. @@ -1617,21 +1623,27 @@ int main( args.aeSequence.selected = 0; } args.aeSequence.frameCounter = 0; +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nFailed to get acoustic environment with ID %d\n\n", args.aeSequence.pID[args.aeSequence.selected] ); + goto cleanup; + } +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { -#ifndef FIX_2500_RENDCONF_REFACTOR if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { fprintf( stderr, "\nInvalid acoustic environment configuration parameters\n\n" ); goto cleanup; } -#endif } else { fprintf( stderr, "\nFailed to get acoustic environment with ID %d\n\n", args.aeSequence.pID[args.aeSequence.selected] ); goto cleanup; } +#endif if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n\n", ivas_error_to_string( error ) ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 03fd0fe67..7a85bcdb6 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1232,20 +1232,26 @@ static int32_t errorHandler( #ifdef FIX_2500_RENDCONF_REFACTOR ivas_error RenderConfigReader_checkValues( - RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ + RenderConfigReader *pRenderConfigReader /* i/o: Renderer configuration reader */ ) { - int16_t band_idx, tab_value_err_count; + int16_t tab_value_err_count; int16_t wall_idx; - uint32_t n, i; + uint32_t i; + uint32_t nBands; + uint32_t band_idx; + uint32_t n; + AcousticEnv *pAE; + FrequencyGrid *pFG; tab_value_err_count = 0; - /* Verify all acoustic environments */ + /* Check range for all Acoustic Environment IDs */ for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { - AcousticEnv *pAE = &pRenderConfigReader->pAE[n]; - int16_t nBands = (int16_t) pAE->pFG->nrBands; + pAE = &pRenderConfigReader->pAE[n]; + pFG = pAE->pFG; + nBands = pFG->nrBands; /* Verify the number of frequency bands in the config input data */ if ( ( nBands > N_BANDS_MAX ) || ( nBands < N_BANDS_MIN ) ) @@ -1265,14 +1271,14 @@ ivas_error RenderConfigReader_checkValues( /* Verify if the frequencies are in the ascending order (required for interpolation) */ if ( band_idx != 0 ) { - if ( pAE->pFG->pFc[band_idx] <= pAE->pFG->pFc[band_idx - 1] ) + if ( pFG->pFc[band_idx] <= pFG->pFc[band_idx - 1] ) { tab_value_err_count++; } } /* Check the input frequencies */ - if ( ( pAE->pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( pAE->pFG->pFc[band_idx] < FC_INPUT_MIN ) ) + if ( ( pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( pFG->pFc[band_idx] < FC_INPUT_MIN ) ) { tab_value_err_count++; } @@ -1301,7 +1307,6 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_WRONG_PARAMS; } - /* Early reflections parameter clamping */ if ( pAE->pEarlyReflections != NULL && pAE->pEarlyReflections->use_er == 1 ) { /* Room dimensions */ @@ -1345,20 +1350,23 @@ ivas_error RenderConfigReader_checkValues( } } - /* Apply default distance attenuation if not specified in config */ + /* Distance attenuation range check */ if ( pRenderConfigReader->distAtt[0] == -1 ) { + /* Default values */ pRenderConfigReader->distAtt[0] = 15.75f; pRenderConfigReader->distAtt[1] = 1.0f; pRenderConfigReader->distAtt[2] = 1.0f; } - - /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ - /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ - /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ - pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); - pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); - pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); + else + { + /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ + /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ + /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ + pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); + pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); + pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); + } /* Verify range of directivity patterns */ for ( i = 0; i < pRenderConfigReader->nDP; i++ ) @@ -1369,6 +1377,7 @@ ivas_error RenderConfigReader_checkValues( } return IVAS_ERR_OK; + } #else ivas_error RenderConfigReader_checkValues( diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 89f7c58d6..a46ed261d 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -81,7 +81,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( /* Verifies configuration parameters */ ivas_error RenderConfigReader_checkValues( #ifdef FIX_2500_RENDCONF_REFACTOR - RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ + RenderConfigReader *pRenderConfigReader /* i/o: Renderer configuration reader */ #else IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ #endif -- GitLab From 1a6394e6499f25ff2ed27f114169d321879560c5 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 27 Apr 2026 22:51:25 +0200 Subject: [PATCH 6/8] Clang format --- lib_util/render_config_reader.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 7a85bcdb6..ff851975f 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1239,7 +1239,7 @@ ivas_error RenderConfigReader_checkValues( int16_t wall_idx; uint32_t i; uint32_t nBands; - uint32_t band_idx; + uint32_t band_idx; uint32_t n; AcousticEnv *pAE; FrequencyGrid *pFG; @@ -1377,7 +1377,6 @@ ivas_error RenderConfigReader_checkValues( } return IVAS_ERR_OK; - } #else ivas_error RenderConfigReader_checkValues( -- GitLab From 60b934da451da87c1a762501a9bfe81eb0305149 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Apr 2026 09:53:07 +0200 Subject: [PATCH 7/8] Replace literals in distatt/directivity range check with constants --- lib_util/render_config_reader.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index ff851975f..882ed10a1 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -72,9 +72,19 @@ #define IVAS_ER_LIST_ORIGIN_Y 0.0f #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#define DIST_ATT_MIN_MAXDIST 0.0f +#define DIST_ATT_MIN_REFDIST 0.0f +#define DIST_ATT_MIN_ROLLOFF 0.0f #define DIST_ATT_MAX_MAXDIST 63.0f #define DIST_ATT_MAX_REFDIST 6.3f #define DIST_ATT_MAX_ROLLOFF 4.0f +#define DIST_ATT_DEFAULT_MAXDIST 15.75f +#define DIST_ATT_DEFAULT_REFDIST 1.0f +#define DIST_ATT_DEFAULT_ROLLOFF 1.0f +#define DIRECTIVITY_MIN_ANGLE 0.0f +#define DIRECTIVITY_MAX_ANGLE 360.0f +#define DIRECTIVITY_MIN_ATT_FAC 0.0f +#define DIRECTIVITY_MAX_ATT_FAC 1.0f #endif #ifndef TRUE @@ -1354,26 +1364,26 @@ ivas_error RenderConfigReader_checkValues( if ( pRenderConfigReader->distAtt[0] == -1 ) { /* Default values */ - pRenderConfigReader->distAtt[0] = 15.75f; - pRenderConfigReader->distAtt[1] = 1.0f; - pRenderConfigReader->distAtt[2] = 1.0f; + pRenderConfigReader->distAtt[0] = DIST_ATT_DEFAULT_MAXDIST; + pRenderConfigReader->distAtt[1] = DIST_ATT_DEFAULT_REFDIST; + pRenderConfigReader->distAtt[2] = DIST_ATT_DEFAULT_ROLLOFF; } else { /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ - pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); + pRenderConfigReader->distAtt[1] = min( max( DIST_ATT_MIN_REFDIST, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); - pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); + pRenderConfigReader->distAtt[2] = min( max( DIST_ATT_MIN_ROLLOFF, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); } /* Verify range of directivity patterns */ for ( i = 0; i < pRenderConfigReader->nDP; i++ ) { - pRenderConfigReader->pDP[i].pDirectivity[0] = max( 0.0f, min( 360.0f, pRenderConfigReader->pDP[i].pDirectivity[0] ) ); - pRenderConfigReader->pDP[i].pDirectivity[1] = max( 0.0f, min( 360.0f, pRenderConfigReader->pDP[i].pDirectivity[1] ) ); - pRenderConfigReader->pDP[i].pDirectivity[2] = max( 0.0f, min( 1.0f, pRenderConfigReader->pDP[i].pDirectivity[2] ) ); + pRenderConfigReader->pDP[i].pDirectivity[0] = max( DIRECTIVITY_MIN_ANGLE, min( DIRECTIVITY_MAX_ANGLE, pRenderConfigReader->pDP[i].pDirectivity[0] ) ); + pRenderConfigReader->pDP[i].pDirectivity[1] = max( DIRECTIVITY_MIN_ANGLE, min( DIRECTIVITY_MAX_ANGLE, pRenderConfigReader->pDP[i].pDirectivity[1] ) ); + pRenderConfigReader->pDP[i].pDirectivity[2] = max( DIRECTIVITY_MIN_ATT_FAC, min( DIRECTIVITY_MAX_ATT_FAC, pRenderConfigReader->pDP[i].pDirectivity[2] ) ); } return IVAS_ERR_OK; -- GitLab From a5d1daf9c2466cb44c028730d0f6a855a34f3c33 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Apr 2026 10:07:23 +0200 Subject: [PATCH 8/8] Clang format --- lib_util/render_config_reader.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 882ed10a1..2fef778ad 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -72,12 +72,12 @@ #define IVAS_ER_LIST_ORIGIN_Y 0.0f #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION -#define DIST_ATT_MIN_MAXDIST 0.0f -#define DIST_ATT_MIN_REFDIST 0.0f -#define DIST_ATT_MIN_ROLLOFF 0.0f -#define DIST_ATT_MAX_MAXDIST 63.0f -#define DIST_ATT_MAX_REFDIST 6.3f -#define DIST_ATT_MAX_ROLLOFF 4.0f +#define DIST_ATT_MIN_MAXDIST 0.0f +#define DIST_ATT_MIN_REFDIST 0.0f +#define DIST_ATT_MIN_ROLLOFF 0.0f +#define DIST_ATT_MAX_MAXDIST 63.0f +#define DIST_ATT_MAX_REFDIST 6.3f +#define DIST_ATT_MAX_ROLLOFF 4.0f #define DIST_ATT_DEFAULT_MAXDIST 15.75f #define DIST_ATT_DEFAULT_REFDIST 1.0f #define DIST_ATT_DEFAULT_ROLLOFF 1.0f -- GitLab