Commit 4353d954 authored by norvell's avatar norvell
Browse files

Merge branch 'Ericsson/TD-renderer-ITD-improvement-and-cleanup' into 'main'

[Non-BE] [Renderer Non-BE] 0016: TD renderer ITD improvement and cleanup

See merge request !261
parents b5ea69cc a731ab67
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -331,7 +331,7 @@ external-renderer-make-pytest:
    - make -j IVAS_rend
    - make -j unittests
    - make -j --directory scripts/td_object_renderer/object_renderer_standalone
    - python3 -m pytest -q --log-level ERROR -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    when: always
@@ -353,7 +353,8 @@ external-renderer-cmake-asan-pytest:
    - python3 ci/disable_ram_counting.py
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q --log-level ERROR -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    when: always
@@ -375,7 +376,8 @@ external-renderer-cmake-msan-pytest:
    - python3 ci/disable_ram_counting.py
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan  -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q --log-level ERROR -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
  
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    when: always
@@ -397,7 +399,7 @@ external-renderer-cmake-msan-pytest:
  script:
    - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true -DDEC_TO_REND_FLOAT_DUMP=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q --log-level ERROR -n 1 -rA --junit-xml=report-junit.xml tests/renderer/test_renderer_vs_decoder.py
    - python3 -m pytest -q -n 1 -rA --junit-xml=report-junit.xml tests/renderer/test_renderer_vs_decoder.py
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    when: always
+12 −1
Original line number Diff line number Diff line
@@ -1388,8 +1388,19 @@ 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 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 */
#endif

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

+60 −2
Original line number Diff line number Diff line
@@ -5004,7 +5004,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,                                          /* 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                */
#endif
);

void HRTF_model_precalc(
@@ -5029,12 +5035,22 @@ 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
    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 ----- */
@@ -5067,7 +5083,20 @@ 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 *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                              */
    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
);

ivas_error TDREND_SRC_Alloc(
@@ -5080,8 +5109,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 ----- */
@@ -5126,8 +5159,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(
@@ -5158,7 +5195,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                    */
@@ -5180,8 +5217,29 @@ 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          */
    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                           */
);
#endif
/*----------------------------------------------------------------------------------*
 * Filter-bank (FB) Mixer
 *----------------------------------------------------------------------------------*/

lib_com/options.h

100755 → 100644
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,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                                         /* Contribution 16: TD renderer ITD improvement and code cleanup */
#define REMOVE_SID_HARM_LEFTOVERS                       /* Issue 192: remove leftovers from the SID bitrate harmonization */
#define FIX_MCT_UNINIT_MEM                              /* Issue 166: Reading of uninitialized memory in TCX range coder */
#define FIX_IGF_NOISE_REPETITION                        /* Issue 182: fix repetition of same noise in IGF */
+18 −3
Original line number Diff line number Diff line
@@ -1328,6 +1328,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
{
@@ -1391,6 +1393,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
{
@@ -1583,10 +1586,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;


@@ -1609,7 +1612,19 @@ 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 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;

/* Top level TD binaural renderer handle */
Loading