Commit 1e65bda4 authored by norvell's avatar norvell
Browse files

Added interpolation for large changes in position metadata

parent 8a343bc3
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1396,6 +1396,9 @@ typedef enum
#define SFX_SPAT_BIN_NUM_SUBSAMPLES             64
#define ITD_MEM_LEN                             (MAX_ITD + SFX_SPAT_BIN_SINC_M)
#define L_SUBFRAME5MS_48k                       (L_FRAME48k/4)
#define MAX_ANGULAR_STEP                        (15.0f)
#define MAX_ANGULAR_STEP_INV                    ( 1.0f / MAX_ANGULAR_STEP )
#define MAX_INTERPOLATION_STEPS                 12
#define BINAURAL_TD_LATENCY_S                   0.0f                        /* ITD fix removes TD renderer delay -- should be cleaned out */
#else
#define BINAURAL_TD_LATENCY_S                   0.00675f                    /* Binaural TD renderer latency in second == 324 samples in between 333 and 315 */
+19 −6
Original line number Diff line number Diff line
@@ -5002,8 +5002,8 @@ void GetFilterFromAngle(
    const float Elev,                                           /* i  : Elevation, degrees                      */
    float Azim,                                                 /* i  : Azimuth, degrees                        */
#ifdef FIX_ITD
    float *LeftFilter_p,                                        /* o  : Left HR filter                          */
    float *RightFilter_p,                                       /* o  : Right HR filter                         */
    float *LeftFilter,                                          /* o  : Left HR filter                          */
    float *RightFilter,                                         /* o  : Right HR filter                         */
    int16_t *itd                                                /* o  : ITD value                               */
#else
    SFX_SpatBin_Params_t *SfxSpatBinParams_p                    /* i/o: Currently used HR filter                */
@@ -5032,8 +5032,14 @@ void TDREND_HRFILT_SetFiltSet(

ivas_error TDREND_REND_RenderSourceHRFilt(
    TDREND_SRC_t *Src_p,                                        /* i/o: The source to be rendered               */
#ifdef FIX_ITD
    const float *hrf_left_delta,                                /*   i: Left filter interpolation delta         */
    const float *hrf_right_delta,                               /*   i: Right filter interpolation delta        */
    const int16_t intp_count,                                   /*   i: Interpolation count                     */        
#else
#ifdef TDREND_HRTF_TABLE_METHODS
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,          /* i/o: TD renderer handle                      */
#endif
#endif
    float output_buf[][L_SPATIAL_SUBFR_48k],                    /* o  : Output buffer                           */
#ifdef FIX_ITD
@@ -5075,11 +5081,16 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams(
    TDREND_SRC_REND_t *SrcRend_p,                               /* i/o: Source object                           */
    TDREND_SRC_SPATIAL_t *SrcSpatial_p,                         /* i  : Spatial aspects of source               */
#ifdef FIX_ITD
    float *LeftFilter_p,                                        /*   o: Left filter                             */
    float *RightFilter_p,                                       /*   o: Right filter                            */
    float *hrf_left_prev,                                       /*   o: Left filter                             */
    float *hrf_right_prev,                                      /*   o: Right filter                            */
    float *hrf_left_delta,                                      /*   o: Left filter interpolation delta         */
    float *hrf_right_delta,                                     /*   o: Right filter interpolation delta        */
    int16_t *intp_count,                                        /*   o: Interpolation count                     */        
    int16_t *filterlength,                                      /*   o: Length of filters                       */
    int16_t *itd,                                               /*   o: ITD value                               */
    float *Gain                                                 /*   o: Gain value                              */
    float *Gain,                                                /*   o: Gain value                              */
    TDREND_SRC_t *Src_p,
    const int16_t subframe_idx                                  /* i  : Subframe index to 5 ms subframe         */
#else
    const int32_t output_Fs                                     /* i  : Output sample rate                      */
#endif
@@ -5218,7 +5229,9 @@ void TDREND_Apply_ITD(

void TDREND_firfilt(
    float *signal,                                              /* i/o: Input signal / Filtered signal          */
    const float *filter,                                        /* i/o: FIR filter                              */
    float *filter,                                              /* i/o: FIR filter                              */
    const float *filter_delta,                                  /* i  : FIR filter delta                        */
    const int16_t intp_count,                                   /* i  : interpolation count                     */              
    float *mem,                                                 /* i/o: filter memory                           */
    const int16_t subframe_length,                              /* i  : Length of signal                        */
    const int16_t filterlength                                  /* i  : Filter length                           */
+6 −4
Original line number Diff line number Diff line
@@ -1617,10 +1617,12 @@ typedef struct
    int16_t previtd;
    int16_t filterlength;
    float mem_itd[ITD_MEM_LEN];
    float hr_filt_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; /* Todo: Should we allocate these buffers with count_malloc instead of the maximum length? */
    float hr_filt_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
    float mem_hr_filt_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
    float mem_hr_filt_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
    float hrf_left_prev[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; /* Todo: Should we allocate these buffers with count_malloc instead of the maximum length? */
    float hrf_right_prev[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
    float azim_prev;
    float elev_prev;
    float mem_hrf_left[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
    float mem_hrf_right[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1];
    float Gain;
#endif
} TDREND_SRC_t;
+17 −5
Original line number Diff line number Diff line
@@ -330,12 +330,24 @@ static 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_ITD
    float hrf_left_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
    float hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH];
    int16_t intp_count;
#endif
    error = IVAS_ERR_OK;

    /* Clear the output buffer to accumulate rendered sources */
    set_f( output_buf[0], 0.0f, subframe_length );
    set_f( output_buf[1], 0.0f, subframe_length );

#ifdef FIX_ITD
    /* Clear interpolation buffers and counter */
    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 );
    intp_count = 0;
#endif

    /* Create the mix */
    /* Loop through the source list and render each source */
    for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ )
@@ -348,8 +360,8 @@ static ivas_error TDREND_GetMix(
        if ( hBinRendererTd->Listener_p->PoseUpdated || SrcSpatial_p->Updated )
        {
#ifdef FIX_ITD
            TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, Src_p->hr_filt_left,
                                                            Src_p->hr_filt_right, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain );
            TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, Src_p->hrf_left_prev,
                                                            Src_p->hrf_right_prev, hrf_left_delta, hrf_right_delta, &intp_count, &Src_p->filterlength, &Src_p->itd, &Src_p->Gain, Src_p, subframe_idx );
#else
            TDREND_SRC_REND_UpdateFiltersFromSpatialParams( hBinRendererTd, SrcRend_p, SrcSpatial_p, output_Fs );
#endif
@@ -358,11 +370,11 @@ static ivas_error TDREND_GetMix(
        /* Render source if needed */
        if ( ( SrcRend_p->InputAvailable == TRUE ) && ( SrcRend_p->PlayStatus == TDREND_PLAYSTATUS_PLAYING ) )
        {
#ifdef FIX_ITD
            error = TDREND_REND_RenderSourceHRFilt( Src_p, hrf_left_delta, hrf_right_delta, intp_count, output_buf, subframe_length );
#else
#ifdef TDREND_HRTF_TABLE_METHODS
            error = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, subframe_length, output_Fs );
#else
#ifdef FIX_ITD
            error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, subframe_length );
#else
            error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, subframe_length, output_Fs );
#endif
+15 −9
Original line number Diff line number Diff line
@@ -344,8 +344,14 @@ void TDREND_HRFILT_SetFiltSet(

ivas_error TDREND_REND_RenderSourceHRFilt(
    TDREND_SRC_t *Src_p, /* i/o: The source to be rendered               */
#ifdef FIX_ITD
    const float *hrf_left_delta,  /*   i: Left filter interpolation delta         */
    const float *hrf_right_delta, /*   i: Right filter interpolation delta        */
    const int16_t intp_count,     /*   i: Interpolation count                     */
#else
#ifdef TDREND_HRTF_TABLE_METHODS
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle                      */
#endif
#endif
    float output_buf[][L_SPATIAL_SUBFR_48k], /* o  : Output buffer              */
#ifdef FIX_ITD
@@ -366,8 +372,8 @@ ivas_error TDREND_REND_RenderSourceHRFilt(

#ifdef FIX_ITD
    TDREND_Apply_ITD( Src_p->InputFrame_p, LeftOutputFrame, RightOutputFrame, &Src_p->previtd, Src_p->itd, Src_p->mem_itd, subframe_length );
    TDREND_firfilt( LeftOutputFrame, Src_p->hr_filt_left, Src_p->mem_hr_filt_left, subframe_length, Src_p->filterlength );
    TDREND_firfilt( RightOutputFrame, Src_p->hr_filt_right, Src_p->mem_hr_filt_right, subframe_length, Src_p->filterlength );
    TDREND_firfilt( LeftOutputFrame, Src_p->hrf_left_prev, hrf_left_delta, intp_count, Src_p->mem_hrf_left, subframe_length, Src_p->filterlength );
    TDREND_firfilt( RightOutputFrame, Src_p->hrf_right_prev, hrf_right_delta, intp_count, Src_p->mem_hrf_right, subframe_length, Src_p->filterlength );
#else

    /* Input channel rendering loop */
@@ -713,8 +719,8 @@ void GetFilterFromAngle(
    const float Elev,                     /* i  : Elevation, degrees       */
    float Azim,                           /* i  : Azimuth, degrees         */
#ifdef FIX_ITD
    float *LeftFilter_p,  /* o  : Left HR filter           */
    float *RightFilter_p, /* o  : Right HR filter          */
    float *hrf_left,  /* o  : Left HR filter           */
    float *hrf_right, /* o  : Right HR filter          */
    int16_t *itd      /* o  : ITD value                */
#else
    SFX_SpatBin_Params_t *SfxSpatBinParams_p /* i/o: Currently used HR filter */
@@ -728,8 +734,8 @@ void GetFilterFromAngle(
    GenerateFilter( Elev, Azim, &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval );

#ifdef FIX_ITD
    mvr2r( HrFiltSet_p->ModelEval.hrfModL, LeftFilter_p, HrFiltSet_p->ModelParams.K );
    mvr2r( HrFiltSet_p->ModelEval.hrfModR, RightFilter_p, HrFiltSet_p->ModelParams.K );
    mvr2r( HrFiltSet_p->ModelEval.hrfModL, hrf_left, HrFiltSet_p->ModelParams.K );
    mvr2r( HrFiltSet_p->ModelEval.hrfModR, hrf_right, HrFiltSet_p->ModelParams.K );
#else
    /* Renderer requires filter in reversed order: */
    count = 0;
Loading