Commit 0f6ce2d5 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Linking compact room acoustics data provided with RTP to the rendering reconfiguration

parent cad37be1
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@
#ifdef IVAS_RTPDUMP
#include "ivas_rtp_file.h"
#endif
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#include "ivas_cnst.h"
#endif

#include "jbm_file_writer.h"
#include "hrtf_file_reader.h"
#include "ls_custom_file_reader.h"
@@ -446,7 +450,11 @@ int main(
     *------------------------------------------------------------------------------------------*/

    asked_frame_size = arg.renderFramesize;
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : IVAS_DEFAULT_AEID;
#else
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535;
#endif

    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled,
                                       arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled,
+3 −0
Original line number Diff line number Diff line
@@ -312,6 +312,9 @@ typedef enum
#endif
typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
{
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    int16_t aeID; /* Acoustic environment ID*/
#endif
    int16_t nBands;                                   /* Number of frequency bands for which reverb properties are provided, integer, range [2..256]        */
    float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX];      /* Center frequencies for which following values are provided:                                        */
    float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /*  - The room's T60 per center frequency                                                             */
+3 −0
Original line number Diff line number Diff line
@@ -1580,6 +1580,9 @@ typedef enum
#define RV_LENGTH_NR_FC                         ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1
#define RV_LENGTH_NR_FC_16KHZ                   ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1
#define IVAS_REVERB_DEFAULT_N_BANDS             31
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
#define IVAS_DEFAULT_AEID                       ( 65535 )
#endif

#define LR_IAC_LENGTH_NR_FC                     ( RV_LENGTH_NR_FC )
#define LR_IAC_LENGTH_NR_FC_16KHZ               ( RV_LENGTH_NR_FC_16KHZ )
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@

#define RTP_S4_251135_CR26253_0016_REV1                /* RTP Pack/Unpack API corresponding to CR 26253 */
#define IVAS_RTPDUMP                                   /* RTPDUMP writing and reading for IVAS payloads */
#define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT              /* RTPDUMP acoustic environment */

/* ################### Start BE switches ################################# */
/* only BE switches wrt selection floating point code */
+126 −0
Original line number Diff line number Diff line
@@ -3210,6 +3210,9 @@ static ivas_error copyRendererConfigStruct(
            hRCout->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE;
            break;
    }
#endif
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    hRCout->roomAcoustics.aeID = hRCin->roomAcoustics.aeID;
#endif
    hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands;
    hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay;
@@ -3307,6 +3310,9 @@ ivas_error IVAS_DEC_FeedRenderConfig(
    {
        hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND;
    }
#endif
#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
    hRenderConfig->roomAcoustics.aeID = renderConfig.roomAcoustics.aeID;
#endif
    hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands;
    hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay;
@@ -3393,6 +3399,112 @@ ivas_error IVAS_DEC_FeedRenderConfig(
    return IVAS_ERR_OK;
}

#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
/*---------------------------------------------------------------------*
 * IVAS_DEC_FeedAcousticEnvPI( )
 *
 * Set acoustic environment from the PI data
 *---------------------------------------------------------------------*/

ivas_error IVAS_DEC_FeedAcousticEnvPI(
    IVAS_DEC_HANDLE hIvasDec,                   /* i/o: IVAS decoder handle         */
    const IVAS_PIDATA_ACOUSTIC_ENV hAcoustEnvPI /* i  : Render configuration struct */
)
{
    RENDER_CONFIG_HANDLE hRenderConfig;
    Decoder_Struct *st_ivas;
    ivas_error error;

    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    hRenderConfig = hIvasDec->st_ivas->hRenderConfig;
    st_ivas = hIvasDec->st_ivas;

#ifdef DEBUGGING
    hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE;
    if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_FASTCONV )
    {
        hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_FASTCONV;
    }
    if ( renderConfig.renderer_type_override == IVAS_RENDER_TYPE_OVERRIDE_CREND )
    {
        hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND;
    }
#endif
    hRenderConfig->roomAcoustics.aeID = hAcoustEnvPI.aeid;
    hRenderConfig->roomAcoustics.nBands = IVAS_PI_AE_NUM_BANDS;
    hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_LOW] = IVAS_PI_AE_LOW_FREQ;
    hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_MID] = IVAS_PI_AE_MID_FREQ;
    hRenderConfig->roomAcoustics.pFc_input[IVAS_PI_AE_HIGH] = IVAS_PI_AE_HIGH_FREQ;
    hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_LOW] = hAcoustEnvPI.rt60[IVAS_PI_AE_LOW];
    hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_MID] = hAcoustEnvPI.rt60[IVAS_PI_AE_MID];
    hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_HIGH] = hAcoustEnvPI.rt60[IVAS_PI_AE_HIGH];
    hRenderConfig->roomAcoustics.inputPreDelay = (float)(0.1 * hRenderConfig->roomAcoustics.pAcoustic_rt60[IVAS_PI_AE_MID]);
    hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_LOW] = hAcoustEnvPI.dsr[IVAS_PI_AE_LOW];
    hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_MID] = hAcoustEnvPI.dsr[IVAS_PI_AE_MID];
    hRenderConfig->roomAcoustics.pAcoustic_dsr[IVAS_PI_AE_HIGH] = hAcoustEnvPI.dsr[IVAS_PI_AE_HIGH];

    hRenderConfig->roomAcoustics.use_er = hAcoustEnvPI.availEarlyReflections;

    if ( hAcoustEnvPI.availEarlyReflections )
    {
        hRenderConfig->roomAcoustics.dimensions.x = hAcoustEnvPI.roomDimensions.x;
        hRenderConfig->roomAcoustics.dimensions.y = hAcoustEnvPI.roomDimensions.y;
        hRenderConfig->roomAcoustics.dimensions.z = hAcoustEnvPI.roomDimensions.z;
        mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF );
    }

    /* Re-initialize reverb instance if already available */

    /* TD renderer Jot reverberator */
    if ( st_ivas->hReverb != NULL )
    {
        if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    /* CREND Jot reverberator */
    if ( st_ivas->hCrendWrapper != NULL && st_ivas->hCrendWrapper->hCrend[0] != NULL && st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL )
    {
        if ( ( error = ivas_reverb_open( &st_ivas->hCrendWrapper->hCrend[0]->hReverb, st_ivas->hHrtfStatistics, hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    /* Parametric renderer reverberator */
    if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->hReverb != NULL )
    {
        ivas_binaural_reverb_close( &( st_ivas->hDiracDecBin[0]->hReverb ) );

        if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hDiracDecBin[0]->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES,
                                                  &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    /* FastConv renderer reverberator */
    if ( st_ivas->hBinRenderer != NULL && st_ivas->hBinRenderer->hReverb != NULL )
    {
        ivas_binaural_reverb_close( &( st_ivas->hBinRenderer->hReverb ) );

        if ( ( error = ivas_binaural_reverb_init( &( st_ivas->hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, st_ivas->hBinRenderer->conv_band, st_ivas->hBinRenderer->timeSlots,
                                                  &( hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }

    return IVAS_ERR_OK;
}

#endif

/*---------------------------------------------------------------------*
 * IVAS_DEC_GetDelay( )
@@ -5647,6 +5759,20 @@ ivas_error IVAS_RTP_ApplyPiData( IVAS_DEC_HANDLE hIvasDec, PIDATA_TS *piData, ui
            }
            break;

#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT
            case IVAS_PI_ACOUSTIC_ENVIRONMENT:
            {
                uint16_t aeid = piData->data.acousticEnv.aeid;
                DEBUG_PRINT( stdout, "PI_ACOUSTIC_ENVIRONMENT : AEID : %d\n", aeid );

                if ( piData->data.acousticEnv.availLateReverb && aeid != hIvasDec->st_ivas->hRenderConfig->roomAcoustics.aeID )
                {
                    error = IVAS_DEC_FeedAcousticEnvPI( hIvasDec, piData->data.acousticEnv );
                }
            }
            break;
#endif

#ifdef RTP_S4_251135_CR26253_0016_REV1
            case IVAS_PI_DIEGETIC_TYPE:
            {
Loading