Commit 5542bb62 authored by norvell's avatar norvell
Browse files

Flexible allocation of filter buffers under FIX_569_TD_FILTER_FLEXIBLE_LENGTH

parent f880161a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1535,7 +1535,9 @@ typedef enum
#define HRTF_MODEL_N_SECTIONS                   3                           /* No. sections used in approximate evaluation of model             */
#define HRTF_MODEL_BSPLINE_NUM_COEFFS           4                           /* No. BSpline coefficients, including zeroth order e.g. cubic -> 4 */
#define HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ        16                          /* Square of HRTF_MODEL_BSPLINE_NUM_COEFFS                          */
#ifndef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
#define SFX_SPAT_BIN_MAX_FILTER_LENGTH          256
#endif

#define SPAT_BIN_MAX_INPUT_CHANNELS             1                           /* Max number of input channels per source/object. Mono for now, but stereo objects may be considered. */
#define MAX_ITD                                 50
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@
#define FIX_TCX_LOWRATE_LIMITATION                      /* VA: issue 577: TCX bitrate limitation only when DEBUGGING is active */
#define FIX_575_LOW_OVERLAP_PLC_RECOVERY                /* FhG: Issue 575 fix for PLC and transistion to TCX5*/
#define FIX_580_PARAMMC_ENER_BURSTS                     /* FhG: issue 580: energy bursts due to ILD holding when energy relations change too much */
#define FIX_569_TD_FILTER_FLEXIBLE_LENGTH               /* Eri: Issue 569: Flexible allocation of filter buffers. Allows any length on filter in binary format. Uses frame-wise malloc for allocation of buffers */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+21 −0
Original line number Diff line number Diff line
@@ -349,13 +349,22 @@ ivas_error TDREND_GetMix(
    TDREND_SRC_REND_t *SrcRend_p;
    ivas_error error;
    float output_buf[2][L_SPATIAL_SUBFR_48k]; /* Temp buffer for left/right rendered signal */
#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
    float *hrf_left_delta;
    float *hrf_right_delta;
    int16_t FiltLength;
#else
    float hrf_left_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
    float hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
#endif
    int16_t intp_count;
    float pan_left, pan_right;
    int16_t subframe_update_flag;

    subframe_update_flag = subframe_idx == ism_md_subframe_update;
#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
    FiltLength = hBinRendererTd->HrFiltSet_p->FiltLength;
#endif

    error = IVAS_ERR_OK;

@@ -364,8 +373,15 @@ ivas_error TDREND_GetMix(
    set_f( output_buf[1], 0.0f, subframe_length );

    /* Clear interpolation buffers and counter */
#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
    hrf_left_delta = malloc( FiltLength * sizeof( float ) );
    hrf_right_delta = malloc( FiltLength * sizeof( float ) );
    set_f( hrf_left_delta, 0.0f, FiltLength );
    set_f( hrf_right_delta, 0.0f, FiltLength );
#else
    set_f( hrf_left_delta, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH );
    set_f( hrf_right_delta, 0.0f, SFX_SPAT_BIN_MAX_FILTER_LENGTH );
#endif
    intp_count = 0;

    /* Create the mix */
@@ -405,6 +421,11 @@ ivas_error TDREND_GetMix(
    /* Clear the PoseUpdated and Source position update flags */
    TDREND_Clear_Update_flags( hBinRendererTd );

#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
    free( hrf_left_delta );
    free( hrf_right_delta );
#endif

    return error;
}

+8 −0
Original line number Diff line number Diff line
@@ -317,12 +317,20 @@ ivas_error TDREND_MIX_AddSrc(
        {

            /* Alloc and init a complete source: signal+spatial+rend components */
#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
            if ( ( error = TDREND_SRC_Alloc( &Src_p, hBinRendererTd->HrFiltSet_p->FiltLength ) ) != IVAS_ERR_OK )
#else
            if ( ( error = TDREND_SRC_Alloc( &Src_p ) ) != IVAS_ERR_OK )
#endif
            {
                return error;
            }

#ifdef FIX_569_TD_FILTER_FLEXIBLE_LENGTH
            TDREND_SRC_Init( Src_p, PosType, hBinRendererTd->HrFiltSet_p->FiltLength );
#else
            TDREND_SRC_Init( Src_p, PosType );
#endif

            /* Special OpenAL initialization due to a common distance attenuation model */
            if ( hBinRendererTd->DistAttenModel != 0 )
+11 −0
Original line number Diff line number Diff line
@@ -240,13 +240,20 @@ void TDREND_firfilt(
    const float prevGain           /* i  : Previous gain                  */
)
{
#ifdef FIX_569
    float *buffer;
#else
    float buffer[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1 + L_SUBFRAME5MS_48k];
#endif
    float *p_signal;
    float *p_tmp;
    float *p_filter;
    float tmp;
    int16_t i, j;
    float step, gain_tmp, gain_delta;
#ifdef FIX_569
    buffer = (float *) malloc( ( filterlength - 1 + L_SUBFRAME5MS_48k ) * sizeof( float ) );
#endif

    gain_delta = ( Gain - prevGain );
    step = gain_delta / ( subframe_length );
@@ -278,5 +285,9 @@ void TDREND_firfilt(
        }
    }

#ifdef FIX_569
    free( buffer );
#endif

    return;
}
Loading