Commit 7f79519e authored by norvell's avatar norvell
Browse files

Added TD renderer ITD update and cleanup under define FIX_ITD

parent c6357c57
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1390,8 +1390,16 @@ typedef enum
#define SFX_SPAT_BIN_MAX_FILTER_LENGTH          256

#define SPAT_BIN_MAX_INPUT_CHANNELS             1                           /* Max number of input channels per source/object. Mono for now, but stereo objects may be considered. */

#ifdef FIX_ITD
#define MAX_ITD                                 50
#define SFX_SPAT_BIN_SINC_M                     5
#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 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 */
#endif

/* ----- Enums - TD Renderer ----- */

+46 −1
Original line number Diff line number Diff line
@@ -4992,7 +4992,13 @@ void GetFilterFromAngle(
    TDREND_HRFILT_FiltSet_t *HrFiltSet_p,                       /* i/o: HR filter set structure                 */
    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                         */
    int16_t *itd                                                /* o  : ITD value                               */
#else
    SFX_SpatBin_Params_t *SfxSpatBinParams_p                    /* i/o: Currently used HR filter                */
#endif
);

void HRTF_model_precalc(
@@ -5021,8 +5027,12 @@ ivas_error TDREND_REND_RenderSourceHRFilt(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,          /* i/o: TD renderer handle                      */
#endif
    float output_buf[][L_SPATIAL_SUBFR_48k],                    /* o  : Output buffer                           */
#ifdef FIX_ITD
    const int16_t subframe_length                               /* i  : Subframe length in use                  */
#else
    const int16_t subframe_length,                              /* i  : Subframe length in use                  */
    const int32_t output_Fs                                     /* i  : Output sample rate                      */
#endif
);

/* ----- Object renderer - sources ----- */
@@ -5055,7 +5065,15 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,          /* i/o: TD renderer handle                      */
    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                            */
    int16_t *filterlength,                                      /*   o: Length of filters                       */
    int16_t *itd,                                               /*   o: ITD value                               */
    float *Gain                                                 /*   o: Gain value                              */
#else
    const int32_t output_Fs                                     /* i  : Output sample rate                      */
#endif
);

