Commit 3cbeff31 authored by TYAGIRIS's avatar TYAGIRIS
Browse files

move head track structs outside isar_stat.h

parent 5a3e89cd
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -57,6 +57,12 @@
#define IVAS_MAX_PARAM_SPATIAL_SUBFRAMES 4
#define IVAS_ROOM_ABS_COEFF              6

/* Maximum buffer length (per channel) in samples */
#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k )

/* Frame size required when rendering to binaural */
#define BINAURAL_RENDERING_FRAME_SIZE_MS 5

/*----------------------------------------------------------------------------------*
 * Common API enum for output audio configurations
 *----------------------------------------------------------------------------------*/
+0 −3
Original line number Diff line number Diff line
@@ -51,9 +51,6 @@
#include "string.h"
#endif

#define MAX_BUFFER_LENGTH_PER_CHANNEL       ( L_FRAME48k )
#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 )

/*---------------------------------------------------------------------*
 * Local function declarations
 *---------------------------------------------------------------------*/
+3 −141
Original line number Diff line number Diff line
@@ -44,57 +44,30 @@
#include "isar_lc3plus_enc.h"
#include "isar_lc3plus_dec.h"
#include "isar_cnst.h"
#endif

/*-------------------------------------------------------------------*
 *  constants common between isar and ivas rend
 *  ISAR post rend constants
 *-------------------------------------------------------------------*/

/* Maximum buffer length (per channel) in samples.
 * Keep this separate from L_FRAME48k in case we want to support different size later */
#define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k )
#ifdef SPLIT_REND_WITH_HEAD_ROT
#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 )
#define MAX_CLDFB_BUFFER_LENGTH             ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS )
#define MAX_BIN_BUFFER_LENGTH               ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS )
#define MAX_CLDFB_BIN_BUFFER_LENGTH         ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS )
#endif

/* Frame size required when rendering to binaural */
#define BINAURAL_RENDERING_FRAME_SIZE_MS 5

/*-------------------------------------------------------------------*
 *  structures common between isar and ivas rend
 *  ISAR post rend structs
 *-------------------------------------------------------------------*/

typedef struct ivas_orient_trk_state_t
{
    IVAS_HEAD_ORIENT_TRK_T orientation_tracking;
    float centerAdaptationRate;
    float offCenterAdaptationRate;
    float adaptationAngle;

    float alpha;
    IVAS_QUATERNION absAvgRot; /* average absolute orientation */
    IVAS_QUATERNION refRot;    /* reference orientation */
    IVAS_QUATERNION trkRot;    /* tracked rotation */

} ivas_orient_trk_state_t;

typedef struct
{
    int8_t headRotEnabled;
    IVAS_QUATERNION headPositions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
    float crossfade[L_FRAME48k / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis;
#endif
    ivas_orient_trk_state_t *hOrientationTracker;

} IVAS_REND_HeadRotData;
} IVAS_POST_REND_HeadRotData;

#ifdef SPLIT_REND_WITH_HEAD_ROT
typedef struct
{
#ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG
@@ -105,9 +78,7 @@ typedef struct
    HANDLE_CLDFB_FILTER_BANK cldfbSyn[BINAURAL_CHANNELS];

} CLDFB_HANDLES_WRAPPER, *CLDFB_HANDLES_WRAPPER_HANDLE;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
typedef struct isar_split_rend_huffman_cfg_t
{
    const int32_t *codebook;
@@ -269,115 +240,6 @@ typedef struct

} ISAR_SPLIT_POST_REND_WRAPPER;

typedef struct
{
    int16_t N; /* Polynomial degree */

    int16_t elevDim2;
    int16_t elevDim3;
    const float *elevKSeq; /* Array, length elevDim3-2       */
    int16_t azimDim2;
    int16_t azimDim3;
    const float *azimKSeq; /* Array, length azimDim3-2            */
    const float *W;        /* Array, size (elevDim3*azimDim3) x K */

    int16_t azimBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    int16_t azimBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    const float *azimBsShape;
    int16_t azimSegSamples;

    int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    const float *elevBsShape;
    int16_t elevSegSamples;
    float resamp_factor;

    /* Pointers for allocation of dynamic memory  */
    float *elevKSeq_dyn;
    float *azimKSeq_dyn;
    float *W_dyn;
    float *azimBsShape_dyn;
    float *elevBsShape_dyn;

} ISAR_ModelParamsITD_t;

typedef struct
{
    float val;
    int16_t i;

} ISAR_ValueIndex_t;

