LCOV - code coverage report
Current view: top level - lib_rend - ivas_objectRenderer_mix.c (source / functions) Hit Total Coverage
Test: Coverage on main -- short test vectors @ 6c9ddc4024a9c0e1ecb8f643f114a84a0e26ec6b Lines: 136 176 77.3 %
Date: 2025-05-23 08:37:30 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /******************************************************************************************************
       2             : 
       3             :    (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
       4             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
       5             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
       6             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
       7             :    contributors to this repository. All Rights Reserved.
       8             : 
       9             :    This software is protected by copyright law and by international treaties.
      10             :    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
      11             :    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
      12             :    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
      13             :    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
      14             :    contributors to this repository retain full ownership rights in their respective contributions in
      15             :    the software. This notice grants no license of any kind, including but not limited to patent
      16             :    license, nor is any license granted by implication, estoppel or otherwise.
      17             : 
      18             :    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
      19             :    contributions.
      20             : 
      21             :    This software is provided "AS IS", without any express or implied warranties. The software is in the
      22             :    development stage. It is intended exclusively for experts who have experience with such software and
      23             :    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
      24             :    and fitness for a particular purpose are hereby disclaimed and excluded.
      25             : 
      26             :    Any dispute, controversy or claim arising under or in relation to providing this software shall be
      27             :    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
      28             :    accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
      29             :    the United Nations Convention on Contracts on the International Sales of Goods.
      30             : 
      31             : *******************************************************************************************************/
      32             : 
      33             : #include <stdint.h>
      34             : #include "options.h"
      35             : #include "prot.h"
      36             : #include "ivas_prot_rend.h"
      37             : #include "ivas_rom_TdBinauralRenderer.h"
      38             : #include "ivas_error.h"
      39             : #include "wmc_auto.h"
      40             : #include "ivas_rom_rend.h"
      41             : #include "ivas_rom_binaural_crend_head.h"
      42             : #include <math.h>
      43             : #ifdef DEBUGGING
      44             : #include "debug.h"
      45             : #endif
      46             : 
      47             : 
      48             : /*-------------------------------------------------------------------------
      49             :  * Local functions declaration
      50             :  *-------------------------------------------------------------------------*/
      51             : 
      52             : static ivas_error DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const int32_t output_Fs );
      53             : 
      54             : 
      55             : /*-------------------------------------------------------------------*
      56             :  * TDREND_MIX_LIST_SetPos()
      57             :  *
      58             :  * Sets the listener's position in the specified mixer unit.
      59             :  --------------------------------------------------------------------*/
      60             : 
      61     1583868 : void TDREND_MIX_LIST_SetPos(
      62             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle      */
      63             :     const float *Pos_p                                 /* i  : Listener's position     */
      64             : )
      65             : {
      66             :     TDREND_MIX_Listener_t *Listener_p;
      67             : 
      68     1583868 :     Listener_p = hBinRendererTd->Listener_p;
      69             : 
      70     1583868 :     if ( ( Pos_p[0] != Listener_p->Pos[0] ) || ( Pos_p[1] != Listener_p->Pos[1] ) || ( Pos_p[2] != Listener_p->Pos[2] ) )
      71             :     {
      72             :         /* Set position */
      73       20058 :         mvr2r( Pos_p, Listener_p->Pos, 3 );
      74             : 
      75             :         /* Set pose update flag */
      76       20058 :         Listener_p->PoseUpdated = TRUE;
      77             :     }
      78             : 
      79     1583868 :     return;
      80             : }
      81             : 
      82             : 
      83             : /*-------------------------------------------------------------------*
      84             :  * TDREND_MIX_LIST_SetOrient()
      85             :  *
      86             :  * Sets the listener's orientation vectors in the specified mixer unit.
      87             :  --------------------------------------------------------------------*/
      88             : 
      89     1583868 : ivas_error TDREND_MIX_LIST_SetOrient(
      90             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle                  */
      91             :     const float *FrontVec_p,                           /* i  : Listener's orientation front vector */
      92             :     const float *UpVec_p                               /* i  : Listener's orientation up vector    */
      93             : )
      94             : {
      95             :     TDREND_MIX_Listener_t *List_p;
      96             :     /* Value verification */
      97     1583868 :     if ( ( FrontVec_p[0] == 0.0f ) && ( FrontVec_p[1] == 0.0f ) && ( FrontVec_p[2] == 0.0f ) )
      98             :     {
      99           0 :         return ( IVAS_ERROR( IVAS_ERR_INTERNAL, "Zero front vector. Command is ignored!\n" ) );
     100             :     }
     101             : 
     102     1583868 :     if ( ( UpVec_p[0] == 0.0f ) && ( UpVec_p[1] == 0.0f ) && ( UpVec_p[2] == 0.0f ) )
     103             :     {
     104           0 :         return ( IVAS_ERROR( IVAS_ERR_INTERNAL, "Zero up vector. Command is ignored!\n" ) );
     105             :     }
     106             : 
     107             :     /* Get listener */
     108     1583868 :     List_p = hBinRendererTd->Listener_p;
     109             : 
     110             :     /* Evaluate the normalized orientation vectors and set pose update flag */
     111     1583868 :     List_p->PoseUpdated = TDREND_SPATIAL_EvalOrthonormOrient( List_p->Front, List_p->Up, List_p->Right, FrontVec_p, UpVec_p );
     112             : 
     113     1583868 :     return IVAS_ERR_OK;
     114             : }
     115             : 
     116             : 
     117             : /*-------------------------------------------------------------------*
     118             :  * TDREND_MIX_Dealloc()
     119             :  *
     120             :  * Deallocates the TDREND_MIX_t variable
     121             :  --------------------------------------------------------------------*/
     122             : 
     123        2427 : void TDREND_MIX_Dealloc(
     124             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle    */
     125             : )
     126             : {
     127             :     int16_t i;
     128             : 
     129             :     /* Deallocate source list */
     130        7715 :     for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ )
     131             :     {
     132        5288 :         TDREND_SRC_Dealloc( hBinRendererTd->Sources[i] );
     133             :     }
     134             :     /* Deallocate Listener and RendListener */
     135        2427 :     if ( hBinRendererTd->Listener_p != NULL )
     136             :     {
     137        2427 :         free( hBinRendererTd->Listener_p );
     138        2427 :         hBinRendererTd->Listener_p = NULL;
     139             :     }
     140             :     /* Dealloc HR filter set */
     141        2427 :     if ( ( *hBinRendererTd->pHrFiltSet_p != NULL ) && ( hBinRendererTd->HrFiltSet_p != NULL ) )
     142             :     {
     143        1232 :         if ( hBinRendererTd->HrFiltSet_p->FilterMethod == TDREND_HRFILT_Method_BSplineModel )
     144             :         {
     145        1232 :             BSplineModelEvalDealloc( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval );
     146             :         }
     147             :         else
     148             :         {
     149           0 :             if ( hBinRendererTd->HrFiltSet_p->Elev_p != NULL )
     150             :             {
     151           0 :                 free( hBinRendererTd->HrFiltSet_p->Elev_p );
     152           0 :                 hBinRendererTd->HrFiltSet_p->Elev_p = NULL;
     153             :             }
     154           0 :             if ( hBinRendererTd->HrFiltSet_p->Azim_p != NULL )
     155             :             {
     156           0 :                 free( hBinRendererTd->HrFiltSet_p->Azim_p );
     157           0 :                 hBinRendererTd->HrFiltSet_p->Azim_p = NULL;
     158             :             }
     159           0 :             if ( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p != NULL )
     160             :             {
     161           0 :                 free( hBinRendererTd->HrFiltSet_p->LeftFiltSet_p );
     162           0 :                 hBinRendererTd->HrFiltSet_p->LeftFiltSet_p = NULL;
     163             :             }
     164           0 :             if ( hBinRendererTd->HrFiltSet_p->RightFiltSet_p != NULL )
     165             :             {
     166           0 :                 free( hBinRendererTd->HrFiltSet_p->RightFiltSet_p );
     167           0 :                 hBinRendererTd->HrFiltSet_p->RightFiltSet_p = NULL;
     168             :             }
     169             :         }
     170             : 
     171        1232 :         if ( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == 1 )
     172             :         {
     173             : 
     174        1232 :             free( hBinRendererTd->HrFiltSet_p );
     175        1232 :             hBinRendererTd->HrFiltSet_p = NULL;
     176        1232 :             *hBinRendererTd->pHrFiltSet_p = NULL;
     177             :         }
     178             :     }
     179             : 
     180        2427 :     return;
     181             : }
     182             : 
     183             : 
     184             : /*-------------------------------------------------------------------*
     185             :  * TDREND_MIX_Init()
     186             :  *
     187             :  * Initializes the mixer and sets HRTF
     188             :  --------------------------------------------------------------------*/
     189             : 
     190        2427 : ivas_error TDREND_MIX_Init(
     191             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle                       */
     192             :     TDREND_HRFILT_FiltSet_t **hHrtfTD,                 /* i/o: HRTF data (initialized in case of NULL)  */
     193             :     const TDREND_MixSpatSpec_t *MixSpatSpec_p,         /* i  : Mixer spatial specification              */
     194             :     const int32_t output_Fs                            /* i  : Output sampling rate                     */
     195             : )
     196             : {
     197             :     ivas_error error;
     198             : 
     199        2427 :     hBinRendererTd->Gain = 1.0f;
     200             : 
     201             :     /* Init source list */
     202             : 
     203             :     /* Spatial settings */
     204        2427 :     if ( MixSpatSpec_p != NULL )
     205             :     {
     206        2427 :         hBinRendererTd->UseCommonDistAttenModel = MixSpatSpec_p->UseCommonDistAttenModel;
     207        2427 :         hBinRendererTd->DistAttenModel = MixSpatSpec_p->DistAttenModel;
     208             :     }
     209             :     else
     210             :     {
     211           0 :         hBinRendererTd->UseCommonDistAttenModel = TRUE;
     212           0 :         hBinRendererTd->DistAttenModel = 0x0000; /* Distance attenuation not activated; */
     213             :     }
     214             : 
     215             :     /* Init virtual and rendering listeners for spatial mixers */
     216        2427 :     TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Pos, 0.0f, 0.0f, 0.0f );
     217        2427 :     TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Vel, 0.0f, 0.0f, 0.0f );
     218        2427 :     TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Front, 0.0f, 0.0f, -1.0f );
     219        2427 :     TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Up, 0.0f, 1.0f, 0.0f );
     220        2427 :     TDREND_SPATIAL_VecInit( hBinRendererTd->Listener_p->Right, 1.0f, 0.0f, 0.0f );
     221             : 
     222             :     /* Init HR filter set */
     223        2427 :     if ( *hHrtfTD == NULL )
     224             :     {
     225        1232 :         if ( ( hBinRendererTd->HrFiltSet_p = (TDREND_HRFILT_FiltSet_t *) malloc( sizeof( TDREND_HRFILT_FiltSet_t ) ) ) == NULL )
     226             :         {
     227           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     228             :         }
     229             : 
     230        1232 :         if ( ( error = DefaultBSplineModel( hBinRendererTd->HrFiltSet_p, output_Fs ) ) != IVAS_ERR_OK )
     231             :         {
     232           0 :             return error;
     233             :         }
     234        1232 :         *hHrtfTD = hBinRendererTd->HrFiltSet_p;
     235             :     }
     236             :     else
     237             :     {
     238        1195 :         hBinRendererTd->HrFiltSet_p = *hHrtfTD;
     239             :     }
     240             : 
     241        2427 :     hBinRendererTd->pHrFiltSet_p = hHrtfTD;
     242             : 
     243        2427 :     if ( hBinRendererTd->HrFiltSet_p->SampleRate != output_Fs )
     244             :     {
     245           0 :         return ( IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "The sampling rate for the HR filter set does not match the output sampling rate.\n" ) );
     246             :     }
     247             : 
     248        2427 :     return IVAS_ERR_OK;
     249             : }
     250             : 
     251             : 
     252             : /*-------------------------------------------------------------------*
     253             :  * TDREND_MIX_SetDistAttenModel()
     254             :  *
     255             :  * Set the distance attenuation model of the mixer
     256             :  --------------------------------------------------------------------*/
     257             : 
     258        2427 : ivas_error TDREND_MIX_SetDistAttenModel(
     259             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle         */
     260             :     const TDREND_DistAttenModel_t DistAttenModel       /* i  : Distance attenuation model */
     261             : )
     262             : {
     263             : 
     264             :     /* Value validation */
     265        2427 :     if ( ( DistAttenModel < TDREND_DIST_ATTEN_MODEL_INV_DIST ) || ( DistAttenModel > TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED ) )
     266             :     {
     267           0 :         return ( IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid distance attenuation model!\n" ) );
     268             :     }
     269             :     else
     270             :     {
     271             :         /* Set the common distance attenuation model */
     272        2427 :         hBinRendererTd->DistAttenModel = DistAttenModel;
     273             : 
     274             :         /* If using common distance attenuation model, set it. */
     275        2427 :         if ( hBinRendererTd->UseCommonDistAttenModel )
     276             :         {
     277        2427 :             hBinRendererTd->DistAttenEnabled = TRUE;
     278        2427 :             hBinRendererTd->DistAttenModel = DistAttenModel;
     279             :         }
     280             :     }
     281             : 
     282        2427 :     return IVAS_ERR_OK;
     283             : }
     284             : 
     285             : 
     286             : /*-------------------------------------------------------------------*
     287             :  * TDREND_MIX_AddSrc()
     288             :  *
     289             :  * Adds the specified input source unit to the specified mixer unit.
     290             :  --------------------------------------------------------------------*/
     291             : 
     292        5288 : ivas_error TDREND_MIX_AddSrc(
     293             :     BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle                */
     294             :     int16_t *SrcInd,                                   /* o  : Source index                      */
     295             :     const TDREND_PosType_t PosType                     /* i  : Position type (absolute/relative) */
     296             : )
     297             : {
     298             :     TDREND_SRC_t *Src_p;
     299             :     ivas_error error;
     300             : 
     301             :     /* Get unique source index */
     302        5288 :     *SrcInd = hBinRendererTd->MaxSrcInd + 1;
     303        5288 :     hBinRendererTd->MaxSrcInd++;
     304        5288 :     hBinRendererTd->NumOfSrcs++;
     305             : 
     306        5288 :     if ( hBinRendererTd->NumOfSrcs > MAX_NUM_TDREND_CHANNELS )
     307             :     {
     308           0 :         return ( IVAS_ERROR( IVAS_ERR_INTERNAL, "Maximum number of sources exceeded!\n" ) );
     309             :     }
     310             :     else
     311             :     {
     312        5288 :         if ( ( PosType < TDREND_POSTYPE_ABSOLUTE ) || ( PosType > TDREND_POSTYPE_NON_DIEGETIC ) )
     313             :         {
     314           0 :             return ( IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid position type!\n" ) );
     315             :         }
     316             :         else
     317             :         {
     318             :             /* Alloc and init a complete source: signal+spatial+rend components */
     319        5288 :             if ( ( error = TDREND_SRC_Alloc( &Src_p ) ) != IVAS_ERR_OK )
     320             :             {
     321           0 :                 return error;
     322             :             }
     323             : 
     324        5288 :             TDREND_SRC_Init( Src_p, PosType );
     325             : 
     326             :             /* Special OpenAL initialization due to a common distance attenuation model */
     327        5288 :             if ( hBinRendererTd->DistAttenModel != 0 )
     328             :             {
     329        5288 :                 Src_p->SrcSpatial_p->DistAttenEnabled = TRUE;
     330        5288 :                 Src_p->SrcSpatial_p->DistAtten.DistAttenModel = hBinRendererTd->DistAttenModel;
     331             :             }
     332             :             /* Add source to mixer */
     333        5288 :             hBinRendererTd->Sources[*SrcInd] = Src_p;
     334             :         }
     335             :     }
     336             : 
     337        5288 :     return IVAS_ERR_OK;
     338             : }
     339             : 
     340             : 
     341             : /*-------------------------------------------------------------------*
     342             :  * BSplineModelEvalAlloc()
     343             :  *
     344             :  * Allocate the B Spline HR Filter model.
     345             :  --------------------------------------------------------------------*/
     346             : 
     347        1232 : static ivas_error BSplineModelEvalAlloc(
     348             :     ModelParams_t *model,  /* i  : Model parameters           */
     349             :     ModelEval_t *modelEval /* i/o: Model evaluation structure */
     350             : )
     351             : {
     352        1232 :     if ( ( modelEval->hrfModL = (float *) malloc( model->K * sizeof( float ) ) ) == NULL )
     353             :     {
     354           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     355             :     }
     356             : 
     357        1232 :     if ( ( modelEval->hrfModR = (float *) malloc( model->K * sizeof( float ) ) ) == NULL )
     358             :     {
     359           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     360             :     }
     361             : 
     362        1232 :     return IVAS_ERR_OK;
     363             : }
     364             : 
     365             : 
     366             : /*-------------------------------------------------------------------*
     367             :  * DefaultBSplineModel()
     368             :  *
     369             :  * Init default HRTF model
     370             :  --------------------------------------------------------------------*/
     371             : 
     372        1232 : static ivas_error DefaultBSplineModel(
     373             :     TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o  : Loaded HR filter set      */
     374             :     const int32_t output_Fs               /* i  : Output sampling rate      */
     375             : )
     376             : {
     377             :     ModelParams_t *model;
     378             :     ModelParamsITD_t *modelITD;
     379             :     int16_t i, j;
     380             :     ivas_error error;
     381             :     float azimSegSamples;
     382             : 
     383        1232 :     HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
     384        1232 :     model = &( HrFiltSet_p->ModelParams );
     385        1232 :     modelITD = &( HrFiltSet_p->ModelParamsITD );
     386             : 
     387             :     /* Set ROM flag for correct deallocation */
     388        1232 :     model->modelROM = TRUE;
     389             : 
     390             :     /* int16_t parameters */
     391        1232 :     model->UseItdModel = defaultHRIR_rom_model_configuration[0];
     392        1232 :     model->elevDim3 = defaultHRIR_rom_model_configuration[1];
     393        1232 :     model->AlphaN = defaultHRIR_rom_model_configuration[2];
     394        1232 :     model->num_unique_azim_splines = defaultHRIR_rom_model_configuration[3];
     395        1232 :     model->elevSegSamples = defaultHRIR_rom_model_configuration[4];
     396        1232 :     model->elevBsLen = defaultHRIR_rom_elevBsLen;
     397        1232 :     model->elevBsStart = defaultHRIR_rom_elevBsStart;
     398        1232 :     model->azimDim3 = defaultHRIR_rom_azimDim3;
     399        1232 :     model->azim_start_idx = defaultHRIR_rom_azim_start_idx;
     400        1232 :     model->azimSegSamples = defaultHRIR_rom_azimSegSamples;
     401        1232 :     model->azimShapeIdx = defaultHRIR_rom_azimShapeIdx;
     402        1232 :     model->azimShapeSampFactor = defaultHRIR_rom_azimShapeSampFactor;
     403             : 
     404             :     /* float parameters */
     405        1232 :     model->elevKSeq = (const float *) defaultHRIR_rom_elevKSeq;
     406        1232 :     model->elevBsShape = (const float *) defaultHRIR_rom_elevBsShape;
     407             : 
     408        1232 :     if ( ( model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ) ) == NULL )
     409             :     {
     410           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     411             :     }
     412             : 
     413        1232 :     model->azimBsShape[0] = (const float *) defaultHRIR_rom_azimBsShape;
     414             : 
     415        1232 :     if ( ( model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ) ) == NULL )
     416             :     {
     417           0 :         return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     418             :     }
     419             : 
     420       19712 :     for ( i = 0; i < model->elevDim3; i++ )
     421             :     {
     422       18480 :         if ( ( model->azimKSeq[i] = (float *) malloc( ( model->azimDim3[i] + 1 ) * sizeof( float * ) ) ) == NULL )
     423             :         {
     424           0 :             return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) );
     425             :         }
     426             : 
     427       18480 :         if ( model->azimShapeIdx[i] < 0 )
     428             :         {
     429        2464 :             azimSegSamples = 360.0f;
     430             :         }
     431             :         else
     432             :         {
     433       16016 :             azimSegSamples = defaultHRIR_rom_azimSegSamples[model->azimShapeIdx[i]];
     434             :         }
     435             : 
     436       18480 :         assert( azimSegSamples == 360.0f / model->azimDim3[i] );
     437      616000 :         for ( j = 0; j < model->azimDim3[i] + 1; j++ )
     438             :         {
     439      597520 :             model->azimKSeq[i][j] = azimSegSamples * j;
     440             :         }
     441             :     }
     442             : 
     443        1232 :     switch ( output_Fs )
     444             :     {
     445        1139 :         case 48000:
     446        1139 :             model->AlphaL = (const float *) defaultHRIR_rom_AlphaL48;
     447        1139 :             model->AlphaR = (const float *) defaultHRIR_rom_AlphaR48;
     448        1139 :             model->EL = (const float *) defaultHRIR_rom_EL48;
     449        1139 :             model->ER = (const float *) defaultHRIR_rom_ER48;
     450        1139 :             model->K = defaultHRIR_rom_model_configuration[5];
     451        1139 :             if ( HrFiltSet_p->ModelParams.UseItdModel )
     452             :             {
     453        1139 :                 modelITD->resamp_factor = 1.0f;
     454             :             }
     455        1139 :             break;
     456          93 :         case 32000:
     457          93 :             model->AlphaL = (const float *) defaultHRIR_rom_AlphaL32;
     458          93 :             model->AlphaR = (const float *) defaultHRIR_rom_AlphaR32;
     459          93 :             model->EL = (const float *) defaultHRIR_rom_EL32;
     460          93 :             model->ER = (const float *) defaultHRIR_rom_ER32;
     461          93 :             model->K = (int16_t) ceilf( RESAMPLE_FACTOR_32_48 * defaultHRIR_rom_model_configuration[5] );
     462          93 :             if ( HrFiltSet_p->ModelParams.UseItdModel )
     463             :             {
     464          93 :                 modelITD->resamp_factor = RESAMPLE_FACTOR_32_48;
     465             :             }
     466          93 :             break;
     467           0 :         case 16000:
     468           0 :             model->AlphaL = (const float *) defaultHRIR_rom_AlphaL16;
     469           0 :             model->AlphaR = (const float *) defaultHRIR_rom_AlphaR16;
     470           0 :             model->EL = (const float *) defaultHRIR_rom_EL16;
     471           0 :             model->ER = (const float *) defaultHRIR_rom_ER16;
     472           0 :             model->K = (int16_t) ceilf( RESAMPLE_FACTOR_16_48 * defaultHRIR_rom_model_configuration[5] );
     473           0 :             if ( HrFiltSet_p->ModelParams.UseItdModel )
     474             :             {
     475           0 :                 modelITD->resamp_factor = RESAMPLE_FACTOR_16_48;
     476             :             }
     477           0 :             break;
     478           0 :         default:
     479           0 :             break;
     480             :     }
     481             : 
     482        1232 :     modelITD->elevDim3 = defaultHRIR_rom_ITD_model_configuration[0];
     483        1232 :     modelITD->azimDim3 = defaultHRIR_rom_ITD_model_configuration[1];
     484        1232 :     modelITD->elevSegSamples = defaultHRIR_rom_ITD_model_configuration[2];
     485        1232 :     modelITD->azimSegSamples = defaultHRIR_rom_ITD_model_configuration[3];
     486        1232 :     modelITD->elevBsLen = defaultHRIR_rom_ITD_elevBsLen;
     487        1232 :     modelITD->elevBsStart = defaultHRIR_rom_ITD_elevBsStart;
     488             : 
     489        1232 :     modelITD->elevKSeq = defaultHRIR_rom_ITD_elevKSeq;
     490             : 
     491        1232 :     modelITD->azimBsLen = defaultHRIR_rom_ITD_azimBsLen;
     492        1232 :     modelITD->azimBsStart = defaultHRIR_rom_ITD_azimBsStart;
     493             : 
     494        1232 :     modelITD->azimKSeq = defaultHRIR_rom_ITD_azimKSeq;
     495        1232 :     modelITD->W = (const float *) defaultHRIR_rom_ITD_W;
     496        1232 :     modelITD->azimBsShape = (const float *) defaultHRIR_rom_ITD_azimBsShape;
     497        1232 :     modelITD->elevBsShape = (const float *) defaultHRIR_rom_ITD_elevBsShape;
     498             : 
     499        1232 :     HRTF_model_precalc( model );
     500             : 
     501        1232 :     HrFiltSet_p->latency_s = defaultHRIR_rom_latency_s;
     502             : 
     503        1232 :     HrFiltSet_p->SampleRate = output_Fs;
     504        1232 :     HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K;
     505             : 
     506        1232 :     if ( ( error = BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ) ) != IVAS_ERR_OK )
     507             :     {
     508           0 :         return error;
     509             :     }
     510             : 
     511        1232 :     return IVAS_ERR_OK;
     512             : }

Generated by: LCOV version 1.14