Commit 6f9a19f0 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Selectable AE based on already available acoustic environments

parent 8c307cd2
Loading
Loading
Loading
Loading
Loading
+39 −4
Original line number Diff line number Diff line
@@ -227,6 +227,10 @@ int main(
    IVAS_RENDER_FRAMESIZE asked_frame_size;
    IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
    ObjectEditFileReader *objectEditFileReader = NULL;
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA **pAE = NULL;
    uint32_t aeCount = 0;
#endif
#ifdef DEBUGGING
    int32_t noClipping;
    int32_t cnt_frames_limited;
@@ -637,13 +641,31 @@ int main(
            goto cleanup;
        }
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
        uint32_t aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader );
        aeCount = RenderConfigReader_getAcousticEnvironmentCount( renderConfigReader );
        if ( aeCount > 0 )
        {
            IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) );
            uint32_t n;

            if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, &pAE ) ) != IVAS_ERR_OK )
            pAE = malloc( aeCount * sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA * ) );

            if ( pAE == NULL )
            {
                fprintf( stderr, "\nError: cannot allocate memory for acoustic environment array\n\n" );
                goto cleanup;
            }

            for ( n = 0; n < aeCount; n++ )
            {
                pAE[n] = NULL;

                if ( NULL == ( pAE[n] = malloc( sizeof( IVAS_ROOM_ACOUSTICS_CONFIG_DATA ) ) ) )
                {
                    fprintf( stderr, "\nError: cannot allocate memory for acoustic environment\n\n" );
                    goto cleanup;
                }
            }

            if ( ( error = RenderConfigReader_getAcousticEnvironments( renderConfigReader, pAE ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error while getting acoustic environments\n\n" );
                goto cleanup;
@@ -651,7 +673,7 @@ int main(

            for ( n = 0; n < aeCount; n++ )
            {
                if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, pAE[n] ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, *pAE[n] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "Failed to add acoustic environments\n\n" );
                    goto cleanup;
@@ -836,6 +858,19 @@ cleanup:

    free( pcmBuf );

#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    if ( pAE != NULL )
    {
        uint16_t n;

        for ( n = 0; n < aeCount; n++ )
        {
            free( pAE[n] );
        }

        free( pAE );
    }
#endif
    if ( arg.aeSequence.count > 0 )
    {
        free( arg.aeSequence.pID );
+14 −3
Original line number Diff line number Diff line
@@ -3237,12 +3237,17 @@ ivas_error IVAS_DEC_AddAcousticEnvironment(
    mvr2r( roomAcousticsConfig.pAcoustic_rt60, pAE->pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX );
    mvr2r( roomAcousticsConfig.pAcoustic_dsr, pAE->pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX );

    pAE->use_er = roomAcousticsConfig.use_er;

    if ( pAE->use_er == 1 )
    {
        pAE->use_er = roomAcousticsConfig.use_er;
        pAE->lowComplexity = roomAcousticsConfig.lowComplexity;
        pAE->dimensions = roomAcousticsConfig.dimensions;
        pAE->ListenerOrigin = roomAcousticsConfig.ListenerOrigin;
        pAE->dimensions.x = roomAcousticsConfig.dimensions.x;
        pAE->dimensions.y = roomAcousticsConfig.dimensions.y;
        pAE->dimensions.z = roomAcousticsConfig.dimensions.z;
        pAE->ListenerOrigin.x = roomAcousticsConfig.ListenerOrigin.x;
        pAE->ListenerOrigin.y = roomAcousticsConfig.ListenerOrigin.y;
        pAE->ListenerOrigin.z = roomAcousticsConfig.ListenerOrigin.z;

        mvr2r( roomAcousticsConfig.AbsCoeff, pAE->AbsCoeff, IVAS_ROOM_ABS_COEFF );
    }
@@ -3272,6 +3277,12 @@ ivas_error IVAS_DEC_GetAcousticEnvironment(
    }
    st_ivas = hIvasDec->st_ivas;

    /* In case of default AE ID, select the first one available */
    if ( aeID == IVAS_DEFAULT_AEID && st_ivas->acousticEnvironmentsCount > 0 )
    {
        aeID = (uint16_t) st_ivas->pAcousticEnvironments[0].aeID;
    }

    for ( n = 0; n < st_ivas->acousticEnvironmentsCount; n++ )
    {
        IVAS_ROOM_ACOUSTICS_CONFIG_DATA ae = st_ivas->pAcousticEnvironments[n];
+21 −17
Original line number Diff line number Diff line
@@ -2963,7 +2963,7 @@ ivas_error RenderConfigReader_read(
/*------------------------------------------------------------------------------------------*
 * RenderConfigReader_getAcousticEnvironments()
 *
 * Gets all acoustic environments data
 * Gets number of acoustic environments available
 *------------------------------------------------------------------------------------------*/
uint32_t RenderConfigReader_getAcousticEnvironmentCount(
    RenderConfigReader *pRenderConfigReader /* i  : RenderConfigReader handle               */
@@ -2975,7 +2975,7 @@ uint32_t RenderConfigReader_getAcousticEnvironmentCount(
/*------------------------------------------------------------------------------------------*
 * RenderConfigReader_getAcousticEnvironments()
 *
 * Gets all acoustic environments data
 * Gets all acoustic environments
 *------------------------------------------------------------------------------------------*/
ivas_error RenderConfigReader_getAcousticEnvironments(
    RenderConfigReader *pRenderConfigReader,  /* i  : RenderConfigReader handle             */
@@ -2994,6 +2994,7 @@ ivas_error RenderConfigReader_getAcousticEnvironments(
        AcousticEnv pIn = pRenderConfigReader->pAE[n];
        IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pOut = ppAcEnv[n];

        pOut->aeID = (uint16_t) pIn.id;
        pOut->nBands = (uint16_t) pIn.pFG->nrBands;
        pOut->inputPreDelay = pIn.preDelay;

@@ -3010,18 +3011,21 @@ ivas_error RenderConfigReader_getAcousticEnvironments(
            pOut->use_er = pIn.pEarlyReflections->use_er;               /* ER activation flag */
            pOut->lowComplexity = pIn.pEarlyReflections->lowComplexity; /* Low complexity flag */
            pOut->dimensions = pIn.pEarlyReflections->dimensions;

            /* Use default listener origin position if non provided */
            if ( pIn.pEarlyReflections->pListenerOrigin == NULL )
            {
                if ( ( pIn.pEarlyReflections->pListenerOrigin = malloc( sizeof( IVAS_VECTOR3 ) ) ) == NULL )
            if ( pIn.pEarlyReflections->pListenerOrigin != NULL )
            {
                    return IVAS_ERR_FAILED_ALLOC;
                pOut->ListenerOrigin.x = pIn.pEarlyReflections->pListenerOrigin->x;
                pOut->ListenerOrigin.y = pIn.pEarlyReflections->pListenerOrigin->y;
                pOut->ListenerOrigin.z = pIn.pEarlyReflections->pListenerOrigin->z;
            }
                pIn.pEarlyReflections->pListenerOrigin->x = IVAS_ER_LIST_ORIGIN_X;
                pIn.pEarlyReflections->pListenerOrigin->y = IVAS_ER_LIST_ORIGIN_Y;
                pIn.pEarlyReflections->pListenerOrigin->z = IVAS_ER_LIST_HEIGHT;
            else
            {
                pOut->ListenerOrigin.x = IVAS_ER_LIST_ORIGIN_X;
                pOut->ListenerOrigin.y = IVAS_ER_LIST_ORIGIN_Y;
                pOut->ListenerOrigin.z = IVAS_ER_LIST_HEIGHT;
            }
            pOut->ListenerOrigin = *pIn.pEarlyReflections->pListenerOrigin;

            for ( j = 0; j < IVAS_ROOM_ABS_COEFF; j++ )
            {
                pOut->AbsCoeff[j] = pIn.pEarlyReflections->pAbsCoeff[j];