From a076319bf93d65757b9ca440e695c2aa048bc371 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 2 Apr 2026 21:11:18 +0200 Subject: [PATCH 01/13] Port the missing part of RenderConfigReader_checkValues() from float; fix RefDist_fx calculation. --- lib_com/common_api_types.h | 4 ++ lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_fx.c | 8 +++ lib_rend/ivas_objectRenderer_sources_fx.c | 29 +++++++++++ lib_rend/ivas_render_config_fx.c | 4 ++ lib_rend/ivas_stat_rend.h | 6 ++- lib_util/render_config_reader.c | 60 +++++++++++++++++++++++ 7 files changed, 111 insertions(+), 1 deletion(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 5b158d957..6334a5079 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -351,7 +351,11 @@ typedef struct _IVAS_RENDER_CONFIG float directivity[IVAS_MAX_NUM_OBJECTS * 3]; Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15} float distAtt[3]; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + Word32 distAtt_fx[3]; /* {Q27, Q27, Q30} */ +#else Word32 distAtt_fx[3]; /* {Q27, Q30, Q30} */ +#endif } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 07e40107a..4ad33a583 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define FIX_BASOP_2497_MCMASA_LFE_WRONG_SF_INDEX /* Nokia: BASOP 2497: Fix wrong subframe index in McMASA LFE synth. */ #define FIX_BASOP_2496_OMASA_OBJ_EDIT_WRONG_ASSIGN /* Nokia: BASOP 2496: Fix wrong assignment in OMASA object edit code */ #define FIX_2495_Q_ALIGN_OSBA_RENDERER /* FhG: Basop issue #2495: Corrected exponent scaling of outAudio.data_fx before buffer accumulation in renderSbaToBinaural(). */ +#define FIX_2500_ISM4_BIN_REVERB_DISTORTION /* FhG: Basop issue #2500: Port the missing part of RenderConfigReader_checkValues() from float; fix RefDist_fx calculation. */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 19e0d450a..26f8445fd 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -204,7 +204,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx( move16(); DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ move32(); +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + DistAtten.RefDist_fx = ONE_IN_Q27; // Q27 +#else DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 +#endif move32(); DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30 move32(); @@ -264,7 +268,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx( move16(); DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ move32(); +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + DistAtten.RefDist_fx = ONE_IN_Q27; // Q27 +#else DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 +#endif move32(); DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30 move32(); diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 7a278a8bb..e95c529f0 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -653,7 +653,11 @@ static void TDREND_SRC_SPATIAL_Init_fx( move16(); SrcSpatial_p->DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 move16(); +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q27; // Q27 +#else SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 +#endif move32(); SrcSpatial_p->DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ move32(); @@ -859,13 +863,30 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( { case TDREND_DIST_ATTEN_MODEL_INV_DIST: /* DistGain = powf( DistAtten_p->RefDist / Dist2, DistAtten_p->RollOffFactor ); */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 4) */ + tmp32 = L_deposit_h( tmp16 ); /* tmp32 is Q(31 - Dist_s + Dist2_e - 4) */ + /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 4) = Dist_s - Dist2_e + 4, RollOffFactor_fx exponent: 31 - 30 = 1 */ + tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 4 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */ +#else tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 1) */ tmp32 = L_deposit_h( tmp16 ); /* tmp32 is Q(31 - Dist_s + Dist2_e - 1) */ /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 1) = Dist_s - Dist2_e + 1, RollOffFactor_fx exponent: 31 - 30 = 1 */ tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 1 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */ +#endif BREAK; case TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED: +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 4 ); + IF( flag < 0 ) + { + Dist2_fx = DistAtten_p->RefDist_fx; // Q27 + move32(); + Dist2_e = 4; + move16(); + } +#else flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->RefDist_fx, 1 ); IF( flag < 0 ) { @@ -874,6 +895,7 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( Dist2_e = 1; move16(); } +#endif flag = BASOP_Util_Cmp_Mant32Exp( Dist2_fx, Dist2_e, DistAtten_p->MaxDist_fx, 4 ); IF( flag > 0 ) { @@ -883,10 +905,17 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( move16(); } /* DistGain = powf( DistAtten_p->RefDist / Dist2, DistAtten_p->RollOffFactor ); */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 4) */ + tmp32 = L_deposit_h( tmp16 ); /* tmp32 is Q(31 - Dist_s + Dist2_e - 4) */ + /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 4) = Dist_s - Dist2_e + 4, RollOffFactor_fx exponent: 31 - 30 = 1 */ + tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 4 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */ +#else tmp16 = BASOP_Util_Divide3232_Scale( DistAtten_p->RefDist_fx, Dist2_fx, &Dist_s ); /* tmp16 is Q(15 - Dist_s + Dist2_e - 1) */ tmp32 = L_deposit_h( tmp16 ); /* tmp32 is Q(31 - Dist_s + Dist2_e - 1) */ /* tmp32 exponent: 31 - (31 - Dist_s + Dist2_e - 1) = Dist_s - Dist2_e + 1, RollOffFactor_fx exponent: 31 - 30 = 1 */ tmp32 = BASOP_Util_fPow( tmp32, add( sub( Dist_s, Dist2_e ), 1 ), DistAtten_p->RollOffFactor_fx, 1, &tmp_e ); /* Q(31 - tmp_e) */ +#endif BREAK; } diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 81f66bf60..9a7d67614 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -142,7 +142,11 @@ ivas_error ivas_render_config_init_from_rom_fx( } ( *hRenderConfig )->distAtt_fx[0] = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ /* Default max dist */ move32(); +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q27; // Q27 /* Default ref dist */ +#else ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q30; // Q30 /* Default ref dist */ +#endif move32(); ( *hRenderConfig )->distAtt_fx[2] = ONE_IN_Q30; // Q30 /* Default rolloff factor */ move32(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ea5fbcd4e..42002c272 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1178,7 +1178,11 @@ typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct typedef struct { TDREND_DistAttenModel_t DistAttenModel; - Word32 RefDist_fx; /* Q30 */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + Word32 RefDist_fx; /* Q27 */ +#else + Word32 RefDist_fx; /* Q30 */ +#endif Word32 MaxDist_fx; /* Q27 */ Word32 RollOffFactor_fx; /* Q30 */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 318072fe8..dc3dbc8aa 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -51,6 +51,15 @@ #define SHORTEST_REV_DEL_LINE ( 0.015f ) #define N_BANDS_MIN ( 2 ) #define N_BANDS_MAX ( 60 ) + +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#define FC_INPUT_MAX_Q14 1638400000 // ( 1.0e+5f ) in Q14 +#define ACOUSTIC_RT60_MIN_Q26 67109 // ( 1.0e-3f ) in Q26 +#define ACOUSTIC_RT60_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 +#define ACOUSTIC_DSR_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 +#define INPUTPREDELAY_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 +#endif + #define FC_INPUT_MIN ( 0.0f ) #define FC_INPUT_MAX ( 1.0e+5f ) #define ACOUSTIC_RT60_MIN ( 1.0e-3f ) @@ -1264,12 +1273,22 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics = &hRenderConfig->roomAcoustics; tab_value_err_count = 0; int16_t wall_idx; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + int16_t i; +#endif /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) { return IVAS_ERR_WRONG_PARAMS; } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + /* Verify input pre-delay value */ + if ( ( pRoom_acoustics->inputPreDelay_fx > INPUTPREDELAY_MAX_Q24 ) || ( pRoom_acoustics->inputPreDelay_fx < INPUTPREDELAY_MIN ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } +#endif /* Verify data per band in the acoustic properties table */ for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) @@ -1282,9 +1301,31 @@ ivas_error RenderConfigReader_checkValues( tab_value_err_count++; } } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + /* Check the input frequencies */ + if ( ( shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ) > FC_INPUT_MAX_Q14 ) || ( pRoom_acoustics->pFc_input_fx[band_idx] < FC_INPUT_MIN ) ) + { + tab_value_err_count++; + } + + /* Check the input RT60 values */ + if ( ( shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ) > ACOUSTIC_RT60_MAX_Q24 ) || ( pRoom_acoustics->pAcoustic_rt60_fx[band_idx] < ACOUSTIC_RT60_MIN_Q26 ) ) + { + tab_value_err_count++; + } + /* Check the input DSR values */ + if ( ( shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ) > ACOUSTIC_DSR_MAX_Q24 ) || ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] < ACOUSTIC_DSR_MIN ) ) + { + tab_value_err_count++; + } +#endif /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] <= 0 ) +#else if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] == 0 ) +#endif { pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; } @@ -1336,6 +1377,21 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; } } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ + /* 0.0 <= distAtt[2] <= 10.0 */ + hRenderConfig->distAtt_fx[0] = L_max( ONE_IN_Q27, hRenderConfig->distAtt_fx[0] ); + hRenderConfig->distAtt_fx[1] = L_max( hRenderConfig->distAtt_fx[0], hRenderConfig->distAtt_fx[1] ); + hRenderConfig->distAtt_fx[2] = L_max( 0, hRenderConfig->distAtt_fx[2] ); // min( 10.0f, hRenderConfig->distAtt[2] ) is removed, because distAtt_fx[2] is always < 10.0f in Q30 format. + + /* Verify range of directivity patterns */ + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) + { + hRenderConfig->directivity_fx[i * 3] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3] ) ); + hRenderConfig->directivity_fx[i * 3 + 1] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3 + 1] ) ); + hRenderConfig->directivity_fx[i * 3 + 2] = s_max( 0, s_min( ONE_IN_Q15 - 1, hRenderConfig->directivity_fx[i * 3 + 2] ) ); + } +#endif } @@ -3132,7 +3188,11 @@ ivas_error RenderConfigReader_getDistanceAttenuation( /* Convert to Word32 */ distAtt_fx[0] = (Word32) ( distAtt[0] * ( 1u << 27 ) ); +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + distAtt_fx[1] = (Word32) ( distAtt[1] * ( 1u << 27 ) ); +#else distAtt_fx[1] = (Word32) ( distAtt[1] * ( 1u << 30 ) ); +#endif distAtt_fx[2] = (Word32) ( distAtt[2] * ( 1u << 30 ) ); return IVAS_ERR_OK; -- GitLab From b4db50d3cbd5dc9e4f9a3a0b4b2ca245248a534b Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 2 Apr 2026 21:26:14 +0200 Subject: [PATCH 02/13] Apply Clang format. --- lib_util/render_config_reader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index dc3dbc8aa..351603e4e 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -48,9 +48,9 @@ #define MAX_ITEM_LENGTH ( 64 ) #define N_ABS_COEFFS ( 6 ) -#define SHORTEST_REV_DEL_LINE ( 0.015f ) -#define N_BANDS_MIN ( 2 ) -#define N_BANDS_MAX ( 60 ) +#define SHORTEST_REV_DEL_LINE ( 0.015f ) +#define N_BANDS_MIN ( 2 ) +#define N_BANDS_MAX ( 60 ) #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION #define FC_INPUT_MAX_Q14 1638400000 // ( 1.0e+5f ) in Q14 -- GitLab From 10d42196bcef74a89b9a29c4125010effb908165 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 3 Apr 2026 09:29:09 +0200 Subject: [PATCH 03/13] Correct comparison conditions. --- lib_util/render_config_reader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 351603e4e..0ca2760f2 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1284,7 +1284,7 @@ ivas_error RenderConfigReader_checkValues( } #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Verify input pre-delay value */ - if ( ( pRoom_acoustics->inputPreDelay_fx > INPUTPREDELAY_MAX_Q24 ) || ( pRoom_acoustics->inputPreDelay_fx < INPUTPREDELAY_MIN ) ) + if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN ) ) { return IVAS_ERR_WRONG_PARAMS; } @@ -1303,18 +1303,18 @@ ivas_error RenderConfigReader_checkValues( } #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Check the input frequencies */ - if ( ( shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ) > FC_INPUT_MAX_Q14 ) || ( pRoom_acoustics->pFc_input_fx[band_idx] < FC_INPUT_MIN ) ) + if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN ) ) { tab_value_err_count++; } /* Check the input RT60 values */ - if ( ( shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ) > ACOUSTIC_RT60_MAX_Q24 ) || ( pRoom_acoustics->pAcoustic_rt60_fx[band_idx] < ACOUSTIC_RT60_MIN_Q26 ) ) + if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ), ACOUSTIC_RT60_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], ACOUSTIC_RT60_MIN_Q26 ) ) { tab_value_err_count++; } /* Check the input DSR values */ - if ( ( shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ) > ACOUSTIC_DSR_MAX_Q24 ) || ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] < ACOUSTIC_DSR_MIN ) ) + if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN ) ) { tab_value_err_count++; } -- GitLab From 6d49b3117fd8a5d25add4a59d479cbbb6156ceac Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 3 Apr 2026 10:19:49 +0200 Subject: [PATCH 04/13] Change macro from float to int; apply BASOP standard format. --- lib_util/render_config_reader.c | 97 ++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 0ca2760f2..93b24d961 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -53,10 +53,13 @@ #define N_BANDS_MAX ( 60 ) #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#define FC_INPUT_MIN_FX 0 // ( 0.0f ) #define FC_INPUT_MAX_Q14 1638400000 // ( 1.0e+5f ) in Q14 #define ACOUSTIC_RT60_MIN_Q26 67109 // ( 1.0e-3f ) in Q26 #define ACOUSTIC_RT60_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 +#define ACOUSTIC_DSR_MIN_FX 0 // ( 0.0f ) #define ACOUSTIC_DSR_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 +#define INPUTPREDELAY_MIN_FX 0 // ( 0.0f ) #define INPUTPREDELAY_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 #endif @@ -1268,13 +1271,21 @@ ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ ) { +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + Word16 band_idx, tab_value_err_count; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; + pRoom_acoustics = &hRenderConfig->roomAcoustics; + Word16 wall_idx; + Word16 i; + + tab_value_err_count = 0; + move16(); +#else int16_t band_idx, tab_value_err_count; IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; pRoom_acoustics = &hRenderConfig->roomAcoustics; tab_value_err_count = 0; int16_t wall_idx; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - int16_t i; #endif /* Verify the number of frequency bands in the config input data */ @@ -1284,52 +1295,66 @@ ivas_error RenderConfigReader_checkValues( } #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Verify input pre-delay value */ - if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN ) ) + if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN_FX ) ) { return IVAS_ERR_WRONG_PARAMS; } -#endif /* Verify data per band in the acoustic properties table */ - for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) + FOR( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) { /* Verify if the frequencies are in the ascending order (required for interpolation) */ - if ( band_idx != 0 ) + IF( band_idx != 0 ) { if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] ) { - tab_value_err_count++; + tab_value_err_count = add( tab_value_err_count, 1 ); } } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Check the input frequencies */ - if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN ) ) + if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN_FX ) ) { - tab_value_err_count++; + tab_value_err_count = add( tab_value_err_count, 1 ); } /* Check the input RT60 values */ if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ), ACOUSTIC_RT60_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], ACOUSTIC_RT60_MIN_Q26 ) ) { - tab_value_err_count++; + tab_value_err_count = add( tab_value_err_count, 1 ); } /* Check the input DSR values */ - if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN ) ) + if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN_FX ) ) { - tab_value_err_count++; + tab_value_err_count = add( tab_value_err_count, 1 ); } -#endif /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] <= 0 ) + { + pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; + move32(); + } + } #else + /* Verify data per band in the acoustic properties table */ + for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) + { + /* Verify if the frequencies are in the ascending order (required for interpolation) */ + if ( band_idx != 0 ) + { + if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] ) + { + tab_value_err_count++; + } + } + + /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] == 0 ) -#endif { pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; } } +#endif if ( tab_value_err_count != 0 ) { @@ -1337,44 +1362,76 @@ ivas_error RenderConfigReader_checkValues( } +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + IF( pRoom_acoustics->use_er == 1 ) +#else if ( pRoom_acoustics->use_er == 1 ) +#endif { /* Room dimensions */ if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } /* Abs Coeff */ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + FOR( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) +#else for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) +#endif { if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION + move32(); +#endif } } #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION @@ -1385,11 +1442,11 @@ ivas_error RenderConfigReader_checkValues( hRenderConfig->distAtt_fx[2] = L_max( 0, hRenderConfig->distAtt_fx[2] ); // min( 10.0f, hRenderConfig->distAtt[2] ) is removed, because distAtt_fx[2] is always < 10.0f in Q30 format. /* Verify range of directivity patterns */ - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) + FOR( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) { - hRenderConfig->directivity_fx[i * 3] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3] ) ); - hRenderConfig->directivity_fx[i * 3 + 1] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[i * 3 + 1] ) ); - hRenderConfig->directivity_fx[i * 3 + 2] = s_max( 0, s_min( ONE_IN_Q15 - 1, hRenderConfig->directivity_fx[i * 3 + 2] ) ); + hRenderConfig->directivity_fx[imult1616( i, 3 )] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[imult1616( i, 3 )] ) ); + hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 1 )] = s_max( 0, s_min( 23040 /*360.0f in Q6*/, hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 1 )] ) ); + hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = s_max( 0, s_min( ONE_IN_Q15 - 1, hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] ) ); } #endif } -- GitLab From e6d5fc32f9c50c39959a703ac8245c18dfc4a24a Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 7 Apr 2026 11:55:30 +0200 Subject: [PATCH 05/13] Fix lower bound of hRenderConfig->distAtt_fx[0] calculation. --- lib_util/render_config_reader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 93b24d961..c1538927d 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1306,7 +1306,7 @@ ivas_error RenderConfigReader_checkValues( /* Verify if the frequencies are in the ascending order (required for interpolation) */ IF( band_idx != 0 ) { - if ( pRoom_acoustics->pFc_input_fx[band_idx] <= pRoom_acoustics->pFc_input_fx[band_idx - 1] ) + if ( LE_32( pRoom_acoustics->pFc_input_fx[band_idx], pRoom_acoustics->pFc_input_fx[band_idx - 1] ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); } @@ -1329,7 +1329,7 @@ ivas_error RenderConfigReader_checkValues( } /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ - if ( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] <= 0 ) + if ( LE_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], 0 ) ) { pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; move32(); @@ -1437,7 +1437,7 @@ ivas_error RenderConfigReader_checkValues( #ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Verify range of distance attenuation parameters: 0.1 <= distAtt[0] <= distAtt[1] */ /* 0.0 <= distAtt[2] <= 10.0 */ - hRenderConfig->distAtt_fx[0] = L_max( ONE_IN_Q27, hRenderConfig->distAtt_fx[0] ); + hRenderConfig->distAtt_fx[0] = L_max( 13421773 /* 0.1 in Q27 */, hRenderConfig->distAtt_fx[0] ); hRenderConfig->distAtt_fx[1] = L_max( hRenderConfig->distAtt_fx[0], hRenderConfig->distAtt_fx[1] ); hRenderConfig->distAtt_fx[2] = L_max( 0, hRenderConfig->distAtt_fx[2] ); // min( 10.0f, hRenderConfig->distAtt[2] ) is removed, because distAtt_fx[2] is always < 10.0f in Q30 format. -- GitLab From 17ba43636fc6faefa50fe0dffae887ae21234dd9 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 22 Apr 2026 07:21:17 +0200 Subject: [PATCH 06/13] Clang format --- lib_rend/ivas_objectRenderer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 1eb30ddfb..a6c7accb1 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -285,14 +285,14 @@ ivas_error ivas_td_binaural_open_unwrap_fx( move32(); DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28 move32(); -#else +#else DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ move32(); DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 move32(); DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30 move32(); -#endif +#endif } ELSE { -- GitLab From 80e5836c0bbab0aa651391548eef023697c1a52e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 22 Apr 2026 07:35:00 +0200 Subject: [PATCH 07/13] Remove unused variable --- lib_util/render_config_reader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 0d3ef481c..bacd50990 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1294,7 +1294,6 @@ ivas_error RenderConfigReader_checkValues( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; pRoom_acoustics = &hRenderConfig->roomAcoustics; Word16 wall_idx; - Word16 i; tab_value_err_count = 0; move16(); -- GitLab From b983f991438fc006f95aa3b6bd48438ac27c6284 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 22 Apr 2026 09:02:08 +0200 Subject: [PATCH 08/13] Range check refactoring --- apps/decoder.c | 20 +++ apps/renderer.c | 11 ++ lib_util/render_config_reader.c | 229 +++++++++++++++++++++----------- lib_util/render_config_reader.h | 6 + 4 files changed, 185 insertions(+), 81 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 054a21906..b17c54880 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -501,6 +501,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 ) { @@ -581,11 +589,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 { @@ -2104,6 +2114,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 ) @@ -2268,11 +2286,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 a11d07725..33f553131 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1200,6 +1200,13 @@ int main( fprintf( stderr, "\nFailed to read renderer configuration from file %s\n", args.renderConfigFilePath ); 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_fx ) ) != 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] ); @@ -1215,11 +1222,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 { @@ -1672,11 +1681,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, "Invalid acoustic environment configuration parameters\n\n" ); goto cleanup; } +#endif } else { diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index bacd50990..9009a9163 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -96,6 +96,7 @@ #define DIST_ATT_MAX_MAXDIST 63.0f #define DIST_ATT_MAX_REFDIST 6.3f #define DIST_ATT_MAX_ROLLOFF 4.0f +#endif #ifndef min #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) @@ -104,7 +105,6 @@ #ifndef max #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif -#endif #ifndef TRUE #define TRUE 1 @@ -1285,74 +1285,165 @@ static int32_t errorHandler( * * Verifies if the configuration parameters lie within acceptable limits *------------------------------------------------------------------------------------------*/ +#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION ivas_error RenderConfigReader_checkValues( - IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ + RenderConfigReader *pRenderConfigReader /* i/o : RenderConfigReader handle */ ) { -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - Word16 band_idx, tab_value_err_count; - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; - pRoom_acoustics = &hRenderConfig->roomAcoustics; - Word16 wall_idx; - - tab_value_err_count = 0; - move16(); -#else int16_t band_idx, tab_value_err_count; - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; - pRoom_acoustics = &hRenderConfig->roomAcoustics; - tab_value_err_count = 0; int16_t wall_idx; -#endif + uint32_t n, i; - /* Verify the number of frequency bands in the config input data */ - if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) - { - return IVAS_ERR_WRONG_PARAMS; - } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - /* Verify input pre-delay value */ - if ( GT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MAX_Q24 ) || LT_32( pRoom_acoustics->inputPreDelay_fx, INPUTPREDELAY_MIN_FX ) ) - { - return IVAS_ERR_WRONG_PARAMS; - } + tab_value_err_count = 0; - /* Verify data per band in the acoustic properties table */ - FOR( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) + /* Verify all acoustic environments */ + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { - /* Verify if the frequencies are in the ascending order (required for interpolation) */ - IF( band_idx != 0 ) + 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 ) ) { - if ( LE_32( pRoom_acoustics->pFc_input_fx[band_idx], pRoom_acoustics->pFc_input_fx[band_idx - 1] ) ) - { - tab_value_err_count = add( tab_value_err_count, 1 ); - } + return IVAS_ERR_WRONG_PARAMS; } - /* Check the input frequencies */ - if ( GT_32( L_shr( pRoom_acoustics->pFc_input_fx[band_idx], Q2 ), FC_INPUT_MAX_Q14 ) || LT_32( pRoom_acoustics->pFc_input_fx[band_idx], FC_INPUT_MIN_FX ) ) + + /* Verify input pre-delay value */ + if ( ( pAE->preDelay > INPUTPREDELAY_MAX ) || ( pAE->preDelay < INPUTPREDELAY_MIN ) ) { - tab_value_err_count = add( tab_value_err_count, 1 ); + return IVAS_ERR_WRONG_PARAMS; } - /* Check the input RT60 values */ - if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], Q2 ), ACOUSTIC_RT60_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_rt60_fx[band_idx], ACOUSTIC_RT60_MIN_Q26 ) ) + /* Verify data per band in the acoustic properties table */ + for ( band_idx = 0; band_idx < nBands; band_idx++ ) { - tab_value_err_count = add( tab_value_err_count, 1 ); + /* 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; + } } - /* Check the input DSR values */ - if ( GT_32( L_shr( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], Q6 ), ACOUSTIC_DSR_MAX_Q24 ) || LT_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], ACOUSTIC_DSR_MIN_FX ) ) + + if ( tab_value_err_count != 0 ) { - tab_value_err_count = add( tab_value_err_count, 1 ); + return IVAS_ERR_WRONG_PARAMS; } - /* Replace zero DSR values with very small positive values, to avoid issues with coloration filter design */ - if ( LE_32( pRoom_acoustics->pAcoustic_dsr_fx[band_idx], 0 ) ) + /* Early reflections parameter clamping */ + if ( pAE->pEarlyReflections != NULL && pAE->pEarlyReflections->use_er == 1 ) { - pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; - move32(); + /* 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; + } + } } } -#else + + /* 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 ); +#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 */ +) +{ + int16_t band_idx, tab_value_err_count; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoom_acoustics; + pRoom_acoustics = &hRenderConfig->roomAcoustics; + tab_value_err_count = 0; + int16_t wall_idx; + + /* Verify the number of frequency bands in the config input data */ + if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) + { + return IVAS_ERR_WRONG_PARAMS; + } /* Verify data per band in the acoustic properties table */ for ( band_idx = 0; band_idx < pRoom_acoustics->nBands; band_idx++ ) { @@ -1371,7 +1462,6 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; } } -#endif if ( tab_value_err_count != 0 ) { @@ -1379,76 +1469,44 @@ ivas_error RenderConfigReader_checkValues( } -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - IF( pRoom_acoustics->use_er == 1 ) -#else if ( pRoom_acoustics->use_er == 1 ) -#endif { /* Room dimensions */ if ( pRoom_acoustics->dimensions.x_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MIN_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->dimensions.x_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.x_fx = ER_MAX_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->dimensions.y_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MIN_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->dimensions.y_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.y_fx = ER_MAX_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->dimensions.z_fx < ER_MIN_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MIN_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->dimensions.z_fx > ER_MAX_ROOM_DIMENSION_FX ) { pRoom_acoustics->dimensions.z_fx = ER_MAX_ROOM_DIMENSION_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } /* Abs Coeff */ -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - FOR( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) -#else for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) -#endif { if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] < ER_MIN_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MIN_ABS_COEFF_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } if ( pRoom_acoustics->AbsCoeff_fx[wall_idx] > ER_MAX_ABS_COEFF_FX ) { pRoom_acoustics->AbsCoeff_fx[wall_idx] = ER_MAX_ABS_COEFF_FX; -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION - move32(); -#endif } } } @@ -1456,6 +1514,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } +#endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ /*------------------------------------------------------------------------------------------* * RenderConfigReader_open() @@ -3058,13 +3117,16 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; pAcEnv->inputPreDelay_fx = (Word32) ( pRenderConfigReader->pAE[n].preDelay * ONE_IN_Q27 ); +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( pRenderConfigReader->pAE[n].preDelay > INPUTPREDELAY_MAX || pRenderConfigReader->pAE[n].preDelay < INPUTPREDELAY_MIN ) { return IVAS_ERR_INVALID_RENDER_CONFIG; } +#endif for ( m = 0; m < pAcEnv->nBands; m++ ) { +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION if ( pRenderConfigReader->pAE[n].pFG->pFc[m] > FC_INPUT_MAX || pRenderConfigReader->pAE[n].pFG->pFc[m] < FC_INPUT_MIN || pRenderConfigReader->pAE[n].pRT60[m] > ACOUSTIC_RT60_MAX || @@ -3074,6 +3136,7 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { return IVAS_ERR_INVALID_RENDER_CONFIG; } +#endif pAcEnv->pFc_input_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pFG->pFc[m] * ONE_IN_Q16 ); pAcEnv->pAcoustic_rt60_fx[m] = (Word32) ( pRenderConfigReader->pAE[n].pRT60[m] * ONE_IN_Q26 ); @@ -3210,11 +3273,13 @@ ivas_error RenderConfigReader_getDirectivity( FOR( n = 0; n < 4; n++ ) { #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Verify range of directivity patterns */ /* Range needs to be checked before converting to fixed point -- different from float */ directivity[n * 3] = max( 0.0f, min( 360.0f, directivity[n * 3] ) ); directivity[n * 3 + 1] = max( 0.0f, min( 360.0f, directivity[n * 3 + 1] ) ); directivity[n * 3 + 2] = max( 0.0f, min( 1.0f, directivity[n * 3 + 2] ) ); +#endif #endif directivity_fx[n * 3] = (Word16) ( directivity[n * 3] * ( 1u << 6 ) ); @@ -3255,6 +3320,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( /* Convert to Word32 */ #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION /* Range needs to be checked before converting to fixed point -- different from float */ /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ @@ -3262,6 +3328,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( distAtt[1] = min( max( 0, distAtt[1] ), DIST_ATT_MAX_REFDIST ); distAtt[0] = min( max( distAtt[1], distAtt[0] ), DIST_ATT_MAX_MAXDIST ); distAtt[2] = min( max( 0.0f, distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); +#endif distAtt_fx[0] = (Word32) ( distAtt[0] * ( 1u << 25 ) ); distAtt_fx[1] = (Word32) ( distAtt[1] * ( 1u << 28 ) ); diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index c533f1393..8c76a8b26 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -78,9 +78,15 @@ ivas_error RenderConfigReader_getDistanceAttenuation( Word32 *distAtt_fx /* 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 deebe29a0fdc220f1f8699058116a2cc43bdda10 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 14:10:20 +0200 Subject: [PATCH 09/13] Cleanup and align with float code --- apps/decoder.c | 8 ++++---- apps/renderer.c | 6 +++--- lib_com/options.h | 2 +- lib_util/render_config_reader.c | 36 ++++++++++----------------------- lib_util/render_config_reader.h | 8 +++----- 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b17c54880..38b7124a8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -501,7 +501,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" ); @@ -589,7 +589,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" ); @@ -2115,7 +2115,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" ); @@ -2286,7 +2286,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 33f553131..30e2821c4 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1200,7 +1200,7 @@ int main( fprintf( stderr, "\nFailed to read renderer configuration from file %s\n", args.renderConfigFilePath ); 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" ); @@ -1222,7 +1222,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" ); @@ -1681,7 +1681,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, "Invalid acoustic environment configuration parameters\n\n" ); diff --git a/lib_com/options.h b/lib_com/options.h index 24c602467..cebd6e309 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #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: Port the missing part of RenderConfigReader_checkValues() from float; fix RefDist_fx calculation. */ +#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, adding clamping of distance att input and listener position */ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ #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 9009a9163..7dce9a811 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -52,17 +52,6 @@ #define N_BANDS_MIN ( 2 ) #define N_BANDS_MAX ( 60 ) -#ifdef FIX_2500_ISM4_BIN_REVERB_DISTORTION -#define FC_INPUT_MIN_FX 0 // ( 0.0f ) -#define FC_INPUT_MAX_Q14 1638400000 // ( 1.0e+5f ) in Q14 -#define ACOUSTIC_RT60_MIN_Q26 67109 // ( 1.0e-3f ) in Q26 -#define ACOUSTIC_RT60_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 -#define ACOUSTIC_DSR_MIN_FX 0 // ( 0.0f ) -#define ACOUSTIC_DSR_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 -#define INPUTPREDELAY_MIN_FX 0 // ( 0.0f ) -#define INPUTPREDELAY_MAX_Q24 1677721600 // ( 1.0e+2f ) in Q24 -#endif - #define FC_INPUT_MIN ( 0.0f ) #define FC_INPUT_MAX ( 1.0e+5f ) #define ACOUSTIC_RT60_MIN ( 1.0e-3f ) @@ -1285,14 +1274,14 @@ 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 */ ) { 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; @@ -1408,15 +1397,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 ); -#endif /* Verify range of directivity patterns */ for ( i = 0; i < pRenderConfigReader->nDP; i++ ) @@ -1428,7 +1414,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 +1500,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } -#endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ +#endif /*------------------------------------------------------------------------------------------* * RenderConfigReader_open() @@ -3117,7 +3103,7 @@ ivas_error RenderConfigReader_getAcousticEnvironment( { pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; pAcEnv->inputPreDelay_fx = (Word32) ( pRenderConfigReader->pAE[n].preDelay * ONE_IN_Q27 ); -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( pRenderConfigReader->pAE[n].preDelay > INPUTPREDELAY_MAX || pRenderConfigReader->pAE[n].preDelay < INPUTPREDELAY_MIN ) { @@ -3126,7 +3112,7 @@ ivas_error RenderConfigReader_getAcousticEnvironment( #endif for ( m = 0; m < pAcEnv->nBands; m++ ) { -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR if ( pRenderConfigReader->pAE[n].pFG->pFc[m] > FC_INPUT_MAX || pRenderConfigReader->pAE[n].pFG->pFc[m] < FC_INPUT_MIN || pRenderConfigReader->pAE[n].pRT60[m] > ACOUSTIC_RT60_MAX || @@ -3273,7 +3259,7 @@ ivas_error RenderConfigReader_getDirectivity( FOR( n = 0; n < 4; n++ ) { #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR /* Verify range of directivity patterns */ /* Range needs to be checked before converting to fixed point -- different from float */ directivity[n * 3] = max( 0.0f, min( 360.0f, directivity[n * 3] ) ); @@ -3320,7 +3306,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( /* Convert to Word32 */ #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION -#ifndef FIX_2500_ISM4_BIN_REVERB_DISTORTION +#ifndef FIX_2500_RENDCONF_REFACTOR /* Range needs to be checked before converting to fixed point -- different from float */ /* Verify range of distance attenuation parameters: refDist: 0.0 <= distAtt[1] <= 6.3 */ /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index 8c76a8b26..27e120967 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -78,15 +78,13 @@ ivas_error RenderConfigReader_getDistanceAttenuation( Word32 *distAtt_fx /* 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 801a214cc57d562b95adeacbd37dda1cef35cbbe Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 24 Apr 2026 14:21:49 +0200 Subject: [PATCH 10/13] 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 2c06ce895..d59c1b370 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1281,7 +1281,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 ae128fa68a575a7eefe3eb1b31b5cc1676ba21a9 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 27 Apr 2026 23:01:55 +0200 Subject: [PATCH 11/13] Cleanup under FIX_2500_RENDCONF_REFACTOR --- apps/decoder.c | 24 +++++++++++++----- apps/renderer.c | 22 +++++++++++++---- lib_util/render_config_reader.c | 44 +++++++++++++++++++-------------- lib_util/render_config_reader.h | 2 +- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0e8de0a42..ad318fdcc 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -510,7 +510,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 @@ -593,21 +593,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. @@ -2128,7 +2134,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 @@ -2294,21 +2300,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 2fe08831d..0b99e4b48 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1249,7 +1249,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 @@ -1266,21 +1266,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, "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. @@ -1725,21 +1731,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, "Invalid acoustic environment configuration parameters\n\n" ); goto cleanup; } -#endif } else { fprintf( stderr, "Failed 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 d59c1b370..d5b14a09d 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1276,20 +1276,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 ) ) @@ -1309,14 +1315,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++; } @@ -1345,7 +1351,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 */ @@ -1389,20 +1394,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++ ) @@ -3264,8 +3272,8 @@ ivas_error RenderConfigReader_getDirectivity( /* Convert to Word16 */ FOR( n = 0; n < 4; n++ ) { -#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION #ifndef FIX_2500_RENDCONF_REFACTOR +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* Verify range of directivity patterns */ /* Range needs to be checked before converting to fixed point -- different from float */ directivity[n * 3] = max( 0.0f, min( 360.0f, directivity[n * 3] ) ); diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index c5d415e62..54180eabb 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -80,7 +80,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 d0adef03d212ad26b23a267972b7cebd9e35b3a2 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Apr 2026 09:59:31 +0200 Subject: [PATCH 12/13] Replace literals in distatt/directivity range check with constants --- lib_util/render_config_reader.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index d5b14a09d..454c28543 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -82,9 +82,19 @@ #define IVAS_ER_LIST_ORIGIN_Y_FX 0 #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION -#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 +#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 min @@ -1398,26 +1408,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 db771234f0ae218107265821238372a8cb064bce Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 30 Apr 2026 10:20:29 +0200 Subject: [PATCH 13/13] Replaced literals in distance attenuation init with constants --- lib_com/ivas_cnst.h | 5 +++++ lib_rend/ivas_objectRenderer_fx.c | 12 ++++++------ lib_rend/ivas_objectRenderer_sources_fx.c | 6 +++--- lib_rend/ivas_render_config_fx.c | 6 +++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1cf37f401..9c6c82507 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1588,6 +1588,11 @@ typedef enum #define RESAMPLE_FACTOR_16_48_FX ( 5461 ) // Q14 #define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14 +#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#define DIST_ATT_DEFAULT_MAXDIST_Q25 528482304 /* Q25 */ /* Default maxDist based on maximum radius in encoded metadata (2^ISM_RADIUS_NBITS-1)*0.25 */ +#define DIST_ATT_DEFAULT_REFDIST_Q28 ONE_IN_Q28 /* Q28 */ /* Default refDist 1.0 in Q28 */ +#define DIST_ATT_DEFAULT_ROLLOFF_Q28 ONE_IN_Q28 /* Q28 */ /* Default rolloffFactor 1.0 in Q28 */ +#endif /* ----- Enums - TD Renderer ----- */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 8109a8226..5266824fe 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -203,11 +203,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx( DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 move16(); #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION - DistAtten.MaxDist_fx = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ + DistAtten.MaxDist_fx = DIST_ATT_DEFAULT_MAXDIST_Q25; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ move32(); - DistAtten.RefDist_fx = ONE_IN_Q28; // Q28 + DistAtten.RefDist_fx = DIST_ATT_DEFAULT_REFDIST_Q28; // Q28 move32(); - DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28 + DistAtten.RollOffFactor_fx = DIST_ATT_DEFAULT_ROLLOFF_Q28; // Q28 move32(); #else DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ @@ -272,11 +272,11 @@ ivas_error ivas_td_binaural_open_unwrap_fx( DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 move16(); #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION - DistAtten.MaxDist_fx = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ + DistAtten.MaxDist_fx = DIST_ATT_DEFAULT_MAXDIST_Q25; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ move32(); - DistAtten.RefDist_fx = ONE_IN_Q28; // Q28 + DistAtten.RefDist_fx = DIST_ATT_DEFAULT_REFDIST_Q28; // Q28 move32(); - DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28 + DistAtten.RollOffFactor_fx = DIST_ATT_DEFAULT_ROLLOFF_Q28; // Q28 move32(); #else DistAtten.MaxDist_fx = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 1beac8fe7..611c0c45e 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -672,11 +672,11 @@ static void TDREND_SRC_SPATIAL_Init_fx( SrcSpatial_p->DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 move16(); #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION - SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q28; // Q28 + SrcSpatial_p->DistAtten.RefDist_fx = DIST_ATT_DEFAULT_REFDIST_Q28; // Q28 move32(); - SrcSpatial_p->DistAtten.MaxDist_fx = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ + SrcSpatial_p->DistAtten.MaxDist_fx = DIST_ATT_DEFAULT_MAXDIST_Q25; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ move32(); - SrcSpatial_p->DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28 + SrcSpatial_p->DistAtten.RollOffFactor_fx = DIST_ATT_DEFAULT_ROLLOFF_Q28; // Q28 move16(); #else SrcSpatial_p->DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index b548153d7..efd794501 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -153,11 +153,11 @@ ivas_error ivas_render_config_init_from_rom_fx( move16(); } #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION - ( *hRenderConfig )->distAtt_fx[0] = 528482304; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ /* Default max dist */ + ( *hRenderConfig )->distAtt_fx[0] = DIST_ATT_DEFAULT_MAXDIST_Q25; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ /* Default max dist */ move32(); - ( *hRenderConfig )->distAtt_fx[1] = ONE_IN_Q28; // Q28 /* Default ref dist */ + ( *hRenderConfig )->distAtt_fx[1] = DIST_ATT_DEFAULT_REFDIST_Q28; // Q28 /* Default ref dist */ move32(); - ( *hRenderConfig )->distAtt_fx[2] = ONE_IN_Q28; // Q28 /* Default rolloff factor */ + ( *hRenderConfig )->distAtt_fx[2] = DIST_ATT_DEFAULT_ROLLOFF_Q28; // Q28 /* Default rolloff factor */ move32(); #else ( *hRenderConfig )->distAtt_fx[0] = 2113929216; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q27*/ /* Default max dist */ -- GitLab