Loading apps/decoder.c +20 −0 Original line number Diff line number Diff line Loading @@ -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 ) { Loading Loading @@ -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 { Loading Loading @@ -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 ) Loading Loading @@ -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 { Loading apps/renderer.c +11 −0 Original line number Diff line number Diff line Loading @@ -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] ); Loading @@ -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 { Loading Loading @@ -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 { Loading lib_util/render_config_reader.c +148 −81 Original line number Diff line number Diff line Loading @@ -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 ) ) Loading @@ -104,7 +105,6 @@ #ifndef max #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif #endif #ifndef TRUE #define TRUE 1 Loading Loading @@ -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; tab_value_err_count = 0; /* Verify all acoustic environments */ for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { AcousticEnv *pAE = &pRenderConfigReader->pAE[n]; int16_t nBands = (int16_t) pAE->pFG->nrBands; /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) if ( ( nBands > N_BANDS_MAX ) || ( 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 ) ) 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 < pRoom_acoustics->nBands; band_idx++ ) 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 ( band_idx != 0 ) { if ( LE_32( pRoom_acoustics->pFc_input_fx[band_idx], pRoom_acoustics->pFc_input_fx[band_idx - 1] ) ) if ( pAE->pFG->pFc[band_idx] <= pAE->pFG->pFc[band_idx - 1] ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } } /* 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 ) ) if ( ( pAE->pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( pAE->pFG->pFc[band_idx] < FC_INPUT_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ) ) if ( ( pAE->pRT60[band_idx] > ACOUSTIC_RT60_MAX ) || ( pAE->pRT60[band_idx] < ACOUSTIC_RT60_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ( ( pAE->pDSR[band_idx] > ACOUSTIC_DSR_MAX ) || ( pAE->pDSR[band_idx] < ACOUSTIC_DSR_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ) ) if ( pAE->pDSR[band_idx] <= 0.0f ) { pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; move32(); pAE->pDSR[band_idx] = ACOUSTIC_DSR_EPSILON; } } #else if ( tab_value_err_count != 0 ) { return IVAS_ERR_WRONG_PARAMS; } /* Early reflections parameter clamping */ if ( pAE->pEarlyReflections != NULL && pAE->pEarlyReflections->use_er == 1 ) { /* Room dimensions */ if ( pAE->pEarlyReflections->dimensions.x < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.x = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.x > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.x = ER_MAX_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.y < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.y = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.y > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.y = ER_MAX_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.z < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.z = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.z > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.z = ER_MAX_ROOM_DIMENSION; } /* Abs Coeff */ for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) { if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) { pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; } if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) { pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; } } } } /* Apply default distance attenuation if not specified in config */ if ( pRenderConfigReader->distAtt[0] == -1 ) { pRenderConfigReader->distAtt[0] = 15.75f; pRenderConfigReader->distAtt[1] = 1.0f; pRenderConfigReader->distAtt[2] = 1.0f; } /* Verify range of distance attenuation parameters */ #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* refDist: 0.0 <= distAtt[1] <= 6.3 */ /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); #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++ ) { Loading @@ -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 ) { Loading @@ -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 } } } Loading @@ -1456,6 +1514,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } #endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ /*------------------------------------------------------------------------------------------* * RenderConfigReader_open() Loading Loading @@ -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 || Loading @@ -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 ); Loading Loading @@ -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 ) ); Loading Loading @@ -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 */ Loading @@ -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 ) ); Loading lib_util/render_config_reader.h +6 −0 Original line number Diff line number Diff line Loading @@ -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( Loading Loading
apps/decoder.c +20 −0 Original line number Diff line number Diff line Loading @@ -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 ) { Loading Loading @@ -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 { Loading Loading @@ -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 ) Loading Loading @@ -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 { Loading
apps/renderer.c +11 −0 Original line number Diff line number Diff line Loading @@ -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] ); Loading @@ -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 { Loading Loading @@ -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 { Loading
lib_util/render_config_reader.c +148 −81 Original line number Diff line number Diff line Loading @@ -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 ) ) Loading @@ -104,7 +105,6 @@ #ifndef max #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif #endif #ifndef TRUE #define TRUE 1 Loading Loading @@ -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; tab_value_err_count = 0; /* Verify all acoustic environments */ for ( n = 0; n < pRenderConfigReader->nAE; n++ ) { AcousticEnv *pAE = &pRenderConfigReader->pAE[n]; int16_t nBands = (int16_t) pAE->pFG->nrBands; /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) if ( ( nBands > N_BANDS_MAX ) || ( 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 ) ) 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 < pRoom_acoustics->nBands; band_idx++ ) 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 ( band_idx != 0 ) { if ( LE_32( pRoom_acoustics->pFc_input_fx[band_idx], pRoom_acoustics->pFc_input_fx[band_idx - 1] ) ) if ( pAE->pFG->pFc[band_idx] <= pAE->pFG->pFc[band_idx - 1] ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } } /* 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 ) ) if ( ( pAE->pFG->pFc[band_idx] > FC_INPUT_MAX ) || ( pAE->pFG->pFc[band_idx] < FC_INPUT_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ) ) if ( ( pAE->pRT60[band_idx] > ACOUSTIC_RT60_MAX ) || ( pAE->pRT60[band_idx] < ACOUSTIC_RT60_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ( ( pAE->pDSR[band_idx] > ACOUSTIC_DSR_MAX ) || ( pAE->pDSR[band_idx] < ACOUSTIC_DSR_MIN ) ) { tab_value_err_count = add( tab_value_err_count, 1 ); tab_value_err_count++; } /* 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 ) ) if ( pAE->pDSR[band_idx] <= 0.0f ) { pRoom_acoustics->pAcoustic_dsr_fx[band_idx] = ACOUSTIC_DSR_EPSILON_FX; move32(); pAE->pDSR[band_idx] = ACOUSTIC_DSR_EPSILON; } } #else if ( tab_value_err_count != 0 ) { return IVAS_ERR_WRONG_PARAMS; } /* Early reflections parameter clamping */ if ( pAE->pEarlyReflections != NULL && pAE->pEarlyReflections->use_er == 1 ) { /* Room dimensions */ if ( pAE->pEarlyReflections->dimensions.x < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.x = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.x > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.x = ER_MAX_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.y < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.y = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.y > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.y = ER_MAX_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.z < ER_MIN_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.z = ER_MIN_ROOM_DIMENSION; } if ( pAE->pEarlyReflections->dimensions.z > ER_MAX_ROOM_DIMENSION ) { pAE->pEarlyReflections->dimensions.z = ER_MAX_ROOM_DIMENSION; } /* Abs Coeff */ for ( wall_idx = 0; wall_idx < IVAS_ROOM_ABS_COEFF; wall_idx++ ) { if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] < ER_MIN_ABS_COEFF ) { pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MIN_ABS_COEFF; } if ( pAE->pEarlyReflections->pAbsCoeff[wall_idx] > ER_MAX_ABS_COEFF ) { pAE->pEarlyReflections->pAbsCoeff[wall_idx] = ER_MAX_ABS_COEFF; } } } } /* Apply default distance attenuation if not specified in config */ if ( pRenderConfigReader->distAtt[0] == -1 ) { pRenderConfigReader->distAtt[0] = 15.75f; pRenderConfigReader->distAtt[1] = 1.0f; pRenderConfigReader->distAtt[2] = 1.0f; } /* Verify range of distance attenuation parameters */ #ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION /* refDist: 0.0 <= distAtt[1] <= 6.3 */ /* maxDist: distAtt[1] <= distAtt[0] <= 63.0 */ /* rollOffFactor: 0 <= distAtt[2] <= 4.0 */ pRenderConfigReader->distAtt[1] = min( max( 0, pRenderConfigReader->distAtt[1] ), DIST_ATT_MAX_REFDIST ); pRenderConfigReader->distAtt[0] = min( max( pRenderConfigReader->distAtt[1], pRenderConfigReader->distAtt[0] ), DIST_ATT_MAX_MAXDIST ); pRenderConfigReader->distAtt[2] = min( max( 0.0f, pRenderConfigReader->distAtt[2] ), DIST_ATT_MAX_ROLLOFF ); #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++ ) { Loading @@ -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 ) { Loading @@ -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 } } } Loading @@ -1456,6 +1514,7 @@ ivas_error RenderConfigReader_checkValues( return IVAS_ERR_OK; } #endif /* FIX_2500_ISM4_BIN_REVERB_DISTORTION */ /*------------------------------------------------------------------------------------------* * RenderConfigReader_open() Loading Loading @@ -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 || Loading @@ -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 ); Loading Loading @@ -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 ) ); Loading Loading @@ -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 */ Loading @@ -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 ) ); Loading
lib_util/render_config_reader.h +6 −0 Original line number Diff line number Diff line Loading @@ -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( Loading