typedef struct
{
    int16_t modelROM;     /* Flag that indicates that the model resides in ROM (controls init/dealloc). */
    int16_t UseItdModel;  /* Controls whether ITD model is used. */
    int16_t SplineDegree; /* Degree of the spline functions */
    int16_t K;            /* Length of filter */
    int16_t elevDim2;
    int16_t elevDim3;
    int16_t AlphaN; /* Number of rows in Alpha matrices */
    int16_t num_unique_azim_splines;
    int16_t elevSegSamples;

    int16_t elevBsLen[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    int16_t elevBsStart[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    const int16_t *azimDim2;
    const int16_t *azimDim3;
    const int16_t *azim_start_idx;
    const int16_t *azimSegSamples;
    const int16_t *azimShapeIdx;
    const int16_t *azimShapeSampFactor;

    const float *elevKSeq; /* Array, N x elevDim2 x elevDim3 */
    const float *AlphaL;   /* Array, size AlphaN x K */
    const float *AlphaR;   /* Array, size AlphaN x K */
    const float *elevBsShape;
    float **azimKSeq; /* Array, length azimDim3+1            */
    const float **azimBsShape;

    int16_t azimDim3Max;
    int16_t iSecFirst[HRTF_MODEL_N_SECTIONS]; /* Indices for start of sections */
    int16_t iSecLast[HRTF_MODEL_N_SECTIONS];  /* Indices for end of sections */
    const float *EL;                          /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */
    const float *ER;                          /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */

    /* Pointers for allocation of dynamic memory  */
    float *AlphaL_dyn;
    float *AlphaR_dyn;
    float *EL_dyn;
    float *ER_dyn;
    float *elevBsShape_dyn;
    float *elevKSeq_dyn;
    int16_t *azimDim2_dyn;
    int16_t *azimDim3_dyn;
    int16_t *azim_start_idx_dyn;
    int16_t *azimSegSamples_dyn;
    int16_t *azimShapeIdx_dyn;
    int16_t *azimShapeSampFactor_dyn;
    float **azimBsShape_dyn;

} ISAR_ModelParams_t;

/* Shared memory for use when evaluating BSpline HR filter model*/
typedef struct
{
    float BM[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    ISAR_ValueIndex_t BMEnergiesL[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    ISAR_ValueIndex_t BMEnergiesR[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    int16_t UseIndsL[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    int16_t UseIndsR[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    float *hrfModL;
    float *hrfModR;
    float elevBfVec[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    float azimBfVec[HRTF_MODEL_BSPLINE_NUM_COEFFS][HRTF_MODEL_BSPLINE_NUM_COEFFS];
    float BM_ITD[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ];
    float elevBfVecITD[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    float azimBfVecITD[HRTF_MODEL_BSPLINE_NUM_COEFFS];
    float itdMod;

} ISAR_ModelEval_t;

typedef struct
{
    MULTI_BIN_REND_POSE_DATA multiBinPoseData;
+3 −3
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ typedef struct
    const AUDIO_CONFIG *pOutConfig;
    const LSSETUP_CUSTOM_STRUCT *pCustomLsOut;
    const EFAP_WRAPPER *pEfapOutWrapper;
    const IVAS_REND_HeadRotData *pHeadRotData;
    const IVAS_POST_REND_HeadRotData *pHeadRotData;
    const RENDER_CONFIG_HANDLE *hhRendererConfig;
    const int16_t *pSplitRendBFI;
} rendering_context;
@@ -125,7 +125,7 @@ struct ISAR_POST_REND
    AUDIO_CONFIG inputConfig;
    AUDIO_CONFIG outputConfig;

    IVAS_REND_HeadRotData headRotData;
    IVAS_POST_REND_HeadRotData headRotData;
    int16_t splitRendBFI;

    int8_t rendererConfigEnabled;
@@ -1392,7 +1392,7 @@ static ivas_error renderSplitBinauralWithPostRot(
    float *readPtr, *writePtr;
    uint32_t ivas_frame_duration_us;
    int16_t iNumBlocksPerFrame, iNumLCLDIterationsPerFrame;
    const IVAS_REND_HeadRotData *pHeadRotData;
    const IVAS_POST_REND_HeadRotData *pHeadRotData;

    isPostRendInputCldfb = 0;
    push_wmops( "renderSplitBinauralWithPostRot" );
+27 −0
Original line number Diff line number Diff line
@@ -644,6 +644,33 @@ typedef struct EFAP
 * Head rotation data structure
 *----------------------------------------------------------------------------------*/

typedef struct ivas_orient_trk_state_t
{
    IVAS_HEAD_ORIENT_TRK_T orientation_tracking;
    float centerAdaptationRate;
    float offCenterAdaptationRate;
    float adaptationAngle;

    float alpha;
    IVAS_QUATERNION absAvgRot; /* average absolute orientation */
    IVAS_QUATERNION refRot;    /* reference orientation */
    IVAS_QUATERNION trkRot;    /* tracked rotation */

} ivas_orient_trk_state_t;

typedef struct
{
    int8_t headRotEnabled;
    IVAS_QUATERNION headPositions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
    float crossfade[L_FRAME48k / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis;
#endif
    ivas_orient_trk_state_t *hOrientationTracker;

} IVAS_REND_HeadRotData;

typedef struct ivas_binaural_head_track_struct
{
    IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES];