Commit 39f1c885 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Control logic simplification

parent 5903f93b
Loading
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -1075,6 +1075,9 @@ ivas_error ivas_binRenderer_open(
    BINAURAL_RENDERER_HANDLE hBinRenderer;
    int16_t convBand, k;
    ivas_error error;
#ifdef FIX_587_DEFAULT_REVERB
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL;
#endif

    error = IVAS_ERR_OK;

@@ -1211,32 +1214,20 @@ ivas_error ivas_binRenderer_open(
        }
    }

#ifdef FIX_587_DEFAULT_REVERB
    /* Allocate and initialize the reverberator */
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
    {
        if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, NULL, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
    else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
    {
        if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#else
    /* Allocate memories needed for reverb module */
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
#ifdef FIX_587_DEFAULT_REVERB
        if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics );
        }
#endif
        if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif
    else
    {
        hBinRenderer->hReverb = NULL;
+10 −34
Original line number Diff line number Diff line
@@ -143,6 +143,9 @@ ivas_error ivas_dirac_dec_init_binaural_data(
    ivas_error error;
    float frequency_axis[CLDFB_NO_CHANNELS_MAX];
    int16_t num_poses, pos_idx;
#ifdef FIX_587_DEFAULT_REVERB
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL;
#endif

    num_poses = 1;
    if ( st_ivas->hSplitBinRend != NULL )
@@ -217,39 +220,6 @@ ivas_error ivas_dirac_dec_init_binaural_data(
        }
        else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */
        {
#ifdef FIX_587_DEFAULT_REVERB
            /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */
            if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) ||
                                                    ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) )
            {
                ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) );
            }

            if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins );

                if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
                {
                    if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }
            else
            {
                set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX );
                if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
                {
                    if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }

#else
            if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins );
@@ -257,6 +227,9 @@ ivas_error ivas_dirac_dec_init_binaural_data(
            else
            {
                set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX );
#ifdef FIX_587_DEFAULT_REVERB
                pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics );
#endif
            }

            /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */
@@ -268,12 +241,15 @@ ivas_error ivas_dirac_dec_init_binaural_data(

            if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
            {
#ifdef FIX_587_DEFAULT_REVERB
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
            }
#endif
        }
        else if ( renderer_type == RENDERER_STEREO_PARAMETRIC )
        {
+1 −1
Original line number Diff line number Diff line
@@ -1876,7 +1876,7 @@ ivas_error ivas_binaural_reverb_init(
    error = IVAS_ERR_OK;

#ifdef FIX_587_DEFAULT_REVERB
    if ( ( roomAcoustics != NULL ) && ( defaultTimes == NULL || defaultEne == NULL ) )
    if ( roomAcoustics != NULL )
#else
    if ( ( roomAcoustics != NULL ) && roomAcoustics->override )
#endif
+10 −26
Original line number Diff line number Diff line
@@ -8312,6 +8312,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    ivas_error error;
    float frequency_axis[CLDFB_NO_CHANNELS_MAX];
    int16_t pos_idx;
#ifdef FIX_587_DEFAULT_REVERB
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL;
#endif

    error = IVAS_ERR_OK;

@@ -8387,31 +8390,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
        }
        else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */
        {
#ifdef FIX_587_DEFAULT_REVERB
            if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins );

                if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
                {
                    if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }
            else
            {
                set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX );
                if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
                {
                    if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, NULL, NULL ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
                }
            }
#else
            if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins );
@@ -8419,16 +8397,22 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
            else
            {
                set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX );
#ifdef FIX_587_DEFAULT_REVERB
                pRoomAcoustics = &( hRendCfg->roomAcoustics );
#endif
            }

            if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */
            {
#ifdef FIX_587_DEFAULT_REVERB
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
            }
#endif
        }
        else if ( renderer_type == RENDERER_STEREO_PARAMETRIC )
        {