Commit 4fb80063 authored by vaclav's avatar vaclav
Browse files

accept SRAM_REDUCTION_BINRENDERER_ROOM

parent 946a84bb
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -3213,7 +3213,6 @@ 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                    */
@@ -3223,13 +3222,7 @@ ivas_error ivas_binaural_reverb_open(
    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                  */
);
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@
/*#define FIX_I1_113*/                                  /* under review : MCT bit distribution optimization for SBA high bitrates*/

#define FIX_I13_TCX_TNS_ISSUE                           /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */
#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 */


+0 −27
Original line number Diff line number Diff line
@@ -371,9 +371,7 @@ 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 */
@@ -489,10 +487,6 @@ 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;
@@ -586,31 +580,10 @@ 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 );
            ivas_binaural_reverb_setPreDelay( hBinRenderer->hReverb, 10 );
        }
        else
        {
            ivas_reverb_prepare_cldfb_params( &st_ivas->hRenderConfig->roomAcoustics, st_ivas->hIntSetup.output_config, st_ivas->hRenderConfig->roomAcoustics.use_brir, st_ivas->hDecoderConfig->output_Fs, t60, ene );
            ivas_binaural_reverb_setReverbTimes( hBinRenderer->hReverb, st_ivas->hDecoderConfig->output_Fs, t60, ene );
            ivas_binaural_reverb_setPreDelay( hBinRenderer->hReverb, (int16_t) roundf( 48000.0f * st_ivas->hRenderConfig->roomAcoustics.acousticPreDelay / CLDFB_NO_CHANNELS_MAX ) );
        }

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

        /* initialize the dmx matrix */
        for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
+2 −99
Original line number Diff line number Diff line
@@ -36,9 +36,7 @@
#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
@@ -315,13 +313,6 @@ 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] );
@@ -341,8 +332,10 @@ void ivas_binaural_reverb_setReverbTimes(
            for ( sample = 0; sample < hReverb->loopBufLength[bin]; sample++ )
            {
                intendedEnergy += currentEnergy;

                /* The randomization at the energy build up affects where the sparse taps are located */
                energyBuildup += currentEnergy + 0.1f * ( (float) binRend_rand( hReverb ) / PCM16_TO_FLT_FAC - 0.5f );

                if ( energyBuildup >= 1.0f ) /* A new filter tap is added at this condition */
                {
                    /* Four efficient phase operations: n*pi/2, n=0,1,2,3 */
@@ -375,7 +368,6 @@ 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             */
@@ -512,96 +504,7 @@ ivas_error ivas_binaural_reverb_open(

    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                    */
    const int16_t numCldfbSlotsPerFrame /* i  : number of CLDFB slots per frame, i.e., reverberator block size */
)
{
    int16_t bin, chIdx, k, tmp;
    REVERB_STRUCT_HANDLE hReverb;

    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 = 0;
    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 );
    }

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

        tmp = hReverb->loopBufLengthMax[bin] + hReverb->blockSize;
        if ( ( hReverb->loopBufReal[bin] = (float *) count_malloc( tmp * 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( tmp * 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, tmp );
        set_f( hReverb->loopBufImag[bin], 0.0f, tmp );

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

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

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

            set_s( hReverb->tapPhaseShiftType[bin][chIdx], 0, tmp );

            tmp = hReverb->blockSize;
            if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) count_malloc( tmp * 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( tmp * 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, tmp );
            set_f( hReverb->outputBufferImag[bin][chIdx], 0.0f, tmp );
        }
    }

    return IVAS_ERR_OK;
}
#endif

/*-------------------------------------------------------------------------
 * ivas_binaural_reverb_close()
+3 −22
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ ivas_error ivas_dirac_dec_init_binaural_data(
            hBinaural->useTdDecorr = 1;
        }
    }
    if ( st_ivas->ivas_format == MASA_FORMAT )
    else if ( st_ivas->ivas_format == MASA_FORMAT )
    {
        if ( ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_48k && st_ivas->nchan_transport == 1 ) || st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE )
        {
@@ -188,7 +188,7 @@ 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 )
@@ -203,26 +203,6 @@ ivas_error ivas_dirac_dec_init_binaural_data(
                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 )
            {
                return error;
            }
        }
        else
        {
            if ( ( error = ivas_binaural_reverb_open( &hBinaural->hReverb, nBins, CLDFB_NO_COL_MAX ) ) != IVAS_ERR_OK )
            {
                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 )
    {
@@ -264,6 +244,7 @@ ivas_error ivas_dirac_dec_init_binaural_data(
    return IVAS_ERR_OK;
}


/*-------------------------------------------------------------------------
 * ivas_dirac_dec_close_binaural_data()
 *