ivas_error TDREND_SRC_Alloc(
@@ -5068,8 +5086,12 @@ void TDREND_SRC_Dealloc(

void TDREND_SRC_Init(
    TDREND_SRC_t *Src_p,                                        /* i/o: Source to initialize                    */ 
#ifdef FIX_ITD
    const TDREND_PosType_t PosType                              /* i  : Position type specifier                 */
#else
    const TDREND_PosType_t PosType,                             /* i  : Position type specifier                 */
    const int32_t output_Fs                                     /* i  : Output sampling rate                    */
#endif
);

/* ----- Object renderer - vec ----- */
@@ -5114,8 +5136,12 @@ int16_t TDREND_SPATIAL_EvalOrthonormOrient(
ivas_error TDREND_MIX_AddSrc(
    BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd,          /* i/o: TD renderer handle                      */
    int16_t *SrcInd,                                            /* o  : Source index                            */
#ifdef FIX_ITD
    const TDREND_PosType_t PosType                              /* i  : Position type (absolute/relative)       */
#else
    const TDREND_PosType_t PosType,                             /* i  : Position type (absolute/relative)       */
    const int32_t output_Fs                                     /* i  : Output sampling rate                    */
#endif
);

ivas_error TDREND_MIX_SetDistAttenModel(
@@ -5146,7 +5172,7 @@ ivas_error TDREND_MIX_Init(
);

 /* ----- Object renderer - sfx ----- */

#ifndef FIX_ITD
ivas_error TDREND_SFX_SpatBin_Initialize(
    SFX_SpatBin_t *SfxSpatBin_p,                                /* i/o: Spatial parameters handle               */
    const int32_t output_Fs                                     /* i  : Output sampling rate                    */
@@ -5168,8 +5194,27 @@ void TDREND_SFX_SpatBin_Execute_Main(
    int16_t *NoOfDeliveredOutputSamples_p,                      /* o  : Number of output samples actually rendered */
    const int32_t output_Fs                                     /* i  : Output sample rate                         */
);
#endif

#ifdef FIX_ITD
void TDREND_Apply_ITD(
    float *input,                                               /*  i: Input SCE subframe to be time adjusted   */
    float *out_left,                                            /*  o: Output left channels with ITD applied    */
    float *out_right,                                           /*  o: Output right channels with ITD applied   */
    int16_t *previtd,                                           /*i/o: Previous ITD value                       */
    const int16_t itd,                                          /*  i: Current subframe ITD value               */
    float *mem_itd,                                             /*i/o: ITD buffer memory                        */
    const int16_t length                                        /*  i: Subframe length                          */
);

void TDREND_firfilt(
    float *signal,                                              /* i/o: Input signal / Filtered signal          */
    const float *filter,                                        /* i/o: FIR filter                              */
    float *mem,                                                 /* i/o: filter memory                           */
    const int16_t subframe_length,                              /* i  : Length of signal                        */
    const int16_t filterlength                                  /* i  : Filter length                           */
);
#endif
/*----------------------------------------------------------------------------------*
 * Filter-bank (FB) Mixer
 *----------------------------------------------------------------------------------*/
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@
#define FIX_MCT_PLC_RECOVERY                            /* Issue 184: scale the old synthesis part correctly in the first good frame after lost frames in MCT modes - to be activated after previous switch is merged */
#define SBA_BR_SWITCHING                                /* Issue 114: Changes for sba bit rate switching*/
#define FIX_AGC_WINFUNC_MEMORY                          /* Issue 62: lower agc_com.winFunc memory consumption */

#define FIX_ITD

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+16 −3
Original line number Diff line number Diff line
@@ -1324,6 +1324,8 @@ typedef struct ivas_binaural_head_track_struct
/*----------------------------------------------------------------------------------*
 * TD ISm Object Renderer structure
 *----------------------------------------------------------------------------------*/

#ifndef FIX_ITD
// VE2AT: move to ivas_rom_rend.h ?
typedef struct
{
@@ -1387,6 +1389,7 @@ typedef struct TDREND_LIST_Item_s
    struct TDREND_LIST_Item_s *Next_p; /* Pointer to the next item */

} TDREND_LIST_Item_t;
#endif

typedef struct
{
@@ -1579,10 +1582,10 @@ typedef struct TDREND_SRC_REND_s
    float SrcGainMax_p[SPAT_BIN_MAX_INPUT_CHANNELS];
    float DirGain_p[SPAT_BIN_MAX_INPUT_CHANNELS];
    float DistGain_p[SPAT_BIN_MAX_INPUT_CHANNELS];

#ifndef FIX_ITD
    /* HR filtering parameters */
    SFX_SpatBin_t *SfxSpatBin_p;

#endif
} TDREND_SRC_REND_t;


@@ -1605,7 +1608,17 @@ typedef struct
    float *InputFrame_p; /* Input frame pointer */
    TDREND_SRC_SPATIAL_t *SrcSpatial_p;
    TDREND_SRC_REND_t *SrcRend_p;

#ifdef FIX_ITD
    int16_t itd;
    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 Gain;
#endif
} TDREND_SRC_t;

/* Top level TD binaural renderer handle */
+2 −0
Original line number Diff line number Diff line
@@ -109,7 +109,9 @@ ivas_error ivas_rend_TDObjRenderFrame(
    const IVAS_REND_HeadRotData *headRotData,        /* i  : Input head positions              */
    const IVAS_REND_AudioObjectPosition *currentPos, /* i  : Object position                   */
    const int16_t output_frame,                      /* i  : output frame length               */
#ifndef FIX_ITD
    const int32_t output_Fs,                         /* i  : output sampling rate              */
#endif
    float output[][L_FRAME48k]                       /* i/o: SCE channels / Binaural synthesis */
);

Loading