Commit 9b1ff7c1 authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/main' into...

Merge remote-tracking branch 'remotes/origin/main' into float-1585-asan-memory-leaks-with-format-switching-in-lib_dec-ivas_init_dec-c-2321-53
parents e0bbbdc5 e5a0c937
Loading
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -621,6 +621,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 )
        {
@@ -700,6 +708,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 )
@@ -713,6 +728,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.
@@ -2350,6 +2366,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 )
@@ -2549,6 +2573,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 )
@@ -2562,6 +2593,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 ) );
+24 −0
Original line number Diff line number Diff line
@@ -1173,6 +1173,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

        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, args.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", args.directivityPatternId[0], args.directivityPatternId[1], args.directivityPatternId[2], args.directivityPatternId[3] );
@@ -1188,6 +1196,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 )
@@ -1201,6 +1216,7 @@ int main(
                fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", aeID );
                goto cleanup;
            }
#endif
        }

        /* ISAR frame size is set from command line, not renderer config file.
@@ -1607,6 +1623,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 )
@@ -1620,6 +1643,7 @@ int main(
                    fprintf( stderr, "\nFailed to get acoustic environment with ID %d\n\n", args.aeSequence.pID[args.aeSequence.selected] );
                    goto cleanup;
                }
#endif
                if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n\n", ivas_error_to_string( error ) );
+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@

#define USE_RTPDUMP                                     /* FhG: RTPDUMP format (rtptools standard) instead of custom format */
#define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API            /* Expose Payload Type setting in RTP Header */
#define FIX_2500_RENDCONF_REFACTOR                      /* Eri: Basop issue #2500: Renderer configuration range check before conversion to fixed point. Harmonize between BASOP/float */
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION         /* Eri: Basop issue 2023: Distance attenuation scaling, synch with BASOP updates and adding clamping of distance att input and listener position  */
#define FIX_1574_EFAP_CODE_LINT                         /* FhG: issue 1574: Code quality fixes in ivas_efap.c */
#define FIX_FLOAT_1569_REND_RENDER_CONFIG_CHECKS        /* Nokia: float issue 1569: fix render config checks in renderer */
+163 −3
Original line number Diff line number Diff line
@@ -72,9 +72,19 @@
#define IVAS_ER_LIST_ORIGIN_Y 0.0f

#ifdef FIX_BASOP_2023_TDREND_DISTATT_PRECISION
#define DIST_ATT_MIN_MAXDIST     0.0f
#define DIST_ATT_MIN_REFDIST     0.0f
#define DIST_ATT_MIN_ROLLOFF     0.0f
#define DIST_ATT_MAX_MAXDIST     63.0f
#define DIST_ATT_MAX_REFDIST     6.3f
#define DIST_ATT_MAX_ROLLOFF     4.0f
#define DIST_ATT_DEFAULT_MAXDIST 15.75f
#define DIST_ATT_DEFAULT_REFDIST 1.0f
#define DIST_ATT_DEFAULT_ROLLOFF 1.0f
#define DIRECTIVITY_MIN_ANGLE    0.0f
#define DIRECTIVITY_MAX_ANGLE    360.0f
#define DIRECTIVITY_MIN_ATT_FAC  0.0f
#define DIRECTIVITY_MAX_ATT_FAC  1.0f
#endif

#ifndef TRUE
@@ -1230,6 +1240,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          */
)
@@ -1364,6 +1523,7 @@ ivas_error RenderConfigReader_checkValues(

    return IVAS_ERR_OK;
}
#endif


/*------------------------------------------------------------------------------------------*
+4 −0
Original line number Diff line number Diff line
@@ -80,7 +80,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                                                                    */