diff --git a/lib_com/options.h b/lib_com/options.h index 33519e38fd3ca6b3d1bc7befb0e803982c51a2aa..24c602467fc1a9b4e5a68a955fb5d83e90976e92 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +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_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_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index bfa5d30396b09886024bb8878181b4873e3f3064..a6c7accb19265434883ea4ce855fd861e6a94bcf 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -278,12 +278,21 @@ 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*/ + move32(); + DistAtten.RefDist_fx = ONE_IN_Q28; // Q28 + move32(); + DistAtten.RollOffFactor_fx = ONE_IN_Q28; // Q28 + move32(); +#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 } ELSE { diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 4a313b6c26ba2370ee14847b532701e9bad1443a..bacd5099045f5483b1ebd4026b13fec55cffa161 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -48,9 +48,21 @@ #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_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 ) @@ -1277,18 +1289,70 @@ 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; + + 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 /* 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; + } + /* 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 ( 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 ); + } + } + /* 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 ) ) + { + 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 = 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_FX ) ) + { + tab_value_err_count = add( tab_value_err_count, 1 ); + } + + /* 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 ) ) + { + 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++ ) { @@ -1307,6 +1371,7 @@ ivas_error RenderConfigReader_checkValues( pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; } } +#endif if ( tab_value_err_count != 0 ) { @@ -1314,44 +1379,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 } } }