Commit 7ae1c8fb authored by vaclav's avatar vaclav
Browse files

Merge branch '145-static-memory-of-fastconv-binaural-handle' into 'main'

Optimize Static memory of FastConv binaural handle

See merge request !172
parents 1072299e 50663c4b
Loading
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -3235,12 +3235,23 @@ void ivas_dirac_dec_binaural(
    const int16_t nchan_transport                               /* i  : number of transport channels            */
);

#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,                            /* i/o: binaural reverb handle                  */
    const int16_t numBins,                                      /* i  : number of CLDFB bins                    */
    const int16_t numCldfbSlotsPerFrame                         /* i  : number of CLDFB slots per frame, i.e., reverberator block size */
    const int16_t numCldfbSlotsPerFrame,                        /* i  : number of CLDFB slots per frame         */
    ivas_roomAcoustics_t *roomAcoustics,                        /* i/o: room acoustics parameters               */
    const AUDIO_CONFIG output_config,                           /* i  : output audio configuration              */
    const int32_t sampling_rate,                                /* i  : sampling rate                           */
    const RENDERER_TYPE renderer_type                           /* i  : renderer type                           */
);

#else
ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,                            /* i/o: binaural reverb handle                  */
    const int16_t numBins,                                      /* i  : number of CLDFB bins                    */
    const int16_t numCldfbSlotsPerFrame                         /* i  : number of CLDFB slots per frame         */
);
#endif
void ivas_binaural_reverb_close(
    REVERB_STRUCT_HANDLE *hReverb                               /* i/o: binaural reverb handle                  */
);

lib_com/options.h

100644 → 100755
+2 −0
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@
#define FIX_DIRAC_CHANNELS                              /* Issue 71: lower number of DirAC analysis channels */
#define HARMONIZE_SBA_NCHAN_TRANSPORT                   /* harmonize setting of number of transport channels in SBA */
#define FIX_I13_TCX_TNS_ISSUE                           /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */
#define SRAM_REDUCTION_BINRENDERER                      /* Issue 145: reduction of static RAM usage in fastconv binaural renderer */
#define SRAM_REDUCTION_BINRENDERER_ROOM                 /* Issue 145: reduction of static RAM usage in fastconv binaural room renderer */
#define FIX_I120_INV_SQRT                               /* Issue 120: inv_sqrt() shall be used instead of 1 / sqrt() to measure the correct complexity */


+191 −5
Original line number Diff line number Diff line
@@ -186,6 +186,89 @@ static ivas_error ivas_binRenderer_convModuleOpen(
        }
    }

