Commit 7182b13c authored by stoutjesdijk's avatar stoutjesdijk 🎧
Browse files

wired up renderconfig to ivas_rend_openCrend and children

parent af202945
Loading
Loading
Loading
Loading
+36 −36
Original line number Diff line number Diff line
@@ -501,6 +501,42 @@ int32_t main( int32_t argc, char **argv )
        exit( -1 );
    }

    /* === Configure === */
    if ( ( error = IVAS_REND_ConfigureConfig( hIvasRend, args.trajectoryFile[0] != '\0', args.renderConfigFile[0] != '\0' ) ) != IVAS_ERR_OK )
    {
        exit( -1 );
    }

    if ( args.renderConfigFile[0] != '\0' )
    {
        IVAS_RENDER_CONFIG_DATA renderConfig;
        
        /* sanity check */
        if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" );
            exit( -1 ); // goto cleanup;
        }

        if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" );
            exit( -1 ); // goto cleanup;
        }

        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFile );
            exit( -1 ); // goto cleanup;
        }

        if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" );
            exit( -1 ); // goto cleanup;
        }
    }

    /* Set up output custom layout configuration */
    if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM )
    {
@@ -589,42 +625,6 @@ int32_t main( int32_t argc, char **argv )
        hMasaMetadata = MasaFileReader_getMetadataHandle( masaReader );
    }

    /* === Configure === */
    if ( ( error = IVAS_REND_ConfigureConfig( hIvasRend, args.trajectoryFile[0] != '\0', args.renderConfigFile[0] != '\0' ) ) != IVAS_ERR_OK )
    {
        exit( -1 );
    }

    if ( args.renderConfigFile[0] != '\0' )
    {
        IVAS_RENDER_CONFIG_DATA renderConfig;
        
        /* sanity check */
        if ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" );
            exit( -1 ); // goto cleanup;
        }

        if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" );
            exit( -1 ); // goto cleanup;
        }

        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFile );
            exit( -1 ); // goto cleanup;
        }

        if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" );
            exit( -1 ); // goto cleanup;
        }
    }

    int32_t numOutChannels;
    if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK )
    {
+0 −1
Original line number Diff line number Diff line
@@ -1658,7 +1658,6 @@ typedef struct ivas_hrtfs_structure

/* Reverberator structures */


typedef struct ivas_roomAcoustics_t
{
    int16_t override;
+17 −14
Original line number Diff line number Diff line
@@ -1149,7 +1149,7 @@ ivas_error ivas_rend_openCrend(
    CREND_WRAPPER *pCrend,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_AudioConfig outConfig,
    //IVAS_RENDER_CONFIG_HANDLE hRendererConfig,
    RENDER_CONFIG_DATA *hRend,
    int32_t output_Fs )
{
    /* TODO tmu : Based on ivas_crend_open() - could be harmonized / refactored */
@@ -1164,7 +1164,7 @@ ivas_error ivas_rend_openCrend(

    if ( pCrend->hHrtfCrend == NULL )
    {
        if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, output_Fs ) ) != IVAS_ERR_OK )
        if ( ( error = ivas_rend_initCrend( pCrend, inConfig, outConfig, hRend, output_Fs ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -1278,15 +1278,19 @@ ivas_error ivas_rend_openCrend(
            hCrend->hTrack = NULL;
        }

        /* TODO tmu : implement renderConfig */
        //if ( ( ( hRendererConfig != NULL ) && hRendererConfig->room_acoustics.late_reverb_on ) )
        //{
        //    //if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), st_ivas->intern_config, hHrtf, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
        //    {
        //        return error;
        //    }
        //}
        //else
        if ( ( hRend != NULL ) && (hRend->roomAcoustics.late_reverb_on ) )
        {
            if ( ( error = ivas_reverb_open( &(hCrend->hReverb),
                                            getIvasAudioConfigFromRendAudioConfig( inConfig ),
                                            pCrend->hHrtfCrend,
                                            hRend,
                                            output_Fs
                                            ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else
        {
            hCrend->hReverb = NULL;
        }
@@ -1308,6 +1312,7 @@ ivas_error ivas_rend_initCrend(
    CREND_WRAPPER *pCrend,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRend,
    int32_t output_Fs )
{
    int16_t i, j, tmp;
@@ -1339,9 +1344,7 @@ ivas_error ivas_rend_initCrend(

    /* set BRIR flag */
    use_brir = false;
    /* TODO tmu : pass down render config handle */
    // if ((pCrend->hRenderConfig != NULL && pCrend->hRenderConfig->roomAcoustics.use_brir) || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
    if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
    if ( (hRend != NULL && hRend->roomAcoustics.use_brir ) || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
    {
        use_brir = true;
    }
+2 −1
Original line number Diff line number Diff line
@@ -41,13 +41,14 @@ ivas_error ivas_rend_openCrend(
    CREND_WRAPPER *pCrend,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_AudioConfig outConfig,
//    IVAS_RENDER_CONFIG_HANDLE hRendererConfig,
    RENDER_CONFIG_DATA *hRend,
    int32_t output_Fs );

ivas_error ivas_rend_initCrend(
    CREND_WRAPPER *pCrend,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRend,
    int32_t output_Fs );

ivas_error ivas_rend_closeCrend(
+20 −11
Original line number Diff line number Diff line
@@ -887,7 +887,8 @@ static CREND_WRAPPER defaultCrendWrapper( void )
static ivas_error setRendInputActiveIsm(
    void *input,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_InputId id )
    IVAS_REND_InputId id,
    RENDER_CONFIG_DATA *hRend )
{
    ivas_error error;
    rendering_context rendCtx;
@@ -919,6 +920,7 @@ static ivas_error setRendInputActiveIsm(
        error = ivas_rend_openCrend( &inputIsm->crendWrapper,
                                     IVAS_REND_AUDIO_CONFIG_7_1_4,
                                     outConfig,
                                     hRend,
                                     *rendCtx.pOutSampleRate );
    }
    if ( error != IVAS_ERR_OK )
@@ -1428,7 +1430,8 @@ static void tmpFixBuggyTdBinRendInit( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRen
static ivas_error initMcBinauralRendering(
    input_mc *inputMc,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_AudioConfig outConfig )
    IVAS_REND_AudioConfig outConfig,
    RENDER_CONFIG_DATA *hRend )
{
    ivas_error error;
    int32_t outSampleRate;
@@ -1480,6 +1483,7 @@ static ivas_error initMcBinauralRendering(
        if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper,
                                            ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_REND_AUDIO_CONFIG_7_1_4 : inConfig,
                                            outConfig,
                                            hRend,
                                            outSampleRate ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -1547,7 +1551,8 @@ static IVAS_REND_LfeRouting defaultLfeRouting(
static ivas_error setRendInputActiveMc(
    void *input,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_InputId id )
    IVAS_REND_InputId id,
    RENDER_CONFIG_DATA *hRend )
{
    ivas_error error;
    rendering_context rendCtx;
@@ -1571,7 +1576,7 @@ static ivas_error setRendInputActiveMc(

    if ( outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
    {
        if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig ) ) != IVAS_ERR_OK )
        if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRend ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -1695,7 +1700,7 @@ static ivas_error initSbaPanGainsForSbaOut( input_sba *inputSba, IVAS_REND_Audio
    return error;
}

static ivas_error updateSbaPanGains( input_sba *inputSba, IVAS_REND_AudioConfig outConfig )
static ivas_error updateSbaPanGains( input_sba *inputSba, IVAS_REND_AudioConfig outConfig, RENDER_CONFIG_DATA *hRend )
{
    ivas_error error;
    IVAS_REND_AudioConfig inConfig;
@@ -1722,6 +1727,7 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, IVAS_REND_AudioConfig
                    error = ivas_rend_openCrend( &inputSba->crendWrapper,
                                                 inConfig,
                                                 outConfig,
                                                 hRend,
                                                 *rendCtx.pOutSampleRate );
                    break;
                case IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM:
@@ -1732,6 +1738,7 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, IVAS_REND_AudioConfig
                    error = ivas_rend_openCrend( &inputSba->crendWrapper,
                                                 IVAS_REND_AUDIO_CONFIG_7_1_4,
                                                 outConfig,
                                                 hRend,
                                                 *rendCtx.pOutSampleRate );
                    break;
                default:
@@ -1753,7 +1760,8 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, IVAS_REND_AudioConfig
static ivas_error setRendInputActiveSba(
    void *input,
    IVAS_REND_AudioConfig inConfig,
    IVAS_REND_InputId id )
    IVAS_REND_InputId id,
    RENDER_CONFIG_DATA *hRend )
{
    ivas_error error;
    rendering_context rendCtx;
@@ -1769,7 +1777,7 @@ static ivas_error setRendInputActiveSba(
    inputSba->crendWrapper = defaultCrendWrapper();
    initRotGains( inputSba->rot_gains_prev );

    if ( ( error = updateSbaPanGains( inputSba, outConfig ) ) != IVAS_ERR_OK )
    if ( ( error = updateSbaPanGains( inputSba, outConfig, hRend ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -2007,7 +2015,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(
            /* Input inactive, skip. */
            continue;
        }
        if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig ) ) != IVAS_ERR_OK )
        if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -2217,7 +2225,7 @@ ivas_error IVAS_REND_AddInput(
    int32_t maxNumInputsOfType;
    void *inputsArray;
    int32_t inputStructSize;
    ivas_error ( *activateInput )( void *, IVAS_REND_AudioConfig, IVAS_REND_InputId );
    ivas_error ( *activateInput )( void *, IVAS_REND_AudioConfig, IVAS_REND_InputId, RENDER_CONFIG_DATA * );
    int32_t inputIndex;

    /*-----------------------------------------------------------------*
@@ -2266,7 +2274,8 @@ ivas_error IVAS_REND_AddInput(

    if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex,
                                  inConfig,
                                  *inputId ) ) != IVAS_ERR_OK )
                                  *inputId,
                                  hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -2318,7 +2327,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout(

    if ( hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL || hIvasRend->outputConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM )
    {
        if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig ) ) != IVAS_ERR_OK )
        if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK )
        {
            return error;
        }