diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8edaf847f3fa16e5528582c5f36fced6..6c2a33a7e24e14211bf396887f5f658a546f484f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */ #define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ +#define FIX_2235_TD_RENDERER_WORD16 /* Eri: Use Word16 in TD renderer without converting to Word32 */ #define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ #define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 537323af591737f9ad114e25139555b13a758d22..a892e999a2916868ea8ccff6a37a8ad33299215e 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -87,6 +87,9 @@ void ivas_HRTF_td_binary_close_fx( free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); } free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + free( ( *hHrtfTD )->ModelParams.azimKSeq_Q_fx ); +#endif IF( ( *hHrtfTD )->ModelEval.hrfModR_fx != NULL ) { free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); @@ -128,6 +131,9 @@ void ivas_HRTF_td_binary_close_fx( free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] ); } free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + free( ( *hHrtfTD )->ModelParams.azimBsShape_Q_fx ); +#endif free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ for ( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ ) @@ -135,6 +141,9 @@ void ivas_HRTF_td_binary_close_fx( free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); } free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + free( ( *hHrtfTD )->ModelParams.azimKSeq_Q_fx ); +#endif free( ( *hHrtfTD )->ModelParams.EL_dyn_fx ); free( ( *hHrtfTD )->ModelParams.ER_dyn_fx ); @@ -255,6 +264,48 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( return IVAS_ERR_OK; } +#ifdef FIX_2235_TD_RENDERER_WORD16 +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int16_ptr_const() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int16_ptr_const( + const Word16 ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (const Word16 **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int16_ptr() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int16_ptr( + Word16 ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (Word16 **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} +#endif + /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_int32_ptr_const() * diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index d5abb8fcef15b24907d0a7b442b6131da552d8b5..f6fa9b50d8f8b323c896d485c5ee36c3d59ae048 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -44,8 +44,14 @@ * Local function prototypes *---------------------------------------------------------------------*/ + +#ifdef FIX_2235_TD_RENDERER_WORD16 +static void getPeriodicBSplineSampVec_fx( Word32 *BfVec_fx, Word16 *AzIdx, const Word16 NumBFs, const Word32 t_fx, Word16 *num_az_idx, const Word32 knot_interval_fx, const Word16 azimKSeq_0_fx, const Word16 azimKSeq_Q_fx, const Word16 azimSegSamples, const Word16 *azimBsShape_fx, const Word16 azimBsShape_Q_fx, const Word16 subSampFactor ); +static void getStandardBSplineSampVec_fx( Word32 *BfVec_fx, Word16 *NzIdx, Word16 *num_idx, const Word16 NumBFs, const Word32 t_fx, const Word16 *KSeq_fx, const Word16 KSeq_Q_fx, const Word16 SegSamples, const Word16 *BsLen, const Word16 *BsStart, const Word16 *BsShape_fx, Word16 BsShape_Q_fx ); +#else static void getPeriodicBSplineSampVec_fx( Word32 *BfVec_fx, Word16 *AzIdx, const Word16 NumBFs, const Word32 t_fx, Word16 *num_az_idx, const Word32 knot_interval_fx, const Word32 azimKSeq_0_fx, const Word16 azimSegSamples, const Word32 *azimBsShape_fx, const Word16 subSampFactor ); static void getStandardBSplineSampVec_fx( Word32 *BfVec_fx, Word16 *NzIdx, Word16 *num_idx, const Word16 NumBFs, const Word32 t_fx, const Word32 *KSeq_fx, const Word16 SegSamples, const Word16 *BsLen, const Word16 *BsStart, const Word32 *BsShape_fx ); +#endif static void GenerateFilter_fx( const Word32 elev, Word32 azim, ModelParams_t *model, ModelEval_t *modelEval ); static void GenerateITD_fx( const Word32 elev, Word32 azim, ModelParamsITD_t *model, ModelEval_t *modelEval ); static void SkipSmallest_ValueIndex_fx( Word16 *use_inds, const ValueIndex_t *VI, const Word16 N, const Word16 n_smallest ); @@ -215,8 +221,13 @@ static void GenerateFilter_fx( Word16 BMEnergiesR_e, BMEnergiesL_e; Word16 tmp_hrfModR_e, tmp_hrfModL_e; +#ifdef FIX_2235_TD_RENDERER_WORD16 + getStandardBSplineSampVec_fx( modelEval->elevBfVec_fx, EvIdx, &num_ev_idx, model->elevDim3, elev, model->elevKSeq_fx, model->elevKSeq_Q_fx, + model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_fx, model->elevBsShape_Q_fx ); +#else getStandardBSplineSampVec_fx( modelEval->elevBfVec_fx, EvIdx, &num_ev_idx, model->elevDim3, elev, model->elevKSeq_fx, model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_fx ); +#endif FOR( p = 0; p < num_ev_idx; p++ ) { @@ -246,13 +257,24 @@ static void GenerateFilter_fx( k = EvIdx[p]; move16(); +#ifdef FIX_2235_TD_RENDERER_WORD16 + knot_interval = L_deposit_h( BASOP_Util_Divide3216_Scale( L_sub( L_deposit_l( model->azimKSeq_fx[k][model->azimDim3[k]] ), L_deposit_l( model->azimKSeq_fx[k][0] ) ), model->azimDim3[k], &tmp_e ) ); + tmp_e = add( tmp_e, 16 + 9 - 15 ); +#else knot_interval = L_deposit_h( BASOP_Util_Divide3216_Scale( L_sub( model->azimKSeq_fx[k][model->azimDim3[k]], model->azimKSeq_fx[k][0] ), model->azimDim3[k], &tmp_e ) ); tmp_e = add( tmp_e, 9 - 15 ); +#endif knot_interval = L_shr( knot_interval, sub( 9, tmp_e ) ); // variable Q to Q22 +#ifdef FIX_2235_TD_RENDERER_WORD16 + getPeriodicBSplineSampVec_fx( modelEval->azimBfVec_fx[p], AzIdx[p], model->azimDim3[k], azim, &num_az_idx[p], + knot_interval, model->azimKSeq_fx[k][0], model->azimKSeq_Q_fx[k], model->azimSegSamples[model->azimShapeIdx[k]], + model->azimBsShape_fx[model->azimShapeIdx[k]], model->azimBsShape_Q_fx[model->azimShapeIdx[k]], model->azimShapeSampFactor[k] ); +#else getPeriodicBSplineSampVec_fx( modelEval->azimBfVec_fx[p], AzIdx[p], model->azimDim3[k], azim, &num_az_idx[p], knot_interval, model->azimKSeq_fx[k][0], model->azimSegSamples[model->azimShapeIdx[k]], model->azimBsShape_fx[model->azimShapeIdx[k]], model->azimShapeSampFactor[k] ); +#endif } } @@ -357,8 +379,13 @@ static void GenerateFilter_fx( FOR( i = 0; i < p; i++ ) { +#ifdef FIX_2235_TD_RENDERER_WORD16 + temp1 = W_add( temp1, Mpy_32_16_1( modelEval->BM_fx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], model->AlphaL_fx[BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaL_e, 1) + temp2 = W_add( temp2, Mpy_32_16_1( modelEval->BM_fx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i], model->AlphaR_fx[BM_idx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaR_e, 1) +#else temp1 = W_add( temp1, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], model->AlphaL_fx[BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaL_e, 1) temp2 = W_add( temp2, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i], model->AlphaR_fx[BM_idx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaR_e, 1) +#endif } tmp_hrfModL_e = W_norm( temp1 ); @@ -445,8 +472,13 @@ static void GenerateITD_fx( IF( NE_32( L_abs( elev_fx ), DEG_90_IN_Q22 ) ) { +#ifdef FIX_2235_TD_RENDERER_WORD16 + getStandardBSplineSampVec_fx( modelEval->elevBfVecITD_fx, EvIdx, &num_ev_idx, model->elevDim3, elev_fx, model->elevKSeq_fx, model->elevKSeq_Q_fx, + model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_fx, model->elevBsShape_Q_fx ); +#else getStandardBSplineSampVec_fx( modelEval->elevBfVecITD_fx, EvIdx, &num_ev_idx, model->elevDim3, elev_fx, model->elevKSeq_fx, model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_fx ); +#endif azim_itd_fx = azim_fx; move32(); @@ -455,8 +487,13 @@ static void GenerateITD_fx( /* Flip spline functions around 180 deg */ azim_itd_fx = L_sub( DEG_360_IN_Q22, azim_fx ); // Q22 } +#ifdef FIX_2235_TD_RENDERER_WORD16 + getStandardBSplineSampVec_fx( modelEval->azimBfVecITD_fx, AzIdx, &num_az_idx, shr( add( model->azimDim3, 1 ), 1 ), azim_itd_fx, model->azimKSeq_fx, model->azimKSeq_Q_fx, + model->azimSegSamples, model->azimBsLen, model->azimBsStart, model->azimBsShape_fx, model->azimBsShape_Q_fx ); +#else getStandardBSplineSampVec_fx( modelEval->azimBfVecITD_fx, AzIdx, &num_az_idx, shr( add( model->azimDim3, 1 ), 1 ), azim_itd_fx, model->azimKSeq_fx, model->azimSegSamples, model->azimBsLen, model->azimBsStart, model->azimBsShape_fx ); +#endif IF( GT_32( azim_fx, DEG_180_IN_Q22 ) ) { /* Flip spline functions around 180 deg */ @@ -492,7 +529,11 @@ static void GenerateITD_fx( /* Compute BM_ITD */ elev_offset = 0; move16(); +#ifdef FIX_2235_TD_RENDERER_WORD16 + if ( EQ_16( model->elevKSeq_fx[0], shl( -90, model->elevKSeq_Q_fx ) ) ) +#else if ( EQ_32( model->elevKSeq_fx[0], -DEG_90_IN_Q22 ) ) +#endif { elev_offset = sub( 1, model->azimDim3 ); } @@ -504,7 +545,11 @@ static void GenerateITD_fx( test(); test(); test(); +#ifdef FIX_2235_TD_RENDERER_WORD16 + IF( EvIdx[p] == 0 && EQ_16( model->elevKSeq_fx[EvIdx[p]], shl( -90, model->elevKSeq_Q_fx ) ) ) +#else IF( EvIdx[p] == 0 && EQ_32( model->elevKSeq_fx[EvIdx[p]], -DEG_90_IN_Q22 ) ) +#endif { modelEval->BM_ITD_fx[qp] = modelEval->elevBfVecITD_fx[p]; // Q30 move32(); @@ -512,7 +557,11 @@ static void GenerateITD_fx( move16(); qp = add( qp, 1 ); } +#ifdef FIX_2235_TD_RENDERER_WORD16 + ELSE IF( EQ_16( EvIdx[p], sub( model->elevDim3, 1 ) ) && EQ_16( model->elevKSeq_fx[sub( EvIdx[p], 2 )], shl( 90, model->elevKSeq_Q_fx ) ) ) +#else ELSE IF( EQ_16( EvIdx[p], sub( model->elevDim3, 1 ) ) && EQ_32( model->elevKSeq_fx[sub( EvIdx[p], 2 )], DEG_90_IN_Q22 ) ) +#endif { /* NB: -2 in if() condition above as number of knot points is numBF-2 */ modelEval->BM_ITD_fx[qp] = modelEval->elevBfVecITD_fx[p]; // Q30 @@ -537,7 +586,11 @@ static void GenerateITD_fx( /* Compute ITD */ AlphaN = add( imult1616( model->elevDim3, model->azimDim3 ), elev_offset ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + if ( EQ_16( model->elevKSeq_fx[sub( model->elevDim3, 3 )], shl( 90, model->elevKSeq_Q_fx ) ) ) /* Constant azimuth basis function */ +#else if ( EQ_32( model->elevKSeq_fx[sub( model->elevDim3, 3 )], DEG_90_IN_Q22 ) ) /* Constant azimuth basis function */ +#endif { AlphaN = sub( AlphaN, sub( model->azimDim3, 1 ) ); } @@ -550,7 +603,11 @@ static void GenerateITD_fx( { index = BM_idx[i]; move32(); +#ifdef FIX_2235_TD_RENDERER_WORD16 + temp = W_add( temp, Mpy_32_16_1( modelEval->BM_ITD_fx[i], model->W_fx[index] ) ); +#else temp = W_add( temp, Mpy_32_32( modelEval->BM_ITD_fx[i], model->W_fx[index] ) ); +#endif } itdMod_e = W_norm( temp ); itdMod_e = sub( itdMod_e, 32 ); @@ -591,10 +648,20 @@ static void getPeriodicBSplineSampVec_fx( const Word32 t_fx, /* i : azimuth Q22 */ Word16 *num_az_idx, /* o : Number of azimuth indices */ const Word32 knot_interval_fx, /* i : The knot interval Q22 */ - const Word32 azimKSeq_0_fx, /* i : Knot sequence Q22 */ - const Word16 azimSegSamples, /* i : Samples per segment */ - const Word32 *azimBsShape_fx, /* i : Basis shape Q30 */ - const Word16 subSampFactor /* i : Subsampling factor */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 azimKSeq_0_fx, /* i : Knot sequence Q azimKSeq_Q_fx*/ + const Word16 azimKSeq_Q_fx, /* i : Q-value of azimKSeq_0_fx */ +#else + const Word32 azimKSeq_0_fx, /* i : Knot sequence Q22 */ +#endif + const Word16 azimSegSamples, /* i : Samples per segment */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *azimBsShape_fx, /* i : Basis shape Q azimBsShape_Q_fx */ + const Word16 azimBsShape_Q_fx, /* i : Q-value of azimBsShape_fx */ +#else + const Word32 *azimBsShape_fx, /* i : Basis shape Q30 */ +#endif + const Word16 subSampFactor /* i : Subsampling factor */ ) { Word16 i, nI, d0, d; @@ -619,7 +686,11 @@ static void getPeriodicBSplineSampVec_fx( { tmp32 = L_deposit_h( BASOP_Util_Divide3216_Scale( knot_interval_fx, SegSamples, &tmp_e1 ) ); tmp_e1 = add( tmp_e1, 9 - 15 ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( t_fx, L_shl( L_deposit_l( azimKSeq_0_fx ), 22 - azimKSeq_Q_fx ) ), tmp32, &tmp_e2 ) ); +#else tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( t_fx, azimKSeq_0_fx ), tmp32, &tmp_e2 ) ); +#endif tmp_e2 = add( tmp_e2, sub( 9, tmp_e1 ) ); tmp32 = L_shr( tmp32, sub( 9, tmp_e2 ) ); // Q22 (assuming tmp32 will be in range of Q22) d0 = extract_l( round_hrFilt_fx( tmp32, Q22 ) ); @@ -646,8 +717,13 @@ static void getPeriodicBSplineSampVec_fx( { d = sub( d0, imult1616( ( sub( add( i, nI ), 1 ) ), SegSamples ) ); /* offset of knot_interval */ d = sub( d0, imult1616( sub( add( i, nI ), 1 ), SegSamples ) ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + BfVec_fx[i] = L_shl( L_deposit_l( azimBsShape_fx[i_mult( abs_s( d ), subSampFactor )] ), 30 - azimBsShape_Q_fx ); +#else BfVec_fx[i] = azimBsShape_fx[i_mult( abs_s( d ), subSampFactor )]; +#endif move32(); + AzIdx[i] = add( nI, i ) % NumBFs; move16(); } @@ -662,16 +738,26 @@ static void getPeriodicBSplineSampVec_fx( --------------------------------------------------------------------*/ static void getStandardBSplineSampVec_fx( - Word32 *BfVec_fx, /* o : values for non-zero basis functions Q30 */ - Word16 *NzIdx, /* o : indices of non-zero basis functions */ - Word16 *num_idx, /* i/o: number of non-zero indices */ - const Word16 NumBFs, /* i : the number of basis functions = third index of Bf */ - const Word32 t_fx, /* i : estimation point Q22 */ + Word32 *BfVec_fx, /* o : values for non-zero basis functions Q30 */ + Word16 *NzIdx, /* o : indices of non-zero basis functions */ + Word16 *num_idx, /* i/o: number of non-zero indices */ + const Word16 NumBFs, /* i : the number of basis functions = third index of Bf */ + const Word32 t_fx, /* i : estimation point Q22 */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *KSeq_fx, /* i : knot sequence including multiplicities Q KSeq_Q_fx */ + const Word16 KSeq_Q_fx, /* i : Q-value of knot sequence */ +#else const Word32 *KSeq_fx, /* i : knot sequence including multiplicities Q22 */ +#endif const Word16 SegSamples, /* i : samples per segment */ const Word16 *BsLen, /* i : lengths of basis shapes */ const Word16 *BsStart, /* i : start of basis shapes */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *BsShape_fx, /* i : basis shapes Q BsShape_Q_fx */ + Word16 BsShape_Q_fx /* i : Q-value of basis shapes */ +#else const Word32 *BsShape_fx /* i : basis shapes Q30 */ +#endif ) { Word16 i, nI; @@ -681,13 +767,22 @@ static void getStandardBSplineSampVec_fx( Word32 tmp32; /* assuming triple knot at the first knot */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + tmp32 = L_shl( L_sub( L_deposit_l( KSeq_fx[NumBFs - 3] ), L_deposit_l( KSeq_fx[0] ) ), sub( 22, KSeq_Q_fx ) ); /* Q22 */ + knot_interval_fx = L_deposit_h( BASOP_Util_Divide3216_Scale( tmp32, sub( NumBFs, 3 ), &tmp_e1 ) ); +#else knot_interval_fx = L_deposit_h( BASOP_Util_Divide3216_Scale( L_sub( KSeq_fx[NumBFs - 3], KSeq_fx[0] ), sub( NumBFs, 3 ), &tmp_e1 ) ); +#endif tmp_e1 = add( tmp_e1, 9 - 15 ); /* index of closest sample point */ tmp32 = L_deposit_h( BASOP_Util_Divide3216_Scale( knot_interval_fx, SegSamples, &tmp_e2 ) ); tmp_e2 = add( tmp_e2, sub( tmp_e1, 15 ) ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( t_fx, L_shl( L_deposit_l( KSeq_fx[0] ), 22 - KSeq_Q_fx ) ), tmp32, &tmp_e3 ) ); +#else tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( t_fx, KSeq_fx[0] ), tmp32, &tmp_e3 ) ); +#endif tmp_e3 = add( tmp_e3, sub( 9, tmp_e2 ) ); tmp32 = L_shr( tmp32, sub( 9, tmp_e3 ) ); // Q22 (assuming tmp32 will be in range of Q22) d0 = extract_l( round_hrFilt_fx( tmp32, 22 ) ); @@ -722,8 +817,13 @@ static void getStandardBSplineSampVec_fx( { d = sub( shl( sub( BsLen[shape_idx], 1 ), 1 ), d ); } +#ifdef FIX_2235_TD_RENDERER_WORD16 + assert( d >= 0 && d < BsLen[shape_idx] ); + BfVec_fx[i] = L_shl( L_deposit_l( BsShape_fx[add( BsStart[shape_idx], d )] ), 30 - BsShape_Q_fx ); /* Q30 */ +#else BfVec_fx[i] = BsShape_fx[add( BsStart[shape_idx], abs_s( d ) )]; /*TT, verify if abs is needed */ move32(); +#endif NzIdx[i] = add( nI, i ); move16(); } @@ -777,17 +877,25 @@ void BSplineModelEvalDealloc_fx( IF( model->modelROM ) { +#ifndef FIX_2235_TD_RENDERER_WORD16 FOR( i = 0; i < model->num_unique_azim_splines; i++ ) { free( model->azimBsShape_dyn_fx[i] ); } free( model->azimBsShape_dyn_fx ); +#endif free( (void *) model->azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + free( model->azimBsShape_Q_fx ); +#endif FOR( i = 0; i < model->elevDim3; i++ ) { free( model->azimKSeq_fx[i] ); } free( model->azimKSeq_fx ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + free( model->azimKSeq_Q_fx ); +#endif IF( modelEval != NULL ) { free( modelEval->hrfModL_fx ); diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index a0a57d0a2179bd51055513ff5ac2a66ebd62c4ef..9a7771c95841d5798de405d9e17f188beb4eb09c 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -151,6 +151,7 @@ void TDREND_MIX_Dealloc_fx( { BSplineModelEvalDealloc_fx( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval ); } +#ifndef FIX_2235_TD_RENDERER_WORD16 IF( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM ) { IF( hBinRendererTd->HrFiltSet_p->ModelParams.UseItdModel ) @@ -164,10 +165,9 @@ void TDREND_MIX_Dealloc_fx( free( hBinRendererTd->HrFiltSet_p->ModelParams.elevKSeq_dyn_fx ); free( hBinRendererTd->HrFiltSet_p->ModelParams.AlphaL_dyn_fx ); free( hBinRendererTd->HrFiltSet_p->ModelParams.AlphaR_dyn_fx ); - free( hBinRendererTd->HrFiltSet_p->ModelParams.elevBsShape_dyn_fx ); } - +#endif IF( EQ_16( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM, 1 ) ) { @@ -414,6 +414,10 @@ static ivas_error DefaultBSplineModel_fx( model->azimShapeIdx = defaultHRIR_rom_azimShapeIdx; // Q0 model->azimShapeSampFactor = defaultHRIR_rom_azimShapeSampFactor; // Q0 +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->elevKSeq_fx = defaultHRIR_rom_elevKSeq_fx; + model->elevKSeq_Q_fx = defaultHRIR_rom_elevKSeq_Q_fx; +#else model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); IF( model->elevKSeq_dyn_fx == NULL ) { @@ -421,7 +425,12 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_elevKSeq_fx, model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ), Q22 - defaultHRIR_rom_elevKSeq_Q_fx ); // Q22 model->elevKSeq_fx = model->elevKSeq_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->elevBsShape_fx = defaultHRIR_rom_elevBsShape_fx; + model->elevBsShape_Q_fx = defaultHRIR_rom_elevBsShape_Q_fx; +#else model->elevBsShape_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_elevBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); IF( model->elevBsShape_dyn_fx == NULL ) { @@ -429,7 +438,14 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_elevBsShape_fx, model->elevBsShape_dyn_fx, sizeof( defaultHRIR_rom_elevBsShape_fx ) / sizeof( Word16 ), Q30 - defaultHRIR_rom_elevBsShape_Q_fx ); // Q30 model->elevBsShape_fx = model->elevBsShape_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + IF( ( model->azimBsShape_fx = (const Word16 **) malloc( model->num_unique_azim_splines * sizeof( Word16 * ) ) ) == NULL || ( model->azimBsShape_Q_fx = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } +#else IF( ( model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); @@ -439,6 +455,11 @@ static ivas_error DefaultBSplineModel_fx( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->azimBsShape_fx[0] = defaultHRIR_rom_azimBsShape_fx; + model->azimBsShape_Q_fx[0] = defaultHRIR_rom_azimBsShape_Q_fx; +#else model->azimBsShape_dyn_fx[0] = (Word32 *) malloc( sizeof( defaultHRIR_rom_azimBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); IF( model->azimBsShape_dyn_fx[0] == NULL ) { @@ -446,19 +467,33 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_azimBsShape_fx, model->azimBsShape_dyn_fx[0], sizeof( defaultHRIR_rom_azimBsShape_fx ) / sizeof( Word16 ), Q30 - defaultHRIR_rom_azimBsShape_Q_fx ); // Q30 model->azimBsShape_fx[0] = model->azimBsShape_dyn_fx[0]; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + IF( ( model->azimKSeq_fx = (Word16 **) malloc( model->elevDim3 * sizeof( Word16 * ) ) ) == NULL || ( model->azimKSeq_Q_fx = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ) ) == NULL ) +#else IF( ( model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); } FOR( i = 0; i < model->elevDim3; i++ ) { +#ifdef FIX_2235_TD_RENDERER_WORD16 + if ( ( model->azimKSeq_fx[i] = (Word16 *) malloc( ( model->azimDim3[i] + 1 ) * sizeof( Word16 * ) ) ) == NULL ) +#else if ( ( model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3[i] + 1 ) * sizeof( Word32 * ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); } +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->azimKSeq_Q_fx[i] = defaultHRIR_rom_azimKSeq_Q_fx; + move16(); +#endif + IF( LT_16( model->azimShapeIdx[i], 0 ) ) { azimSegSamples = 360; @@ -470,16 +505,32 @@ static ivas_error DefaultBSplineModel_fx( move16(); assert( azimSegSamples == 360 / model->azimDim3[i] ); + FOR( j = 0; j < model->azimDim3[i] + 1; j++ ) { +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->azimKSeq_fx[i][j] = extract_l( L_shl_r( L_mult0( defaultHRIR_rom_azimSegSamples[0], j ), model->azimKSeq_Q_fx[i] ) ); // Q model->azimKSeq_Q_fx[i] + move16(); +#else model->azimKSeq_fx[i][j] = L_shl_r( L_mult0( defaultHRIR_rom_azimSegSamples[0], j ), Q22 ); // Q22 move32(); +#endif } } SWITCH( output_Fs ) { case 48000: +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->AlphaL_fx = defaultHRIR_rom_AlphaL48_fx; // Q14 + move16(); + model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha48_Q_fx; + move16(); + model->AlphaR_fx = defaultHRIR_rom_AlphaR48_fx; // Q14 + move16(); + model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha48_Q_fx; + move16(); +#else model->AlphaL_dyn_fx = (Word32 *) malloc( 60160 * sizeof( Word32 ) ); if ( model->AlphaL_dyn_fx == NULL ) { @@ -500,10 +551,13 @@ static ivas_error DefaultBSplineModel_fx( model->AlphaR_fx = model->AlphaR_dyn_fx; model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha48_Q_fx; move16(); - model->EL_fx = (const Word32 *) defaultHRIR_rom_EL48_fx; // Q28 +#endif + model->EL_fx = defaultHRIR_rom_EL48_fx; // Q28 + move16(); model->EL_e = Q31 - defaultHRIR_rom_E48_Q_fx; move16(); - model->ER_fx = (const Word32 *) defaultHRIR_rom_ER48_fx; // Q28 + model->ER_fx = defaultHRIR_rom_ER48_fx; // Q28 + move16(); model->ER_e = Q31 - defaultHRIR_rom_E48_Q_fx; move16(); model->K = defaultHRIR_rom_model_configuration[5]; // Q0 @@ -515,6 +569,16 @@ static ivas_error DefaultBSplineModel_fx( } BREAK; case 32000: +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->AlphaL_fx = defaultHRIR_rom_AlphaL32_fx; // Q14 + move16(); + model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha32_Q_fx; + move16(); + model->AlphaR_fx = defaultHRIR_rom_AlphaR32_fx; // Q14 + move16(); + model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha32_Q_fx; + move16(); +#else model->AlphaL_dyn_fx = (Word32 *) malloc( 40420 * sizeof( Word32 ) ); if ( model->AlphaL_dyn_fx == NULL ) { @@ -535,10 +599,13 @@ static ivas_error DefaultBSplineModel_fx( model->AlphaR_fx = model->AlphaR_dyn_fx; model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha32_Q_fx; move16(); - model->EL_fx = (const Word32 *) defaultHRIR_rom_EL32_fx; // Q28 +#endif + model->EL_fx = defaultHRIR_rom_EL32_fx; // Q28 + move16(); model->EL_e = Q31 - defaultHRIR_rom_E32_Q_fx; move16(); - model->ER_fx = (const Word32 *) defaultHRIR_rom_ER32_fx; // Q28 + model->ER_fx = defaultHRIR_rom_ER32_fx; // Q28 + move16(); model->ER_e = Q31 - defaultHRIR_rom_E32_Q_fx; move16(); model->K = ( RESAMPLE_FACTOR_32_48_FX * defaultHRIR_rom_model_configuration[5] + ( 1 << 14 ) - 1 ) >> 14; // Q0 @@ -550,6 +617,14 @@ static ivas_error DefaultBSplineModel_fx( } BREAK; case 16000: +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->AlphaL_fx = defaultHRIR_rom_AlphaL16_fx; // Q14 + model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha16_Q_fx; + move16(); + model->AlphaR_fx = defaultHRIR_rom_AlphaR16_fx; // Q14 + model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha16_Q_fx; + move16(); +#else model->AlphaL_dyn_fx = (Word32 *) malloc( 20210 * sizeof( Word32 ) ); if ( model->AlphaL_dyn_fx == NULL ) { @@ -568,6 +643,7 @@ static ivas_error DefaultBSplineModel_fx( model->AlphaR_fx = model->AlphaR_dyn_fx; model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha16_Q_fx; move16(); +#endif model->EL_fx = (const Word32 *) defaultHRIR_rom_EL16_fx; // Q28 model->EL_e = Q31 - defaultHRIR_rom_E16_Q_fx; move16(); @@ -597,6 +673,12 @@ static ivas_error DefaultBSplineModel_fx( modelITD->elevBsLen = defaultHRIR_rom_ITD_elevBsLen; modelITD->elevBsStart = defaultHRIR_rom_ITD_elevBsStart; +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->elevKSeq_fx = defaultHRIR_rom_ITD_elevKSeq_fx; + move16(); + modelITD->elevKSeq_Q_fx = defaultHRIR_rom_ITD_elevKSeq_Q_fx; + move16(); +#else modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_elevKSeq_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); IF( modelITD->elevKSeq_dyn_fx == NULL ) { @@ -605,10 +687,17 @@ static ivas_error DefaultBSplineModel_fx( Copy_Scale_sig_16_32_r( defaultHRIR_rom_ITD_elevKSeq_fx, modelITD->elevKSeq_dyn_fx, sizeof( defaultHRIR_rom_ITD_elevKSeq_fx ) / sizeof( Word16 ), Q22 - defaultHRIR_rom_ITD_elevKSeq_Q_fx ); // Q22 modelITD->elevKSeq_fx = modelITD->elevKSeq_dyn_fx; +#endif modelITD->azimBsLen = defaultHRIR_rom_ITD_azimBsLen; modelITD->azimBsStart = defaultHRIR_rom_ITD_azimBsStart; +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->azimKSeq_fx = defaultHRIR_rom_ITD_azimKSeq_fx; + move16(); + modelITD->azimKSeq_Q_fx = defaultHRIR_rom_ITD_azimKSeq_Q_fx; + move16(); +#else modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ IF( modelITD->azimKSeq_dyn_fx == NULL ) { @@ -616,6 +705,10 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_ITD_azimKSeq_fx, modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ), Q22 - defaultHRIR_rom_ITD_azimKSeq_Q_fx ); // Q22 modelITD->azimKSeq_fx = modelITD->azimKSeq_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->W_fx = defaultHRIR_rom_ITD_W_fx; +#else modelITD->W_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_W_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ IF( modelITD->W_dyn_fx == NULL ) { @@ -623,8 +716,15 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_ITD_W_fx, modelITD->W_dyn_fx, sizeof( defaultHRIR_rom_ITD_W_fx ) / sizeof( Word16 ), Q25 - defaultHRIR_rom_ITD_W_Q_fx ); // Q22 modelITD->W_fx = modelITD->W_dyn_fx; +#endif modelITD->W_e = Q15 - defaultHRIR_rom_ITD_W_Q_fx; move16(); +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->azimBsShape_fx = defaultHRIR_rom_ITD_azimBsShape_fx; + move16(); + modelITD->azimBsShape_Q_fx = defaultHRIR_rom_ITD_azimBsShape_Q_fx; + move16(); +#else modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_azimBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ IF( modelITD->azimBsShape_dyn_fx == NULL ) { @@ -632,6 +732,13 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_ITD_azimBsShape_fx, modelITD->azimBsShape_dyn_fx, sizeof( defaultHRIR_rom_ITD_azimBsShape_fx ) / sizeof( Word16 ), Q30 - defaultHRIR_rom_ITD_azimBsShape_Q_fx ); // Q22 modelITD->azimBsShape_fx = modelITD->azimBsShape_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->elevBsShape_fx = defaultHRIR_rom_ITD_elevBsShape_fx; + move16(); + modelITD->elevBsShape_Q_fx = defaultHRIR_rom_ITD_elevBsShape_Q_fx; + move16(); +#else modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_elevBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); IF( modelITD->elevBsShape_dyn_fx == NULL ) { @@ -639,6 +746,7 @@ static ivas_error DefaultBSplineModel_fx( } Copy_Scale_sig_16_32_r( defaultHRIR_rom_ITD_elevBsShape_fx, modelITD->elevBsShape_dyn_fx, sizeof( defaultHRIR_rom_ITD_elevBsShape_fx ) / sizeof( Word16 ), Q30 - defaultHRIR_rom_ITD_elevBsShape_Q_fx ); // Q22 modelITD->elevBsShape_fx = modelITD->elevBsShape_dyn_fx; +#endif HRTF_model_precalc( model ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index b393971b7bcbda183494ad2150363e12bce87520..c59520d621ce38205384fd267e1fe1b2a03abb1e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -616,6 +616,13 @@ ivas_error ivas_HRTF_binary_open_buffers_int16( const uint32_t mem_size /* i : size of buffer */ ); +#ifdef FIX_2235_TD_RENDERER_WORD16 +ivas_error ivas_HRTF_binary_open_buffers_int16_ptr( + int16_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); +#endif + ivas_error ivas_HRTF_binary_open_buffers_int32( int32_t **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ @@ -626,6 +633,13 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( const uint32_t mem_size /* i : size of buffer */ ); +#ifdef FIX_2235_TD_RENDERER_WORD16 +ivas_error ivas_HRTF_binary_open_buffers_int16_ptr_const( + const int16_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); +#endif + ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( const int32_t ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index 176dc1f3eb8864f7c1664fa9e4eb3fba54e83645..60ef5d4c6fafe74e4872c04066f32cd1a162cbee 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -52,6 +52,9 @@ extern const Word16 defaultHRIR_rom_azimShapeIdx[15]; extern const Word16 defaultHRIR_rom_azimShapeSampFactor[15]; extern const Word16 defaultHRIR_rom_elevKSeq_Q_fx; extern const Word16 defaultHRIR_rom_elevKSeq_fx[13]; +#ifdef FIX_2235_TD_RENDERER_WORD16 +extern const Word16 defaultHRIR_rom_azimKSeq_Q_fx; +#endif extern const Word16 defaultHRIR_rom_Alpha48_Q_fx; extern const Word16 defaultHRIR_rom_AlphaL48_fx[470 * 128]; /*Q30*/ extern const Word16 defaultHRIR_rom_AlphaR48_fx[470 * 128]; /*Q30*/ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c index 980b692420e95b8086049bf8b8ec8da55087e323..d9ebceeecfdb58908669faa4f317ff2e53f3cdcc 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c @@ -88,6 +88,9 @@ const Word16 defaultHRIR_rom_elevKSeq_Q_fx = 8; const Word16 defaultHRIR_rom_elevKSeq_fx [13] = { -23040, -19200, -15360, -11520, -7680, -3840, 0, 3840, 7680, 11520, 15360, 19200, 23040, }; +#ifdef FIX_2235_TD_RENDERER_WORD16 +const Word16 defaultHRIR_rom_azimKSeq_Q_fx = 6; +#endif const Word16 defaultHRIR_rom_elevBsShape_Q_fx = 15; const Word16 defaultHRIR_rom_elevBsShape_fx[36] = { 32767, 13824, 4096, 512, 0, 0, 16256, 19456, 14976, 8192, 3456, 1024, 128, 0, 0, 2603, 8533, 14976, 19115, 18901, 15360, 10283, 5461, 2304, 683, 85, 0, 0, 85, 683, 2304, 5461, 10325, 15701, 20053, 21845, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 1a6e33e728359c5acd5aa526c8bf20e07e22f034..0cacbd26d2497c3543e3833eb749afa08841fbd1 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1050,6 +1050,19 @@ typedef struct const Word16 *azimShapeIdx; const Word16 *azimShapeSampFactor; +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *elevKSeq_fx; /* Array, N x elevDim2 x elevDim3 */ + Word16 elevKSeq_Q_fx; /* Q-value of elevKSeq_fx */ + const Word16 *elevBsShape_fx; + Word16 elevBsShape_Q_fx; + const Word16 **azimBsShape_fx; /* 2d Array, length num_unique_azim_splines */ + Word16 *azimBsShape_Q_fx; /* Array, length num_unique_azim_splines, Q-values for each k of azimBsShape_fx[k] */ + Word16 **azimKSeq_fx; /* Array, length azimDim3+1 */ + Word16 *azimKSeq_Q_fx; /* Array, length azimDim3+1, Q-values for each k of azimKSeq_fx[k] */ + const Word16 *AlphaL_fx; /* Array, size AlphaN x K */ + Word16 AlphaL_e; + const Word16 *AlphaR_fx; /* Array, size AlphaN x K */ +#else const Word32 *elevKSeq_fx; /* Array, N x elevDim2 x elevDim3 */ const Word32 *elevBsShape_fx; const Word32 **azimBsShape_fx; @@ -1057,6 +1070,7 @@ typedef struct const Word32 *AlphaL_fx; /* Array, size AlphaN x K */ Word16 AlphaL_e; const Word32 *AlphaR_fx; /* Array, size AlphaN x K */ +#endif Word16 AlphaR_e; const Word32 *EL_fx; /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */ Word16 EL_e; @@ -1067,12 +1081,22 @@ typedef struct Word16 iSecFirst[HRTF_MODEL_N_SECTIONS]; /* Indices for start of sections */ Word16 iSecLast[HRTF_MODEL_N_SECTIONS]; /* Indices for end of sections */ /* Pointers for allocation of dynamic memory */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + Word16 *AlphaL_dyn_fx; + Word16 *AlphaR_dyn_fx; +#else Word32 *AlphaL_dyn_fx; Word32 *AlphaR_dyn_fx; +#endif Word32 *EL_dyn_fx; Word32 *ER_dyn_fx; +#ifdef FIX_2235_TD_RENDERER_WORD16 + Word16 *elevBsShape_dyn_fx; + Word16 *elevKSeq_dyn_fx; +#else Word32 *elevBsShape_dyn_fx; Word32 *elevKSeq_dyn_fx; +#endif Word16 *elevBsLen_dyn; Word16 *elevBsStart_dyn; Word16 *azimDim3_dyn; @@ -1080,7 +1104,11 @@ typedef struct Word16 *azimSegSamples_dyn; Word16 *azimShapeIdx_dyn; Word16 *azimShapeSampFactor_dyn; +#ifdef FIX_2235_TD_RENDERER_WORD16 + Word16 **azimBsShape_dyn_fx; +#else Word32 **azimBsShape_dyn_fx; +#endif } ModelParams_t; @@ -1095,20 +1123,47 @@ typedef struct const Word16 *elevBsLen; const Word16 *elevBsStart; Word16 elevSegSamples; - Word16 resamp_factor_fx; /*Q14*/ + Word16 resamp_factor_fx; /*Q14*/ +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *elevKSeq_fx; /* Array, length elevDim3-2 */ + Word16 elevKSeq_Q_fx; /* Q-value of elevKSeq_fx */ + const Word16 *azimKSeq_fx; /* Array, length azimDim3-2 */ + Word16 azimKSeq_Q_fx; /* Q-value of azimKSeq_fx */ + const Word16 *W_fx; /* Array, size (elevDim3*azimDim3) x K */ +#else const Word32 *elevKSeq_fx; /* Array, length elevDim3-2 */ const Word32 *azimKSeq_fx; /* Array, length azimDim3-2 */ const Word32 *W_fx; /* Array, size (elevDim3*azimDim3) x K */ +#endif + Word16 W_e; +#ifdef FIX_2235_TD_RENDERER_WORD16 + const Word16 *azimBsShape_fx; + Word16 azimBsShape_Q_fx; + const Word16 *elevBsShape_fx; + Word16 elevBsShape_Q_fx; +#else const Word32 *azimBsShape_fx; const Word32 *elevBsShape_fx; +#endif /* Pointers for allocation of dynamic memory */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + Word16 *elevKSeq_dyn_fx; + Word16 *azimKSeq_dyn_fx; + Word16 *W_dyn_fx; +#else Word32 *elevKSeq_dyn_fx; Word32 *azimKSeq_dyn_fx; Word32 *W_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + Word16 *azimBsShape_dyn_fx; + Word16 *elevBsShape_dyn_fx; +#else Word32 *azimBsShape_dyn_fx; Word32 *elevBsShape_dyn_fx; +#endif Word16 *azimBsLen_dyn_fx; Word16 *azimBsStart_dyn_fx; Word16 *elevBsLen_dyn_fx; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3742459f87722595da30c69cf2e24a944169f8b4..dcda32d5d046e57fc5506f81dffe763778ca31c0 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -286,9 +286,12 @@ static ivas_error TDREND_LoadBSplineBinaryITD( FILE *f_hrtf /* i : HR filter data file handle */ ) { + Word16 tmp, factor_Q; +#ifndef FIX_2235_TD_RENDERER_WORD16 Word16 *v_tmp16; Word16 j; +#endif if ( modelITD == NULL || f_hrtf == NULL ) { @@ -296,6 +299,15 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) ); + if ( modelITD->elevKSeq_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &modelITD->elevKSeq_Q_fx, sizeof( Word16 ), 1, f_hrtf ); + fread( modelITD->elevKSeq_dyn_fx, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( modelITD->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) @@ -309,8 +321,18 @@ static ivas_error TDREND_LoadBSplineBinaryITD( modelITD->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#endif fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ + if ( modelITD->azimKSeq_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &modelITD->azimKSeq_Q_fx, sizeof( Word16 ), 1, f_hrtf ); + fread( modelITD->azimKSeq_dyn_fx, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) ); if ( modelITD->azimKSeq_dyn_fx == NULL || v_tmp16 == NULL ) @@ -324,8 +346,19 @@ static ivas_error TDREND_LoadBSplineBinaryITD( modelITD->azimKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#endif fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &modelITD->W_dyn_fx, tmp * sizeof( Word16 ) ); + if ( modelITD->W_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); + modelITD->W_e = Q15 - factor_Q; + fread( modelITD->W_dyn_fx, sizeof( Word16 ), tmp, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( Word32 ) ); if ( modelITD->W_dyn_fx == NULL ) { @@ -346,7 +379,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( modelITD->W_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q25 - factor_Q ); } free( v_tmp16 ); - +#endif /* azimuth */ ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); if ( modelITD->azimBsLen_dyn_fx == NULL ) @@ -362,6 +395,15 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->azimBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( Word16 ) ); + if ( modelITD->azimBsShape_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &modelITD->azimBsShape_Q_fx, sizeof( Word16 ), 1, f_hrtf ); + fread( modelITD->azimBsShape_dyn_fx, sizeof( Word16 ), tmp, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( modelITD->azimBsShape_dyn_fx == NULL || v_tmp16 == NULL ) @@ -375,6 +417,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( modelITD->azimBsShape_dyn_fx[j] = L_shl_r( v_tmp16[j], Q30 - factor_Q ); } free( v_tmp16 ); +#endif fread( &modelITD->azimSegSamples, sizeof( Word16 ), 1, f_hrtf ); @@ -393,6 +436,15 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->elevBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word16 ) ); + if ( modelITD->elevBsShape_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &modelITD->elevBsShape_Q_fx, sizeof( Word16 ), 1, f_hrtf ); + fread( modelITD->elevBsShape_dyn_fx, sizeof( Word16 ), tmp, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); if ( modelITD->elevBsShape_dyn_fx == NULL ) { @@ -411,13 +463,25 @@ static ivas_error TDREND_LoadBSplineBinaryITD( modelITD->elevBsShape_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } free( v_tmp16 ); +#endif fread( &modelITD->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->elevKSeq_fx = (const Word16 *) modelITD->elevKSeq_dyn_fx; + modelITD->azimKSeq_fx = (const Word16 *) modelITD->azimKSeq_dyn_fx; + modelITD->W_fx = (const Word16 *) modelITD->W_dyn_fx; +#else modelITD->elevKSeq_fx = (const Word32 *) modelITD->elevKSeq_dyn_fx; modelITD->azimKSeq_fx = (const Word32 *) modelITD->azimKSeq_dyn_fx; modelITD->W_fx = (const Word32 *) modelITD->W_dyn_fx; +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + modelITD->azimBsShape_fx = (const Word16 *) modelITD->azimBsShape_dyn_fx; + modelITD->elevBsShape_fx = (const Word16 *) modelITD->elevBsShape_dyn_fx; +#else modelITD->azimBsShape_fx = (const Word32 *) modelITD->azimBsShape_dyn_fx; modelITD->elevBsShape_fx = (const Word32 *) modelITD->elevBsShape_dyn_fx; +#endif modelITD->azimBsLen = (const Word16 *) modelITD->azimBsLen_dyn_fx; modelITD->azimBsStart = (const Word16 *) modelITD->azimBsStart_dyn_fx; modelITD->elevBsLen = (const Word16 *) modelITD->elevBsLen_dyn_fx; @@ -440,8 +504,10 @@ static ivas_error TDREND_LoadBSplineBinary( { ModelParams_t *model; Word16 i, tmp, factor_Q; +#ifndef FIX_2235_TD_RENDERER_WORD16 Word16 *v_tmp16; Word32 j; +#endif ivas_error error; if ( HrFiltSet_p == NULL || f_hrtf == NULL ) @@ -489,6 +555,15 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( Word16 ) ); + if ( model->elevKSeq_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &model->elevKSeq_Q_fx, 1, sizeof( Word16 ), f_hrtf ); + fread( model->elevKSeq_dyn_fx, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word16 ) ); @@ -503,9 +578,15 @@ static ivas_error TDREND_LoadBSplineBinary( model->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#endif ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( Word16 ) ); ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( Word16 ) ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( Word16 * ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimKSeq_Q_fx, model->elevDim3 * sizeof( Word16 ) ); +#else ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( float * ) ); +#endif if ( model->azimDim3_dyn == NULL || model->azim_start_idx_dyn == NULL || model->azimKSeq_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -515,6 +596,15 @@ static ivas_error TDREND_LoadBSplineBinary( { fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) ); + if ( model->azimKSeq_fx[i] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &model->azimKSeq_Q_fx[i], sizeof( Word16 ), 1, f_hrtf ); + fread( model->azimKSeq_fx[i], sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) ); @@ -529,8 +619,16 @@ static ivas_error TDREND_LoadBSplineBinary( model->azimKSeq_fx[i][j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#endif } fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( Word16 ) ); + if ( model->AlphaL_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } +#else ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); v_tmp16 = (Word16 *) malloc( model->AlphaN * model->K * sizeof( Word16 ) ); @@ -538,17 +636,30 @@ static ivas_error TDREND_LoadBSplineBinary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } +#endif fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); model->AlphaL_e = Q15 - factor_Q; // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ model->AlphaR_e = model->AlphaL_e; +#ifdef FIX_2235_TD_RENDERER_WORD16 + fread( model->AlphaL_dyn_fx, sizeof( Word16 ), model->AlphaN * model->K, f_hrtf ); +#else fread( v_tmp16, sizeof( Word16 ), model->AlphaN * model->K, f_hrtf ); for ( j = 0; j < model->AlphaN * model->K; j++ ) { model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } +#endif +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( Word16 ) ); + if ( model->AlphaR_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( model->AlphaR_dyn_fx, sizeof( Word16 ), model->AlphaN * model->K, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( Word32 ) ); if ( model->AlphaR_dyn_fx == NULL ) { @@ -562,11 +673,18 @@ static ivas_error TDREND_LoadBSplineBinary( } free( v_tmp16 ); +#endif /* azimuth */ fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( Word16 * ) ); + ivas_HRTF_binary_open_buffers_int16_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( Word16 * ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimBsShape_Q_fx, model->num_unique_azim_splines * sizeof( Word16 ) ); +#else ivas_HRTF_binary_open_buffers_int32_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( float * ) ); ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( float * ) ); +#endif ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( Word16 ) ); if ( model->azimBsShape_fx == NULL || model->azimBsShape_dyn_fx == NULL || model->azimSegSamples_dyn == NULL ) { @@ -576,6 +694,16 @@ static ivas_error TDREND_LoadBSplineBinary( for ( i = 0; i < model->num_unique_azim_splines; i++ ) { fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->azimBsShape_dyn_fx[i], tmp * sizeof( Word16 ) ); + if ( model->azimBsShape_dyn_fx[i] == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &model->azimBsShape_Q_fx[i], sizeof( Word16 ), 1, f_hrtf ); + fread( model->azimBsShape_dyn_fx[i], sizeof( Word16 ), tmp, f_hrtf ); + fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); +#else ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( Word32 ) ); if ( model->azimBsShape_dyn_fx[i] == NULL ) { @@ -595,6 +723,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); free( v_tmp16 ); +#endif } ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( Word16 ) ); if ( model->azimShapeIdx_dyn == NULL ) @@ -624,6 +753,15 @@ static ivas_error TDREND_LoadBSplineBinary( fread( model->elevBsStart_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2235_TD_RENDERER_WORD16 + ivas_HRTF_binary_open_buffers_int16( &model->elevBsShape_dyn_fx, tmp * sizeof( Word16 ) ); + if ( model->elevBsShape_dyn_fx == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( &model->elevBsShape_Q_fx, sizeof( Word16 ), 1, f_hrtf ); + fread( model->elevBsShape_dyn_fx, sizeof( Word16 ), tmp, f_hrtf ); +#else v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); if ( model->elevBsShape_dyn_fx == NULL || v_tmp16 == NULL ) @@ -638,7 +776,7 @@ static ivas_error TDREND_LoadBSplineBinary( model->elevBsShape_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } free( v_tmp16 ); - +#endif fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); @@ -661,14 +799,24 @@ static ivas_error TDREND_LoadBSplineBinary( fread( (Word32 *) model->ER_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf ); /* Set const pointers */ +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->AlphaL_fx = (const Word16 *) model->AlphaL_dyn_fx; + model->AlphaR_fx = (const Word16 *) model->AlphaR_dyn_fx; +#else model->AlphaL_fx = (const Word32 *) model->AlphaL_dyn_fx; model->AlphaR_fx = (const Word32 *) model->AlphaR_dyn_fx; +#endif model->EL_fx = (const Word32 *) model->EL_dyn_fx; model->ER_fx = (const Word32 *) model->ER_dyn_fx; model->elevBsLen = (const Word16 *) model->elevBsLen_dyn; model->elevBsStart = (const Word16 *) model->elevBsStart_dyn; +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->elevBsShape_fx = (const Word16 *) model->elevBsShape_dyn_fx; + model->elevKSeq_fx = (const Word16 *) model->elevKSeq_dyn_fx; +#else model->elevBsShape_fx = (const Word32 *) model->elevBsShape_dyn_fx; model->elevKSeq_fx = (const Word32 *) model->elevKSeq_dyn_fx; +#endif model->azimDim3 = (const Word16 *) model->azimDim3_dyn; model->azim_start_idx = (const Word16 *) model->azim_start_idx_dyn; model->azimSegSamples = (const Word16 *) model->azimSegSamples_dyn; @@ -677,7 +825,11 @@ static ivas_error TDREND_LoadBSplineBinary( for ( i = 0; i < model->num_unique_azim_splines; i++ ) { +#ifdef FIX_2235_TD_RENDERER_WORD16 + model->azimBsShape_fx[i] = (const Word16 *) model->azimBsShape_dyn_fx[i]; +#else model->azimBsShape_fx[i] = (const Word32 *) model->azimBsShape_dyn_fx[i]; +#endif } HRTF_model_precalc( model );