#ifdef SRAM_REDUCTION_BINRENDERER
    /* allocate memory for filter states */
    if ( ( hBinRenConvModule->filterTapsLeftReal = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    if ( ( hBinRenConvModule->filterTapsLeftImag = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    if ( ( hBinRenConvModule->filterTapsRightReal = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    if ( ( hBinRenConvModule->filterTapsRightImag = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
    {
        if ( ( hBinRenConvModule->filterTapsLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }

        if ( ( hBinRenConvModule->filterTapsLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }

        if ( ( hBinRenConvModule->filterTapsRightReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }

        if ( ( hBinRenConvModule->filterTapsRightImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }
    }

    if ( ( hBinRenConvModule->filterStatesLeftReal = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    if ( ( hBinRenConvModule->filterStatesLeftImag = (float ***) count_malloc( hBinRenderer->conv_band * sizeof( float ** ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
    }

    for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
    {
        if ( ( hBinRenConvModule->filterStatesLeftReal[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }

        if ( ( hBinRenConvModule->filterStatesLeftImag[bandIdx] = (float **) count_malloc( hBinRenderer->nInChannels * sizeof( float * ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
        }

        for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ )
        {
            if ( ( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] = (float *) count_malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
            }

            if ( ( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx] = (float *) count_malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) );
            }
        }
    }
#endif

    /* set memories */
    for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
    {
        for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ )
@@ -225,8 +308,13 @@ static ivas_error ivas_binRenderer_convModuleOpen(
            if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && hRenderConfig->roomAcoustics.use_brir )
            {
                /* set the memories to zero */
#ifdef SRAM_REDUCTION_BINRENDERER
                set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] );
                set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTapsArray[bandIdx] );
#else
                set_zero( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx], hBinRenConvModule->numTaps );
                set_zero( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx], hBinRenConvModule->numTaps );
#endif

                if ( isLoudspeaker )
                {
@@ -290,6 +378,9 @@ static void ivas_binaural_obtain_DMX(
{
    int16_t chIdx, bandIdx, k;

#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
    // ToDo: hBinRenderer->ivas_format is never set to ISM_FORMAT -> TBV
#endif
    if ( hBinRenderer->ivas_format == MC_FORMAT || hBinRenderer->ivas_format == ISM_FORMAT )
    {
        /* Obtain the downmix */
@@ -405,8 +496,10 @@ ivas_error ivas_binRenderer_open(
{
    BINAURAL_RENDERER_HANDLE hBinRenderer;
    int16_t convBand, chIdx, k;
#ifndef SRAM_REDUCTION_BINRENDERER_ROOM
    float t60[CLDFB_NO_CHANNELS_MAX];
    float ene[CLDFB_NO_CHANNELS_MAX];
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -500,10 +593,17 @@ ivas_error ivas_binRenderer_open(
    /* Allocate memories needed for reverb module */
    if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
    {
#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
        if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, RENDERER_BINAURAL_FASTCONV_ROOM ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#else
        if ( ( error = ivas_binaural_reverb_open( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( !st_ivas->hRenderConfig->roomAcoustics.override )
        {
            ivas_binaural_reverb_setReverbTimes( hBinRenderer->hReverb, st_ivas->hDecoderConfig->output_Fs, fastconvReverberationTimes, fastconvReverberationEneCorrections );
@@ -517,6 +617,8 @@ ivas_error ivas_binRenderer_open(
        }

        hBinRenderer->hReverb->useBinauralCoherence = 1;
#endif

        /* initialize the dmx matrix */
        for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
        {
@@ -560,6 +662,86 @@ ivas_error ivas_binRenderer_open(
    return error;
}

#ifdef SRAM_REDUCTION_BINRENDERER
/*-------------------------------------------------------------------------
 * ivas_binRenderer_convModuleClose()
 *
 * Close convolution module handle of fastconv binaural renderer
 *------------------------------------------------------------------------*/

static void ivas_binRenderer_convModuleClose(
    BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle    */
)
{
    int16_t bandIdx, chIdx;
    BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule;

    hBinRenConvModule = ( *hBinRenderer )->hBinRenConvModule;

    if ( hBinRenConvModule == NULL )
    {
        return;
    }

    for ( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ )
    {
        count_free( hBinRenConvModule->filterTapsLeftReal[bandIdx] );
        hBinRenConvModule->filterTapsLeftReal[bandIdx] = NULL;

        count_free( hBinRenConvModule->filterTapsLeftImag[bandIdx] );
        hBinRenConvModule->filterTapsLeftImag[bandIdx] = NULL;

        count_free( hBinRenConvModule->filterTapsRightReal[bandIdx] );
        hBinRenConvModule->filterTapsRightReal[bandIdx] = NULL;

        count_free( hBinRenConvModule->filterTapsRightImag[bandIdx] );
        hBinRenConvModule->filterTapsRightImag[bandIdx] = NULL;
    }

    count_free( hBinRenConvModule->filterTapsLeftReal );
    hBinRenConvModule->filterTapsLeftReal = NULL;

    count_free( hBinRenConvModule->filterTapsLeftImag );
    hBinRenConvModule->filterTapsLeftImag = NULL;

    count_free( hBinRenConvModule->filterTapsRightReal );
    hBinRenConvModule->filterTapsRightReal = NULL;

    count_free( hBinRenConvModule->filterTapsRightImag );
    hBinRenConvModule->filterTapsRightImag = NULL;


    for ( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ )
    {
        for ( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ )
        {
            count_free( hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] );
            hBinRenConvModule->filterStatesLeftReal[bandIdx][chIdx] = NULL;

            count_free( hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx] );
            hBinRenConvModule->filterStatesLeftImag[bandIdx][chIdx] = NULL;
        }

        count_free( hBinRenConvModule->filterStatesLeftReal[bandIdx] );
        hBinRenConvModule->filterStatesLeftReal[bandIdx] = NULL;

        count_free( hBinRenConvModule->filterStatesLeftImag[bandIdx] );
        hBinRenConvModule->filterStatesLeftImag[bandIdx] = NULL;
    }

    count_free( hBinRenConvModule->filterStatesLeftReal );
    hBinRenConvModule->filterStatesLeftReal = NULL;

    count_free( hBinRenConvModule->filterStatesLeftImag );
    hBinRenConvModule->filterStatesLeftImag = NULL;


    count_free( ( *hBinRenderer )->hBinRenConvModule );
    ( *hBinRenderer )->hBinRenConvModule = NULL;

    return;
}
#endif

/*-------------------------------------------------------------------------
 * ivas_binRenderer_close()
@@ -578,8 +760,12 @@ void ivas_binRenderer_close(

    if ( ( *hBinRenderer )->hBinRenConvModule != NULL )
    {
#ifdef SRAM_REDUCTION_BINRENDERER
        ivas_binRenderer_convModuleClose( hBinRenderer );
#else
        count_free( ( *hBinRenderer )->hBinRenConvModule );
        ( *hBinRenderer )->hBinRenConvModule = NULL;
#endif
    }

    if ( ( *hBinRenderer )->hReverb != NULL )
@@ -775,10 +961,10 @@ void ivas_binRenderer(
    /* Obtain the binaural dmx and compute the reverb */
    if ( hBinRenderer->hReverb != NULL )
    {
        float reverbRe[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float reverbIm[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float inRe[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float inIm[2][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float reverbRe[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float reverbIm[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float inRe[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
        float inIm[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];

        ivas_binaural_obtain_DMX( numTimeSlots, hBinRenderer, RealBuffer, ImagBuffer, inRe, inIm );

@@ -791,7 +977,7 @@ void ivas_binRenderer(
            }
        }

        ivas_binaural_reverb_processFrame( hBinRenderer->hReverb, 2, inRe, inIm, reverbRe, reverbIm, 0u );
        ivas_binaural_reverb_processFrame( hBinRenderer->hReverb, BINAURAL_CHANNELS, inRe, inIm, reverbRe, reverbIm, 0u );

        /* Add the conv module and reverb module output */
        for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
+144 −2
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@
#include "ivas_prot.h"
#include "prot.h"
#include "ivas_rom_com.h"
#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
#include "ivas_rom_binauralRenderer.h"
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
@@ -312,12 +315,13 @@ void ivas_binaural_reverb_setReverbTimes(
        }
        hReverb->binauralCoherenceDirectGains[bin] = sqrtf( 1.0f - fabsf( tmpVal ) );

#ifndef SRAM_REDUCTION_BINRENDERER_ROOM
        /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long
         * but not excessively long loops to generate reverberation. */
        /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */
        hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 );
        hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] );

#endif
        /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */
        attenuationFactorPerSample = powf( 10.0f, -3.0f * ( 1.0f / ( (float) CLDFB_SLOTS_PER_SECOND * revTimes[bin] ) ) );
        hReverb->loopAttenuationFactor[bin] = powf( attenuationFactorPerSample, hReverb->loopBufLength[bin] );
@@ -371,6 +375,144 @@ void ivas_binaural_reverb_setReverbTimes(
 * Allocate and initialize binaural room reverberator handle
 *------------------------------------------------------------------------*/

#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,     /* i/o: binaural reverb handle           */
    const int16_t numBins,               /* i  : number of CLDFB bins             */
    const int16_t numCldfbSlotsPerFrame, /* i  : number of CLDFB slots per frame  */
    ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters        */
    const AUDIO_CONFIG output_config,    /* i  : output audio configuration       */
    const int32_t sampling_rate,         /* i  : sampling rate                    */
    const RENDERER_TYPE renderer_type    /* i  : renderer type                    */
)
{
    int16_t bin, chIdx, k, len;
    REVERB_STRUCT_HANDLE hReverb;
    const float *revTimes;
    float t60[CLDFB_NO_CHANNELS_MAX];
    float ene[CLDFB_NO_CHANNELS_MAX];

    if ( ( *hReverbPr = (REVERB_STRUCT_HANDLE) count_malloc( sizeof( REVERB_STRUCT ) ) ) == NULL )
    {
        return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
    }

    hReverb = *hReverbPr;

    hReverb->useBinauralCoherence = 1;
    hReverb->preDelayBufferLength = 1;
    hReverb->preDelayBufferIndex = 0;

    hReverb->numBins = numBins;
    hReverb->blockSize = numCldfbSlotsPerFrame;

    for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ )
    {
        set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins );
        set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins );
    }

    if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
    {
        if ( !roomAcoustics->override )
        {
            revTimes = fastconvReverberationTimes;
        }
        else
        {
            revTimes = t60;
        }
    }
    else
    {
        revTimes = parametricReverberationTimes;
    }

    for ( bin = 0; bin < hReverb->numBins; bin++ )
    {
        /* Loop Buffer */
        hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) );

        len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize;
        if ( ( hReverb->loopBufReal[bin] = (float *) count_malloc( len * sizeof( float ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
        }

        if ( ( hReverb->loopBufImag[bin] = (float *) count_malloc( len * sizeof( float ) ) ) == NULL )
        {
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
        }

        set_f( hReverb->loopBufReal[bin], 0.0f, len );
        set_f( hReverb->loopBufImag[bin], 0.0f, len );

        /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long
         * but not excessively long loops to generate reverberation. */
        /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */
        hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 );
        hReverb->loopBufLength[bin] = min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] );

        /* Sparse Filter Tap Locations */
        for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
        {
            len = hReverb->loopBufLength[bin];

            if ( ( hReverb->tapPhaseShiftType[bin][chIdx] = (int16_t *) count_malloc( len * sizeof( int16_t ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
            }
            set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, len );

            if ( ( hReverb->tapPointersReal[bin][chIdx] = (float **) count_malloc( len * sizeof( float * ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
            }

            if ( ( hReverb->tapPointersImag[bin][chIdx] = (float **) count_malloc( len * sizeof( float * ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
            }

            len = hReverb->blockSize;
            if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) count_malloc( len * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
            }

            if ( ( hReverb->outputBufferImag[bin][chIdx] = (float *) count_malloc( len * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) );
            }

            set_f( hReverb->outputBufferReal[bin][chIdx], 0.0f, len );
            set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, len );
        }
    }

    if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
    {
        if ( !roomAcoustics->override )
        {
            ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, fastconvReverberationTimes, fastconvReverberationEneCorrections );
            ivas_binaural_reverb_setPreDelay( hReverb, 10 );
        }
        else
        {
            ivas_reverb_prepare_cldfb_params( roomAcoustics, output_config, roomAcoustics->use_brir, sampling_rate, t60, ene );
            ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, t60, ene );
            ivas_binaural_reverb_setPreDelay( hReverb, (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) );
        }
    }
    else
    {
        ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, parametricReverberationTimes, parametricReverberationEneCorrections );
        ivas_binaural_reverb_setPreDelay( hReverb, 10 );
    }

    return IVAS_ERR_OK;
}
#else
ivas_error ivas_binaural_reverb_open(
    REVERB_STRUCT_HANDLE *hReverbPr,    /* i/o: binaural reverb handle                  */
    const int16_t numBins,              /* i  : number of CLDFB bins                    */
@@ -459,7 +601,7 @@ ivas_error ivas_binaural_reverb_open(

    return IVAS_ERR_OK;
}

#endif

/*-------------------------------------------------------------------------
 * ivas_binaural_reverb_close()
+18 −0
Original line number Diff line number Diff line
@@ -188,6 +188,22 @@ ivas_error ivas_dirac_dec_init_binaural_data(
    else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */
    {
        mvr2r( parametricEarlyPartEneCorrection, hBinaural->earlyPartEneCorrection, nBins );
#ifdef SRAM_REDUCTION_BINRENDERER_ROOM
        if ( hBinaural->useSubframeMode )
        {
            if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
        else
        {
            if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX, NULL, st_ivas->hIntSetup.output_config, output_Fs, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
#else
        if ( hBinaural->useSubframeMode )
        {
            if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK )
@@ -202,9 +218,11 @@ ivas_error ivas_dirac_dec_init_binaural_data(
                return error;
            }
        }

        ivas_binaural_reverb_setReverbTimes( hBinaural->hReverb, output_Fs, parametricReverberationTimes, parametricReverberationEneCorrections );
        hBinaural->hReverb->useBinauralCoherence = 1;
        ivas_binaural_reverb_setPreDelay( hBinaural->hReverb, 10 );
#endif
    }
    else if ( renderer_type == RENDERER_STEREO_PARAMETRIC )
    {
Loading