diff --git a/apps/decoder.c b/apps/decoder.c index f019fc339dd6cbc61b167e9ff014e059b0dbeda4..ad318fdcc4c1e75e8be8626309cbaef090dfce5e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -507,6 +507,14 @@ int main( goto cleanup; } +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid renderer configuration parameters\n\n" ); + goto cleanup; + } +#endif + aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader ); if ( aeCount > 0 ) { @@ -585,6 +593,13 @@ 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 ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -598,6 +613,7 @@ int main( 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. @@ -2114,6 +2130,14 @@ static ivas_error decodeG192( fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); goto cleanup; } + +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid renderer configuration parameters\n\n" ); + goto cleanup; + } +#endif } for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) @@ -2276,6 +2300,13 @@ 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 ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -2289,6 +2320,7 @@ static ivas_error decodeG192( 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 ff3520f4c32658c2a867b1f7762c26dc8a995456..8c48c97c6cd70fcb739f891bd3196a4fb46248ea 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1246,6 +1246,13 @@ int main( fprintf( stderr, "\nFailed to read renderer configuration from file %s\n", args.renderConfigFilePath ); goto cleanup; } +#ifdef FIX_2500_RENDCONF_REFACTOR + if ( RenderConfigReader_checkValues( renderConfigReader ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid renderer 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] ); @@ -1259,6 +1266,13 @@ 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 ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -1272,6 +1286,7 @@ int main( 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. @@ -1716,6 +1731,13 @@ 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 ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -1729,6 +1751,7 @@ int main( 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_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1cf37f4017725343f0aa67827a845f6bc31deca6..9c6c825079de125bda1ee115925c8ae84d560e62 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_com/options.h b/lib_com/options.h index 6579999f28044ff0135600ea87d9cabd47d8fc8a..6a1cf8b5926429ceabf9872c1bd672e3ffbe12eb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,6 +118,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_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 FIX_BASOP_2023_TDREND_DISTATT_PRECISION_BUGFIX /* Eri: Bug discovered in cleanup of basop issue 2023 */ #define USE_RTPDUMP /* FhG: RTPDUMP format (rtptools standard) instead of custom format */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index b904e2be03a1378f64b5be7986f677932c50e874..5266824fe251c3435d1ba1bd761488d43a419778 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*/ @@ -271,12 +271,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 = DIST_ATT_DEFAULT_MAXDIST_Q25; /* Maximum radius (2^ISM_RADIUS_NBITS-1)*0.25 */ /*15.75 in Q25*/ + move32(); + DistAtten.RefDist_fx = DIST_ATT_DEFAULT_REFDIST_Q28; // Q28 + move32(); + 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*/ move32(); DistAtten.RefDist_fx = ONE_IN_Q30; // Q30 move32(); DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30 move32(); +#endif } ELSE { diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 1beac8fe74a757c46022e9d2e19d28b889424a09..611c0c45e39e86cfae34fbe6f5c6c72cd1d2cd0f 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 b548153d79ebf1b2d46d09c1951d6d34094d6e0e..efd7945013ced49190466e523466b9aa0187774f 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 */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index c208d6ffe9931e552c8eb4f2ba3bfb8efb4701fb..0101924f5baf1ad105d1cd52d7f7e746bd3e8c23 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -48,9 +48,10 @@ #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 ) + #define FC_INPUT_MIN ( 0.0f ) #define FC_INPUT_MAX ( 1.0e+5f ) #define ACOUSTIC_RT60_MIN ( 1.0e-3f ) @@ -81,9 +82,20 @@ #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 #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) @@ -92,7 +104,6 @@ #ifndef max #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif -#endif #ifndef TRUE #define TRUE 1 @@ -1273,6 +1284,155 @@ static int32_t errorHandler( * * Verifies if the configuration parameters lie within acceptable limits *------------------------------------------------------------------------------------------*/ +#ifdef FIX_2500_RENDCONF_REFACTOR +ivas_error RenderConfigReader_checkValues( + RenderConfigReader *pRenderConfigReader /* i/o: Renderer configuration reader */ +) +{ + int16_t tab_value_err_count; + int16_t wall_idx; + uint32_t i; + uint32_t nBands; + uint32_t band_idx; + uint32_t n; + AcousticEnv *pAE; + FrequencyGrid *pFG; + + tab_value_err_count = 0; + + /* Check range for all Acoustic Environment IDs */ + for ( n = 0; n < pRenderConfigReader->nAE; n++ ) + { + 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 ) ) + { + 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 ( pFG->pFc[band_idx] <= pFG->pFc[band_idx - 1] ) + { + tab_value_err_count++; + } + } + + /* Check the input frequencies */ + if ( ( pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( 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; + } + + 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; + } + } + } + } + + /* Distance attenuation range check */ + if ( pRenderConfigReader->distAtt[0] == -1 ) + { + /* Default values */ + 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( 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( 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( 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; +} +#else ivas_error RenderConfigReader_checkValues( IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ ) @@ -1288,7 +1448,6 @@ ivas_error RenderConfigReader_checkValues( { 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++ ) { @@ -1359,6 +1518,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } +#endif /*------------------------------------------------------------------------------------------* * RenderConfigReader_open() @@ -2967,13 +3127,16 @@ ivas_error RenderConfigReader_getAcousticEnvironment( #endif pAcEnv->nBands = (int16_t) pRenderConfigReader->pAE[n].pFG->nrBands; pAcEnv->inputPreDelay_fx = (Word32) ( pRenderConfigReader->pAE[n].preDelay * ONE_IN_Q27 ); +#ifndef FIX_2500_RENDCONF_REFACTOR 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_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 || @@ -2983,6 +3146,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 ); @@ -3118,12 +3282,14 @@ ivas_error RenderConfigReader_getDirectivity( /* Convert to Word16 */ FOR( n = 0; n < 4; n++ ) { +#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] ) ); 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 ) ); @@ -3164,6 +3330,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( /* Convert to Word32 */ #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION +#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 */ @@ -3171,6 +3338,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 ) ); distAtt_fx[2] = (Word32) ( distAtt[2] * ( 1u << 28 ) ); diff --git a/lib_util/render_config_reader.h b/lib_util/render_config_reader.h index c533f1393eec98edbb92fb304757515f37b7a61b..54180eabb0d8004e386b0ff955295e1ed5bff4dc 100644 --- a/lib_util/render_config_reader.h +++ b/lib_util/render_config_reader.h @@ -79,7 +79,11 @@ ivas_error RenderConfigReader_getDistanceAttenuation( ); /* Verifies configuration parameters */ ivas_error RenderConfigReader_checkValues( +#ifdef FIX_2500_RENDCONF_REFACTOR + RenderConfigReader *pRenderConfigReader /* i/o: Renderer configuration reader */ +#else IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* o : Renderer configuration handle */ +#endif ); /* Reads a configuration */