From 53f08a06f2d5ca0138732bf75d77ef99b3bedad2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 13:55:36 +0100 Subject: [PATCH 01/22] [cleanup] accept FIX_2235_TD_RENDERER_WORD16 --- lib_com/ivas_cnst.h | 2 - lib_com/options.h | 1 - lib_rend/ivas_hrtf_fx.c | 42 ---- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 122 ----------- lib_rend/ivas_objectRenderer_mix_fx.c | 207 ------------------ lib_rend/ivas_prot_rend_fx.h | 4 - lib_rend/ivas_rom_TdBinauralRenderer.h | 29 --- lib_rend/ivas_rom_TdBinauralRenderer_fx.c | 53 ----- lib_rend/ivas_stat_rend.h | 46 ---- lib_util/hrtf_file_reader.c | 242 ---------------------- 10 files changed, 748 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ecf28ae6d..2c83a0264 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1575,9 +1575,7 @@ typedef enum #define DEG_360_IN_Q22 ( 360 << Q22 ) /* Q22 */ #define DEG_180_IN_Q22 ( 180 << Q22 ) /* Q22 */ #define DEG_90_IN_Q22 ( 90 << Q22 ) /* Q22 */ -#ifdef FIX_2235_TD_RENDERER_WORD16 #define DEG_90_IN_Q8 ( 90 << Q8 ) /* Q8 */ -#endif #define ONE_BY_360_Q31 ( 5965232 ) /* Q31 */ #define ONE_BY_360_Q15 ( 91 ) /* Q15 */ #define ONE_BY_180_Q31 ( 11930465 ) /* Q31 */ diff --git a/lib_com/options.h b/lib_com/options.h index 7fa610801..108d09884 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2235_TD_RENDERER_WORD16 /* Eri: Use Word16 in TD renderer without converting to Word32*/ #define HARMONIZE_TBE2 /* VA: basop issue 2399: Remove duplicated code: TBE, step 2 */ #define HARMONIZE_2427_GETPLC /* FhG: basop issue : 2427 Harmonizing getPLCDecision functions:*/ #define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 8ae204562..10a21dd7d 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -175,19 +175,11 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( } -#ifdef FIX_2235_TD_RENDERER_WORD16 /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_int16() * * Allocate buffer with dynamic length for HRTF binary handle *-----------------------------------------------------------------------*/ -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_CRend_binary_open_buffers_int16() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ -#endif ivas_error ivas_HRTF_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const UWord32 mem_size /* i : size of buffer */ @@ -203,19 +195,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int16( return IVAS_ERR_OK; } -#ifdef FIX_2235_TD_RENDERER_WORD16 /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_uint16() * * Allocate buffer with dynamic length for HRTF binary handle *-----------------------------------------------------------------------*/ -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open_buffers_uint16() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ -#endif ivas_error ivas_HRTF_binary_open_buffers_uint16( UWord16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ @@ -231,19 +215,11 @@ ivas_error ivas_HRTF_binary_open_buffers_uint16( return IVAS_ERR_OK; } -#ifdef FIX_2235_TD_RENDERER_WORD16 /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_int32() * * Allocate buffer with dynamic length for HRTF binary handle *-----------------------------------------------------------------------*/ -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open_buffers_int32() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ -#endif ivas_error ivas_HRTF_binary_open_buffers_int32( Word32 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ @@ -259,19 +235,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int32( return IVAS_ERR_OK; } -#ifdef FIX_2235_TD_RENDERER_WORD16 /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_int32_ptr() * * Allocate buffer with dynamic length for HRTF binary handle *-----------------------------------------------------------------------*/ -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open_buffers_int32_ptr() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ -#endif ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( Word32 ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ @@ -287,7 +255,6 @@ 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() * @@ -327,21 +294,12 @@ ivas_error ivas_HRTF_binary_open_buffers_int16_ptr( return IVAS_ERR_OK; } -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open_buffers_int32_ptr_const() * * Allocate buffer with dynamic length for HRTF binary handle *-----------------------------------------------------------------------*/ -#else -/*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open_buffers_int32_ptr_const() - * - * Allocate buffer with dynamic length for HRTF binary Crend handle - *-----------------------------------------------------------------------*/ -#endif ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( const Word32 ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 2a81e28a8..3088d7b98 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -45,13 +45,8 @@ *---------------------------------------------------------------------*/ -#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 Word16 knot_interval_fx, const Word16 azimKSeq_0_fx, const Word16 azimSegSamples, const Word16 *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 Word16 *KSeq_fx, const Word16 KSeq_Q_fx, const Word16 SegSamples, const Word16 *BsLen, const Word16 *BsStart, const Word16 *BsShape_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 ); @@ -210,30 +205,18 @@ static void GenerateFilter_fx( Word16 num_az_idx[HRTF_MODEL_BSPLINE_NUM_COEFFS]; Word16 num_ev_idx; Word16 BM_idx[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ]; -#ifdef FIX_2235_TD_RENDERER_WORD16 Word16 knot_interval; /* Q6 */ -#else - Word32 knot_interval; -#endif Word32 ETotL, ETotR, ESynL, ESynR; Word16 ETotL_e, ETotR_e, ESynL_e, ESynR_e; Word32 ScaleL, ScaleR; Word16 ScaleL_e, ScaleR_e; Word16 iSec; -#ifndef FIX_2235_TD_RENDERER_WORD16 - Word16 tmp_e; -#endif Word32 tmp32; 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, Q8, model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_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++ ) { @@ -263,23 +246,11 @@ static void GenerateFilter_fx( k = EvIdx[p]; move16(); -#ifdef FIX_2235_TD_RENDERER_WORD16 knot_interval = sub( model->azimKSeq_fx[k][1], model->azimKSeq_fx[k][0] ); /* Q6 */ -#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 ); - knot_interval = L_shr( knot_interval, sub( 9, tmp_e ) ); // variable Q to Q22 -#endif -#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->azimSegSamples[model->azimShapeIdx[k]], model->azimBsShape_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 } } @@ -384,13 +355,8 @@ 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 ); @@ -477,13 +443,8 @@ 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, Q8, model->elevSegSamples, model->elevBsLen, model->elevBsStart, model->elevBsShape_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(); @@ -492,13 +453,8 @@ 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, Q7, model->azimSegSamples, model->azimBsLen, model->azimBsStart, model->azimBsShape_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 */ @@ -534,11 +490,7 @@ static void GenerateITD_fx( /* Compute BM_ITD */ elev_offset = 0; move16(); -#ifdef FIX_2235_TD_RENDERER_WORD16 if ( EQ_16( model->elevKSeq_fx[0], -DEG_90_IN_Q8 ) ) -#else - if ( EQ_32( model->elevKSeq_fx[0], -DEG_90_IN_Q22 ) ) -#endif { elev_offset = sub( 1, model->azimDim3 ); } @@ -550,11 +502,7 @@ static void GenerateITD_fx( test(); test(); test(); -#ifdef FIX_2235_TD_RENDERER_WORD16 IF( EvIdx[p] == 0 && EQ_16( model->elevKSeq_fx[EvIdx[p]], -DEG_90_IN_Q8 ) ) -#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(); @@ -562,11 +510,7 @@ 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 )], DEG_90_IN_Q8 ) ) -#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 @@ -591,11 +535,7 @@ 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 )], DEG_90_IN_Q8 ) ) /* 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 ) ); } @@ -608,11 +548,7 @@ 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 ); @@ -652,19 +588,10 @@ static void getPeriodicBSplineSampVec_fx( const Word16 NumBFs, /* i : the number of basis functions = third index of Bf. */ const Word32 t_fx, /* i : azimuth Q22 */ Word16 *num_az_idx, /* o : Number of azimuth indices */ -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 knot_interval_fx, /* i : The knot interval Q6 */ const Word16 azimKSeq_0_fx, /* i : Knot sequence Q6 */ -#else - const Word32 knot_interval_fx, /* i : The knot interval Q22 */ - 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 Q15 */ -#else - const Word32 *azimBsShape_fx, /* i : Basis shape Q30 */ -#endif const Word16 subSampFactor /* i : Subsampling factor */ ) { @@ -688,17 +615,9 @@ static void getPeriodicBSplineSampVec_fx( } ELSE { -#ifdef FIX_2235_TD_RENDERER_WORD16 tmp32 = L_deposit_h( BASOP_Util_Divide1616_Scale( knot_interval_fx, SegSamples, &tmp_e1 ) ); -#else - tmp32 = L_deposit_h( BASOP_Util_Divide3216_Scale( knot_interval_fx, SegSamples, &tmp_e1 ) ); -#endif 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 ), Q22 - Q6 ) ), 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 ) ); @@ -725,11 +644,7 @@ 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 )] ), Q30 - Q15 ); -#else - BfVec_fx[i] = azimBsShape_fx[i_mult( abs_s( d ), subSampFactor )]; -#endif move32(); AzIdx[i] = add( nI, i ) % NumBFs; @@ -751,53 +666,28 @@ static void getStandardBSplineSampVec_fx( 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 Q15 */ -#else - const Word32 *BsShape_fx /* i : basis shapes Q30 */ -#endif ) { Word16 i, nI; -#ifdef FIX_2235_TD_RENDERER_WORD16 Word16 knot_interval_fx; -#else - Word32 knot_interval_fx; -#endif Word16 d0, d, shape_idx, start_idx; Word16 tmp_e1, tmp_e2, tmp_e3; Word32 tmp32; /* assuming triple knot at the first knot */ -#ifdef FIX_2235_TD_RENDERER_WORD16 knot_interval_fx = shl( sub( KSeq_fx[1], KSeq_fx[0] ), Q6 - KSeq_Q_fx ); /* Variable Q -> Q6 */ tmp_e1 = 9; -#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 ) ); - tmp_e1 = add( tmp_e1, 9 - 15 ); -#endif /* index of closest sample point */ -#ifdef FIX_2235_TD_RENDERER_WORD16 tmp32 = L_deposit_h( BASOP_Util_Divide1616_Scale( knot_interval_fx, SegSamples, &tmp_e2 ) ); -#else - tmp32 = L_deposit_h( BASOP_Util_Divide3216_Scale( knot_interval_fx, SegSamples, &tmp_e2 ) ); -#endif 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] ), sub( 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 ) ); @@ -832,13 +722,8 @@ 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 )] ), Q30 - Q15 ); /* 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(); } @@ -892,13 +777,6 @@ 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. */ FOR( i = 0; i < model->elevDim3; i++ ) diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index f42f8b109..a6a26609f 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -151,24 +151,6 @@ 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 ) - { - free( hBinRendererTd->HrFiltSet_p->ModelParamsITD.elevKSeq_dyn_fx ); - free( hBinRendererTd->HrFiltSet_p->ModelParamsITD.azimKSeq_dyn_fx ); - free( hBinRendererTd->HrFiltSet_p->ModelParamsITD.W_dyn_fx ); - free( hBinRendererTd->HrFiltSet_p->ModelParamsITD.azimBsShape_dyn_fx ); - free( hBinRendererTd->HrFiltSet_p->ModelParamsITD.elevBsShape_dyn_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 ) ) { @@ -415,74 +397,24 @@ 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; -#else - model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); - IF( model->elevKSeq_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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; -#else - model->elevBsShape_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_elevBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); - IF( model->elevBsShape_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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 ) { 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" ) ); - } - model->azimBsShape_dyn_fx = (Word32 **) malloc( sizeof( Word32 * ) ); - IF( model->azimBsShape_dyn_fx == NULL ) - { - 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; /* Q15 */ -#else - model->azimBsShape_dyn_fx[0] = (Word32 *) malloc( sizeof( defaultHRIR_rom_azimBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); - IF( model->azimBsShape_dyn_fx[0] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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 ) -#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" ) ); } @@ -500,20 +432,14 @@ static ivas_error DefaultBSplineModel_fx( 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 ), Q6 ) ); /* Q6 */ 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; @@ -522,41 +448,11 @@ static ivas_error DefaultBSplineModel_fx( 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaL48_fx, model->AlphaL_dyn_fx, 30080, Q30 - defaultHRIR_rom_Alpha48_Q_fx ); // Q30 - Copy_Scale_sig_16_32_r( &defaultHRIR_rom_AlphaL48_fx[30080], &model->AlphaL_dyn_fx[30080], 30080, Q30 - defaultHRIR_rom_Alpha48_Q_fx ); // Q30 - model->AlphaL_fx = model->AlphaL_dyn_fx; - model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha48_Q_fx; - move16(); - model->AlphaR_dyn_fx = (Word32 *) malloc( 60160 * sizeof( Word32 ) ); - if ( model->AlphaR_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaR48_fx, model->AlphaR_dyn_fx, 30080, Q30 - defaultHRIR_rom_Alpha48_Q_fx ); // Q22 - Copy_Scale_sig_16_32_r( &defaultHRIR_rom_AlphaR48_fx[30080], &model->AlphaR_dyn_fx[30080], 30080, Q30 - defaultHRIR_rom_Alpha48_Q_fx ); // Q22 - model->AlphaR_fx = model->AlphaR_dyn_fx; - model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha48_Q_fx; - move16(); -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 model->EL_fx = defaultHRIR_rom_EL48_fx; // Q28 -#else - model->EL_fx = (const Word32 *) defaultHRIR_rom_EL48_fx; // Q28 -#endif move16(); model->EL_e = Q31 - defaultHRIR_rom_E48_Q_fx; move16(); -#ifdef FIX_2235_TD_RENDERER_WORD16 model->ER_fx = defaultHRIR_rom_ER48_fx; // Q28 -#else - model->ER_fx = (const Word32 *) defaultHRIR_rom_ER48_fx; // Q28 -#endif move16(); model->ER_e = Q31 - defaultHRIR_rom_E48_Q_fx; move16(); @@ -569,7 +465,6 @@ 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; @@ -578,41 +473,11 @@ static ivas_error DefaultBSplineModel_fx( 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaL32_fx, model->AlphaL_dyn_fx, 20210, Q30 - defaultHRIR_rom_Alpha32_Q_fx ); // Q22 - Copy_Scale_sig_16_32_r( &defaultHRIR_rom_AlphaL32_fx[20210], &model->AlphaL_dyn_fx[20210], 20210, Q30 - defaultHRIR_rom_Alpha32_Q_fx ); // Q22 - model->AlphaL_fx = model->AlphaL_dyn_fx; - model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha32_Q_fx; - move16(); - model->AlphaR_dyn_fx = (Word32 *) malloc( 40420 * sizeof( Word32 ) ); - if ( model->AlphaR_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaR32_fx, model->AlphaR_dyn_fx, 20210, Q30 - defaultHRIR_rom_Alpha32_Q_fx ); // Q22 - Copy_Scale_sig_16_32_r( &defaultHRIR_rom_AlphaR32_fx[20210], &model->AlphaR_dyn_fx[20210], 20210, Q30 - defaultHRIR_rom_Alpha32_Q_fx ); // Q22 - model->AlphaR_fx = model->AlphaR_dyn_fx; - model->AlphaR_e = Q15 - defaultHRIR_rom_Alpha32_Q_fx; - move16(); -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 model->EL_fx = defaultHRIR_rom_EL32_fx; // Q28 -#else - model->EL_fx = (const Word32 *) defaultHRIR_rom_EL32_fx; // Q28 -#endif move16(); model->EL_e = Q31 - defaultHRIR_rom_E32_Q_fx; move16(); -#ifdef FIX_2235_TD_RENDERER_WORD16 model->ER_fx = defaultHRIR_rom_ER32_fx; // Q28 -#else - model->ER_fx = (const Word32 *) defaultHRIR_rom_ER32_fx; // Q28 -#endif move16(); model->ER_e = Q31 - defaultHRIR_rom_E32_Q_fx; move16(); @@ -625,33 +490,12 @@ 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaL16_fx, model->AlphaL_dyn_fx, 20210, Q30 - defaultHRIR_rom_Alpha16_Q_fx ); // Q22 - model->AlphaL_fx = model->AlphaL_dyn_fx; - model->AlphaL_e = Q15 - defaultHRIR_rom_Alpha16_Q_fx; - move16(); - model->AlphaR_dyn_fx = (Word32 *) malloc( 20210 * sizeof( Word32 ) ); - if ( model->AlphaR_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - Copy_Scale_sig_16_32_r( defaultHRIR_rom_AlphaR16_fx, model->AlphaR_dyn_fx, 20210, Q30 - defaultHRIR_rom_Alpha16_Q_fx ); // Q22 - 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(); @@ -681,72 +525,21 @@ 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(); -#else - modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_elevKSeq_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); - IF( modelITD->elevKSeq_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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(); -#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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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; /* Q15 */ 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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; /* Q15 */ move16(); -#else - modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( sizeof( defaultHRIR_rom_ITD_elevBsShape_fx ) * sizeof( Word32 ) / sizeof( Word16 ) ); - IF( modelITD->elevBsShape_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - 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 e0a46667c..83704923a 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -617,12 +617,10 @@ 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 */ @@ -634,12 +632,10 @@ 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 */ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index 16740568f..b35aa18bc 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -50,9 +50,6 @@ extern const Word16 defaultHRIR_rom_azim_start_idx[15]; extern const Word16 defaultHRIR_rom_azimSegSamples[1]; extern const Word16 defaultHRIR_rom_azimShapeIdx[15]; extern const Word16 defaultHRIR_rom_azimShapeSampFactor[15]; -#ifndef FIX_2235_TD_RENDERER_WORD16 -extern const Word16 defaultHRIR_rom_elevKSeq_Q_fx; -#endif extern const Word16 defaultHRIR_rom_elevKSeq_fx[13]; extern const Word16 defaultHRIR_rom_Alpha48_Q_fx; extern const Word16 defaultHRIR_rom_AlphaL48_fx[470 * 128]; /*Q30*/ @@ -72,44 +69,18 @@ extern const Word32 defaultHRIR_rom_ER32_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28* extern const Word16 defaultHRIR_rom_E16_Q_fx; extern const Word32 defaultHRIR_rom_EL16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/ extern const Word32 defaultHRIR_rom_ER16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/ -#ifdef FIX_2235_TD_RENDERER_WORD16 extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q15*/ -#else -extern const Word16 defaultHRIR_rom_elevBsShape_Q_fx; -extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q30*/ -#endif extern const Word16 defaultHRIR_rom_elevBsLen[4]; extern const Word16 defaultHRIR_rom_elevBsStart[4]; -#ifdef FIX_2235_TD_RENDERER_WORD16 extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q15*/ extern const Word16 defaultHRIR_rom_azimBsShape_fx[21]; /*Q15*/ -#else -extern const Word16 defaultHRIR_rom_elevBsShape_Q_fx; -extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q30*/ -extern const Word16 defaultHRIR_rom_azimBsShape_Q_fx; -extern const Word16 defaultHRIR_rom_azimBsShape_fx[21]; /*Q30*/ -#endif extern const Word16 defaultHRIR_rom_ITD_W_Q_fx; extern const Word16 defaultHRIR_rom_ITD_W_fx[658]; -#ifdef FIX_2235_TD_RENDERER_WORD16 extern const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[84]; /* Q15 */ extern const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[19]; /* Q7 */ extern const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[28]; /* Q15 */ -#else -extern const Word16 defaultHRIR_rom_ITD_azimBsShape_Q_fx; -extern const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[84]; -extern const Word16 defaultHRIR_rom_ITD_azimKSeq_Q_fx; -extern const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[19]; -extern const Word16 defaultHRIR_rom_ITD_elevBsShape_Q_fx; -extern const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[28]; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16]; /* Q8 */ -#else -extern const Word16 defaultHRIR_rom_ITD_elevKSeq_Q_fx; -extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16]; -#endif extern const Word16 defaultHRIR_rom_ITD_model_configuration[4]; extern const Word16 defaultHRIR_rom_ITD_elevBsLen[4]; extern const Word16 defaultHRIR_rom_ITD_elevBsStart[4]; diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c index eeac769b2..1269e7caa 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c @@ -84,36 +84,15 @@ const Word16 defaultHRIR_rom_azimShapeIdx[15] = { const Word16 defaultHRIR_rom_azimShapeSampFactor[15] = { -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, }; -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_elevKSeq_fx [13] = { -23040, -19200, -15360, -11520, -7680, -3840, 0, 3840, 7680, 11520, 15360, 19200, 23040, }; /* Q8 */ -#else -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, -}; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 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, }; /* Q15 */ -#else -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, -}; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_azimBsShape_fx[21] = { 21845, 21534, 20666, 19339, 17651, 15701, 13588, 11409, 9262, 7247, 5461, 3981, 2796, 1873, 1180, 683, 350, 147, 44, 5, 0, }; /* Q15 */ -#else -const Word16 defaultHRIR_rom_azimBsShape_Q_fx = 15; -const Word16 defaultHRIR_rom_azimBsShape_fx[21] = { -21845, 21534, 20666, 19339, 17651, 15701, 13588, 11409, 9262, 7247, 5461, 3981, 2796, 1873, 1180, 683, 350, 147, 44, 5, 0, -}; -#endif const Word16 defaultHRIR_rom_Alpha48_Q_fx = 14; const Word16 defaultHRIR_rom_AlphaL48_fx[470 * 128] = { 2196,437,2620,2054,2197,2199,2307,2350,2385,2307,2258,2205,2160,2123,2102,2085,2065,2056,2023,1908,2395,344,-284,-1067,727, @@ -10200,56 +10179,24 @@ const Word16 defaultHRIR_rom_ITD_azimBsLen[4] = { const Word16 defaultHRIR_rom_ITD_azimBsStart[4] = { 0, 11, 32, 63, }; -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[84] = { 32767,23888,16777,11239,7078,4096,2097,885,262,33,0,0,8413,14221,17768,19399,19456,18285,16228,13631,10838,8192,5972,4194,2810, 1769,1024,524,221,66,8,0,0,461,1726,3613,5942,8533,11207,13782,16078,17916,19115,19543,19268,18402,17061,15360,13413,11335, 9241,7244,5461,3981,2796,1873,1180,683,350,147,44,5,0,0,5,44,147,350,683,1180,1873,2796,3981,5461,7247, 9262,11409,13588,15701,17651,19339,20666,21534,21845, }; /* Q15 */ -#else -const Word16 defaultHRIR_rom_ITD_azimBsShape_Q_fx = 15; -const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[84] = { -32767,23888,16777,11239,7078,4096,2097,885,262,33,0,0,8413,14221,17768,19399,19456,18285,16228,13631,10838,8192,5972,4194,2810, -1769,1024,524,221,66,8,0,0,461,1726,3613,5942,8533,11207,13782,16078,17916,19115,19543,19268,18402,17061,15360,13413,11335, -9241,7244,5461,3981,2796,1873,1180,683,350,147,44,5,0,0,5,44,147,350,683,1180,1873,2796,3981,5461,7247, -9262,11409,13588,15701,17651,19339,20666,21534,21845, -}; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[19] = { 0, 1280, 2560, 3840, 5120, 6400, 7680, 8960, 10240, 11520, 12800, 14080, 15360, 16640, 17920, 19200, 20480, 21760, 23040, }; /* Q7 */ -#else -const Word16 defaultHRIR_rom_ITD_azimKSeq_Q_fx = 7; -const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[19] = { -0, 1280, 2560, 3840, 5120, 6400, 7680, 8960, 10240, 11520, 12800, 14080, 15360, 16640, 17920, 19200, 20480, 21760, 23040, -}; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[28] = { 32767,9709,1214,0,0,18508,16991,8192,2427,303,0,0,4349,12945,19115,18002,12035,5461,1618,202,0,0,202,1618,5461, 12136,18811,21845, }; /* Q15 */ -#else -const Word16 defaultHRIR_rom_ITD_elevBsShape_Q_fx = 15; -const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[28] = { -32767,9709,1214,0,0,18508,16991,8192,2427,303,0,0,4349,12945,19115,18002,12035,5461,1618,202,0,0,202,1618,5461, -12136,18811,21845, -}; -#endif -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16] = { -23040, -19968, -16896, -13824, -10752, -7680, -4608, -1536, 1536, 4608, 7680, 10752, 13824, 16896, 19968, 23040, }; /* Q8 */ -#else -const Word16 defaultHRIR_rom_ITD_elevKSeq_Q_fx = 8; -const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16] = { --23040, -19968, -16896, -13824, -10752, -7680, -4608, -1536, 1536, 4608, 7680, 10752, 13824, 16896, 19968, 23040, -}; -#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 919f24273..90833fc79 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1050,7 +1050,6 @@ typedef struct const Word16 *azimShapeIdx; const Word16 *azimShapeSampFactor; -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 *elevKSeq_fx; /* Array, N x elevDim2 x elevDim3, Q8 [-90,90] */ const Word16 *elevBsShape_fx; /* Q15 */ const Word16 **azimBsShape_fx; /* 2d Array, length num_unique_azim_splines Q15 */ @@ -1058,15 +1057,6 @@ typedef struct 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; - Word32 **azimKSeq_fx; /* Array, length azimDim3+1 */ - 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; @@ -1077,22 +1067,12 @@ 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; @@ -1100,11 +1080,7 @@ 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; @@ -1120,42 +1096,20 @@ typedef struct const Word16 *elevBsStart; Word16 elevSegSamples; Word16 resamp_factor_fx; /*Q14*/ -#ifdef FIX_2235_TD_RENDERER_WORD16 const Word16 *elevKSeq_fx; /* Array, length elevDim3-2, Q8 [-90,90] */ const Word16 *azimKSeq_fx; /* Array, length azimDim3-2 Q7 [-180,180] */ 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; const Word16 *elevBsShape_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 662f56ee2..d961a1e8f 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -288,9 +288,6 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { Word16 tmp, factor_Q; -#ifndef FIX_2235_TD_RENDERER_WORD16 - Word16 *v_tmp16; -#endif Word16 j; if ( modelITD == NULL || f_hrtf == NULL ) @@ -299,7 +296,6 @@ 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 ) { @@ -311,24 +307,8 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { modelITD->elevKSeq_dyn_fx[j] = shl( modelITD->elevKSeq_dyn_fx[j], Q8 - factor_Q ); /* Q8 */ } -#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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), modelITD->elevDim3 - 2, f_hrtf ); - for ( j = 0; j < modelITD->elevDim3 - 2; j++ ) - { - 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 ) { @@ -340,24 +320,8 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { modelITD->azimKSeq_dyn_fx[j] = shl( modelITD->azimKSeq_dyn_fx[j], Q7 - factor_Q ); /* Q7 */ } -#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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); - for ( j = 0; j < ( modelITD->azimDim3 + 1 ) / 2 - 2; j++ ) - { - 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 ) { @@ -366,28 +330,6 @@ static ivas_error TDREND_LoadBSplineBinaryITD( 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); - if ( v_tmp16 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - modelITD->W_e = Q15 - factor_Q; - // modelITD->W_dyn_e = 6; /* force to 6 to be corrected */ - fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); - for ( j = 0; j < tmp; j++ ) - { - 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 ) @@ -403,7 +345,6 @@ 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 ) { @@ -415,21 +356,6 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { modelITD->azimBsShape_dyn_fx[j] = shl( modelITD->azimBsShape_dyn_fx[j], Q15 - factor_Q ); /* Q15 */ } -#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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); - for ( j = 0; j < tmp; j++ ) - { - 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 ); @@ -448,7 +374,6 @@ 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 ) { @@ -460,44 +385,13 @@ static ivas_error TDREND_LoadBSplineBinaryITD( { modelITD->elevBsShape_dyn_fx[j] = shl( modelITD->elevBsShape_dyn_fx[j], Q15 - factor_Q ); /* Q15 */ } -#else - ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( Word32 ) ); - if ( modelITD->elevBsShape_dyn_fx == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); - if ( v_tmp16 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); - for ( j = 0; j < tmp; j++ ) - { - 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; @@ -520,9 +414,6 @@ static ivas_error TDREND_LoadBSplineBinary( { ModelParams_t *model; Word16 i, tmp, factor_Q; -#ifndef FIX_2235_TD_RENDERER_WORD16 - Word16 *v_tmp16; -#endif Word32 j; ivas_error error; @@ -571,7 +462,6 @@ 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 ) { @@ -583,29 +473,9 @@ static ivas_error TDREND_LoadBSplineBinary( { model->elevKSeq_dyn_fx[j] = shl( model->elevKSeq_dyn_fx[j], Q8 - factor_Q ); /* Q8 */ } -#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 ) ); - if ( model->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), model->elevDim3 - 2, f_hrtf ); - for ( j = 0; j < model->elevDim3 - 2; j++ ) - { - 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 * ) ); -#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" ); @@ -615,7 +485,6 @@ 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 ) { @@ -627,88 +496,30 @@ static ivas_error TDREND_LoadBSplineBinary( { model->azimKSeq_fx[i][j] = shl( model->azimKSeq_fx[i][j], Q6 - factor_Q ); /* Q6 */ } -#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 ) ); - if ( model->azimKSeq_fx[i] == NULL || v_tmp16 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); - for ( j = 0; j < model->azimDim3_dyn[i] + 1; j++ ) - { - 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 ) ); - if ( model->AlphaL_dyn_fx == NULL || v_tmp16 == NULL ) - { - 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; -#ifndef FIX_2235_TD_RENDERER_WORD16 - // model->AlphaL_dyn_e = 1; /* force to 6 to be corrected */ -#endif 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - fread( v_tmp16, sizeof( Word16 ), model->AlphaN * model->K, f_hrtf ); - for ( j = 0; j < model->AlphaN * model->K; j++ ) - { - model->AlphaR_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); - } - - 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 * ) ); -#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 ) { @@ -718,7 +529,6 @@ 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 ) { @@ -731,27 +541,6 @@ static ivas_error TDREND_LoadBSplineBinary( model->azimBsShape_dyn_fx[i][j] = shl( model->azimBsShape_dyn_fx[i][j], Q15 - factor_Q ); /* Q15 */ } 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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); - if ( v_tmp16 == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); - for ( j = 0; j < tmp; j++ ) - { - model->azimBsShape_dyn_fx[i][j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); - } - 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 ) @@ -781,7 +570,6 @@ 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 ) { @@ -793,22 +581,6 @@ static ivas_error TDREND_LoadBSplineBinary( { model->elevBsShape_dyn_fx[j] = shl( model->elevBsShape_dyn_fx[j], Q15 - factor_Q ); /* Q15 */ } -#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 ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - - fread( &factor_Q, sizeof( Word16 ), 1, f_hrtf ); - fread( v_tmp16, sizeof( Word16 ), tmp, f_hrtf ); - for ( j = 0; j < tmp; j++ ) - { - 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 ) ); @@ -831,24 +603,14 @@ 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; @@ -857,11 +619,7 @@ 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 ); -- GitLab From 620de6da3068ea538dd890b0d2b9de35417deec3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 13:56:37 +0100 Subject: [PATCH 02/22] [cleanup] accept HARMONIZE_TBE2 --- lib_com/options.h | 1 - lib_com/prot_fx.h | 81 -- lib_com/swb_tbe_com_fx.c | 1452 +----------------------------------- lib_dec/swb_tbe_dec_fx.c | 28 - lib_enc/evs_enc_fx.c | 9 - lib_enc/ivas_core_enc_fx.c | 37 - lib_enc/prot_fx_enc.h | 19 - lib_enc/swb_pre_proc_fx.c | 459 ------------ lib_enc/swb_tbe_enc_fx.c | 21 - 9 files changed, 23 insertions(+), 2084 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 108d09884..bdc99e5fd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define HARMONIZE_TBE2 /* VA: basop issue 2399: Remove duplicated code: TBE, step 2 */ #define HARMONIZE_2427_GETPLC /* FhG: basop issue : 2427 Harmonizing getPLCDecision functions:*/ #define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ #define FIX_2429_POST_DECODER diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8f41d4871..83453e02d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2725,26 +2725,6 @@ void flip_spectrum_and_decimby4_fx( ); void GenShapedWBExcitation_fx( -#ifndef HARMONIZE_TBE2 - Word16 *excSHB, /* o : synthesized shaped shb exctiation */ - const Word16 *lpc_shb, /* i : lpc coefficients */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - Word32 *mem_csfilt, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ - Word16 *state_lpc_syn, /* i/o : memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, /* i : Q for memories */ - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ - const Word16 signal_type, - const Word16 igf_flag ); - -void GenShapedWBExcitation_ivas_fx( -#endif Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ @@ -2801,12 +2781,8 @@ void GenShapedSHBExcitation_fx( const Word32 bitrate, const Word16 prev_bfi ); -#ifdef HARMONIZE_TBE2 void GenShapedSHBExcitation_ivas_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ -#else -void GenShapedSHBExcitation_ivas_enc_fx( -#endif Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ @@ -2851,49 +2827,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ ); -#ifndef HARMONIZE_TBE2 -void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); -#endif void GenSHBSynth_fx( const Word16 *shb_target_speech, /* i : i synthesized speech */ Word16 *shb_syn_speech_32k, /* o : output highband component */ @@ -10006,20 +9939,6 @@ void Copy_Scale_sig32( const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ ); -#ifndef HARMONIZE_TBE2 -void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ -#ifdef HARMONIZE_TBE2 - const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers */ -#endif - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); -#endif /* o : Q(2x - 31 - gb) */ Word32 sum2_f_32_fx( const Word32 *vec, /* i : input vector, Qx */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 7f39768d9..30dad09e5 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -1341,11 +1341,7 @@ void flip_spectrum_and_decimby4_fx( /* CALLED FROM : */ /*==========================================================================*/ -#ifdef HARMONIZE_TBE2 void GenShapedWBExcitation_fx( -#else -void GenShapedWBExcitation_ivas_fx( -#endif Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q_bwe_exc*/ @@ -1451,7 +1447,6 @@ void GenShapedWBExcitation_ivas_fx( fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, LPC_WHTN_ORDER_WB, 0, 3 ); /* Ensure pow1 is greater than zero when computing normalization */ -#ifdef HARMONIZE_TBE2 Word16 Q_pow = Q10; move16(); if ( element_mode == EVS_MONO ) @@ -1459,7 +1454,6 @@ void GenShapedWBExcitation_ivas_fx( Q_pow = Q7; move16(); } -#endif max_val = 0; move16(); FOR( i = 0; i < L_FRAME16k / 4; i++ ) @@ -1491,11 +1485,7 @@ void GenShapedWBExcitation_ivas_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ // saturation not possible: excTmp2_frac[i] < MIN_16 -#ifdef HARMONIZE_TBE2 pow1 = L_add_sat( pow1, L_shr( L_tmp, Q_pow ) ); /* Q22 */ -#else - pow1 = L_add_sat( pow1, L_shr( L_tmp, 10 ) ); /* Q22 */ -#endif } } @@ -1541,15 +1531,10 @@ void GenShapedWBExcitation_ivas_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { L_tmp = L_mult_sat( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ -#ifdef HARMONIZE_TBE2 pow22 = L_add( pow22, L_shr( L_tmp, Q_pow ) ); /* Q22 */ -#else - pow22 = L_add( pow22, L_shr( L_tmp, 10 ) ); /* Q22 */ -#endif } } -#ifdef HARMONIZE_TBE2 Word16 Q_root = Q19; move16(); if ( element_mode == EVS_MONO ) @@ -1557,17 +1542,12 @@ void GenShapedWBExcitation_ivas_fx( Q_root = Q22; move16(); } -#endif test(); test(); IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) { -#ifdef HARMONIZE_TBE2 L_tmp = root_a_over_b_fx( pow1, sub( Q_root, shl( n1, 1 ) ), pow22, sub( Q_root, shl( n2, 1 ) ), &exp ); -#else - L_tmp = root_a_over_b_fx( pow1, sub( 19, shl( n1, 1 ) ), pow22, sub( 19, shl( n2, 1 ) ), &exp ); -#endif scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ sc = sub( add( n2, Q_bwe_exc ), 14 ); FOR( i = 0; i < L_FRAME16k / 4; i++ ) @@ -1599,11 +1579,7 @@ void GenShapedWBExcitation_ivas_fx( Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); temp1 = round_fx_sat( L_shl_sat( Ltemp1, exp ) ); /* Q15 */ L_tmp = Mult_32_16( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ -#ifdef HARMONIZE_TBE2 Ltemp2 = root_a_over_b_fx( L_tmp, sub( Q_root, shl( n1, 1 ) ), pow22, sub( Q_root, shl( n2, 1 ) ), &exp ); -#else - Ltemp2 = root_a_over_b_fx( L_tmp, sub( 19, shl( n1, 1 ) ), pow22, sub( 19, shl( n2, 1 ) ), &exp ); -#endif temp2 = round_fx_sat( L_shl_sat( Ltemp2, exp ) ); /* Q15 */ FOR( j = 0; j < L_FRAME16k / 16; j++ ) { @@ -1617,13 +1593,11 @@ void GenShapedWBExcitation_ivas_fx( } } -#ifdef HARMONIZE_TBE2 IF( element_mode == EVS_MONO ) { Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); } ELSE -#endif { Scale_sig( state_lpc_syn, LPC_SHB_ORDER, -Q2 ); /* Q(Q_bwe_exc) -> Q(Q_bwe_exc - 2) */ @@ -1636,253 +1610,6 @@ void GenShapedWBExcitation_ivas_fx( return; } -#ifndef HARMONIZE_TBE2 -void GenShapedWBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation Q(Q_bwe_exc) */ - const Word16 *lpc_shb, /* i : lpc coefficients Q12 */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation Q(Q_bwe_exc) */ - Word32 *mem_csfilt, /* i/o : memory Q(Q_bwe_exc+16) */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory Q(Q_bwe_exc) */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory Q(Q_bwe_exc) */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory Q(Q_bwe_exc) */ - Word16 *state_lpc_syn, /* i/o : memory Q(Q_bwe_exc) */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bwidth extended exciatation Q(Q_bwe_exc) */ - const Word16 Q_bwe_exc, /* i : Q for memories */ - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor Q15 */ - const Word16 uv_flag, /* i : unvoiced flag */ - const Word16 igf_flag ) -{ - Word16 i, j, k; - Word16 wht_fil_mem[LPC_WHTN_ORDER_WB]; - Word16 lpc_whtn[LPC_WHTN_ORDER_WB + 1]; - Word16 R_h[LPC_WHTN_ORDER_WB + 2], R_l[LPC_WHTN_ORDER_WB + 2]; - Word16 Q_R; - Word16 excTmp[L_FRAME16k]; - Word16 excTmp2[L_FRAME16k / 4]; - Word16 excTmp2_frac[L_FRAME16k / 4]; - Word16 exc4k[L_FRAME16k / 4]; - Word16 exc4k_frac[L_FRAME16k / 4]; - Word32 exc4k_32[L_FRAME16k / 4]; - Word32 pow1, pow22; - Word16 scale; - Word32 excNoisyEnv[L_FRAME16k / 4]; - Word16 csfilt_num2[1] = { 1638 }; /* Q15*/ - Word16 neg_csfilt_den2[2] = { -32768, 31457 }; /* Q15 */ - Word32 L_tmp, Ltemp1, Ltemp2; - Word16 temp1, temp2, exp; - Word32 Lmax; - Word16 max_val, n1, n2, sc; - Word32 LepsP[LPC_WHTN_ORDER_WB + 1]; - Word16 tmp_vfac; - Word16 avg_voice_fac; - move16(); - move16(); - move16(); - - /*0.25f*sum_f(voice_factors, NB_SUBFR)*/ - L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); - FOR( i = 1; i < NB_SUBFR; i++ ) - { - L_tmp = L_mac( L_tmp, voice_factors[i], 8192 /*0.25 in Q15 */ ); - } - avg_voice_fac = round_fx( L_tmp ); - - test(); - test(); - test(); - test(); - IF( igf_flag != 0 && ( EQ_16( coder_type, VOICED ) || GT_16( avg_voice_fac, 11469 /* 0.35 in Q15 */ ) ) ) /*Q15 -> 0.35f*/ - { - csfilt_num2[0] = 6554; - move16(); /*Q15 -> 0.2f*/ - neg_csfilt_den2[1] = 26214; - move16(); /*Q15 -> 0.8f*/ - } - ELSE IF( igf_flag != 0 && ( EQ_16( coder_type, UNVOICED ) || LT_16( avg_voice_fac, 6654 /* 0.2 in Q15 */ ) ) ) /*Q15 -> 0.2f*/ - { - csfilt_num2[0] = 328; - move16(); /*Q15 -> 0.01f*/ - neg_csfilt_den2[1] = 32440; - move16(); /*Q15 -> 0.99f*/ - } - set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER_WB ); - Decimate_allpass_steep_fx( bwe_exc_extended, mem_genSHBexc_filt_down1, L_FRAME32k, excTmp ); - flip_spectrum_and_decimby4_fx( excTmp, exc4k, L_FRAME16k, mem_genSHBexc_filt_down2, mem_genSHBexc_filt_down3, 0 ); - - IF( uv_flag ) - { - create_random_vector_fx( exc4kWhtnd, L_FRAME16k / 4, bwe_seed, element_mode ); - IF( LT_16( Q_bwe_exc, 5 ) ) - { - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - exc4kWhtnd[i] = shl_r( exc4kWhtnd[i], sub( Q_bwe_exc, 5 ) ); /*Q(Q_bwe_exc)/Q5(if Q_bwe_exc > 5) */ - move16(); - } - } - } - ELSE - { - autocorr_fx( exc4k, LPC_WHTN_ORDER_WB + 1, R_h, R_l, &Q_R, - L_FRAME16k / 4, win_flatten_4k_fx, 0, 1 ); - - /* Ensure R[0] isn't zero when entering Levinson Durbin */ - R_l[0] = s_max( R_l[0], 1 ); - move16(); - FOR( i = 1; i <= LPC_WHTN_ORDER_WB; i++ ) - { - L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); - L_Extract( L_tmp, &R_h[i], &R_l[i] ); - } - - E_LPC_lev_dur_fx( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER_WB, NULL ); - - Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER_WB + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); - - fir_fx( exc4k, lpc_whtn, exc4kWhtnd, wht_fil_mem, L_FRAME16k / 4, - LPC_WHTN_ORDER_WB, 0, 3 ); - - /* Ensure pow1 is greater than zero when computing normalization */ - max_val = 0; - move16(); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - excTmp2[i] = abs_s( exc4kWhtnd[i] ); - move16(); /* Q_bwe_exc */ - max_val = s_max( max_val, excTmp2[i] ); - move16(); - } - - IF( max_val == 0 ) - { - pow1 = 1; - move16(); - n1 = 0; - move16(); - } - ELSE - { - n1 = norm_s( max_val ); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - excTmp2_frac[i] = shl( excTmp2[i], n1 ); - move16(); /* Q14 */ - } - n1 = sub( sub( 14, n1 ), Q_bwe_exc ); - pow1 = 1; - move32(); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - L_tmp = L_mult_sat( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ - pow1 = L_add_sat( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */ - } - } - - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - excNoisyEnv[i] = L_add_sat( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) ); - move32(); /* Q_bwe_exc+16 */ - *mem_csfilt = Mpy_32_16_1( excNoisyEnv[i], neg_csfilt_den2[1] ); - move32(); /* Q_bwe_exc+16 */ - } - - create_random_vector_fx( exc4k, L_FRAME16k / 4, bwe_seed, element_mode ); - - /* Ensure pow22 is greater than zero when computing normalization */ - Lmax = 0; - move32(); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - exc4k_32[i] = Mpy_32_16_1( excNoisyEnv[i], exc4k[i] ); - move32(); /* Q_bwe_exc+6 */ - Lmax = L_max( Lmax, L_abs( exc4k_32[i] ) ); - } - - IF( Lmax == 0 ) - { - pow22 = 1; - move16(); - n2 = 0; - move16(); - set16_fx( exc4k_frac, 0, L_FRAME16k / 4 ); - } - ELSE - { - n2 = norm_l( Lmax ); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */ - move16(); - } - n2 = sub( sub( 30, n2 ), add( Q_bwe_exc, 6 ) ); - pow22 = 1; - move32(); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - L_tmp = L_mult_sat( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ - pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22 */ - } - } - - test(); - test(); - IF( EQ_16( coder_type, UNVOICED ) || ( igf_flag != 0 && LT_16( avg_voice_fac, 6654 /*0.2 in Q15 */ ) ) ) - { - L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); - scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ - sc = sub( add( n2, Q_bwe_exc ), 14 ); - FOR( i = 0; i < L_FRAME16k / 4; i++ ) - { - exc4kWhtnd[i] = round_fx_sat( L_shl_sat( L_mult_sat( exc4k_frac[i], scale ), sc ) ); /* Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */ - move16(); - } - } - ELSE - { - sc = sub( add( n2, Q_bwe_exc ), 14 ); /* Q_bwe_exc+n2-14*/ - - k = 0; - move16(); - FOR( i = 0; i < 4; i++ ) - { - test(); - IF( igf_flag != 0 && EQ_16( coder_type, VOICED ) ) - { - /*tmp_vfac = 2*voice_factors[i]; - tmp_vfac = min(1, tmp_vfac);*/ - tmp_vfac = shl_sat( voice_factors[i], 1 ); - } - ELSE - { - tmp_vfac = voice_factors[i]; - move16(); - } - - Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp ); - temp1 = round_fx_sat( L_shl_sat( Ltemp1, exp ) ); /* Q15 */ - L_tmp = Mpy_32_16_1( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/ - Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp ); - temp2 = round_fx_sat( L_shl_sat( Ltemp2, exp ) ); /* Q15 */ - FOR( j = 0; j < L_FRAME16k / 16; j++ ) - { - L_tmp = L_mult_sat( temp1, exc4kWhtnd[k] ); /* Q(16+Q_bwe_exc) */ - L_tmp = L_add_sat( L_tmp, L_shl_sat( L_mult_sat( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */ - exc4kWhtnd[k] = round_fx_sat( L_tmp ); /* Q_bwe_exc */ - move16(); - k = add( k, 1 ); - } - } - } - } - - Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); - - return; -} -#endif /*-------------------------------------------------------------------* * GenWBSynth() @@ -2588,7 +2315,6 @@ void GenShapedSHBExcitation_fx( return; } -#ifdef HARMONIZE_TBE2 static void synthesis_enc_dec( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word16 shift, /* i : scaling to apply Q0 */ @@ -2612,14 +2338,9 @@ static void synthesis_enc_dec( return; } -#endif -#ifdef HARMONIZE_TBE2 void GenShapedSHBExcitation_ivas_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ -#else -void GenShapedSHBExcitation_ivas_enc_fx( -#endif Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ @@ -2718,7 +2439,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( Word16 delta; Word32 c0_part[NUM_SHB_SUBGAINS], c1_part[NUM_SHB_SUBGAINS], c2_part[NUM_SHB_SUBGAINS], c3_part[NUM_SHB_SUBGAINS], c4_part[NUM_SHB_SUBGAINS], c5_part[NUM_SHB_SUBGAINS]; Word64 W_tmp; -#ifdef HARMONIZE_TBE2 Word16 Q_temp, Q_exc16kWhtnd; Word16 chk1; Word32 chk2; @@ -2731,7 +2451,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move32(); (void) prev_bfi; -#endif mix_factor = 0; /* Q15 */ move16(); @@ -2787,10 +2506,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* Estimate pow1 associated with Low band nonlinear extended excitation */ /* pow1=0.00001f */ -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); W_tmp = W_shl( 21475 /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ FOR( k = 0; k < L_FRAME16k; k++ ) @@ -2805,7 +2522,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( exp = W_norm( W_tmp ); pow1 = W_extract_h( W_shl( W_tmp, exp ) ); // 2*Q_bwe_exc+1+exp-32 = // tmp+exp Q_pow1 = add( tmp, exp ); -#ifdef HARMONIZE_TBE2 } ELSE { @@ -2823,7 +2539,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } Q_pow1 = shl( *Q_bwe_exc, 1 ); } -#endif IF( flag_ACELP16k == 0 ) { @@ -2868,65 +2583,31 @@ void GenShapedSHBExcitation_ivas_enc_fx( neg_csfilt_den2[1] = varEnvShape; // Q15 move16(); -#ifndef HARMONIZE_TBE2 - test(); - test(); - test(); + IF( MSFlag > 0 ) + { + // varEnvShape = 0.995f; + varEnvShape = 32604; + move16(); + csfilt_num2[0] = 32768 - varEnvShape; + // csfilt_num2[0] = sub( 32767, varEnvShape ); + move16(); + neg_csfilt_den2[1] = varEnvShape; + move16(); + } + + White_exc16k = exc16k; + Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc ); + IF( *mem_csfilt ) + { + Q_excTmp2 = s_min( Q_excTmp2, sub( add( norm_l( *mem_csfilt ), *Q_bwe_exc ), 1 ) ); + } + test(); - IF( EQ_16( element_mode, EVS_MONO ) && *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) ) + /* Track the low band envelope */ + IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) { - /* pre-init smoothing filter to avoid energy drop outs */ - L_tmp = L_mult( excTmp2[0], 1638 ); - FOR( i = 1; i < L_SUBFR16k / 4; i++ ) - { - L_tmp = L_mac( L_tmp, excTmp2[i], 1638 ); /*1638 = 1/20 in Q15*/ - } - /*L_tmp = sum(excTmp2, L_SUBFR16k/4)*(1/20) where L_SUBFR16k/4 =20 */ - - /* don't apply for FB in case the FB start-frame was potentially lost - White_exc16k is very sensitive to enery mismatch between enc - dec */ - /* rather stick to the more conservative approach, to avoid potential clippings */ - test(); - IF( !( prev_bfi && EQ_16( extl, FB_TBE ) ) ) - { - /* use weak smoothing for 1st frame after switching to make filter recover more quickly */ - varEnvShape = 26214 /*0.8f Q15*/; - move16(); - csfilt_num2[0] = sub( MAX_16, varEnvShape ); - move16(); - neg_csfilt_den2[1] = varEnvShape; - move16(); - } - - *mem_csfilt = Mult_32_16( L_tmp, varEnvShape ); - move32(); - } - -#endif - IF( MSFlag > 0 ) - { - // varEnvShape = 0.995f; - varEnvShape = 32604; - move16(); - csfilt_num2[0] = 32768 - varEnvShape; - // csfilt_num2[0] = sub( 32767, varEnvShape ); - move16(); - neg_csfilt_den2[1] = varEnvShape; - move16(); - } - - White_exc16k = exc16k; - Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc ); - IF( *mem_csfilt ) - { - Q_excTmp2 = s_min( Q_excTmp2, sub( add( norm_l( *mem_csfilt ), *Q_bwe_exc ), 1 ) ); - } - - test(); - /* Track the low band envelope */ - IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - test(); - IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) ) + test(); + IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) ) { mem_csfilt_left = 0; mem_csfilt_right = 0; @@ -2998,10 +2679,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( } /* normalize the amplitude of the gaussian excitation to that of the LB exc. */ -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT; // Q31 move32(); move32(); @@ -3027,7 +2706,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); } -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3064,7 +2742,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#endif } ELSE { @@ -3083,10 +2760,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( } /* White_exc16k in Q6 */ -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif /* calculate pow22 */ /* pow22=0.00001f */ tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 ); @@ -3108,7 +2783,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( pow22 = W_extract_h( W_shl( W_tmp, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32 Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 ); Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) ); -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3133,7 +2807,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 ); Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) ); } -#endif } flag_plosive = 0; @@ -3399,10 +3072,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* save buffers for IC-BWE */ // mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k); Copy( exc16kWhtnd, nlExc16k, L_FRAME16k ); // Q_bwe_exc -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif *nlExc16k_e = sub( 15, *Q_bwe_exc ); move16(); @@ -3418,7 +3089,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } *mixExc16k_e = sub( 15, sub( Q_White_exc16k, exp ) ); move16(); -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3436,13 +3106,10 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#endif } -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif Copy( White_exc16k, White_exc16k_FB, L_FRAME16k ); // Q_White_exc16k prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; *Q_bwe_exc_fb = Q_White_exc16k; @@ -3459,7 +3126,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( /* i: tbe_demph_fx (Q_White_exc16k) */ *tbe_demph = shr_sat( tbe_demph_fx, sub( Q_White_exc16k, *Q_bwe_exc ) ); move16(); -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3491,7 +3157,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( *tbe_premph = shl_sat( *tbe_premph, sub( Q_White_exc16k, sub( *Q_bwe_exc, NOISE_QADJ ) ) ); move16(); } -#endif test(); IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) @@ -3500,17 +3165,14 @@ void GenShapedSHBExcitation_ivas_enc_fx( { /* re-scale gaussian excitation at the beginning to gradually move from old energy to new energy */ /* old_scale = (float) sqrt( *prev_pow_exc16kWhtnd / pow1 ); */ -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif old_scale = round_fx_sat( root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp ) ); // exp old_scale = shl( old_scale, s_min( 0, exp ) ); // limit Q factor to 15 exp = s_max( 0, exp ); // new_scale = 1.0f; new_scale = shr( 32767, exp ); // exp -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3521,7 +3183,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( new_scale = 32767; move16(); } -#endif // step_scale = (new_scale - old_scale) / (L_FRAME16k / 2); step_scale = mult_r( sub( new_scale, old_scale ), 205 ); // exp @@ -3542,10 +3203,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( shift = add( exp, sub( *Q_bwe_exc, Q_White_exc16k ) ); /* mixing of LB and gaussian excitation in the first half of the frame */ -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif FOR( k = 0; k < L_FRAME16k / 2; k++ ) { /* exc16kWhtnd[k] = (float)fact * (White_exc16k[k] * scale) + (float)(1 - fact) * exc16kWhtnd[k]; */ @@ -3566,7 +3225,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( exc16kWhtnd[k] = mac_r( L_tmp, sub( 32767, new_fact ), exc16kWhtnd[k] ); // Q_bwe_exc move16(); } -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3587,7 +3245,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#endif } preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc @@ -3597,10 +3254,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( test(); IF( EQ_16( coder_type, UNVOICED ) || EQ_16( MSFlag, 1 ) ) { -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif scale = 0; move16(); @@ -3618,7 +3273,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3636,7 +3290,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#endif preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } @@ -3698,10 +3351,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ } -#ifdef HARMONIZE_TBE2 IF( enc_dec == ENC ) { -#endif shift = sub( *Q_bwe_exc, Q_White_exc16k ); FOR( j = 0; j < lSubFr; j++ ) { @@ -3710,7 +3361,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); // Q_bwe_exc move16(); } -#ifdef HARMONIZE_TBE2 } ELSE { @@ -3722,7 +3372,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } -#endif k = add( k, lSubFr ); /* estimate the pre-emph factor */ @@ -3741,7 +3390,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( } } -#ifdef HARMONIZE_TBE2 IF( enc_dec == DEC ) { *tbe_premph = shl_sat( *tbe_premph, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); @@ -3749,15 +3397,10 @@ void GenShapedSHBExcitation_ivas_enc_fx( Scale_sig( White_exc16k, L_FRAME16k, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); } -#endif IF( LT_32( extl_brate, SWB_TBE_2k8 ) ) { -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); -#else - syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); -#endif /* i: exc16kWhtnd in Q_bwe_exc */ /* o: excSHB in Q_bwe_exc */ } @@ -3765,11 +3408,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( { set16_fx( zero_mem, 0, LPC_SHB_ORDER ); -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, tempSHB, 80, zero_mem, 1 ); -#else - syn_filt_fx( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, tempSHB, 80, zero_mem, 1 ); -#endif tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); Scale_sig( tempSHB, 80, tmp ); syn_shb_ener_sf[0] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); @@ -3777,11 +3416,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( syn_shb_ener_sf_q[0] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); move16(); -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, tempSHB, 80, zero_mem, 1 ); -#else - syn_filt_fx( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, tempSHB, 80, zero_mem, 1 ); -#endif tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); Scale_sig( tempSHB, 80, tmp ); syn_shb_ener_sf[1] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); @@ -3789,11 +3424,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( syn_shb_ener_sf_q[1] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); move16(); -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, tempSHB, 80, zero_mem, 1 ); -#else - syn_filt_fx( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, tempSHB, 80, zero_mem, 1 ); -#endif tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); Scale_sig( tempSHB, 80, tmp ); syn_shb_ener_sf[2] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); @@ -3801,11 +3432,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( syn_shb_ener_sf_q[2] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); move16(); -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, tempSHB, 80, zero_mem, 1 ); -#else - syn_filt_fx( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, tempSHB, 80, zero_mem, 1 ); -#endif tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); Scale_sig( tempSHB, 80, tmp ); syn_shb_ener_sf[3] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); @@ -3868,17 +3495,10 @@ void GenShapedSHBExcitation_ivas_enc_fx( } /* Do mem_stp_swb_fx scaling before PostShortTerm_fx */ -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, excSHB, 80, state_lpc_syn, 1 ); synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, excSHB + 80, 80, state_lpc_syn, 1 ); synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, excSHB + 160, 80, state_lpc_syn, 1 ); synthesis_enc_dec( enc_dec, 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, excSHB + 240, 80, state_lpc_syn, 1 ); -#else - syn_filt_fx( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, excSHB, 80, state_lpc_syn, 1 ); - syn_filt_fx( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, excSHB + 80, 80, state_lpc_syn, 1 ); - syn_filt_fx( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, excSHB + 160, 80, state_lpc_syn, 1 ); - syn_filt_fx( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, excSHB + 240, 80, state_lpc_syn, 1 ); -#endif /* i: exc16kWhtnd in (Q_bwe_exc) */ /* o: excSHB in (Q_bwe_exc) */ } @@ -3888,11 +3508,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( tmp = sub( add( *Q_bwe_exc_fb, 20 ), prev_Q_bwe_exc_fb ); Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp ); Scale_sig( fb_tbe_demph, 1, tmp ); -#ifdef HARMONIZE_TBE2 synthesis_enc_dec( enc_dec, 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 ); -#else - syn_filt_fx( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 ); -#endif /* i: White_exc16k_FB in (Q_bwe_exc_fb) / (14-n2)*/ /* o: White_exc16k_FB_temp in (Q_bwe_exc_fb) / (14-n2)*/ @@ -3924,1028 +3540,6 @@ void GenShapedSHBExcitation_ivas_enc_fx( return; } -#ifndef HARMONIZE_TBE2 -void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, /* i : bitrate */ - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - - - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling Q0 */ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling Q0 */ -) -{ - Word16 i, j, k; - Word16 wht_fil_mem[LPC_WHTN_ORDER]; - Word16 lpc_whtn[LPC_WHTN_ORDER + 1]; - Word16 R_h[LPC_WHTN_ORDER + 2]; /* Autocorrelations of windowed speech MSB */ - Word16 R_l[LPC_WHTN_ORDER + 2]; /* Autocorrelations of windowed speech LSB */ - Word16 Q_R; - Word32 LepsP[LPC_WHTN_ORDER + 1]; - Word16 exc32k[L_FRAME32k], exc16k[L_FRAME16k]; - Word32 pow1, pow22; - Word16 scale, temp1, temp2, temp3; - Word16 Q_White_exc16k; - Word16 excTmp2[L_FRAME16k]; - Word16 *White_exc16k; - Word16 excNoisyEnv[L_FRAME16k]; - Word16 csfilt_num2[1] = { 6554 }; /*0.2 in Q15 */ - move16(); - Word16 neg_csfilt_den2[2] = { -32767, 26214 }; /* {1.0f, -0.8f} */ - move16(); - move16(); - Word16 varEnvShape; - Word16 fb_deemph_fac = 15729; /*0.48f in Q15 */ - Word16 exc16kWhtnd[L_FRAME16k]; - - Word32 L_tmp; - Word16 vf_tmp; - Word16 tmp, exp, tmp2 = 0; - move16(); - Word16 voiceFacEst[NB_SUBFR16k]; - Word16 zero_mem[LPC_SHB_ORDER]; - Word32 syn_shb_ener_sf[4]; - Word16 syn_shb_ener_sf_q[4]; - Word16 tempSHB[80]; - Word16 Q_pow1, Q_pow22; - - Word32 L_tmp2, L_tmp3, L_tmp4; - Word16 temp; - - Word16 White_exc16k_FB_temp[L_FRAME16k]; - Word32 White_exc16k_32[L_FRAME16k]; - Word16 White_exc16k_tmp[L_FRAME16k]; - Word16 Q_temp; - Word16 prev_Q_bwe_exc_fb, Q_exc16kWhtnd; - Word16 chk1; - Word32 chk2; - chk1 = 0; - chk2 = 0; - move16(); - move32(); - - Word16 alpha, step, mem_csfilt_left, mem_csfilt_right, excNoisyEnvLeft[L_FRAME16k], excNoisyEnvRight[L_FRAME16k]; - Word16 cbsize; - Word16 mix_factor, old_fact, new_fact, fact, old_scale, new_scale, step_scale; - Word32 c0, c1, c2, c3, c4, c5, den; - Word16 g1, g2, g, g1_e, g2_e, g_e, den_e, shift, tmp_e, tmp1_e; - Word16 EnvWhiteExc16k[L_FRAME16k], EnvExc16kWhtnd[L_FRAME16k]; - Word16 EnvWhiteExc16k_4k[L_FRAME4k] = { 0 }, EnvExc16kWhtnd_4k[L_FRAME4k] = { 0 }; - Word16 flag_plosive; - Word16 delta; - Word32 c0_part[NUM_SHB_SUBGAINS], c1_part[NUM_SHB_SUBGAINS], c2_part[NUM_SHB_SUBGAINS], c3_part[NUM_SHB_SUBGAINS], c4_part[NUM_SHB_SUBGAINS], c5_part[NUM_SHB_SUBGAINS]; - Word64 W_tmp; - - mix_factor = 0; /* Q15 */ - move16(); - - set16_fx( zero_mem, 0, LPC_SHB_ORDER ); - set16_fx( wht_fil_mem, 0, LPC_WHTN_ORDER ); - FOR( i = 0; i < L_FRAME32k; i = i + 2 ) - { - exc32k[i] = negate( bwe_exc_extended[i] ); // Q_bwe_exc - move16(); - exc32k[i + 1] = bwe_exc_extended[i + 1]; // Q_bwe_exc - move16(); - } - - /* Decimate by 2 */ - Decimate_allpass_steep_fx( exc32k, mem_genSHBexc_filt_down_shb, 2 * L_FRAME16k, exc16k ); // Q_bwe_exc - /* i: exc32k in Q_bwe_exc */ - /* o: exc16k in Q_bwe_exc */ - - autocorr_fx( exc16k, LPC_WHTN_ORDER + 1, R_h, R_l, &Q_R, L_FRAME16k, win_flatten_fx, 0, 1 ); // Q_R - /* Ensure R[0] isn't zero when entering Levinson Durbin */ - R_l[0] = s_max( R_l[0], 1 ); - move16(); - FOR( i = 1; i <= LPC_WHTN_ORDER; i++ ) - { - L_tmp = Mpy_32( R_h[i], R_l[i], wac_h[i - 1], wac_l[i - 1] ); - L_Extract( L_tmp, &R_h[i], &R_l[i] ); // Q_R - } - E_LPC_lev_dur_fx( R_h, R_l, lpc_whtn, LepsP, LPC_WHTN_ORDER, NULL ); - Copy_Scale_sig( lpc_whtn, lpc_whtn, LPC_WHTN_ORDER + 1, sub( norm_s( lpc_whtn[0] ), 2 ) ); // Q12 - fir_fx( exc16k, lpc_whtn, exc16kWhtnd, wht_fil_mem, L_FRAME16k, LPC_WHTN_ORDER, 0, 3 ); // Q_bwe_exc - - /* i: exc16k in Q_bwe_exc */ - /* o: exc16kWhtnd in Q_bwe_exc */ - - IF( GE_32( extl_brate, SWB_TBE_2k8 ) ) - { - temp2 = 0; - move16(); - FOR( j = 0; j < 4; j++ ) - { - temp1 = shb_res_gshape[j]; - move16(); - FOR( i = 0; i < 80; i++ ) - { - exc16kWhtnd[temp2 + i] = round_fx( L_shl( L_mult( exc16kWhtnd[temp2 + i], temp1 ), 1 ) ); // Q_bwe_exc - move16(); - /* exc16kWhtnd in Q_bwe_exc, shb_res_gshape in Q14 */ - } - temp2 = add( temp2, 80 ); - } - } - - /* Estimate pow1 associated with Low band nonlinear extended excitation */ - /* pow1=0.00001f */ - tmp = sub( shl( *Q_bwe_exc, 1 ), 31 ); - pow1 = L_shl_sat( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(Q_bwe_exc) */ - FOR( k = 0; k < L_FRAME16k; k++ ) - { - /*excTmp2[k ] = (float)(fabs(exc16kWhtnd[k]));*/ - excTmp2[k] = abs_s( exc16kWhtnd[k] ); - move16(); - chk1 = s_or( chk1, exc16kWhtnd[k] ); - - /* pow1 += exc16kWhtnd[k] * exc16kWhtnd[k]; */ - pow1 = L_mac0_sat( pow1, exc16kWhtnd[k], exc16kWhtnd[k] ); /* 2*Q_bwe_exc */ - } - Q_pow1 = shl( *Q_bwe_exc, 1 ); - - test(); - - IF( flag_ACELP16k == 0 ) - { - /* varEnvShape = mean_fx(voice_factors, 4); */ - /* unroll the loop */ - L_tmp = L_mult( voice_factors[0], 8192 /*0.25 in Q15 */ ); - L_tmp = L_mac( L_tmp, voice_factors[1], 8192 /*0.25 in Q15 */ ); - L_tmp = L_mac( L_tmp, voice_factors[2], 8192 /*0.25 in Q15 */ ); - varEnvShape = mac_r( L_tmp, voice_factors[3], 8192 /*0.25 in Q15 */ ); /* varEnvShape in Q15 */ - } - ELSE /* 16k core */ - { - /* varEnvShape = mean_fx(voice_factors, 5); */ - /* unroll the loop */ - L_tmp = L_mult( voice_factors[0], 6554 /*0.2 in Q15 */ ); - L_tmp = L_mac( L_tmp, voice_factors[1], 6554 /*0.2 in Q15 */ ); - L_tmp = L_mac( L_tmp, voice_factors[2], 6554 /*0.2 in Q15 */ ); - L_tmp = L_mac( L_tmp, voice_factors[3], 6554 /*0.2 in Q15 */ ); - varEnvShape = mac_r( L_tmp, voice_factors[4], 6554 /*0.2 in Q15 */ ); /* varEnvShape in Q15 */ - } - - IF( EQ_16( extl, FB_TBE ) ) - { - /*pow(varEnvShape,3) */ - tmp = mult_r( varEnvShape, varEnvShape ); - tmp = mult_r( tmp, varEnvShape ); - - /* max_val((0.68f - (float)pow(varEnvShape, 3)), 0.48f); */ - fb_deemph_fac = sub( 22282 /*0.68f Q15*/, tmp ); - fb_deemph_fac = s_max( fb_deemph_fac, 15729 /*0.48f Q15*/ ); - } - - /*varEnvShape = 1.09875f - 0.49875f * varEnvShape; */ - varEnvShape = msu_r( 1179773824l /*0.549375f Q31*/, 8172 /*0.249375f Q15*/, varEnvShape ); - - /*varEnvShape = min( max_val(varEnvShape, 0.6f), 0.999f); */ - varEnvShape = s_max( varEnvShape, 9830 /*0.3f Q15*/ ); - varEnvShape = s_min( varEnvShape, 16368 /*0.4995f Q15*/ ); - varEnvShape = shl( varEnvShape, 1 ); - csfilt_num2[0] = sub( MAX_16, varEnvShape ); // Q15 - move16(); - neg_csfilt_den2[1] = varEnvShape; // Q15 - move16(); - - test(); - test(); - test(); - - IF( EQ_16( element_mode, EVS_MONO ) && *mem_csfilt == 0 && ( ( EQ_32( bitrate, ACELP_9k60 ) ) || ( EQ_32( bitrate, ACELP_16k40 ) ) || ( EQ_32( bitrate, ACELP_24k40 ) ) ) ) - { - /* pre-init smoothing filter to avoid energy drop outs */ - L_tmp = L_mult( excTmp2[0], 1638 ); - FOR( i = 1; i < L_SUBFR16k / 4; i++ ) - { - L_tmp = L_mac( L_tmp, excTmp2[i], 1638 ); /*1638 = 1/20 in Q15*/ - } - /*L_tmp = sum(excTmp2, L_SUBFR16k/4)*(1/20) where L_SUBFR16k/4 =20 */ - - /* don't apply for FB in case the FB start-frame was potentially lost - White_exc16k is very sensitive to enery mismatch between enc - dec */ - /* rather stick to the more conservative approach, to avoid potential clippings */ - test(); - IF( !( prev_bfi && EQ_16( extl, FB_TBE ) ) ) - { - /* use weak smoothing for 1st frame after switching to make filter recover more quickly */ - varEnvShape = 26214 /*0.8f Q15*/; - move16(); - csfilt_num2[0] = sub( MAX_16, varEnvShape ); - move16(); - neg_csfilt_den2[1] = varEnvShape; - move16(); - } - - *mem_csfilt = Mult_32_16( L_tmp, varEnvShape ); - move32(); - } - - IF( MSFlag > 0 ) - { - // varEnvShape = 0.995f; - varEnvShape = 32604; - move16(); - csfilt_num2[0] = 32768 - varEnvShape; - // csfilt_num2[0] = sub( 32767, varEnvShape ); - move16(); - neg_csfilt_den2[1] = varEnvShape; - move16(); - } - - White_exc16k = exc16k; - move16(); - Word16 Q_excTmp2 = add( getScaleFactor16( excTmp2, L_FRAME16k ), *Q_bwe_exc ); - IF( *mem_csfilt ) - { - Q_excTmp2 = s_min( Q_excTmp2, sub( add( norm_l( *mem_csfilt ), *Q_bwe_exc ), 1 ) ); - } - test(); - /* Track the low band envelope */ - IF( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - test(); - IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) ) - { - mem_csfilt_left = 0; - mem_csfilt_right = 0; - move16(); - move16(); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - // excNoisyEnvLeft[k] = mem_csfilt_left + csfilt_num2[0] * excTmp2[k]; - excNoisyEnvLeft[k] = add( mem_csfilt_left, mult_r( csfilt_num2[0], shl( excTmp2[k], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2 - move16(); - // mem_csfilt_left = -csfilt_den2[1] * excNoisyEnvLeft[k]; - mem_csfilt_left = mult_r( neg_csfilt_den2[1], excNoisyEnvLeft[k] ); // Q_excTmp2 - // excNoisyEnvRight[L_FRAME16k - k - 1] = mem_csfilt_right + csfilt_num2[0] * excTmp2[L_FRAME16k - k - 1]; - excNoisyEnvRight[L_FRAME16k - k - 1] = add( mem_csfilt_right, mult_r( csfilt_num2[0], shl( excTmp2[L_FRAME16k - k - 1], sub( Q_excTmp2, *Q_bwe_exc ) ) ) ); // Q_excTmp2 - move16(); - // mem_csfilt_right = -csfilt_den2[1] * excNoisyEnvRight[L_FRAME16k - k - 1]; - mem_csfilt_right = mult_r( neg_csfilt_den2[1], excNoisyEnvRight[L_FRAME16k - k - 1] ); // Q_excTmp2 - } - - alpha = 0; - move16(); - // step = 1.0f / L_FRAME16k; - step = 102; // Q15 - move16(); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - // excNoisyEnv[k] = alpha * excNoisyEnvLeft[k] + (1 - alpha) * excNoisyEnvRight[k]; - excNoisyEnv[k] = add( mult_r( alpha, excNoisyEnvLeft[k] ), mult_r( sub( 32767, alpha ), excNoisyEnvRight[k] ) ); // Q_excTmp2 - move16(); - alpha = add( alpha, step ); - } - } - } - ELSE - - { - /* Track the low band envelope */ - L_tmp = L_shl( *mem_csfilt, sub( Q_excTmp2, *Q_bwe_exc ) ); - move32(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - excNoisyEnv[i] = mac_r( L_tmp, csfilt_num2[0], shl( excTmp2[i], sub( Q_excTmp2, *Q_bwe_exc ) ) ); - move16(); - /* Work-around to avoid 0s for very small value*/ - test(); - test(); - test(); - test(); - if ( excNoisyEnv[i] == 0 && ( L_tmp != 0 || ( csfilt_num2[0] != 0 && excTmp2[i] != 0 ) ) ) - { - excNoisyEnv[i] = 1; - move16(); - } - /* excNoisyEnv : Q_excTmp2, - *mem_csfilt: Q_excTmp2+16, excTmp2: Q_excTmp2, csfilt_num2[0] Q_excTmp2 */ - L_tmp = L_mult( excNoisyEnv[i], neg_csfilt_den2[1] ); /* Q_excTmp2 + 16 */ - } - *mem_csfilt = L_shr( L_tmp, sub( Q_excTmp2, *Q_bwe_exc ) ); - move32(); - } - test(); - IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) - { - /* generate gaussian (white) excitation */ - FOR( k = 0; k < L_FRAME16k; k++ ) - { - White_exc16k[k] = own_random( &bwe_seed[0] ); - move16(); - } - - /* normalize the amplitude of the gaussian excitation to that of the LB exc. */ - Word32 pow22_inv = POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49; - move32(); - move32(); - pow22 = POW_EXC16k_WHTND_FX; - Q_pow22 = -6; - move16(); - // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), White_exc16k, L_FRAME16k); - Word16 pow1_exp = sub( Q31, Q_pow1 ); - Word32 temp_pow = Sqrt32( pow1, &pow1_exp ); - temp_pow = Mpy_32_32( temp_pow, pow22_inv ); - /*Word16 out_exp; - Word32 temp_pow1 = root_a_over_b_fx(pow1, Q_pow1, pow22, Q_pow22, &out_exp); - temp_pow1 = L_shl(temp_pow1, out_exp);*/ - // v_multc_fx_16_16(White_exc16k, round_fx(temp_pow), White_exc16k, L_FRAME16k); - L_tmp = 0; - move32(); - shift = getScaleFactor16( White_exc16k, L_FRAME16k ); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - White_exc16k_32[k] = Mpy_32_16_1( temp_pow, White_exc16k[k] ); - move32(); - White_exc16k[k] = round_fx( L_shl( White_exc16k_32[k], shift ) ); // Q_White_exc16k - move16(); - L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); - } - Q_White_exc16k = add( shift, sub( 49 - 31, pow1_exp ) ); - Q_temp = norm_l( L_tmp ); - IF( L_tmp == 0 ) - { - Q_temp = 31; - move16(); - } - } - ELSE - { - /* create a random excitation - Reuse exc16k memory */ - White_exc16k = exc16k; - move16(); - create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); // Q5 - create_random_vector_fx( White_exc16k + L_FRAME, L_FRAME16k - L_FRAME, bwe_seed, element_mode ); // Q5 - - L_tmp = L_deposit_l( 0 ); - tmp = add( *Q_bwe_exc, 1 ); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - L_tmp4 = L_mult( excNoisyEnv[k], White_exc16k[k] ); /* (Q_excTmp2) +5 +1*/ - White_exc16k_32[k] = L_tmp4; /* (Q_excTmp2) +5 +1*/ - move32(); - L_tmp = L_max( L_tmp, L_abs( White_exc16k_32[k] ) ); - } - Q_temp = norm_l( L_tmp ); - IF( L_tmp == 0 ) - { - Q_temp = 31; - move16(); - } - /*Copy_Scale_sig( White_exc16k, White_exc16k, L_FRAME16k, sub(NOISE_QFAC, 5) );)*/ - /* White_exc16k in Q6 */ - - /* calculate pow22 */ - /* pow22=0.00001f */ - tmp = sub( shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ), 31 ); - Word64 sum = W_shl( 21475l /*0.00001f Q31*/, tmp ); /* 0.00001f in 2*(*Q_bwe_exc-NOISE_QADJ) */ - Q_White_exc16k = getScaleFactor32( White_exc16k_32, L_FRAME16k ); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - - White_exc16k[k] = extract_h( L_shl( White_exc16k_32[k], Q_White_exc16k ) ); // Q_excTmp2 + 6 + Q_White_exc16k - 16 ==> Q_excTmp2 + Q_White_exc16k - 10 - chk2 = L_or( chk2, White_exc16k_32[k] ); - /* i: excNoisyEnv in (Q_excTmp2) */ - /* i: White_exc16k in Q6 */ - /* o: White_exc16k in (Q_White_exc16k) */ - /* pow22 += White_exc16k[k] * White_exc16k[k]; */ - sum = W_mac0_16_16( sum, White_exc16k[k], White_exc16k[k] ); /* 2*(Q_excTmp2 + Q_White_exc16k - 10)*/ - move16(); - } - Q_pow22 = W_norm( sum ); - pow22 = W_extract_h( W_shl( sum, Q_pow22 ) ); // 2*(Q_excTmp2 + Q_White_exc16k - 10)+Q_pow22-32 - Q_pow22 = sub( add( Q_pow22, shl( sub( add( Q_White_exc16k, Q_excTmp2 ), 10 ), 1 ) ), 32 ); - Q_White_exc16k = add( Q_White_exc16k, sub( Q_excTmp2, 10 ) ); - } - - flag_plosive = 0; - move16(); - test(); - test(); - test(); - IF( GE_32( extl_brate, SWB_TBE_2k8 ) || EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) - { - IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */ - { - test(); - IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) - { - FOR( k = 0; k < L_FRAME16k; k++ ) - { - White_exc16k_tmp[k] = round_fx( L_shl( White_exc16k_32[k], *Q_bwe_exc ) ); - move16(); - } - - /* calculate TD envelopes of exc16kWhtnd and White_exc16k */ - find_td_envelope_fx( White_exc16k_tmp, L_FRAME16k, 20, NULL, EnvWhiteExc16k ); /* Q_bwe_exc */ - find_td_envelope_fx( exc16kWhtnd, L_FRAME16k, 20, NULL, EnvExc16kWhtnd ); /* Q_bwe_exc */ - - FOR( k = 0; k < L_FRAME4k; k++ ) - { - EnvWhiteExc16k_4k[k] = EnvWhiteExc16k[4 * k]; /* Q_bwe_exc */ - move16(); - EnvExc16kWhtnd_4k[k] = EnvExc16kWhtnd[4 * k]; /* Q_bwe_exc */ - move16(); - } - - /* calculate the optimal mix factor */ - c0 = c1 = c2 = c3 = c4 = c5 = 0; /* Q0 */ - move32(); - move32(); - move32(); - move32(); - move32(); - move32(); - - temp1 = add( shl( *Q_bwe_exc, 1 ), 1 ); - temp2 = add( add( Q_shb, *Q_bwe_exc ), 1 ); - temp3 = add( shl( Q_shb, 1 ), 1 ); - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - // c0_part[i] = sum2_f( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c0_part[i] = L_shr( sum2_fx( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ), temp1 ); /* Q0 */ - move32(); - // c1_part[i] = -2.0f * dotp( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c1_part[i] = L_shr( L_negate( Dot_product( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ) ), sub( temp2, 1 ) ); /* Q0 */ - move32(); - // c2_part[i] = sum2_f( &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c2_part[i] = L_shr( sum2_fx( &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ), temp1 ); /* Q0 */ - move32(); - // c3_part[i] = -2.0f * dotp( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c3_part[i] = L_shr( L_negate( Dot_product( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ) ), sub( temp2, 1 ) ); /* Q0 */ - move32(); - // c4_part[i] = 2.0f * dotp( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c4_part[i] = L_shr( Dot_product( &EnvExc16kWhtnd_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], &EnvWhiteExc16k_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ), sub( temp1, 1 ) ); /* Q0 */ - move32(); - // c5_part[i] = sum2_f( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ); - c5_part[i] = L_shr( sum2_fx( &EnvSHBres_4k[i * L_FRAME4k / NUM_SHB_SUBGAINS], L_FRAME4k / NUM_SHB_SUBGAINS ), temp3 ); /* Q0 */ - move32(); - - c0 = L_add( c0, c0_part[i] ); - c1 = L_add( c1, c1_part[i] ); - c2 = L_add( c2, c2_part[i] ); - c3 = L_add( c3, c3_part[i] ); - c4 = L_add( c4, c4_part[i] ); - c5 = L_add( c5, c5_part[i] ); - } - - // den = 4.0f * c0 * c2 - c4 * c4; - W_tmp = W_sub( W_shl( W_mult0_32_32( c0, c2 ), 2 ), W_mult0_32_32( c4, c4 ) ); - den_e = 63; - move16(); - shift = W_norm( W_tmp ); - den = W_extract_h( W_shl( W_tmp, shift ) ); - den_e = sub( den_e, shift ); - - IF( den == 0 ) - { - den = 1; - move32(); - den_e = 31; - move16(); - } - - // g1 = ( c3 * c4 - 2 * c1 * c2 ) / den; - W_tmp = W_sub( W_mult0_32_32( c3, c4 ), W_shl( W_mult0_32_32( c1, c2 ), 1 ) ); - g1_e = 63; - move16(); - shift = W_norm( W_tmp ); - L_tmp = W_extract_h( W_shl( W_tmp, shift ) ); - g1_e = sub( g1_e, shift ); - - g1 = BASOP_Util_Divide3232_Scale( L_tmp, den, &tmp_e ); - g1_e = sub( add( tmp_e, g1_e ), den_e ); - - // g2 = ( c1 * c4 - 2 * c0 * c3 ) / den; - W_tmp = W_sub( W_mult0_32_32( c1, c4 ), W_shl( W_mult0_32_32( c0, c3 ), 1 ) ); - g2_e = 63; - move16(); - shift = W_norm( W_tmp ); - L_tmp = W_extract_h( W_shl( W_tmp, shift ) ); - g2_e = sub( g2_e, shift ); - - g2 = BASOP_Util_Divide3232_Scale( L_tmp, den, &tmp_e ); - g2_e = sub( add( tmp_e, g2_e ), den_e ); - - // *Env_error = 0.0f; - *Env_error = 0; - move16(); - flag_plosive = 0; - move16(); - FOR( i = 0; i < NUM_SHB_SUBGAINS; i++ ) - { - // Env_error_part[i] = c5_part[i] + g1 * g1 * c0_part[i] + g1 * c1_part[i] + g2 * g2 * c2_part[i] + g2 * c3_part[i] + g1 * g2 * c4_part[i]; - L_tmp = BASOP_Util_Add_Mant32Exp( c5_part[i], 31, Mpy_32_32( L_mult( g1, g1 ), c0_part[i] ), add( shl( g1_e, 1 ), 31 ), &tmp_e ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, tmp_e, Mpy_32_16_1( c1_part[i], g1 ), add( 31, g1_e ), &tmp_e ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, tmp_e, Mpy_32_32( L_mult( g2, g2 ), c2_part[i] ), add( shl( g2_e, 1 ), 31 ), &tmp_e ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, tmp_e, Mpy_32_16_1( c3_part[i], g2 ), add( 31, g2_e ), &tmp_e ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, tmp_e, Mpy_32_32( L_mult( g1, g2 ), c4_part[i] ), add( add( g1_e, g2_e ), 31 ), &tmp_e ); - - // Env_error_part[i] = L_shr( L_tmp, 31 - tmp_e ); // Check Exponent - Env_error_part[i] = extract_h( L_shr_sat( L_tmp, sub( Q15, tmp_e ) ) ); /* Q0 */ - move16(); - - // *Env_error += Env_error_part[i]; - *Env_error = add_sat( *Env_error, Env_error_part[i] ); /* Q0 */ - move16(); - - if ( GT_16( Env_error_part[i], THR_ENV_ERROR_PLOSIVE_FX ) ) // Check which Q - { - /* envelope error is too high -> likely a plosive */ - flag_plosive = 1; - move16(); - } - } - - IF( flag_plosive ) - { - /* plosive detected -> set the mixing factor to 0 */ - *vf_ind = 0; - move16(); - mix_factor = 0; - move16(); - } - ELSE - { - /* normalize gain */ - // g = g2 / ( g1 + g2 ); - tmp1_e = BASOP_Util_Add_MantExp( g1, g1_e, g2, g2_e, &tmp ); - IF( tmp == 0 ) - { - tmp = 1; - move16(); - tmp1_e = 15; - move16(); - } - g = BASOP_Util_Divide1616_Scale( g2, tmp, &tmp_e ); - g_e = sub( add( tmp_e, g2_e ), tmp1_e ); - - /* quantization of the mixing factor */ - cbsize = 1 << NUM_BITS_SHB_VF; - move16(); - // delta = 1.0f / ( cbsize - 1 ); - delta = 2341; /* Q14 */ - move16(); - // if ( g > 1.0f ) - IF( BASOP_Util_Cmp_Mant32Exp( g, add( 16, g_e ), ONE_IN_Q31, 0 ) > 0 ) - { - // g = 1.0f; - g = MAX16B; /* Q15 */ - } - // else if ( g < shl( delta, ( 15 - g_e ) - 14 ) ) - ELSE IF( BASOP_Util_Cmp_Mant32Exp( g, add( 16, g_e ), delta, 17 ) < 0 ) - { - /* prevent low gains to be quantized to 0 as this is reserved for plosives */ - // g = delta; - g = shl( delta, 1 ); /* Q15 */ - } - - *vf_ind = usquant_fx( g, &mix_factor, 0, delta, cbsize ); - move16(); - } - } - ELSE - { - Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, - ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); - tmp = voiceFacEst[0]; - tmp2 = MAX_16; - move16(); - move16(); - if ( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) - { - tmp2 = 26214 /*0.8f Q15*/; - move16(); - } - } - } - ELSE /* decoder side */ - { - test(); - IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) - { - IF( *vf_ind == 0 ) - { - // mix_factor = 0.0f; - mix_factor = 0; - move16(); - flag_plosive = 1; - move16(); - } - ELSE - { - // mix_factor = usdequant(*vf_ind, 0.0f, 1.0f / ((1 << NUM_BITS_SHB_VF) - 1)); - mix_factor = usdequant_fx( *vf_ind, 0, 2341 ); - } - } - ELSE - { - /* *vf_ind is an integer scale by 0.125f*/ - tmp = shl( *vf_ind, ( 15 - 3 ) ); - tmp2 = MAX_16; - move16(); - IF( LE_16( tmp, 22938 /*0.7f Q15*/ ) ) - { - tmp2 = 26214 /*0.8f Q15*/; - move16(); - } - } - } - test(); - IF( NE_32( extl_brate, SWB_TBE_1k10 ) && NE_32( extl_brate, SWB_TBE_1k75 ) ) - { - voice_factors[0] = mult_r( voice_factors[0], tmp2 ); - move16(); - voice_factors[1] = mult_r( voice_factors[1], tmp2 ); - move16(); - voice_factors[2] = mult_r( voice_factors[2], tmp2 ); - move16(); - voice_factors[3] = mult_r( voice_factors[3], tmp2 ); - move16(); - voice_factors[4] = mult_r( voice_factors[4], tmp2 ); - move16(); - } - } - test(); - IF( GE_16( element_mode, IVAS_CPE_DFT ) && nlExc16k != NULL ) - { - /* save buffers for IC-BWE */ - // mvr2r(exc16kWhtnd, nlExc16k, L_FRAME16k); - Copy( exc16kWhtnd, nlExc16k, L_FRAME16k ); - // v_multc(White_exc16k, (float)sqrt(pow1 / pow22), mixExc16k, L_FRAME16k); - /*Word16 temp_fac = divide3232(L_shr(pow1, Q_pow1), pow22); - Word16 temp_fac_exp = 0; - temp_fac = Sqrt16(temp_fac, &temp_fac_exp);*/ - L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); - Word16 temp_fac = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 - shift = sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ); - // v_multc_fx_16_16(White_exc16k,shr(temp_fac, temp_fac_exp) , mixExc16k, L_FRAME16k); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - mixExc16k[k] = mult_r( shl_sat( White_exc16k[k], shift ), temp_fac ); - move16(); - } - } - - tmp = sub( Q_temp, 3 ); - FOR( k = 0; k < L_FRAME16k; k++ ) - { - White_exc16k_FB[k] = White_exc16k[k]; /* Q_White_exc16k */ - } - prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; - move16(); - *Q_bwe_exc_fb = Q_White_exc16k; - move16(); - *tbe_demph = shl_sat( *tbe_demph, sub( Q_White_exc16k, sub( *Q_bwe_exc, NOISE_QADJ ) ) ); - deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); - *tbe_demph = shl_sat( *tbe_demph, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); - - Q_exc16kWhtnd = getScaleFactor16( exc16kWhtnd, L_FRAME16k ); - Q_exc16kWhtnd = add( Q_exc16kWhtnd, *Q_bwe_exc ); - - shift = getScaleFactor16( White_exc16k, L_FRAME16k ); - - shift = s_min( Q_exc16kWhtnd, add( shift, Q_White_exc16k ) ); - scale_sig( exc16kWhtnd, L_FRAME16k, sub( shift, *Q_bwe_exc ) ); - scale_sig( White_exc16k, L_FRAME16k, sub( shift, Q_White_exc16k ) ); - - Q_exc16kWhtnd = Q_White_exc16k = shift; - move16(); - move16(); - *tbe_premph = shl_sat( *tbe_premph, sub( Q_White_exc16k, sub( *Q_bwe_exc, NOISE_QADJ ) ) ); - move16(); - test(); - IF( EQ_32( extl_brate, SWB_TBE_1k10 ) || EQ_32( extl_brate, SWB_TBE_1k75 ) ) - { - IF( !flag_plosive ) /* use only LB excitation in case of plosives */ - { - /* re-scale gaussian excitation at the beginning to gradually move from old energy to new energy */ - // old_scale = (float)sqrt(*prev_pow_exc16kWhtnd / pow1); - // old_scale = divide3232(*prev_pow_exc16kWhtnd, pow1); // exp = Q15 - (Q_pow1) - // Word16 old_scale_exp = Q15 - (Q_pow1); - // old_scale = Sqrt16(old_scale, &old_scale_exp); - // old_scale = shl(old_scale, old_scale_exp); //Q15 - L_tmp = root_a_over_b_fx( *prev_pow_exc16kWhtnd, 0, pow1, Q_pow1, &exp ); - old_scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); // Q15 - // new_scale = 1.0f; - new_scale = 32767; - move16(); - // step_scale = (new_scale - old_scale) / (L_FRAME16k / 2); - step_scale = mult_r( sub( new_scale, old_scale ), 205 ); - scale = old_scale; - move16(); - /* interpolate between the old and the new value of the mixing factor */ - old_fact = *prev_mix_factor; - move16(); - new_fact = mix_factor; - move16(); - // step = (new_fact - old_fact) / (L_FRAME16k / 2); - step = mult_r( sub( new_fact, old_fact ), 205 ); - fact = old_fact; - move16(); - /* mixing of LB and gaussian excitation in the first half of the frame */ - FOR( k = 0; k < L_FRAME16k / 2; k++ ) - { - exc16kWhtnd[k] = mac_r( L_mult( fact, mult_r( White_exc16k[k], scale ) ), - sub( 32767, fact ), exc16kWhtnd[k] ); // Q_exc16kWhtnd - move16(); - fact = add_sat( fact, step ); - scale = add_sat( scale, step_scale ); - } - - /* mixing of LB and gaussian excitation in the second half of the frame */ - FOR( ; k < L_FRAME16k; k++ ) - { - exc16kWhtnd[k] = mac_r( L_mult( new_fact, White_exc16k[k] ), - sub( 32767, new_fact ), exc16kWhtnd[k] ); // Q_exc16kWhtnd - move16(); - } - } - - preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - } - ELSE - { - test(); - IF( EQ_16( coder_type, UNVOICED ) || EQ_16( MSFlag, 1 ) ) - { - L_tmp = root_a_over_b_fx( pow1, Q_pow1, pow22, Q_pow22, &exp ); - test(); - if ( chk1 == 0 && chk2 == 0 ) - { - L_tmp = 0; - move32(); - } - scale = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ - FOR( k = 0; k < L_FRAME16k; k++ ) - { - exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale ); - move16(); - } - preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_exc16kWhtnd - } - ELSE - { - Word16 nbSubFr, lSubFr; - Word16 tempQ15; - Word32 tempQ31; - nbSubFr = NB_SUBFR16k; - lSubFr = ( L_FRAME16k / NB_SUBFR16k ); - move16(); - move16(); - IF( LT_32( extl_brate, SWB_TBE_2k8 ) ) - { - nbSubFr = NB_SUBFR; - move16(); - lSubFr = ( L_FRAME16k / NB_SUBFR ); - move16(); - } - k = 0; - move16(); - FOR( i = 0; i < nbSubFr; i++ ) - { - test(); - IF( EQ_16( coder_type, VOICED ) && ( LT_32( extl_brate, SWB_TBE_2k8 ) ) ) - { - exp = 0; - move16(); - tempQ15 = Sqrt16( voice_factors[i], &exp ); /* Q15 */ - temp = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ - exp = 0; - move16(); - tempQ15 = Sqrt16( temp, &exp ); /* Q15 */ - temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ - - /*temp2 = root_a_over_b_fx( pow1 * (1.0f - temp), pow22 ); */ - temp = sub( MAX_16, temp ); - tempQ31 = Mult_32_16( pow1, temp ); - L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); - temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ - } - ELSE - { - /* Adjust noise mixing for formant sharpening filter */ - tempQ15 = mult_r( SWB_NOISE_MIX_FAC_FX, formant_fac ); - /* vf_tmp = voice_factors[i] * (1.0f - vf_tmp); */ - vf_tmp = sub( MAX_16, tempQ15 ); - vf_tmp = mult( voice_factors[i], vf_tmp ); - - exp = 0; - move16(); - tempQ15 = Sqrt16( vf_tmp, &exp ); /* Q15 */ - temp1 = shl( tempQ15, exp ); /* Q15 exc16kWhtnd scale factor */ - - /*temp2 = root_a_over_b(pow1 * (1.0f - vf_tmp), pow22); */ - temp = sub( MAX_16, vf_tmp ); - tempQ31 = Mult_32_16( pow1, temp ); - L_tmp = root_a_over_b_fx( tempQ31, Q_pow1, pow22, Q_pow22, &exp ); - temp2 = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q15 whiteEnvShapedExc scale factor */ - } - - FOR( j = 0; j < lSubFr; j++ ) - { - /*exc16kWhtnd[k+j] = temp1 * exc16kWhtnd[k+j] + temp2 * White_exc16k[k+j]; */ - L_tmp = L_mult( temp2, White_exc16k[k + j] ); - exc16kWhtnd[k + j] = mac_r_sat( L_tmp, temp1, exc16kWhtnd[k + j] ); - move16(); - /* Q_exc16kWhtnd */ - } - k = add( k, lSubFr ); - - /* estimate the pre-emph factor */ - tempQ15 = sub( MAX_16, voice_factors[i] ); - exp = 0; - move16(); - temp = Sqrt16( tempQ15, &exp ); - temp = shl( temp, sub( exp, 1 ) ); - - temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */ - temp = div_s( temp, temp2 ); /* Q15 */ - temp = mult_r( PREEMPH_FAC, temp ); - preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_exc16kWhtnd - } - } - } - *tbe_premph = shl_sat( *tbe_premph, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); - move16(); - Scale_sig( White_exc16k, L_FRAME16k, sub( sub( *Q_bwe_exc, NOISE_QADJ ), Q_White_exc16k ) ); - Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); - - IF( LT_32( extl_brate, SWB_TBE_2k8 ) ) - { - Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, exc16kWhtnd, excSHB, L_FRAME16k, state_lpc_syn, 1 ); - /* i: exc16kWhtnd in Q_bwe_exc */ - /* o: excSHB in Q_bwe_exc */ - } - ELSE - { - set16_fx( zero_mem, 0, LPC_SHB_ORDER ); - - Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, tempSHB, 80, zero_mem, 1 ); - tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); - Scale_sig( tempSHB, 80, tmp ); - syn_shb_ener_sf[0] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); - move32(); - syn_shb_ener_sf_q[0] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); - move16(); - - Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, tempSHB, 80, zero_mem, 1 ); - tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); - Scale_sig( tempSHB, 80, tmp ); - syn_shb_ener_sf[1] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); - move32(); - syn_shb_ener_sf_q[1] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); - move16(); - - Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, tempSHB, 80, zero_mem, 1 ); - tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); - Scale_sig( tempSHB, 80, tmp ); - syn_shb_ener_sf[2] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); - move32(); - syn_shb_ener_sf_q[2] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); - move16(); - - Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, tempSHB, 80, zero_mem, 1 ); - tmp = sub( getScaleFactor16( tempSHB, 80 ), 2 ); - Scale_sig( tempSHB, 80, tmp ); - syn_shb_ener_sf[3] = L_shr( sum2_fx( tempSHB, 80 ), 3 ); - move32(); - syn_shb_ener_sf_q[3] = add( shl( add( *Q_bwe_exc, tmp ), 1 ), 1 ); - move16(); - - tmp2 = s_min( s_min( syn_shb_ener_sf_q[0], syn_shb_ener_sf_q[1] ), s_min( syn_shb_ener_sf_q[3], syn_shb_ener_sf_q[2] ) ); - syn_shb_ener_sf[0] = L_shl( syn_shb_ener_sf[0], sub( tmp2, syn_shb_ener_sf_q[0] ) ); - move32(); - syn_shb_ener_sf[1] = L_shl( syn_shb_ener_sf[1], sub( tmp2, syn_shb_ener_sf_q[1] ) ); - move32(); - syn_shb_ener_sf[2] = L_shl( syn_shb_ener_sf[2], sub( tmp2, syn_shb_ener_sf_q[2] ) ); - move32(); - syn_shb_ener_sf[3] = L_shl( syn_shb_ener_sf[3], sub( tmp2, syn_shb_ener_sf_q[3] ) ); - move32(); - - /* i: exc16kWhtnd in Q_bwe_exc */ - /* o: tempSHB in Q_bwe_exc */ - /* o: syn_shb_ener_sf in tmp2 */ - IF( LE_32( bitrate, MAX_ACELP_BRATE ) ) - { - L_tmp = sum32_fx( syn_shb_ener_sf, 4 ); - - /* find root_a(tempSHB[0]) = root_a_over_b(shb_ener_sf[0]), L_tmp) */ - tmp = shl( Q_shb, 1 ); - L_tmp2 = root_a_over_b_fx( shb_ener_sf_32, tmp, L_tmp, tmp2, &exp ); /* L_tmp2 in (Q31-exp) */ - - *Q_bwe_exc = sub( *Q_bwe_exc, exp ); - move16(); /* compensate for the exp shift */ - tmp2 = add( prev_Q_bwe_syn, n_mem2 ); - IF( GT_16( *Q_bwe_exc, tmp2 ) ) - { - L_tmp2 = L_shl( L_tmp2, sub( tmp2, *Q_bwe_exc ) ); - *Q_bwe_exc = tmp2; - move16(); - } - FOR( i = 0; i < L_FRAME16k; i++ ) - { - L_tmp3 = Mult_32_16( L_tmp2, exc16kWhtnd[i] ); /* *Q_bwe_exc + (31-exp) - 15 */ - exc16kWhtnd[i] = round_fx( L_tmp3 ); /* *Q_bwe_exc - exp */ - move16(); - } - } - /* i: L_tmp2 in (Q31-exp) */ - /* i: exc16kWhtnd in Q_bwe_exc */ - /* o: exc16kWhtnd in Q_bwe_exc: (Q_bwe_exc-exp) */ - - /* Rescale the past memories: LP synth and SHB look ahead buffers */ - tmp = sub( *Q_bwe_exc, prev_Q_bwe_syn ); - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - state_lpc_syn[i] = shl_sat( state_lpc_syn[i], tmp ); - move16(); - } - FOR( i = -L_SHB_LAHEAD; i < 0; i++ ) - { - excSHB[i] = shl_sat( excSHB[i], tmp ); - move16(); - } - /* Do mem_stp_swb_fx scaling before PostShortTerm_fx */ - - Syn_filt_s( 0, lpc_shb_sf, LPC_SHB_ORDER, exc16kWhtnd, excSHB, 80, state_lpc_syn, 1 ); - Syn_filt_s( 0, lpc_shb_sf + ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 80, excSHB + 80, 80, state_lpc_syn, 1 ); - Syn_filt_s( 0, lpc_shb_sf + 2 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 160, excSHB + 160, 80, state_lpc_syn, 1 ); - Syn_filt_s( 0, lpc_shb_sf + 3 * ( LPC_SHB_ORDER + 1 ), LPC_SHB_ORDER, exc16kWhtnd + 240, excSHB + 240, 80, state_lpc_syn, 1 ); - /* i: exc16kWhtnd in (Q_bwe_exc) */ - /* o: excSHB in (Q_bwe_exc) */ - } - - IF( EQ_16( extl, FB_TBE ) ) - { - tmp = sub( add( *Q_bwe_exc_fb, 20 ), prev_Q_bwe_exc_fb ); - Scale_sig( fb_state_lpc_syn, LPC_SHB_ORDER, tmp ); - Scale_sig( fb_tbe_demph, 1, tmp ); - Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER, White_exc16k_FB, White_exc16k_FB_temp, L_FRAME16k, fb_state_lpc_syn, 1 ); - /* i: White_exc16k_FB in (14-n2) */ - /* o: White_exc16k_FB_temp in (14-n2) */ - - FOR( i = 0; i < 10; i++ ) - { - FOR( j = 0; j < 32; ++j ) - { - White_exc16k_FB_temp[i * 32 + j] = mult_r_sat( White_exc16k_FB_temp[i * 32 + j], cos_fb_exc_fx[j] ); - move16(); - } - } - - *Q_bwe_exc_fb = add( *Q_bwe_exc_fb, 20 ); - move16(); /**Q_bwe_exc_fb +35 +1 -16*/ - flip_spectrum_fx( White_exc16k_FB_temp, White_exc16k_FB, L_FRAME16k ); - - deemph_fx( White_exc16k_FB, fb_deemph_fac, L_FRAME16k, fb_tbe_demph ); - } - ELSE - { - set16_fx( White_exc16k_FB, 0, L_FRAME16k ); - } - - *prev_pow_exc16kWhtnd = L_shr_sat( pow1, Q_pow1 ); // power goes above MAX_32 - *prev_mix_factor = mix_factor; - return; -} -#endif /*====================================================================================*/ /* FUNCTION : void GenSHBSynth_fx() */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index cb0a565d0..c761d8ebc 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -945,27 +945,10 @@ void wb_tbe_dec_fx( Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); -#ifdef HARMONIZE_TBE2 GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, - hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, - bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); - } - ELSE - { - GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, - hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, coder_type, st_fx->element_mode, - bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified, uv_flag, st_fx->igf ); - } -#endif curr_pow = 0; move32(); @@ -5410,7 +5393,6 @@ void swb_tbe_dec_ivas_fx( { Copy( hBWE_TD->state_syn_shbexc_fx, shaped_shb_excitation_fx, L_SHB_LAHEAD ); -#ifdef HARMONIZE_TBE2 GenShapedSHBExcitation_ivas_fx( DEC, shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, @@ -5419,16 +5401,6 @@ void swb_tbe_dec_ivas_fx( &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, st->element_mode, st->flag_ACELP16k, nlExc16k_fx, NULL, mixExc16k_fx, NULL, st->extl_brate, MSFlag, NULL, 0, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); -#else - GenShapedSHBExcitation_ivas_dec_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, - hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, - st->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st->extl, - &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_32, - shb_res_gshape_fx, shb_res_dummy_fx, &vind, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, - &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, &Q_bwe_exc_fb, Q_shb, n_mem2, hBWE_TD->prev_Q_bwe_syn, st->total_brate, st->prev_bfi, - st->element_mode, st->flag_ACELP16k, nlExc16k_fx, mixExc16k_fx, st->extl_brate, MSFlag, - NULL, &( hBWE_TD->prev_pow_exc16kWhtnd_fx32 ), &( hBWE_TD->prev_mix_factor_fx ), NULL, NULL ); -#endif } *Q_white_exc = Q_bwe_exc_fb; diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index e6e934ec8..82e6b5ce2 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -416,12 +416,7 @@ ivas_error evs_enc_fx( IF( GE_32( st->input_Fs, 16000 ) && ( LT_16( st->bwidth, SWB ) ) ) { /* Common pre-processing for WB TBE and WB BWE */ -#ifdef HARMONIZE_TBE2 wb_pre_proc_fx( st, EVS_MONO, new_inp_resamp16k, hb_speech ); -#else - wb_pre_proc_fx( st, new_inp_resamp16k, hb_speech ); - /* o: new_inp_resamp16k at Q = -1 */ -#endif } IF( EQ_16( st->extl, WB_TBE ) ) @@ -452,11 +447,7 @@ ivas_error evs_enc_fx( IF( !st->Opt_SC_VBR && GE_32( st->input_Fs, 32000 ) ) { /* Common pre-processing for SWB(FB) TBE and SWB BWE */ -#ifdef HARMONIZE_TBE2 swb_pre_proc_fx( st, new_swb_speech, shb_speech, realBuffer, imagBuffer, 0, &cldfbScale, NULL ); -#else - swb_pre_proc_fx( st, st->input_fx, new_swb_speech, shb_speech, &Q_shb_spch, realBuffer, imagBuffer, &cldfbScale ); -#endif } ELSE IF( GE_32( st->input_Fs, 32000 ) ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 60dd1d1a3..571d405f6 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -625,11 +625,7 @@ ivas_error ivas_core_enc_fx( IF( GE_32( input_Fs, 16000 ) && LT_16( st->bwidth, SWB ) && st->hBWE_TD != NULL ) { /* Common pre-processing for WB TBE and WB BWE */ -#ifdef HARMONIZE_TBE2 wb_pre_proc_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx ); -#else - wb_pre_proc_ivas_fx( st, last_element_mode, new_inp_resamp16k_fx[n], hb_speech_fx ); -#endif } test(); @@ -672,43 +668,10 @@ ivas_error ivas_core_enc_fx( shb_speech_fx = new_inp_resamp16k_fx[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */ test(); -#ifdef HARMONIZE_TBE2 IF( GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL ) -#else - test(); - IF( !st->Opt_SC_VBR && GE_32( input_Fs, 32000 ) && st->hBWE_TD != NULL ) -#endif { /* Common pre-processing for SWB(FB) TBE and SWB(FB) BWE */ -#ifdef HARMONIZE_TBE2 swb_pre_proc_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], NULL, hCPE ); -#else - /* Scaling cldfb_state_fx */ - Word16 q_shift, scf_cldfb; - scf_cldfb = L_norm_arr( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length ); - - scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, scf_cldfb ); - st->cldfbSynTd->Q_cldfb_state = add( st->cldfbSynTd->Q_cldfb_state, scf_cldfb ); - - q_shift = sub( sub( q_re_im_buf[n], 1 ), st->cldfbSynTd->Q_cldfb_state ); // cldfb_state_fx will be used in cldfbSynthesis_ivas_fx and has to be aligned with (q_re_im_buf[n] - 1) - IF( GT_32( q_shift, 0 ) ) - { - FOR( Word16 ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - scale_sig32( realBuffer_fx[n][ts], CLDFB_NO_CHANNELS_MAX, negate( q_shift ) ); - scale_sig32( imagBuffer_fx[n][ts], CLDFB_NO_CHANNELS_MAX, negate( q_shift ) ); - } - q_re_im_buf[n] = add( st->cldfbSynTd->Q_cldfb_state, 1 ); - } - ELSE - { - scale_sig32( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length, q_shift ); // st->cldfbSynTd->Q_cldfb_state -> q_realImagBuffer - st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); - } - swb_pre_proc_ivas_fx( st, new_swb_speech_fx_16, shb_speech_fx, realBuffer_fx[n], imagBuffer_fx[n], q_re_im_buf[n], hCPE ); - - st->cldfbSynTd->Q_cldfb_state = sub( q_re_im_buf[n], 1 ); -#endif } ELSE IF( GE_32( input_Fs, 32000 ) ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index fc3c7928c..cdf2414ec 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -554,7 +554,6 @@ void swb_CNG_enc_fx( ); void swb_pre_proc_fx( -#ifdef HARMONIZE_TBE2 Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0*/ @@ -563,16 +562,6 @@ void swb_pre_proc_fx( Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers*/ const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers */ CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -#else - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *input_fx, /* i : original i signal */ - Word16 *new_swb_speech_fx, /* o : original i signal at 32kHz */ - Word16 *shb_speech_fx, /* o : SHB target signal (6-14kHz) at 16kHz */ - Word16 *Q_shb_spch, /* o : shb target signal Q factor */ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */ - const CLDFB_SCALE_FACTOR *cldfbScale /* i : scale data of real and imag CLDFB buffers*/ -#endif ); void InitSWBencBufferStates_fx( @@ -663,14 +652,6 @@ void wb_bwe_enc_ivas_fx( ); void wb_pre_proc_fx( -#ifndef HARMONIZE_TBE2 - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_inp_resamp16k, /* i : original i signal */ - Word16 *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */ -); - -void wb_pre_proc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ const Word16 *new_inp_resamp16k, /* i : original input signal in Q-1 */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 9e27f0d74..5f85b1bf9 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -35,162 +35,6 @@ /*========================================================================*/ void wb_pre_proc_fx( -#ifndef HARMONIZE_TBE2 - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_inp_resamp16k, /* i : original input signal in Q-1 */ - Word16 *hb_speech /* o : HB target signal (6-8kHz) at 16kHz in Q-1 */ -) -{ - Word16 Sample_Delay_WB_BWE; - Word16 ramp_flag; - Word16 old_input[NS2SA( 16000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k]; - Word16 *highband_new_speech; - Word16 highband_old_speech[( L_LOOK_12k8 + L_SUBFR + L_FRAME ) * 5 / 16]; - Word16 temp_buf[320]; - Word16 Q_wb_sp, i, max_wb; - Word16 fSwitchFromIO = 0; - move16(); - Word32 temp1 = 0; - move32(); - Word32 temp2 = 0; - move32(); - SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_32( st_fx->last_total_brate, ACELP_6k60 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_8k85 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_12k65 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_14k25 ) ) || - ( EQ_32( st_fx->last_total_brate, ACELP_15k85 ) ) || - ( GE_32( st_fx->last_total_brate, ACELP_18k25 ) && LE_32( st_fx->last_total_brate, ACELP_23k85 ) ) ) - { - fSwitchFromIO = 1; - move16(); - } - - set16_fx( old_input, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); - - max_wb = 1; - move16(); - FOR( i = 0; i < L_FRAME16k; i++ ) - { - max_wb = s_max( max_wb, abs_s( new_inp_resamp16k[i] ) ); - } - Q_wb_sp = norm_s( max_wb ); - - Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, -3 ); - temp1 = L_mac0( temp1, temp_buf[0], temp_buf[0] ); - FOR( i = 1; i < L_FRAME16k; i++ ) - { - temp1 = L_mac0( temp1, temp_buf[i], temp_buf[i] ); - temp2 = L_mac0( temp2, temp_buf[i - 1], temp_buf[i] ); - } - - IF( temp2 < Mult_32_16( temp1, 31129 /*0.95f*/ ) ) - { - Q_wb_sp = sub( Q_wb_sp, 3 ); /* leave 3 bit headroom */ - } - Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, Q_wb_sp ); - Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp ); - Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), Q_wb_sp ); - /* temp_buf, and the memory states are in Q_wb_sp */ - - test(); - test(); - IF( EQ_16( st_fx->extl, WB_BWE ) || EQ_16( st_fx->extl, WB_TBE ) || st_fx->igf != 0 ) - { - ramp_flag = 0; - move16(); - - test(); - test(); - test(); - test(); - if ( ( NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, WB_BWE ) && st_fx->igf == 0 ) || - ( st_fx->igf != 0 && fSwitchFromIO != 0 ) ) - { - ramp_flag = 1; - move16(); - } - - IF( !hSC_VBR->ppp_mode ) - { - /* temp_buf is in Q_wb_sp - hb_speech and the two decimator memories are in Q_wb_sp */ - flip_spectrum_and_decimby4_fx( temp_buf, hb_speech, L_FRAME16k, hBWE_TD->decim_state1_fx, hBWE_TD->decim_state2_fx, ramp_flag ); - - /* rescale the hb_speech and memories back to Q-1 to keep the downstream BWE coding unaffected */ - Scale_sig( hb_speech, L_FRAME16k / 4, -Q_wb_sp ); - Scale_sig( hBWE_TD->decim_state1_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), -Q_wb_sp ); - Scale_sig( hBWE_TD->decim_state2_fx, ( 2 * ALLPASSSECTIONS_STEEP + 1 ), -Q_wb_sp ); - - IF( NE_16( st_fx->extl, WB_TBE ) ) - { - /* Update the previous wideband speech buffer in case of a WB_BWE frame */ - Sample_Delay_WB_BWE = ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16; - - highband_new_speech = highband_old_speech + Sample_Delay_WB_BWE; - Copy( hb_speech, highband_new_speech, L_FRAME16k / 4 ); - Copy( highband_old_speech + L_FRAME16k / 4, hBWE_TD->old_speech_wb_fx, Sample_Delay_WB_BWE ); - } - } - } - ELSE - { - set16_fx( hBWE_TD->decim_state1_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( hBWE_TD->decim_state2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); - } - - /* st->old_input_wb and st->old_wtda_wb must be updated each frame, or there are often some clicks during WB TBE <-> WB BWE switching */ - test(); - test(); - test(); - IF( ( NE_16( st_fx->extl, WB_BWE ) || ( EQ_16( st_fx->extl, WB_BWE ) && LE_32( st_fx->total_brate, ACELP_8k00 ) ) ) && !hSC_VBR->ppp_mode ) - { - Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); - - Copy( new_inp_resamp16k, &old_input[Sample_Delay_WB_BWE], L_FRAME16k ); - Copy( hBWE_FD->old_input_wb_fx, old_input, Sample_Delay_WB_BWE ); - Copy( new_inp_resamp16k + L_FRAME16k - Sample_Delay_WB_BWE, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE ); - Copy( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k ); - } - return; -} - - -/*========================================================================*/ -/* FUNCTION : wb_pre_proc_ivas_fx() */ -/*------------------------------------------------------------------------*/ -/* PURPOSE : Resampling of input signal when input signal sample rate */ -/* is above 16kHz */ -/*------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* Encoder_State *st_fx : Encoder State Structure */ -/* _ (Word16*) input : original input signal */ -/*------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ -/*------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) new_wb_speech : original input signal at 16kHz Q-1 */ -/*------------------------------------------------------------------------*/ - -/* st_fx->old_wtda_wb_fx */ -/*------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*========================================================================*/ - -void wb_pre_proc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ const Word16 *new_inp_resamp16k, /* i : original input signal in Q-1 */ @@ -263,7 +107,6 @@ void wb_pre_proc_ivas_fx( Copy_Scale_sig( new_inp_resamp16k, temp_buf, L_FRAME16k, -3 ); -#ifdef HARMONIZE_TBE2 IF( st_fx->element_mode == EVS_MONO ) { tmp1 = 0; @@ -283,7 +126,6 @@ void wb_pre_proc_ivas_fx( } } ELSE -#endif { temp1 = W_mac_32_32( temp1, temp_buf[0], temp_buf[0] ); FOR( i = 1; i < L_FRAME16k; i++ ) @@ -461,12 +303,8 @@ void wb_pre_proc_ivas_fx( set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); } -#ifdef HARMONIZE_TBE2 test(); if ( hBWE_FD != NULL && st_fx->element_mode != EVS_MONO ) -#else - if ( hBWE_FD != NULL ) -#endif { hBWE_FD->mem_old_wtda_swb_fx = new_inp_resamp16k[L_FRAME16k - L_MEM_RECALC_16K - L_FILT16k - 1]; move16(); @@ -487,9 +325,7 @@ void wb_pre_proc_ivas_fx( IF( NE_16( st_fx->extl, SWB_BWE ) && NE_16( st_fx->extl, FB_BWE ) ) { Copy( old_input, hBWE_FD->L_old_wtda_swb_fx, L_FRAME16k ); -#ifdef HARMONIZE_TBE2 if ( st_fx->element_mode != EVS_MONO ) -#endif { st_fx->Q_old_wtda = -Q1; move16(); @@ -527,294 +363,13 @@ void wb_pre_proc_ivas_fx( /*========================================================================*/ void swb_pre_proc_fx( -#ifndef HARMONIZE_TBE2 - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *input_fx, /* i : original input signal */ - Word16 *new_swb_speech_fx, /* o : original input signal at 32kHz */ - Word16 *shb_speech_fx, /* o : SHB target signal (6-14kHz) at 16kHz */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real CLDFB buffer for target synthesis */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag CLDFB buffer for target synthesis */ - const CLDFB_SCALE_FACTOR *cldfbScale /* i : scale data of real and imag CLDFB buffers */ -) -{ - Word16 Sample_Delay_SWB_BWE, delay; - Word16 inner_frame; - UWord16 inner_Fs; - Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; - Word16 spchTmp_fx[L_FRAME32k]; - Word16 i; - Word16 startB, endB; - Word16 j; - Word32 *realBufferFlipped[CLDFB_NO_COL_MAX]; - Word32 *imagBufferFlipped[CLDFB_NO_COL_MAX]; - Word32 realBufferTmp[CLDFB_NO_COL_MAX][20]; - Word32 imagBufferTmp[CLDFB_NO_COL_MAX][20]; - Word32 cldfbWorkBuffer[256]; - Word16 ts, nB, uB; - /* Highband energy computation using CLDFB */ - Word32 CldfbHB_ener; - Flag Overflow = 0; - move16(); - Word16 realQ_neg1, imagQ_neg1, exp, Cldfbtemp1; - TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) - { - set32_fx( realBufferTmp[j], 0, 20 ); - set32_fx( imagBufferTmp[j], 0, 20 ); - realBufferFlipped[j] = realBufferTmp[j]; - imagBufferFlipped[j] = imagBufferTmp[j]; - } - - set16_fx( old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k ); - - IF( EQ_32( st_fx->input_Fs, 32000 ) ) - { - Copy( input_fx, new_swb_speech_fx, L_FRAME32k ); /*Q0 */ - test(); - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) ) - { - Sample_Delay_SWB_BWE = NS2SA( 32000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Copy( hBWE_FD->old_fdbwe_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], L_FRAME32k ); - set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); - Copy( hBWE_FD->old_fdbwe_speech_fx + L_FRAME32k - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - - IF( sub( st_fx->extl, WB_BWE ) != 0 ) - { - Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, L_FRAME32k ); - } - } - - test(); - IF( NE_16( st_fx->extl, SWB_BWE ) && NE_16( st_fx->extl, FB_BWE ) ) - { - Copy( input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME32k ); - } - } - ELSE /* 48 kHz */ - { - /* 48kHz sampled processing needs review of FD2 memory handling/Q-factors */ - IF( EQ_16( st_fx->codec_mode, MODE1 ) ) - { - test(); - test(); - IF( NE_16( st_fx->extl, SWB_BWE ) && NE_16( st_fx->extl, FB_BWE ) && EQ_16( st_fx->core, ACELP_CORE ) ) - { - /* move the resampling out of the TDBWE path as new_swb_speech is not needed for TDBWE. */ - Copy( input_fx, hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k ); - } - ELSE - { - test(); - IF( NE_16( st_fx->last_extl, SWB_BWE ) && NE_16( st_fx->last_extl, FB_BWE ) ) - { - /* resample 48 kHz to 32kHz */ - IF( ( st_fx->last_bwidth == FB && st_fx->element_mode == EVS_MONO ) || ( EQ_16( st_fx->bwidth, FB ) && st_fx->element_mode > EVS_MONO ) ) // note: once EVS i CR fixed, the condition will simplify to "if ( st->bwidth == FB )" only - { - inner_frame = L_FRAME48k; - inner_Fs = 48000; - Copy( hBWE_FD->old_fdbwe_speech_fx, new_swb_speech_fx, L_FRAME48k ); - } - ELSE - { - inner_frame = L_FRAME32k; - inner_Fs = 32000; - decimate_2_over_3_allpass_fx( hBWE_FD->old_fdbwe_speech_fx, L_FRAME48k, new_swb_speech_fx, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, - decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - move16(); - move16(); - - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Copy( new_swb_speech_fx, &old_input_fx[Sample_Delay_SWB_BWE], inner_frame ); - set16_fx( old_input_fx, 0, Sample_Delay_SWB_BWE ); - Copy( new_swb_speech_fx + inner_frame - Sample_Delay_SWB_BWE, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame ); - st_fx->Q_old_wtda = 0; - move16(); - } - /* resample 48 kHz to 32kHz */ - IF( EQ_16( st_fx->bwidth, FB ) ) - { - Copy( input_fx, new_swb_speech_fx, L_FRAME48k ); - } - ELSE - { - decimate_2_over_3_allpass_fx( input_fx, L_FRAME48k, new_swb_speech_fx, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, - decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - } - } - ELSE - { - /* resample 48 kHz to 32kHz */ - IF( EQ_16( st_fx->bwidth, FB ) ) - { - Copy( input_fx, new_swb_speech_fx, L_FRAME48k ); - } - ELSE - { - decimate_2_over_3_allpass_fx( input_fx, L_FRAME48k, new_swb_speech_fx, hBWE_TD->dec_2_over_3_mem_fx, allpass_poles_3_ov_2, - decimate_3_ov_2_lowpass_num_fx, decimate_3_ov_2_lowpass_den_fx, hBWE_TD->dec_2_over_3_mem_lp_fx ); - } - } - } - - test(); - test(); - test(); - test(); - test(); - IF( ( st_fx->core == ACELP_CORE && NE_16( st_fx->extl, SWB_BWE_HIGHRATE ) && NE_16( st_fx->extl, FB_BWE_HIGHRATE ) ) || ( ( EQ_32( st_fx->total_brate, 9600 ) || st_fx->rf_mode != 0 ) && EQ_16( st_fx->bwidth, SWB ) ) ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - startB = 34; - move16(); - endB = 14; - move16(); - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - uB = 0; - move16(); - FOR( nB = startB; nB > endB; nB-- ) - { - realBufferFlipped[ts][uB] = realBuffer[ts][nB]; - move32(); - if ( s_and( ts, 1 ) != 0 ) - { - realBufferFlipped[ts][uB] = L_negate( realBufferFlipped[ts][uB] ); - move32(); - } - imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; - move32(); - if ( s_and( ts, 1 ) == 0 ) - { - imagBufferFlipped[ts][uB] = L_negate( imagBufferFlipped[ts][uB] ); - move32(); - } - uB = add( uB, 1 ); /* uB ++ */ - } - } - } - ELSE - { - startB = 39; - move16(); - endB = 19; - move16(); - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - uB = 0; - move16(); - FOR( nB = startB; nB > endB; nB-- ) - { - realBufferFlipped[ts][uB] = L_negate( realBuffer[ts][nB] ); - move32(); - imagBufferFlipped[ts][uB] = imagBuffer[ts][nB]; - move32(); - uB = add( uB, 1 ); /* uB ++ */ - } - } - } - - /* Highband energy computation for gain shape control in case of bandwidth switching fix*/ - { - CldfbHB_ener = 0; - move32(); - FOR( nB = 0; nB < 10; nB++ ) - { - FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) - { - realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); - imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ - - CldfbHB_ener = L_mac0_o( CldfbHB_ener, realQ_neg1, realQ_neg1, &Overflow ); - CldfbHB_ener = L_mac0_o( CldfbHB_ener, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ - } - } - - exp = norm_l( CldfbHB_ener ); - CldfbHB_ener = L_shl( CldfbHB_ener, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ - Cldfbtemp1 = ( Log2_norm_lc( CldfbHB_ener ) ); - Cldfbtemp1 = add( shr( Cldfbtemp1, 6 ), shl( sub( 30, sub( exp, 2 ) ), 9 ) ); /* Log2_norm_lc(CldfbHB_ener) = 2^15*(log2(CldfbHB_ener/2^30)) = 2^15*(log2(CldfbHB_fl*(2^-2)*2^exp/2^30)) = 2^15*(log2(CldfbHB_fl) + exp-2-30) => 2^(-6)*l2nc + 2^9(20-(exp-2)) = 2^9*log2(CldfbHB_fl), Q9 */ - CldfbHB_ener = L_mult( sub( Cldfbtemp1, 1741 /*3.401 Q9*/ ), 3495 ); /* 3495 = Q19 log10(2)*0.1/log10(32768), Q = 19+9+1 = 29 */ - hBWE_TD->cldfbHBLT = mac_r( CldfbHB_ener, 29491 /*0.9 Q15*/, hBWE_TD->cldfbHBLT ); /* cldfbHBLT is in Q13 */ - } - cldfbSynthesis_fx( st_fx->cldfbSynTd, realBufferFlipped, imagBufferFlipped, cldfbScale, shb_speech_fx, 0, CLDFB_NO_COL_MAX, cldfbWorkBuffer ); - *Q_shb_spch = 0; /*shb_speech_fx : Q0*/ - move16(); - - test(); - test(); - IF( NE_16( st_fx->extl, WB_TBE ) && NE_16( st_fx->extl, SWB_TBE ) && NE_16( st_fx->extl, FB_TBE ) ) - { - /* Update the previous superwideband speech buffer in case of a SWB_BWE frame - this code is in swb_tbe_enc */ - delay = L_LOOK_16k + L_SUBFR16k; - Copy( shb_speech_fx + L_FRAME16k - delay, hBWE_TD->old_speech_shb_fx, delay ); - } - } - ELSE - { - test(); - IF( EQ_16( st_fx->bwidth, FB ) || EQ_16( st_fx->core, ACELP_CORE ) ) - { - set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); - set16_fx( shb_speech_fx, 0, L_FRAME16k ); /* shb_speech for FB/SWB BWE_HIGHRATE is not used at 64kbps */ - } - ELSE - { - /* flip the spectrm */ - Copy( new_swb_speech_fx, spchTmp_fx, L_FRAME32k ); - - FOR( i = 0; i < L_FRAME32k; i = i + 2 ) - { - spchTmp_fx[i] = negate( spchTmp_fx[i] ); - move16(); - } - - Decimate_allpass_steep_fx( spchTmp_fx, hBWE_TD->state_ana_filt_shb_fx, L_FRAME32k, shb_speech_fx ); - Copy( shb_speech_fx + L_FRAME16k - ( L_LOOK_16k + L_SUBFR16k ), hBWE_TD->old_speech_shb_fx, L_LOOK_16k + L_SUBFR16k ); - } - - /* Reset CLDFB synthesis buffer */ - set16_fx( st_fx->cldfbSynTd->FilterStates, 0, st_fx->cldfbSynTd->p_filter_length + st_fx->cldfbSynTd->no_channels * st_fx->cldfbSynTd->no_col ); - } - IF( EQ_16( st_fx->last_extl, -1 ) ) - { - delay = NS2SA_FX2( st_fx->input_Fs, DELAY_FIR_RESAMPL_NS ); - FOR( i = 0; i < delay; i++ ) - { - shb_speech_fx[i] = mult_r( mult_r( i, 983 /*0.03f Q15*/ ), shb_speech_fx[2 * delay - 1 - i] ); - move16(); - } - } - - return; -} - -/*-------------------------------------------------------------------* - * swb_pre_proc() - * - * - Calculate the 6 to 14 kHz (or 7.5 - 15.5 kHz) SHB target signal - * for SWB TBE or SWB BWE coding - * - Common SWB TBE and SWB BWE pre-processing - *-------------------------------------------------------------------*/ - -void swb_pre_proc_ivas_fx( -#endif Encoder_State *st, /* i/o: encoder state structure */ Word16 *new_swb_speech, /* o : original input signal at 32kHz - st->q_inp */ Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz - Q0 */ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ -#ifdef HARMONIZE_TBE2 const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers */ -#endif CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ) { @@ -914,9 +469,7 @@ void swb_pre_proc_ivas_fx( IF( NE_16( st->extl, WB_BWE ) ) { Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, L_FRAME32k ); -#ifdef HARMONIZE_TBE2 if ( st->element_mode > EVS_MONO ) -#endif { st->Q_old_wtda = st->q_inp; move16(); @@ -1074,13 +627,11 @@ void swb_pre_proc_ivas_fx( Copy( old_input_fx, hBWE_FD->L_old_wtda_swb_fx, inner_frame ); st->Q_old_wtda = st->q_inp; move16(); -#ifdef HARMONIZE_TBE2 if ( st->element_mode == EVS_MONO ) { st->Q_old_wtda = 0; move16(); } -#endif } /* resample 48 kHz to 32kHz */ @@ -1197,7 +748,6 @@ void swb_pre_proc_ivas_fx( thr = icbwe_thr_DFT_fx; regV = icbwe_regressionValuesDFT_fx; } -#ifdef HARMONIZE_TBE2 ELSE IF( st->element_mode == EVS_MONO ) { IF( EQ_16( st->L_frame, L_FRAME ) ) @@ -1293,10 +843,8 @@ void swb_pre_proc_ivas_fx( regV = 0; // just to avoid warnings move16(); } -#endif ELSE { -#ifdef HARMONIZE_TBE2 /* Scaling cldfb_state_fx */ Word16 q_shift, scf_cldfb; scf_cldfb = L_norm_arr( st->cldfbSynTd->cldfb_state_fx, st->cldfbSynTd->p_filter_length ); @@ -1320,7 +868,6 @@ void swb_pre_proc_ivas_fx( st->cldfbSynTd->Q_cldfb_state = sub( q_reImBuffer, 1 ); } -#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { startB = 34; @@ -1444,9 +991,7 @@ void swb_pre_proc_ivas_fx( cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); // Q0 -#ifdef HARMONIZE_TBE2 st->cldfbSynTd->Q_cldfb_state = sub( q_reImBuffer, 1 ); -#endif } IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoICBWE != NULL ) @@ -1610,16 +1155,12 @@ void swb_pre_proc_ivas_fx( } } -#ifdef HARMONIZE_TBE2 IF( st->element_mode == EVS_MONO ) { /* Reset CLDFB synthesis buffer */ set16_fx( st->cldfbSynTd->FilterStates, 0, st->cldfbSynTd->p_filter_length + st->cldfbSynTd->no_channels * st->cldfbSynTd->no_col ); } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) -#else - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) -#endif { /* Reset CLDFB synthesis buffer */ set32_fx( st->cldfbSynTd->cldfb_state_fx, 0, st->cldfbSynTd->p_filter_length ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 2a1a5fad9..03e7adade 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -959,27 +959,10 @@ void wb_tbe_enc_fx( Copy( hBWE_TD->state_syn_shbexc_fx, shaped_wb_excitation, L_SHB_LAHEAD / 4 ); Q_bwe_exc_ext = sub( Q_bwe_exc, 16 ); -#ifdef HARMONIZE_TBE2 GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, vf_modified_fx, uv_flag, st_fx->igf ); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - GenShapedWBExcitation_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, - vf_modified_fx, uv_flag, st_fx->igf ); - } - ELSE - { - GenShapedWBExcitation_ivas_fx( shaped_wb_excitation + L_SHB_LAHEAD / 4, lpc_wb, exc4kWhtnd, hBWE_TD->mem_csfilt_fx, - hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, - hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, st_fx->element_mode, bwe_exc_extended_16, Q_bwe_exc_ext, hBWE_TD->bwe_seed, - vf_modified_fx, uv_flag, st_fx->igf ); - } -#endif curr_pow = 0; move32(); @@ -3180,11 +3163,7 @@ void swb_tbe_enc_ivas_fx( ELSE #endif { -#ifdef HARMONIZE_TBE2 GenShapedSHBExcitation_ivas_fx( ENC, shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, -#else - GenShapedSHBExcitation_ivas_enc_fx( shaped_shb_excitation_fx + L_SHB_LAHEAD, lpc_shb_fx, White_exc16k_fx, hBWE_TD->mem_csfilt_fx, -#endif hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, st_fx->coder_type, bwe_exc_extended_16, hBWE_TD->bwe_seed, vf_modified_fx, st_fx->extl, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), lpc_shb_sf_fx, shb_ener_sf_Q31, shb_res_gshape_fx, shb_res_fx, &vf_ind_fx, formant_fac_fx, hBWE_TD->fb_state_lpc_syn_fx, &( hBWE_TD->fb_tbe_demph_fx ), &Q_bwe_exc, -- GitLab From 382805931931dfdbd9592533bb5434c9ed6ecafe Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 13:59:22 +0100 Subject: [PATCH 03/22] [cleanup] accept HARMONIZE_2427_GETPLC --- lib_com/ivas_prot_fx.h | 5 -- lib_com/options.h | 1 - lib_dec/er_util_fx.c | 136 -------------------------------- lib_dec/ivas_mdct_core_dec_fx.c | 4 - lib_dec/ivas_tcx_core_dec_fx.c | 4 - 5 files changed, 150 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4b943135e..ba91f3609 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1890,11 +1890,6 @@ void TonalMDCTConceal_Detect_ivas_fx( Word16 element_mode ); -#ifndef HARMONIZE_2427_GETPLC -Word16 GetPLCModeDecision_ivas_fx( - Decoder_State *st /* i/o: decoder memory state pointer */ -); -#endif // !HARMONIZE_2427_GETPLC void ivas_DetectTonalComponents_fx( Word16 indexOfTonalPeak[], diff --git a/lib_com/options.h b/lib_com/options.h index bdc99e5fd..2b4bfecf8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define HARMONIZE_2427_GETPLC /* FhG: basop issue : 2427 Harmonizing getPLCDecision functions:*/ #define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ #define FIX_2429_POST_DECODER #define FIX_FLOAT_1526_DIRAC_MEM_LEAK /* FhG: float issue 1526: potential memory leak in DirAC handles in case of format switching */ diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index e07a0717d..3ea02def6 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -366,11 +366,7 @@ void highPassFiltering_fx( * PLC: Decide which Concealment to use. Update pitch lags if needed *----------------------------------------------------------------------------------*/ -#ifndef HARMONIZE_2427_GETPLC -Word16 GetPLCModeDecision_ivas_fx( -#else Word16 GetPLCModeDecision_fx( -#endif // !HARMONIZE_2427_GETPLC Decoder_State *st /* i/o: decoder memory state pointer */ ) { @@ -453,9 +449,6 @@ Word16 GetPLCModeDecision_fx( { pitch = L_add( st->old_fpitch, 0 ); /*Q16*/ } -#ifndef HARMONIZE_2427_GETPLC - TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode ); -#else IF( NE_16( st->element_mode, EVS_MONO ) ) { TonalMDCTConceal_Detect_ivas_fx( st->hTonalMDCTConc, pitch, &numIndices, ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ? &( st->hTcxCfg->psychParamsTCX20 ) : st->hTcxCfg->psychParamsCurrent ), st->element_mode ); @@ -464,7 +457,6 @@ Word16 GetPLCModeDecision_fx( { TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode ); } -#endif // !HARMONIZE_2427_GETPLC test(); test(); @@ -502,131 +494,3 @@ Word16 GetPLCModeDecision_fx( return core; /*Q0*/ } -#ifndef HARMONIZE_2427_GETPLC -Word16 GetPLCModeDecision_fx( - Decoder_State *st /* i/o: decoder memory state pointer */ -) -{ - Word16 /*int*/ core; - Word16 numIndices; - TCX_DEC_HANDLE hTcxDec; - - numIndices = 0; - move16(); - - hTcxDec = st->hTcxDec; - - - IF( EQ_16( st->flagGuidedAcelp, 1 ) ) - { - st->old_pitch_buf_fx[( st->nb_subfr * 2 )] = L_deposit_h( st->guidedT0 ); /*Q16*/ - move32(); - st->old_pitch_buf_fx[( ( st->nb_subfr * 2 ) + 1 )] = L_deposit_h( st->guidedT0 ); /*Q16*/ - move32(); - st->mem_pitch_gain[0] = st->mem_pitch_gain[1] = 16384 /*1.f Q14*/; /*Q14*/ - move16(); - move16(); - } - st->plc_use_future_lag = 0; - move16(); - test(); - test(); - if ( ( st->last_core > ACELP_CORE && hTcxDec->tcxltp_last_gain_unmodified != 0 ) || ( EQ_16( st->flagGuidedAcelp, 1 ) ) ) - { - /* no updates needed here, because already updated in last good frame */ - st->plc_use_future_lag = 1; - move16(); - } - - IF( EQ_16( st->last_core, -1 ) ) - { - core = TCX_20_CORE; - move16(); - st->last_core = ACELP_CORE; - move16(); - if ( st->Opt_AMR_WB ) - { - core = ACELP_CORE; - move16(); - } - st->tonal_mdct_plc_active = 0; - move16(); - } - ELSE - { - core = ACELP_CORE; - move16(); - if ( GT_16( st->nbLostCmpt, 1 ) ) - { - core = st->last_core_bfi; - move16(); - } - - IF( EQ_16( st->nbLostCmpt, 1 ) ) - { - st->tonal_mdct_plc_active = 0; - move16(); - test(); - test(); - test(); - IF( !( st->rf_flag && st->use_partial_copy && ( EQ_16( st->rf_frame_type, RF_TCXTD1 ) || EQ_16( st->rf_frame_type, RF_TCXTD2 ) ) ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->hTonalMDCTConc != NULL && EQ_16( st->last_core, TCX_20_CORE ) ) && ( EQ_16( st->second_last_core, TCX_20_CORE ) ) && ( ( LE_32( st->old_fpitch, L_deposit_h( shr( st->L_frame, 1 ) ) ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) - /* it is fine to call the detection even if no ltp information - is available, meaning that st->old_fpitch == - st->tcxltp_second_last_pitch == st->L_frame */ - && ( EQ_32( st->old_fpitch, hTcxDec->tcxltp_second_last_pitch ) ) && !st->last_tns_active && !st->second_last_tns_active ) - { - Word32 pitch; - - - pitch = L_deposit_h( 0 ); - if ( hTcxDec->tcxltp_last_gain_unmodified > 0 ) - { - pitch = L_add( st->old_fpitch, 0 ); /*Q16*/ - } - - TonalMDCTConceal_Detect( st->hTonalMDCTConc, pitch, &numIndices, st->element_mode ); - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( GT_16( numIndices, 10 ) ) || ( ( GT_16( numIndices, 5 ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) || ( ( numIndices > 0 ) && ( ( LE_16( st->last_good, UNVOICED_TRANSITION ) ) || ( LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) ) && ( LT_32( L_abs( L_sub( hTcxDec->tcxltp_third_last_pitch, hTcxDec->tcxltp_second_last_pitch ) ), 32768l /*0.5f Q16*/ ) ) ) ) - { - core = TCX_20_CORE; - move16(); - st->tonal_mdct_plc_active = 1; - move16(); - } - ELSE IF( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) - { - core = TCX_20_CORE; - move16(); - } - } - ELSE IF( st->last_core != ACELP_CORE ) - { - test(); - if ( LE_16( st->last_good, UNVOICED_TRANSITION ) || LE_16( hTcxDec->tcxltp_last_gain_unmodified, 13107 /*0.4f Q15*/ ) ) - { - core = st->last_core; - move16(); - } - } - } - } - } - - return core; -} -#endif // !HARMONIZE_2427_GETPLC diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 39694bdcb..2da93e97c 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -838,11 +838,7 @@ void ivas_mdct_core_invQ_fx( /* PLC: [Common: mode decision] * PLC: Decide which Concealment to use. Update pitch lags if needed */ -#ifndef HARMONIZE_2427_GETPLC - st->core = GetPLCModeDecision_ivas_fx( st ); -#else st->core = GetPLCModeDecision_fx( st ); -#endif // !HARMONIZE_2427_GETPLC } test(); diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 19025b403..04b5a78ea 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -323,11 +323,7 @@ void stereo_tcx_core_dec_fx( /* PLC: [Common: mode decision] * PLC: Decide which Concealment to use. Update pitch lags if needed */ -#ifndef HARMONIZE_2427_GETPLC - st->core = GetPLCModeDecision_ivas_fx( st ); /* Q0 */ -#else st->core = GetPLCModeDecision_fx( st ); /* Q0 */ -#endif // !HARMONIZE_2427_GETPLC move16(); } -- GitLab From fbccb1e5b3eca39284039d8acf0b88eac27f02b0 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:00:07 +0100 Subject: [PATCH 04/22] [cleanup] accept HARM_FD_BWE --- lib_com/ivas_prot_fx.h | 14 - lib_com/options.h | 1 - lib_com/prot_fx.h | 28 - lib_com/swb_bwe_com_fx.c | 84 --- lib_dec/evs_dec_fx.c | 4 - lib_dec/ivas_core_dec_fx.c | 4 - lib_dec/swb_bwe_dec_fx.c | 155 ----- lib_enc/evs_enc_fx.c | 8 - lib_enc/ivas_core_enc_fx.c | 8 - lib_enc/prot_fx_enc.h | 25 - lib_enc/swb_bwe_enc_fx.c | 1306 +----------------------------------- 11 files changed, 26 insertions(+), 1611 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index ba91f3609..f51065217 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1839,20 +1839,6 @@ void stereoFdCngCoherence_fx( Word16 fft_exp ); -#ifndef HARM_FD_BWE -/* o : Q_syn_hb*/ -Word16 ivas_wb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Word16 *Qpost -); -#endif void ivas_param_ism_config_fx( PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ const Word16 nchan_obj /* i : number of ISM channels */ diff --git a/lib_com/options.h b/lib_com/options.h index 2b4bfecf8..7cdd81116 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ #define FIX_2429_POST_DECODER #define FIX_FLOAT_1526_DIRAC_MEM_LEAK /* FhG: float issue 1526: potential memory leak in DirAC handles in case of format switching */ #define FIX_2437_HARMONIZE_ENCODERINDEX /* FhG: basop issue 2437 EncoderIndex_ivas_fx() and EncoderIndex_fx()*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 83453e02d..ee086a664 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -368,9 +368,7 @@ void SWB_BWE_decoding_fx( ); void time_envelop_shaping_fx( -#ifdef HARM_FD_BWE const Word16 element_mode, /* i : element mode */ -#endif Word16 werr[], /* i/o: SHB synthesis Q_synth*/ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ const Word16 L, /* i : frame length */ @@ -2594,22 +2592,6 @@ Word16 E_UTIL_f_preemph3_ivas_fx( Word16 bits /* Q0 */ ); -#ifndef HARM_FD_BWE -void time_envelop_shaping_fx( - Word16 werr[], /* i/o: SHB synthesis Q_synth*/ - Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ - const Word16 L, /* i : frame length */ - Word16 *Q_synth ); - -void time_envelop_shaping_ivas_fx( -#ifdef HARM_FD_BWE - const Word16 element_mode, /* i : element mode */ -#endif - Word16 werr[], /* i/o: SHB synthesis Q_synth*/ - Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ - const Word16 L, /* i : frame length */ - Word16 *Q_synth ); -#endif void find_td_envelope_fx( const Word16 inp[], /* i : input signal Qx */ const Word16 len, /* i : length of the input signal */ @@ -6955,15 +6937,6 @@ Word16 WB_BWE_gain_deq_fx( /* o : Q_syn_hb*/ Word16 wb_bwe_dec_fx( -#ifndef HARM_FD_BWE - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ); -#else Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ @@ -6973,7 +6946,6 @@ Word16 wb_bwe_dec_fx( Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ Word16 *Qpost ); -#endif /* o : BWE class */ Word16 swb_bwe_gain_deq_fx( diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 525a1db85..399558cbb 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1945,89 +1945,7 @@ return; /*--------------------------------------------------------------------------*/ void time_envelop_shaping_fx( -#ifndef HARM_FD_BWE - Word16 werr[], /* i/o: SHB synthesis Q_synth*/ - Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ - const Word16 L, /* i : frame length */ - Word16 *Q_synth ) -{ - Word16 *pit; - Word32 Energy; - Word16 i, j; - Word16 tmp_ener, Energy_16; - Word16 exp_L, exp, frac, tmp, inv_L; - Word32 L_tmp; - - pit = werr; - exp_L = norm_s( L ); - inv_L = div_s( shl( 1, sub( 14, exp_L ) ), L ); /*Q(29-exp_L) */ - FOR( i = 0; i < SWB_TENV; i++ ) - { - Energy = L_deposit_l( 0 ); - FOR( j = 0; j < L / 4; j++ ) - { - Energy = L_mac0_sat( Energy, *pit, *pit ); /*(2*Q_synth) */ - pit++; - } - Energy = Mult_32_16( Energy, inv_L ); /*Q(29-exp_L-15) -> Q(-exp_L+14+2*Q_synth) */ - Energy_16 = 0; - move16(); - /*exp = 31-(-exp_L+14 +(2*(*Q_synth))); */ - exp = sub( 17, sub( shl( ( *Q_synth ), 1 ), exp_L ) ); - - IF( Energy != 0 ) - { - exp = norm_l( Energy ); - frac = extract_h( L_shl( Energy, exp ) ); - /*exp = sub(exp, 30-(-exp_L+14-2+(2*(*Q_synth)))); */ - exp = sub( exp, sub( 30, add( sub( shl( ( *Q_synth ), 1 ), exp_L ), 14 - 2 ) ) ); - - tmp = div_s( 16384, frac ); - L_tmp = L_deposit_h( tmp ); - Energy = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */ - Energy_16 = round_fx( L_shl( Energy, sub( exp, 15 ) ) ); /*Q0 */ - } - - test(); - IF( LT_32( SWB_tenv[i], 65536 /* 2 in Q15 */ ) && LT_32( Energy, L_shl_sat( SWB_tenv[i], sub( 16, exp ) ) ) ) - { - *Q_synth = add( *Q_synth, 3 ); - move16(); - } - ELSE - { - pit -= shr( L, 2 ); - move16(); - tmp_ener = 0; - move16(); - exp = 0; - move16(); - - IF( Energy_16 != 0 ) - { - exp = norm_s( Energy_16 ); - tmp_ener = div_s( shl( 1, sub( 14, exp ) ), Energy_16 ); /*Q(29-exp) */ - } - - L_tmp = Mult_32_16( SWB_tenv[i], tmp_ener ); /*Q(29-exp) */ - tmp = round_fx( L_tmp ); /*Q(13-exp) */ - - FOR( j = 0; j < L / 4; j++ ) - { - *pit = round_fx_sat( L_shl_sat( L_mult( tmp, *pit ), sub( exp, 1 ) ) ); /*Q(13-exp+1)->Q(14-exp)->Qsyn-3 */ - move16(); - pit++; - } - } - } - - return; -} - -void time_envelop_shaping_ivas_fx( -#else const Word16 element_mode, /* i : element mode */ -#endif Word16 werr[], /* i/o: SHB synthesis Q_synth*/ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ const Word16 L, /* i : frame length */ @@ -2047,7 +1965,6 @@ void time_envelop_shaping_ivas_fx( FOR( i = 0; i < SWB_TENV; i++ ) { -#ifdef HARM_FD_BWE IF( element_mode == EVS_MONO ) { Energy = L_deposit_l( 0 ); @@ -2059,7 +1976,6 @@ void time_envelop_shaping_ivas_fx( Energy_Q = shl( ( *Q_synth ), 1 ); } ELSE -#endif { Energy_64 = L_deposit_l( 0 ); FOR( j = 0; j < L / 4; j++ ) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 0c134ce5b..ba38ae82a 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -381,11 +381,7 @@ ivas_error evs_dec_fx( ELSE IF( EQ_16( st_fx->extl, WB_BWE ) && st_fx->bws_cnt == 0 ) { /* WB BWE decoder */ -#ifdef HARM_FD_BWE hb_synth_fx_exp = wb_bwe_dec_fx( st_fx, NULL, synth_fx, hb_synth_fx, 0, output_frame, voice_factors_fx, pitch_buf_fx, &Qpostd ); /*Q0*/ -#else - hb_synth_fx_exp = wb_bwe_dec_fx( synth_fx, hb_synth_fx, output_frame, voice_factors_fx, pitch_buf_fx, st_fx, &Qpostd ); /*Q0*/ -#endif } /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 791c8172c..5b3366df9 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -957,11 +957,7 @@ ivas_error ivas_core_dec_fx( ELSE IF( EQ_16( st->extl, WB_BWE ) && st->bws_cnt == 0 ) { /* WB BWE decoder */ -#ifdef HARM_FD_BWE Q_hb_synth_fx = wb_bwe_dec_fx( st, output_32_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); -#else - Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_32_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); -#endif } /* Memories Re-Scaling */ diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index f7c6e8c16..f90928a96 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -354,11 +354,7 @@ Word16 WB_BWE_gain_deq_fx( *-------------------------------------------------------------------*/ /* o : Q_syn_hb */ -#ifdef HARM_FD_BWE Word16 wb_bwe_dec_fx( -#else -Word16 ivas_wb_bwe_dec_fx( -#endif Decoder_State *st_fx, /* i/o: decoder state structure */ Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ @@ -442,13 +438,11 @@ Word16 ivas_wb_bwe_dec_fx( { /* de-quantization */ mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx ); -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { hBWE_FD->last_wb_bwe_ener_fx = mult_r( add_sat( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 ); // this would not saturate if written like : rounf_fx(L_mac(L_mult(WB_fenv_fx[0], 16384), WB_fenv_fx[1], 16384)) } ELSE -#endif { hBWE_FD->last_wb_bwe_ener_fx = extract_l( Mpy_32_16_r( L_add( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 /*0.5f in Q15*/ ) ); } @@ -541,147 +535,6 @@ Word16 ivas_wb_bwe_dec_fx( return Q_syn_hb; } -#ifndef HARM_FD_BWE -Word16 wb_bwe_dec_fx( - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ) -{ - Word16 mode; - Word16 WB_fenv_fx[SWB_FENV]; - Word16 ysynth_fx[L_FRAME48k]; - Word16 Q_syn, exp, Q_syn_hb; - Word32 L_wtda_synth_fx[2 * L_FRAME48k], ysynth_32[L_FRAME48k], t_audio32_tmp[L_FRAME48k]; - Word16 scl, new_input_fx_exp; - Word16 i; - FD_BWE_DEC_HANDLE hBWE_FD; - - Word16 coder_type = st_fx->coder_type; - move16(); - - hBWE_FD = st_fx->hBWE_FD; - - /* MDCT of the core synthesis signal */ - - new_input_fx_exp = *Qpost; - move16(); - - { - wtda_fx( synth_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, - &hBWE_FD->old_wtda_swb_fx_exp, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ - output_frame ); - *Qpost = sub( new_input_fx_exp, 15 ); - move16(); - /* DCT of the ACELP core synthesis */ - direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); - } - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scl = sub( 16 + MAX_Q_NEW_INPUT, new_input_fx_exp ); - /* Possible to Upscale? */ - IF( scl > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_syn = Find_Max_Norm32( ysynth_32, output_frame ); - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_syn, scl ); - } - Copy_Scale_sig32_16( ysynth_32, ysynth_fx, output_frame, scl ); - Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); - IF( !st_fx->bfi ) - { - IF( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) - { - /* de-quantization */ - mode = WB_BWE_gain_deq_fx( st_fx, WB_fenv_fx ); - hBWE_FD->last_wb_bwe_ener_fx = mult_r( add_sat( WB_fenv_fx[0], WB_fenv_fx[1] ), 16384 ); // this would not saturate if written like : rounf_fx(L_mac(L_mult(WB_fenv_fx[0], 16384), WB_fenv_fx[1], 16384)) - move16(); - } - ELSE - { - Word32 tmp_brate; - - tmp_brate = st_fx->last_core_brate; - move32(); - - test(); - if ( EQ_32( st_fx->last_total_brate, ACELP_9k60 ) && EQ_16( st_fx->last_extl, SWB_TBE ) ) - { - tmp_brate = ACELP_8k00; /* this is needed in order to stay BE wrt. EVS mono */ - move32(); - } - - if ( NE_16( st_fx->last_extl, WB_BWE ) ) - { - hBWE_FD->prev_SWB_fenv_fx[0] = 0; - move16(); - } - - mode = WB_BWE_gain_pred_fx( WB_fenv_fx, ysynth_fx, coder_type, st_fx->prev_coder_type, hBWE_FD->prev_SWB_fenv_fx[0], - voice_factors_fx, pitch_buf_fx, tmp_brate, hBWE_FD->last_wb_bwe_ener_fx, Q_syn, st_fx->last_extl, st_fx->tilt_wb_fx ); - } - } - ELSE - { - /* FEC */ - mode = NORMAL; - move16(); - FOR( i = 0; i < 2; i++ ) - { - WB_fenv_fx[i] = mult_r( hBWE_FD->prev_SWB_fenv_fx[i], 24576 ); - move16(); - } - } - test(); - IF( NE_16( st_fx->last_extl, WB_BWE ) || st_fx->bfi ) - { - Copy( WB_fenv_fx, hBWE_FD->prev_SWB_fenv_fx, 2 ); - } - - exp = norm_l( hBWE_FD->prev_Energy_wb_fx ); - IF( GT_16( add( hBWE_FD->prev_Q_synth, exp ), Q_syn ) ) - { - hBWE_FD->prev_Energy_wb_fx = L_shr( hBWE_FD->prev_Energy_wb_fx, sub( hBWE_FD->prev_Q_synth, Q_syn ) ); - move32(); - } - ELSE - { - Q_syn = add( hBWE_FD->prev_Q_synth, exp ); - hBWE_FD->prev_Energy_wb_fx = L_shl( hBWE_FD->prev_Energy_wb_fx, exp ); - move32(); - } - - WB_BWE_decoding_fx( ysynth_fx, WB_fenv_fx, ysynth_32, L_FRAME16k, mode, - st_fx->last_extl, &hBWE_FD->prev_Energy_wb_fx, hBWE_FD->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, - st_fx->extl, coder_type, st_fx->total_brate, &hBWE_FD->Seed, &hBWE_FD->prev_flag, - st_fx->prev_coder_type, Q_syn, &Q_syn_hb ); - - IF( EQ_32( st_fx->output_Fs, 32000 ) ) - { - set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME16k ); - } - ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) - { - set32_fx( &ysynth_32[L_FRAME16k], 0, L_FRAME32k ); - } - - Inverse_Transform( ysynth_32, &Q_syn_hb, t_audio32_tmp, 0, output_frame, output_frame, st_fx->element_mode ); - - window_ola_fx( t_audio32_tmp, hb_synth_fx, &Q_syn_hb, hBWE_FD->mem_imdct_fx, &hBWE_FD->mem_imdct_exp_fx, output_frame, - ALDO_WINDOW, ALDO_WINDOW, 0, 0, 0 ); - - hBWE_FD->prev_mode = mode; - move16(); - hBWE_FD->prev_Q_synth = Q_syn; - move16(); - - return Q_syn_hb; -} -#endif /*-------------------------------------------------------------------* * swb_bwe_gain_deq() @@ -1151,11 +1004,7 @@ Word16 swb_bwe_dec_fx( } /* time envelope shaping when the current frame is TRANSIENT frame */ -#ifdef HARM_FD_BWE time_envelop_shaping_fx( st_fx->element_mode, hb_synth_fx, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); -#else - time_envelop_shaping_fx( hb_synth_fx, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); -#endif Q_syn_hb = sub( Q_syn_hb, 3 ); hBWE_FD->prev_td_energy_fx = SWB_tenv_fx[3]; @@ -1521,11 +1370,7 @@ Word16 swb_bwe_dec_fx32( } /* time envelope shaping when the current frame is TRANSIENT frame */ -#ifdef HARM_FD_BWE time_envelop_shaping_fx( st_fx->element_mode, hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); -#else - time_envelop_shaping_ivas_fx( hb_synth_fx16, SWB_tenv_tmp_fx, output_frame, &Q_syn_hb ); -#endif Q_syn_hb = sub( Q_syn_hb, 3 ); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 82e6b5ce2..5e94dcfdc 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -431,11 +431,7 @@ ivas_error evs_enc_fx( ELSE IF( EQ_16( st->extl, WB_BWE ) ) { /* WB BWE encoder */ -#ifdef HARM_FD_BWE wb_bwe_enc_fx( st, new_inp_resamp16k ); -#else - wb_bwe_enc_fx( st, new_inp_resamp16k, st->coder_type ); -#endif } /*---------------------------------------------------------------------* @@ -512,11 +508,7 @@ ivas_error evs_enc_fx( ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { /* SWB BWE encoder */ -#ifdef HARM_FD_BWE swb_bwe_enc_fx( st, EVS_MONO, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, 0, shb_speech, Q_shb_spch, sub( Q_new, 1 ) ); -#else - swb_bwe_enc_fx( st, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, shb_speech, st->coder_type, Q_shb_spch, sub( Q_new, 1 ) ); -#endif } ELSE IF( EQ_16( st->extl, SWB_BWE_HIGHRATE ) || EQ_16( st->extl, FB_BWE_HIGHRATE ) ) { diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 571d405f6..84433de1a 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -638,11 +638,7 @@ ivas_error ivas_core_enc_fx( ELSE IF( EQ_16( st->extl, WB_BWE ) && n == 0 && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { /* WB BWE encoder */ -#ifdef HARM_FD_BWE wb_bwe_enc_fx( st, new_inp_resamp16k_fx[n] ); -#else - wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n] ); -#endif } /*---------------------------------------------------------------------* @@ -716,11 +712,7 @@ ivas_error ivas_core_enc_fx( ELSE IF( EQ_16( st->extl, SWB_BWE ) || EQ_16( st->extl, FB_BWE ) ) { /* SWB(FB) BWE encoder */ -#ifdef HARM_FD_BWE swb_bwe_enc_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, 0, sub( Q_new[n], 1 ) ); -#else - swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); -#endif } Scale_sig( old_syn_12k8_16k_fx[n], L_FRAME16k, sub( Q1, Q_new[n] ) ); // Q0 diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index cdf2414ec..bed59ad02 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -519,19 +519,6 @@ void StableHighPitchDetect_fx( Word16 EspecdB[] ); void swb_bwe_enc_fx( -#ifndef HARM_FD_BWE - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *old_input_12k8_fx, /* i : i signal @12.8kHz for SWB BWE */ - Word16 *old_input_16k_fx, /* i : i signal @16kHz for SWB BWE */ - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ - const Word16 *new_swb_speech_fx, /* i : original i signal at 32kHz */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ - const Word16 coder_type, /* i : coding type */ - Word16 Q_shb_speech, - Word16 Q_slb_speech ); - -void swb_bwe_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ @@ -540,12 +527,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ -#ifdef HARM_FD_BWE Word16 Q_shb_speech, Word16 Q_slb_speech ); -#else - const Word16 Q_slb_speech ); -#endif void swb_CNG_enc_fx( Encoder_State *st_fx, /* i/o: State structure */ @@ -639,14 +622,6 @@ void vad_param_updt_fx( ); void wb_bwe_enc_fx( -#ifndef HARM_FD_BWE - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_wb_speech_fx, /* i : original i signal at 16kHz */ - Word16 coder_type /* i : coding type */ -); - -void wb_bwe_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *new_wb_speech_fx /* i : original i signal at 16kHz */ ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 17e2adeeb..4b02e8b73 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -14,57 +14,9 @@ * Local functions declarations *---------------------------------------------------------------------*/ -#ifdef HARM_FD_BWE static Word16 WB_BWE_encoding_fx( Encoder_State *st_fx, const Word32 *yos_fx, Word16 *WB_fenv_fx, Word16 Q_synth, const Word16 Q_synth_lf ); static Word16 SWB_BWE_encoding_fx( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx_16, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); -#else -static Word16 WB_BWE_encoding_fx( - const Word16 coder_type, /* i : coder type */ - const Word16 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word16 Q_synth, - const Word16 Q_synth_lf ); - -static Word16 WB_BWE_encoding_ivas_fx( - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word32 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Word16 Q_synth, - const Word16 Q_synth_lf ); - -static Word16 SWB_BWE_encoding_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *insig_fx, /* i/o: delayed original input signal at 32kHz (might be rescaled)*/ - const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ - const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ - const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ - const Word16 *yos_fx, /* i : MDCT coefficients of the windowed original input signal at 32kHz */ - Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ - const Word16 tilt_nb_fx, /* i : SWB tilt */ - const Word16 st_offset, /* i : start frequency offset for BWE envelope */ - const Word16 coder_type, /* i : coding type */ - const Word16 Q_insig_lp, - const Word16 Q_shb, - const Word16 Q_synth, - const Word16 Q_synth_lf ); - -static Word16 SWB_BWE_encoding_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *insig_fx, /* i/o: delayed original input signal at 32kHz (might be rescaled)*/ - const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ - const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ - const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ - const Word32 *yos_fx, /* i : MDCT coefficients of the windowed original input signal at 32kHz */ - Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ - const Word16 tilt_nb_fx, /* i : SWB tilt */ - const Word16 st_offset, /* i : start frequency offset for BWE envelope */ - const Word16 Q_insig_lp, - const Word16 Q_shb, - const Word16 Q_synth, - const Word16 Q_synth_lf ); -#endif /*-------------------------------------------------------------------* @@ -151,87 +103,6 @@ static void delay_input_signal_fx( *-------------------------------------------------------------------*/ void wb_bwe_enc_fx( -#ifndef HARM_FD_BWE - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *new_wb_speech_fx, /* i : original input signal at 16kHz */ - Word16 coder_type /* i : coding type */ -) -{ - Word16 mode = 0; - move16(); - Word16 Sample_Delay_WB_BWE; - Word16 old_input_fx[NS2SA( 16000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k]; - Word32 yorig_32[L_FRAME16k]; - Word16 yorig_fx[L_FRAME16k]; - Word32 L_wtda_synth_fx[2 * L_FRAME16k]; - Word16 *new_input_fx; /* pointer to original input signal */ - Word16 scl, new_input_fx_exp; - Word16 Q_synth; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - Word16 WB_fenv_fx[SWB_FENV]; - - IF( EQ_32( st_fx->total_brate, ACELP_13k20 ) ) - { - /*---------------------------------------------------------------------* - * Delay the original input signal to be synchronized with ACELP core synthesis - *---------------------------------------------------------------------*/ - set16_fx( old_input_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); - Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); - - new_input_fx = old_input_fx + Sample_Delay_WB_BWE; - Copy( hBWE_FD->old_input_wb_fx, old_input_fx, Sample_Delay_WB_BWE ); - Copy( new_wb_speech_fx, new_input_fx, L_FRAME16k ); - Copy( old_input_fx + L_FRAME16k, hBWE_FD->old_input_wb_fx, Sample_Delay_WB_BWE ); - - /*---------------------------------------------------------------------*/ - /* WB BWE encoding */ - - - /* MDCT of the core synthesis signal */ - /*---------------------------------------------------------------------*/ - new_input_fx_exp = 0; - move16(); - - wtda_fx( old_input_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, - &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ - L_FRAME16k ); - - /* DCT of the ACELP core synthesis */ - direct_transform_fx( L_wtda_synth_fx, yorig_32, 0, L_FRAME16k, &new_input_fx_exp, /*st_fx->element_mode*/ EVS_MONO ); - - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scl = sub( 16 + 8 /*MAX_Q_NEW_INPUT*/, new_input_fx_exp ); - /* Possible to Upscale? */ - IF( scl > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_synth = Find_Max_Norm32( yorig_32, L_FRAME16k ); - - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_synth, scl ); - } - Copy_Scale_sig32_16( yorig_32, yorig_fx, L_FRAME16k, scl ); - Q_synth = sub( add( sub( new_input_fx_exp, 16 ), scl ), 1 ); - - mode = WB_BWE_encoding_fx( coder_type, yorig_fx, WB_fenv_fx, st_fx, Q_synth, Q_synth ); - push_indice( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); - } - - hBWE_FD->prev_mode = mode; - move16(); - - return; -} - -/*-------------------------------------------------------------------* - * wb_bwe_enc_ivas_fx() - * - * WB BWE encoder - *-------------------------------------------------------------------*/ - -void wb_bwe_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *new_wb_speech_fx /* i : original input signal at 16kHz */ ) @@ -269,13 +140,11 @@ void wb_bwe_enc_ivas_fx( new_input_fx_exp = -Q1; move16(); -#ifdef HARM_FD_BWE if ( st_fx->element_mode == EVS_MONO ) { new_input_fx_exp = 0; move16(); } -#endif wtda_fx( old_input_fx, &new_input_fx_exp, L_wtda_synth_fx, hBWE_FD->L_old_wtda_swb_fx, &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ L_FRAME16k ); @@ -283,11 +152,7 @@ void wb_bwe_enc_ivas_fx( /* DCT of the ACELP core synthesis */ direct_transform_fx( L_wtda_synth_fx, yorig_32, 0, L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); -#ifdef HARM_FD_BWE mode = WB_BWE_encoding_fx( st_fx, yorig_32, WB_fenv_fx, new_input_fx_exp, new_input_fx_exp ); -#else - mode = WB_BWE_encoding_ivas_fx( st_fx, yorig_32, WB_fenv_fx, new_input_fx_exp, new_input_fx_exp ); -#endif move16(); push_indice( st_fx->hBstr, IND_WB_CLASS, sub( mode, 2 ), 1 ); @@ -306,11 +171,7 @@ void wb_bwe_enc_ivas_fx( * SWB BWE encoder (only for 32kHz signals) *-------------------------------------------------------------------*/ -#ifdef HARM_FD_BWE void swb_bwe_enc_fx( -#else -void swb_bwe_enc_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ @@ -319,12 +180,8 @@ void swb_bwe_enc_ivas_fx( const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ -#ifdef HARM_FD_BWE Word16 Q_shb_speech, Word16 Q_slb_speech -#else - const Word16 Q_slb_speech -#endif ) { Word16 i; @@ -358,22 +215,16 @@ void swb_bwe_enc_ivas_fx( Word16 fb_band_begin; Word16 q_new_input_hp; Word16 shb_speech_fx[L_FRAME16k]; -#ifdef HARM_FD_BWE Word16 Qenc_synth_hf, Qenc_synth; -#else - Word16 Q_shb_speech; -#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k ); } ELSE -#endif { Q_shb_speech = getScaleFactor16( shb_speech_fx_Q0, L_FRAME16k ); Copy_Scale_sig( shb_speech_fx_Q0, shb_speech_fx, L_FRAME16k, Q_shb_speech ); // Q0 -> Q_shb_spch @@ -420,19 +271,14 @@ void swb_bwe_enc_ivas_fx( Copy( old_input_12k8_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); } -#ifndef HARM_FD_BWE - } -#endif Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); Copy( old_input_12k8_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME - Sample_Delay_LP ); Copy( old_input_12k8_fx + L_INP_MEM + L_FRAME - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); -#ifdef HARM_FD_BWE } ELSE { delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_12k8_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); } -#endif } ELSE { @@ -453,33 +299,24 @@ ELSE Copy( old_input_16k_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); } -#ifndef HARM_FD_BWE - } -#endif Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); Copy( old_input_16k_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME16k - Sample_Delay_LP ); Copy( old_input_16k_fx + L_INP_MEM + L_FRAME16k - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); -#ifdef HARM_FD_BWE } ELSE { delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_16k_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME16k, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); } -#endif } q_new_input_hp = s_min( Q_shb_speech, hBWE_FD->Q_new_input_hp ); -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); } ELSE IF( LT_16( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ) -#else - IF( LT_16( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ) -#endif { Copy_Scale_sig( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP, sub( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ); // Q_shb_speech Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); // Q_shb_speech @@ -530,12 +367,8 @@ wtda_fx( old_input_fx, &new_input_fx_q, L_old_input_fx, hBWE_FD->L_old_wtda_swb_ direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_q, st_fx->element_mode ); /* high-band gain control in case of BWS */ -#ifdef HARM_FD_BWE test(); IF( st_fx->bwidth_sw_cnt > 0 && st_fx->element_mode > EVS_MONO ) -#else - IF( st_fx->bwidth_sw_cnt > 0 ) -#endif { v_multc_fx_16( &yorig_32[L_FRAME16k], div_s( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ), &yorig_32[L_FRAME16k], sub( inner_frame, L_FRAME16k ) ); } @@ -610,7 +443,6 @@ ELSE Q_shb = sub( Q_synth_hf, 4 ); } -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) ); @@ -641,9 +473,6 @@ ELSE SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth ); } -#else - Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) ); -#endif /* FB BWE encoding */ IF( EQ_16( st_fx->extl, FB_BWE ) ) @@ -691,20 +520,6 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); } -#ifndef HARM_FD_BWE -/* SWB BWE encoding */ -IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) -{ - SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); -} -ELSE -{ - SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); -} - -#endif /* write FB BWE frame gain to the bitstream */ IF( EQ_16( st_fx->extl, FB_BWE ) ) { @@ -714,253 +529,6 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) return; } -#ifndef HARM_FD_BWE -/*-------------------------------------------------------------------* - * swb_bwe_enc() - * - * SWB BWE encoder (only for 32kHz signals) - *-------------------------------------------------------------------*/ -void swb_bwe_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ - Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */ - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */ - const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */ - Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */ - const Word16 coder_type, /* i : coding type */ - Word16 Q_shb_speech, - Word16 Q_slb_speech ) -{ - Word16 i; - Word16 *new_input_fx; - Word16 tmp, exp, exp1; - Word16 frac; - Word32 L_tmp; - Word16 inner_frame; - Word32 inner_Fs; - Word32 L_old_input_fx[2 * L_FRAME48k]; - Word32 yorig_32[L_FRAME48k]; - Word16 old_input_fx[NS2SA( 48000, DELAY_FD_BWE_ENC_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME48k]; - Word16 old_input_lp_fx[L_FRAME16k]; - Word16 new_input_hp_fx[L_FRAME16k]; - Word16 yorig_fx[L_FRAME48k]; - Word16 scl, new_input_fx_exp; - Word16 max; - Word16 Sample_Delay_SWB_BWE; - Word16 Sample_Delay_HP; - Word16 Sample_Delay_LP; - Word16 idxGain = 0; - move16(); - - Word16 Q_synth_hf, Q_synth, Q_shb; - Word16 tilt_nb_fx; - Word16 SWB_fenv_fx[SWB_FENV]; - Word32 ener_low_fx; - Word32 energy_fbe_fb_fx = 0; - move32(); - Word16 fb_ener_adjust_fx; - Word16 ener_adjust_quan_fx = 0; - move16(); - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - /*---------------------------------------------------------------------* - * Delay the original input signal to be synchronized with ACELP core synthesis - *---------------------------------------------------------------------*/ - IF( EQ_16( st_fx->extl, FB_BWE ) ) - { - inner_frame = L_FRAME48k; - move16(); - inner_Fs = 48000; - move32(); - } - ELSE - { - inner_frame = L_FRAME32k; - move16(); - inner_Fs = 32000; - move32(); - } - - set16_fx( old_input_fx, 0, add( NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ), inner_frame ) ); - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 12800, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS ); - - delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_12k8_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); - } - ELSE - { - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - - delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_16k_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME16k, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); - } - move16(); - move16(); - move16(); - - Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); - Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); - Copy( shb_speech_fx + L_FRAME16k - Sample_Delay_HP, hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); - new_input_fx = old_input_fx + Sample_Delay_SWB_BWE; - Copy( hBWE_FD->old_input_fx, old_input_fx, Sample_Delay_SWB_BWE ); - Copy( new_swb_speech_fx, new_input_fx, inner_frame ); - Copy( old_input_fx + inner_frame, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - /*----------------------------------------------------------------------* - * Calculate tilt of the input signal and the ACELP core synthesis - *----------------------------------------------------------------------*/ - - /* tilt returned in Q24 goto to Q11 */ - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); - - /*---------------------------------------------------------------------* - * SWB BWE encoding - * FB BWE encoding - *---------------------------------------------------------------------*/ - - new_input_fx_exp = 0; - move16(); - /* MDCT of the core synthesis signal */ - wtda_fx( old_input_fx, &new_input_fx_exp, L_old_input_fx, hBWE_FD->L_old_wtda_swb_fx, - &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ - inner_frame ); - - /* DCT of the ACELP core synthesis */ - direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_exp, /*st_fx->element_mode*/ EVS_MONO ); - - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scl = sub( 16 + 8, new_input_fx_exp ); - /* Possible to Upscale? */ - IF( scl > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_synth = Find_Max_Norm32( yorig_32, inner_frame ); - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_synth, scl ); - } - Copy_Scale_sig32_16( yorig_32, yorig_fx, inner_frame, scl ); - Q_synth = add( sub( new_input_fx_exp, 16 ), scl ); - - max = 0; - move16(); - Q_synth_hf = 0; - move16(); - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - scl = 300; - } - ELSE - { - scl = 240; - } - move16(); - FOR( i = scl; i < inner_frame; i++ ) - { - max = s_max( max, abs_s( yorig_fx[i] ) ); - } - - IF( max == 0 ) - { - exp = 15; - move16(); - } - ELSE - { - exp = norm_s( max ); - } - - Copy_Scale_sig( &yorig_fx[scl], &yorig_fx[scl], sub( inner_frame, scl ), exp ); - Q_synth_hf = add( exp, Q_synth ); - IF( EQ_16( st_fx->last_extl, SWB_BWE ) || EQ_16( st_fx->last_extl, FB_BWE ) ) - { - exp = norm_l( st_fx->EnergyLT_fx ); - IF( add( st_fx->EnergyLT_fx_exp, exp ) > shl( sub( Q_synth_hf, 4 ), 1 ) ) - { - Q_shb = sub( Q_synth_hf, 4 ); - st_fx->EnergyLT_fx = L_shr( st_fx->EnergyLT_fx, sub( st_fx->EnergyLT_fx_exp, shl( Q_shb, 1 ) ) ); - } - ELSE - { - Q_shb = shr( add( st_fx->EnergyLT_fx_exp, exp ), 1 ); - if ( EQ_16( s_and( exp, 0x0001 ), 1 ) ) - { - exp = sub( exp, 1 ); - } - st_fx->EnergyLT_fx = L_shl( st_fx->EnergyLT_fx, exp ); - move32(); - } - } - ELSE - { - Q_shb = sub( Q_synth_hf, 4 ); - } - Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) ); - /* SWB BWE encoding */ - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, - SWB_fenv_fx, tilt_nb_fx, 80, coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); - } - ELSE - { - SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, - SWB_fenv_fx, tilt_nb_fx, 6, coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); - } - - /* FB BWE encoding */ - IF( EQ_16( st_fx->extl, FB_BWE ) ) - { - energy_fbe_fb_fx = L_deposit_l( 0 ); - FOR( i = FB_BAND_BEGIN; i < FB_BAND_END; i++ ) - { - tmp = shr( yorig_fx[i], 4 ); - energy_fbe_fb_fx = L_mac0( energy_fbe_fb_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ - } - ener_low_fx = 0; - move16(); - FOR( i = FB_BAND_BEGIN - FB_BAND_WIDTH; i < FB_BAND_BEGIN; i++ ) - { - tmp = shr( yorig_fx[i], 4 ); - ener_low_fx = L_mac0( ener_low_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ - } - - IF( energy_fbe_fb_fx != 0 ) - { - exp = norm_l( energy_fbe_fb_fx ); - frac = extract_h( L_shl( energy_fbe_fb_fx, exp ) ); - tmp = div_s( 16384, frac ); /*15+14-(exp+2*(Q_synth_hf-4)-16) -->45-(exp+2*(Q_synth_hf-4)) */ - L_tmp = Mult_32_16( ener_low_fx, tmp ); /*45-(exp+2*(Q_synth_hf-4)) + 2*(Q_synth_hf-4) - 15 = 30-exp */ - exp1 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp1 ); - // exp = 31 - exp1 - ( 30 - exp ); - exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ - } - ELSE - { - fb_ener_adjust_fx = 0; - move16(); - } - - fb_ener_adjust_fx = s_min( fb_ener_adjust_fx, 16384 ); /*Q15 */ - idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); - } - - /* write FB BWE frame gain to the bitstream */ - IF( EQ_16( st_fx->extl, FB_BWE ) ) - { - push_indice( st_fx->hBstr, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); - } - - return; -} -#endif /*==========================================================================*/ /* FUNCTION : static Word16 WB_BWE_fenv_q_fx() */ @@ -2051,9 +1619,7 @@ static void msvq_interpol_2_fx( *-------------------------------------------------------------------*/ static void calculate_Tonality_fx( -#ifdef HARM_FD_BWE const Word16 element_mode, /* i : element mode */ -#endif const Word16 *org, /* i : MDCT coefficients of original Q_new*/ const Word16 *gen, /* i : MDCT coefficients of generated signal Q15*/ Word16 *SFM_org, /* o : Spectral Flatness results Q12*/ @@ -2095,12 +1661,10 @@ static void calculate_Tonality_fx( } } -#ifdef HARM_FD_BWE max = 0; move16(); IF( element_mode == EVS_MONO ) { -#endif FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) { gen_spec[n_coeff] = abs_s( gen[n_coeff] ); @@ -2112,7 +1676,6 @@ static void calculate_Tonality_fx( }*/ max = s_max( max, org_spec[n_coeff] ); } -#ifdef HARM_FD_BWE } ELSE { @@ -2128,7 +1691,6 @@ static void calculate_Tonality_fx( max = s_max( max, gen_spec[n_coeff] ); } } -#endif l_shift = norm_s( max ); FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) { @@ -2222,164 +1784,9 @@ static void calculate_Tonality_fx( return; } -#ifndef HARM_FD_BWE + /*-------------------------------------------------------------------* - * calculate_Tonality_ivas_fx() - * - * Calculate tonality - *-------------------------------------------------------------------*/ - -static void calculate_Tonality_ivas_fx( - const Word16 *org, /* i : MDCT coefficients of original Q_new*/ - const Word16 *gen, /* i : MDCT coefficients of generated signal Q15*/ - Word16 *SFM_org, /* o : Spectral Flatness results Q12*/ - Word16 *SFM_gen, /* o : Spectral Flatness results Q12*/ - const Word16 length /* i : length for calculating tonality */ -) -{ - Word16 n_coeff; - Word16 inv_len, max; - Word16 exp, e_tmp, f_tmp; - Word32 L_tmp, L_tmp2, L_am_org, L_am_gen, L_tmp1; - Word16 org_spec[80], gen_spec[80]; - Word32 L_log_gm_org, L_log_gm_gen; - Word16 l_shift; - - /* to reduce dynamic range of original spectrum */ - max = 0; - move16(); - FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) - { - org_spec[n_coeff] = abs_s( org[n_coeff] ); - move16(); /*Q_new */ - /*test(); */ - /*if( sub(max, org_spec[n_coeff]) < 0) */ - /*{ */ - /* max = org_spec[n_coeff];move16();//Q_new */ - /*} */ - max = s_max( max, org_spec[n_coeff] ); - } - l_shift = norm_s( max ); - FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) - { - org_spec[n_coeff] = shl( org_spec[n_coeff], l_shift ); - move16(); - IF( org_spec[n_coeff] == 0 ) - { - org_spec[n_coeff] = shl( 1, l_shift ); - move16(); - } - } - - max = 0; - move16(); - FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) - { - gen_spec[n_coeff] = abs_s( gen[n_coeff] ); - move16(); /*Q15 */ - /*test(); - if( sub(max,gen_spec[n_coeff]) < 0) - { - max = gen_spec[n_coeff];move16(); - }*/ - max = s_max( max, gen_spec[n_coeff] ); - } - l_shift = norm_s( max ); - FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) - { - gen_spec[n_coeff] = shl_sat( gen_spec[n_coeff], l_shift ); - move16(); - IF( gen_spec[n_coeff] == 0 ) - { - gen_spec[n_coeff] = shl( 1, l_shift ); - move16(); - } - } - - exp = norm_s( length ); - inv_len = div_s( shl( 1, exp ), shl( length, exp ) ); /*Q15 */ - - L_am_org = L_deposit_l( 0 ); - L_am_gen = L_deposit_l( 0 ); - L_log_gm_org = 0; - move32(); - L_log_gm_gen = 0; - move32(); - - FOR( n_coeff = 0; n_coeff < length; n_coeff++ ) - { - L_am_org = L_add( L_am_org, L_deposit_l( org_spec[n_coeff] ) ); /*Q10 */ - L_am_gen = L_add( L_am_gen, L_deposit_l( gen_spec[n_coeff] ) ); /*Q10 */ - - IF( org_spec[n_coeff] != 0 ) - { - L_tmp = L_deposit_h( org_spec[n_coeff] ); /*Q26 */ - e_tmp = norm_l( L_tmp ); - f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) ); - e_tmp = sub( sub( 30, e_tmp ), 26 ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - L_log_gm_org = L_add( L_log_gm_org, L_tmp ); /*Q14 */ - } - - IF( gen_spec[n_coeff] != 0 ) - { - L_tmp = L_deposit_h( gen_spec[n_coeff] ); /*Q26 */ - e_tmp = norm_l( L_tmp ); - f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) ); - e_tmp = sub( sub( 30, e_tmp ), 26 ); - L_tmp = Mpy_32_16( e_tmp, f_tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - L_log_gm_gen = L_add( L_log_gm_gen, L_tmp ); /*Q14 */ - } - } - - IF( L_am_org != 0 ) - { - L_tmp = Mpy_32_16_1( L_am_org, inv_len ); /*Q10 */ - e_tmp = norm_l( L_tmp ); - f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) ); - e_tmp = sub( sub( 30, e_tmp ), 10 ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - } - ELSE - { - L_tmp1 = L_deposit_l( 0 ); - } - - L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ - - L_tmp = L_sub( L_tmp1, L_tmp2 ); - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ - move16(); - *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); - move16(); /*0.0001 and 5.993 in Q12 */ - - IF( L_am_gen != 0 ) - { - L_tmp = Mpy_32_16_1( L_am_gen, inv_len ); /*Q10 */ - e_tmp = norm_l( L_tmp ); - f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) ); - e_tmp = sub( sub( 30, e_tmp ), 10 ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - } - ELSE - { - L_tmp1 = L_deposit_l( 0 ); - } - - L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ - - L_tmp = L_sub( L_tmp1, L_tmp2 ); - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ - move16(); - *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); - move16(); /*0.0001 and 5.993 in Q12 */ - - return; -} -#endif - -/*-------------------------------------------------------------------* - * energy_control_fx() + * energy_control_fx() * *-------------------------------------------------------------------*/ @@ -2448,13 +1855,8 @@ static void energy_control_fx( FOR( n_band = 0; n_band < max_band; ) { -#ifdef HARM_FD_BWE calculate_Tonality_fx( st_fx->element_mode, org_fx + swb_bwe_subband[n_band] + offset, SWB_signal_fx + swb_bwe_subband[n_band] + offset, &SFM_org_fx[n_band], &SFM_gen_fx[n_band], swb_bwe_subband[n_band + band_step] - swb_bwe_subband[n_band] ); -#else - calculate_Tonality_fx( org_fx + swb_bwe_subband[n_band] + offset, SWB_signal_fx + swb_bwe_subband[n_band] + offset, - &SFM_org_fx[n_band], &SFM_gen_fx[n_band], swb_bwe_subband[n_band + band_step] - swb_bwe_subband[n_band] ); -#endif IF( LT_16( SFM_gen_fx[n_band], mult_r( 24576, SFM_org_fx[n_band] ) ) ) { @@ -2476,100 +1878,6 @@ static void energy_control_fx( return; } -#ifndef HARM_FD_BWE -/*-------------------------------------------------------------------* - * energy_control_ivas_fx() - * - *-------------------------------------------------------------------*/ - -static void energy_control_ivas_fx( - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word16 core, /* i : core */ - const Word16 mode, /* i : SHB BWE class */ - const Word16 coder_type, /* i : coder type */ - const Word16 *org_fx, /* i : input spectrum */ - const Word16 offset, /* i : frequency offset */ - Word16 *energy_factor_fx, /* o : energy factor */ - Word16 Q_new_lf ) -{ - Word16 n_band, max_band, band_step; - Word16 gamma_fx, core_type; - Word16 SWB_signal_fx[L_FRAME32k], SFM_org_fx[SWB_FENV], SFM_gen_fx[SWB_FENV]; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - - IF( EQ_16( core, ACELP_CORE ) ) - { - gamma_fx = 11469; - move16(); /*.35 in Q15 */ - test(); - IF( NE_16( coder_type, AUDIO ) && LE_32( st_fx->total_brate, ACELP_8k00 ) ) - { - core_type = 0; - } - ELSE - { - core_type = 1; - } - move16(); - get_normalize_spec_fx( core, st_fx->extl, mode, core_type, org_fx, SWB_signal_fx, &( hBWE_FD->prev_L_swb_norm1 ), offset, Q_new_lf ); - - IF( EQ_16( st_fx->extl, WB_BWE ) ) - { - max_band = 4; - band_step = 2; - } - ELSE - { - max_band = SWB_FENV; - band_step = 1; - } - move16(); - move16(); - } - ELSE /* HQ core */ - { - gamma_fx = 18022; - move16(); /*.55 in Q15 */ - get_normalize_spec_fx( core, st_fx->extl, mode, -1, org_fx, SWB_signal_fx, &( hBWE_FD->prev_L_swb_norm1 ), offset, Q_new_lf ); - - band_step = 1; - move16(); - IF( EQ_16( offset, HQ_GENERIC_FOFFSET_32K ) ) - { - max_band = 12; - } - ELSE - { - max_band = SWB_FENV; - } - move16(); - } - - FOR( n_band = 0; n_band < max_band; ) - { - calculate_Tonality_ivas_fx( org_fx + swb_bwe_subband[n_band] + offset, SWB_signal_fx + swb_bwe_subband[n_band] + offset, - &SFM_org_fx[n_band], &SFM_gen_fx[n_band], swb_bwe_subband[n_band + band_step] - swb_bwe_subband[n_band] ); - - IF( LT_16( SFM_gen_fx[n_band], mult_r( 24576, SFM_org_fx[n_band] ) ) ) - { - energy_factor_fx[n_band] = div_s( SFM_gen_fx[n_band], SFM_org_fx[n_band] ); /*Q15 */ - move16(); - if ( LT_16( energy_factor_fx[n_band], gamma_fx ) ) - { - energy_factor_fx[n_band] = gamma_fx; - move16(); - } - } - ELSE - { - energy_factor_fx[n_band] = 32767; - move16(); /* Q15 */ - } - n_band = add( n_band, band_step ); - } - return; -} -#endif /*-------------------------------------------------------------------* * WB_BWE_encoding() @@ -2579,12 +1887,10 @@ static void energy_control_ivas_fx( /* o : classification of wb signal */ static Word16 WB_BWE_encoding_fx( -#ifndef HARM_FD_BWE - const Word16 coder_type, /* i : coder type */ - const Word16 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word16 Q_synth, + Encoder_State *st_fx, /* i/o: Encoder structure */ + const Word32 *yos_fx, /* i : MDCT coefficients of weighted original */ + Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ + Word16 Q_synth, const Word16 Q_synth_lf ) { Word16 mode; @@ -2596,104 +1902,31 @@ static Word16 WB_BWE_encoding_fx( Word16 ener_40, exp; Word32 L_tmp; Word16 tmp; + Word64 energy_fx_64; + Word16 q_shift, scale; + Word16 q_WB_fenv[2]; + Word16 yos_fx_16[L_FRAME16k]; + Word16 Q_class, Q_energy, Q_fenv[2]; - n_band = 0; - move16(); - FOR( i = 0; i < 2; i++ ) + IF( st_fx->element_mode == EVS_MONO ) { - energy_fx = L_deposit_l( 0 ); - FOR( n_coeff = swb_bwe_subband[n_band]; n_coeff < swb_bwe_subband[n_band + 2]; n_coeff++ ) - { - energy_fx = L_add( energy_fx, L_shr( L_mult0( yos_fx[n_coeff], yos_fx[n_coeff] ), 6 ) ); /*2*Q_synth-6 */ - } + Word16 new_input_fx_exp = Q_synth; - L_WB_fenv_fx[i] = energy_fx; - move32(); /*2*Q_synth-6 */ - n_band = add( n_band, 2 ); - } - mode = FD_BWE_class_fx( yos_fx, 0, 0, Q_synth, 0, st_fx ); + /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ + scale = sub( 16 + 8 /*MAX_Q_NEW_INPUT*/, new_input_fx_exp ); + /* Possible to Upscale? */ + IF( scale > 0 ) + { + /* Yes */ + /* Calc Room to Upscale */ + Q_synth = Find_Max_Norm32( yos_fx, L_FRAME16k ); - energy_control_fx( st_fx, ACELP_CORE, mode, coder_type, yos_fx, 0, energy_factor_fx, Q_synth_lf ); - - FOR( i = 0; i < 2; i++ ) - { - ener_40 = mult_r( shr( energy_factor_fx[shl( i, 1 )], 1 ), 26214 ); /*Q19 */ - L_tmp = Mult_32_16( L_WB_fenv_fx[i], ener_40 ); /*2*Q_synth-2 */ - IF( L_tmp ) - { - exp = norm_l( L_tmp ); - tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); - /*exp = 30-exp-(2*Q_synth-2); */ - exp = sub( sub( 30, exp ), ( sub( shl( Q_synth, 1 ), 2 ) ) ); - L_tmp = Mpy_32_16( exp, tmp, 32767 ); /* Q16 */ - WB_fenv_fx[i] = round_fx( L_shl( L_tmp, 10 ) ); /*Q10 */ - move16(); - } - ELSE - { - WB_fenv_fx[i] = 0; - move16(); - } - } - - index = WB_BWE_fenv_q_fx( WB_fenv_fx, F_2_5_fx, 32, 2 ); - - push_indice( st_fx->hBstr, IND_WB_FENV, index, 5 ); - - return ( mode ); -} - -/*-------------------------------------------------------------------* - * WB_BWE_encoding() - * - * WB BWE main encoder - *-------------------------------------------------------------------*/ - -/* o : classification of wb signal */ -static Word16 WB_BWE_encoding_ivas_fx( -#endif - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word32 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Word16 Q_synth, - const Word16 Q_synth_lf ) -{ - Word16 mode; - Word16 i, n_coeff, n_band; - Word16 index; - Word32 energy_fx; - Word32 L_WB_fenv_fx[2]; - Word16 energy_factor_fx[4]; - Word16 ener_40, exp; - Word32 L_tmp; - Word16 tmp; - Word64 energy_fx_64; - Word16 q_shift, scale; - Word16 q_WB_fenv[2]; - Word16 yos_fx_16[L_FRAME16k]; -#ifdef HARM_FD_BWE - Word16 Q_class, Q_energy, Q_fenv[2]; - - IF( st_fx->element_mode == EVS_MONO ) - { - Word16 new_input_fx_exp = Q_synth; - - /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ - scale = sub( 16 + 8 /*MAX_Q_NEW_INPUT*/, new_input_fx_exp ); - - /* Possible to Upscale? */ - IF( scale > 0 ) - { - /* Yes */ - /* Calc Room to Upscale */ - Q_synth = Find_Max_Norm32( yos_fx, L_FRAME16k ); - - /* Stay within MAX_Q_NEW_INPUT */ - scale = s_min( Q_synth, scale ); - } - Copy_Scale_sig32_16( yos_fx, yos_fx_16, L_FRAME16k, scale ); - Q_synth = sub( add( sub( new_input_fx_exp, 16 ), scale ), 1 ); + /* Stay within MAX_Q_NEW_INPUT */ + scale = s_min( Q_synth, scale ); + } + Copy_Scale_sig32_16( yos_fx, yos_fx_16, L_FRAME16k, scale ); + Q_synth = sub( add( sub( new_input_fx_exp, 16 ), scale ), 1 ); n_band = 0; move16(); @@ -2718,7 +1951,6 @@ static Word16 WB_BWE_encoding_ivas_fx( move16(); } ELSE -#endif { n_band = 0; move16(); @@ -2740,30 +1972,18 @@ static Word16 WB_BWE_encoding_ivas_fx( move16(); n_band = add( n_band, 2 ); -#ifdef HARM_FD_BWE Q_fenv[i] = add( q_WB_fenv[i], 4 ); -#endif } scale = s_min( L_norm_arr( yos_fx, L_FRAME16k ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, L_FRAME16k, scale ); -#ifdef HARM_FD_BWE Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); -#endif } -#ifdef HARM_FD_BWE mode = FD_BWE_class_fx( yos_fx_16, 0, 0, Q_class, 0, st_fx ); -#else - mode = FD_BWE_class_fx( yos_fx_16, 0, 0, sub( add( Q_synth, scale ), Q16 ), 0, st_fx ); -#endif -#ifdef HARM_FD_BWE energy_control_fx( st_fx, ACELP_CORE, mode, st_fx->coder_type, yos_fx_16, 0, energy_factor_fx, Q_energy ); -#else - energy_control_ivas_fx( st_fx, ACELP_CORE, mode, st_fx->coder_type, yos_fx_16, 0, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); -#endif FOR( i = 0; i < 2; i++ ) { @@ -2774,11 +1994,7 @@ static Word16 WB_BWE_encoding_ivas_fx( exp = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); /* exp = 30-exp-(2*Q_synth-2 / exp = 30-exp-(q_WB_fenv[i]+4) */ -#ifdef HARM_FD_BWE exp = sub( sub( 30, exp ), Q_fenv[i] ); -#else - exp = sub( sub( 30, exp ), ( add( q_WB_fenv[i], 4 ) ) ); -#endif L_tmp = Mpy_32_16( exp, tmp, 32767 ); /* Q16 */ WB_fenv_fx[i] = round_fx( L_shl( L_tmp, 10 ) ); /* Q10 */ move16(); @@ -2804,456 +2020,12 @@ static Word16 WB_BWE_encoding_ivas_fx( *-------------------------------------------------------------------*/ static Word16 SWB_BWE_encoding_fx( -#ifndef HARM_FD_BWE - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *insig_fx, /* i : delayed original input signal at 32kHz */ - const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ - const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ - const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ - const Word16 *yos_fx, /* i : MDCT coefficients of the windowed original input signal at 32kHz */ - Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ - const Word16 tilt_nb_fx, /* i : SWB tilt */ - const Word16 st_offset, /* i : start frequency offset for BWE envelope */ - const Word16 coder_type, /* i : coding type */ - const Word16 Q_insig_lp, - const Word16 Q_shb, - const Word16 Q_synth, - const Word16 Q_synth_lf ) -{ - Word16 IsTransient, mode; - Word16 index; - Word16 i, n_coeff, n_band, pos, indice[6]; - Word16 L; - Word16 IsTransient_LF; - - Word16 tmp; - Word32 energy_fx; - Word16 tilt_fx; - Word32 global_gain_fx; - Word32 L_tmp; - Word32 L_SWB_fenv_fx[SWB_FENV]; - Word16 SWB_tenv_fx[SWB_TENV]; - Word32 L_SWB_tenv, WB_tenv_syn_fx, WB_tenv_orig_fx; - Word16 exp, expn, expd; - Word16 num, den; - Word16 scale; - Word16 Rat_tenv_fx; - Word16 SWB_tenv_tmp_fx[SWB_TENV]; - Word16 max_fx; - Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; - FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; - BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - L = L_SUBFR; - } - ELSE - { - L = L_SUBFR16k; - } - move16(); - - /* HF transient detect */ - IsTransient = detect_transient_fx( insig_hp_fx, L_FRAME16k, Q_shb, st_fx ); - st_fx->EnergyLT_fx_exp = shl( Q_shb, 1 ); - - /* LF transient detect */ - IsTransient_LF = 0; - move16(); - FOR( n_band = 0; n_band < 4; n_band++ ) - { - tmp = i_mult2( n_band, L ); - energy_fx = L_deposit_l( 0 ); - FOR( i = 0; i < L; i++ ) - { - energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_slb_speech - 7 */ - } - - if ( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) - { - IsTransient_LF = 1; - move16(); - } - - hBWE_FD->EnergyLF_fx = energy_fx; - move32(); - } - - /* tilt returned in Q24 go to Q11 */ - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); - - test(); - test(); - IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) - { - IsTransient = 0; - move16(); - st_fx->TransientHangOver = 0; - move16(); - } - - IF( EQ_16( IsTransient, 1 ) ) - { - mode = IsTransient; - move16(); - push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); - - /* Energy for the different bands and global energies */ - global_gain_fx = L_deposit_l( 0 ); - FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) - { - energy_fx = L_deposit_l( 0 ); - FOR( n_coeff = swb_bwe_trans_subband[n_band] + st_offset; n_coeff < swb_bwe_trans_subband[n_band + 1] + st_offset; n_coeff++ ) - { - L_tmp = L_shr( L_mult0( yos_fx[n_coeff], yos_fx[n_coeff] ), 7 ); /*2*Q_synth-7 */ - energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-7 */ - } - global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( sub( shl( Q_synth, 1 ), 7 ), shl( Q_shb, 1 ) ) ) ); /*2*Q_shb */ - L_SWB_fenv_fx[n_band] = energy_fx; - move32(); - } - global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ - - FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) - { - expd = norm_s( swb_bwe_trans_subband_width[n_band] ); - tmp = div_s( shl( 1, sub( 14, expd ) ), swb_bwe_trans_subband_width[n_band] ); /*Q(29-expd) */ - L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], tmp ); /*2*Q_synth-7+29-expd - 15 */ - exp = norm_l( L_tmp ); - tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( sub( 30, exp ), sub( add( shl( Q_synth, 1 ), 7 ), expd ) ); - L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - tmp = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ - - SWB_fenv_fx[n_band] = sub( tmp, Mean_env_tr_fx[n_band] ); - move16(); /*Q8 */ - } - - WB_tenv_orig_fx = L_deposit_l( 0 ); - WB_tenv_syn_fx = L_deposit_l( 1 ); - FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) - { - tmp = i_mult2( n_band, L_SUBFR16k ); - L_SWB_tenv = L_deposit_l( 0 ); - FOR( i = 0; i < L_SUBFR16k; i++ ) - { - L_SWB_tenv = L_add_sat( L_SWB_tenv, L_mult0( insig_hp_fx[i + tmp], insig_hp_fx[i + tmp] ) ); /*2*Q_shb */ - } - - tmp = i_mult2( n_band, L ); - FOR( i = 0; i < L; i++ ) - { - WB_tenv_syn_fx = L_add( WB_tenv_syn_fx, L_shr( L_mult0( synth_fx[i + tmp], synth_fx[i + tmp] ), 7 ) ); /*2*st_fx->Q_syn2 - 7 */ - WB_tenv_orig_fx = L_add( WB_tenv_orig_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*2*Q_insig_lp - 7 */ - } - - L_tmp = Mult_32_16( L_SWB_tenv, INV_L_SUBFR16k_FX ); /*2*Q_shb */ - SWB_tenv_fx[n_band] = 0; - move16(); - IF( L_tmp != 0 ) - { - exp = norm_l( L_tmp ); - tmp = extract_h( L_shl( L_tmp, exp ) ); - exp = sub( exp, sub( 30, 2 * Q_shb ) ); - - tmp = div_s( 16384, tmp ); - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp) */ - - SWB_tenv_fx[n_band] = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /*Q3*/ - move16(); - } - } - - IF( WB_tenv_orig_fx != 0 ) - { - expn = norm_l( WB_tenv_orig_fx ); - num = extract_h( L_shl( WB_tenv_orig_fx, expn ) ); - expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); - - expd = norm_l( WB_tenv_syn_fx ); - den = round_fx( L_shl( WB_tenv_syn_fx, expd ) ); - expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); - - scale = shr( sub( den, num ), 15 ); - num = shl( num, scale ); - expn = sub( expn, scale ); - - tmp = div_s( num, den ); - expn = sub( expn, expd ); - - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ - - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ - } - ELSE - { - Rat_tenv_fx = 16384; - move16(); - } - - IF( LT_16( Rat_tenv_fx, 8192 ) ) - { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ - - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ - } - ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) - { - Rat_tenv_fx = 32767; - move16(); - } - - FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) - { - SWB_tenv_fx[n_band] = mult_r( SWB_tenv_fx[n_band], Rat_tenv_fx ); - move16(); /*Q3 */ - } - - max_fx = SWB_tenv_fx[0]; - move16(); - pos = 0; - move16(); - FOR( n_band = 1; n_band < SWB_TENV; n_band++ ) - { - IF( GT_16( SWB_tenv_fx[n_band], max_fx ) ) - { - max_fx = SWB_tenv_fx[n_band]; - move16(); - pos = n_band; - move16(); - } - } - - max_fx = SWB_tenv_fx[0]; - move16(); - FOR( n_band = 1; n_band < SWB_TENV; n_band++ ) - { - tmp = sub( mult_r( SWB_tenv_fx[n_band], 6554 ), SWB_tenv_fx[n_band - 1] ); - IF( tmp > 0 ) - { - BREAK; - } - } - - IF( n_band < SWB_TENV ) - { - energy_fx = L_deposit_l( 0 ); - FOR( n_band = ( pos + 1 ); n_band < SWB_TENV; n_band++ ) - { - energy_fx = L_add( energy_fx, SWB_tenv_fx[n_band] ); /*Q3 */ - } - - IF( pos == sub( SWB_TENV, 1 ) ) - { - energy_fx = L_deposit_l( 0 ); - } - ELSE - { - tmp = sub( SWB_TENV, pos + 1 ); - tmp = div_s( 1, tmp ); /*Q15 */ - energy_fx = Mult_32_16( energy_fx, tmp ); /*Q3 */ - } - - FOR( n_band = 0; n_band < pos; n_band++ ) - { - SWB_tenv_fx[n_band] = mult_r( SWB_tenv_fx[n_band], 16384 ); - move16(); - } - - /*SWB_tenv_fx[pos] = add(SWB_tenv_fx[pos], mult_r(SWB_tenv_fx[pos], 164)); move16();//Q3 */ - SWB_tenv_fx[pos] = round_fx_sat( L_mac_sat( L_mult_sat( SWB_tenv_fx[pos], 32767 ), SWB_tenv_fx[pos], 164 ) ); /*Q3 */ - move16(); - - IF( LT_32( energy_fx, SWB_tenv_fx[pos] ) ) - { - FOR( n_band = pos + 1; n_band < SWB_TENV; n_band++ ) - { - SWB_tenv_fx[n_band] = mult_r( SWB_tenv_fx[n_band], 29491 ); - move16(); /*Q3 */ - } - } - } - ELSE - { - FOR( n_band = 1; n_band < SWB_TENV; n_band++ ) - { - IF( GT_16( SWB_tenv_fx[n_band - 1], SWB_tenv_fx[n_band] ) ) - { - /*SWB_tenv_fx[n_band-1] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ - SWB_tenv_fx[n_band - 1] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ - } - ELSE - { - /*SWB_tenv_fx[n_band] = add(mult_r(SWB_tenv_fx[n_band-1], 16384), mult_r(SWB_tenv_fx[n_band], 16384)); move16();//Q3 */ - SWB_tenv_fx[n_band] = round_fx_sat( L_mac_sat( L_mult( SWB_tenv_fx[n_band - 1], 16384 ), SWB_tenv_fx[n_band], 16384 ) ); /*Q3 */ - } - move16(); - } - - FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) - { - SWB_tenv_fx[n_band] = mult_r( SWB_tenv_fx[n_band], 29491 ); - move16(); /*Q3 */ - } - } - - test(); - test(); - IF( IsTransient_LF == 0 && EQ_16( coder_type, INACTIVE ) && EQ_16( st_fx->TransientHangOver, 1 ) ) - { - FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) - { - SWB_tenv_fx[n_band] = mult_r( SWB_tenv_fx[n_band], 16384 ); - move16(); - } - FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) - { - SWB_fenv_fx[n_band] = mult_r( SWB_fenv_fx[n_band], 1638 ); - move16(); - } - } - ELSE - { - SWB_fenv_fx[2] = mult_r( SWB_fenv_fx[2], 3277 ); - move16(); - SWB_fenv_fx[3] = mult_r( SWB_fenv_fx[3], 1638 ); - move16(); - } - - FOR( n_band = 0; n_band < SWB_TENV; n_band++ ) - { - IF( SWB_tenv_fx[n_band] == 0 ) - { - SWB_tenv_tmp_fx[n_band] = -32768; - move16(); /*-16 in Q11 */ - } - ELSE - { - L_tmp = L_deposit_h( SWB_tenv_fx[n_band] ); /*Q19 */ - expn = norm_l( L_tmp ); - tmp = Log2_norm_lc( L_shl( L_tmp, expn ) ); - expn = sub( sub( 30, expn ), 19 ); - L_tmp = Mpy_32_16( expn, tmp, 32767 ); /* Q16 */ /*1 in Q15 */ - SWB_tenv_tmp_fx[n_band] = round_fx( L_shl( L_tmp, 11 ) ); /* Q11 */ - move16(); - } - - IF( GT_16( SWB_tenv_tmp_fx[n_band], 30720 ) ) - { - index = 15; - move16(); - } - ELSE IF( SWB_tenv_tmp_fx[n_band] < 0 ) - { - index = 0; - move16(); - } - ELSE - { - index = shr( add( SWB_tenv_tmp_fx[n_band], 1024 ), 11 ); - } - - push_indice( hBstr, IND_SWB_TENV, index, 4 ); - } - - MSVQ_Interpol_Tran_fx( SWB_fenv_fx, indice ); - - push_indice( hBstr, IND_SWB_FENV, indice[0], 7 ); - push_indice( hBstr, IND_SWB_FENV, indice[1], 6 ); - } - ELSE - { - /* Energy for the different bands and global energies */ - global_gain_fx = L_deposit_l( 0 ); - FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) - { - energy_fx = L_deposit_l( 0 ); - FOR( n_coeff = swb_bwe_subband[n_band] + st_offset; n_coeff < swb_bwe_subband[n_band + 1] + st_offset; n_coeff++ ) - { - L_tmp = L_shr( L_mult0( yos_fx[n_coeff], yos_fx[n_coeff] ), 5 ); /*2*Q_synth-5 */ - energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-5 */ - } - - IF( LT_16( n_band, sub( SWB_FENV, 2 ) ) ) - { - global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( 2 * Q_synth - 5, 2 * Q_shb ) ) ); /*2*Q_shb */ - } - L_SWB_fenv_fx[n_band] = energy_fx; - move32(); - } - - global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ - mode = FD_BWE_class_fx( yos_fx, global_gain_fx, tilt_nb_fx, Q_synth, Q_shb, st_fx ); - push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); - - energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx, st_offset, energy_factor_fx, Q_synth_lf ); - - FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) - { - L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], energy_factor_fx[n_band] ); /*2*Q_synth-5 */ - L_tmp = Mult_32_16( L_tmp, swb_inv_bwe_subband_width_fx[n_band] ); /*2*Q_synth-5 */ - - IF( L_tmp != 0 ) - { - expn = norm_l( L_tmp ); - tmp = Log2_norm_lc( L_shl( L_tmp, expn ) ); - expn = sub( 30, add( expn, sub( shl( Q_synth, 1 ), 5 ) ) ); - L_tmp = Mpy_32_16( expn, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ - SWB_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ - move16(); - } - ELSE - { - SWB_fenv_fx[n_band] = -24576; - move16(); - } - } - freq_weights_fx( SWB_fenv_fx, w_NOR_fx, w_env_fx, SWB_FENV ); - - FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) - { - SWB_fenv_fx[n_band] = sub( SWB_fenv_fx[n_band], Mean_env_fx[n_band] ); - move16(); - } - - /* Energy VQ */ - msvq_interpol_fx( SWB_fenv_fx, w_env_fx, indice ); - - push_indice( hBstr, IND_SWB_FENV, indice[0], 5 ); - push_indice( hBstr, IND_SWB_FENV, indice[1], 7 ); - push_indice( hBstr, IND_SWB_FENV, indice[2], 6 ); - push_indice( hBstr, IND_SWB_FENV, indice[3], 5 ); - push_indice( hBstr, IND_SWB_FENV, indice[4], 6 ); - } - hBWE_FD->prev_mode = mode; - move16(); - hBWE_FD->prev_global_gain_fx = global_gain_fx; - move32(); - st_fx->prev_Q_shb = Q_shb; - move16(); - - return mode; -} - -/*-------------------------------------------------------------------* - * SWB_BWE_encoding() - * - * SWB BWE encoder, 32-bit variant - *-------------------------------------------------------------------*/ - -static Word16 SWB_BWE_encoding_ivas_fx( -#endif Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 *insig_fx, /* i : delayed original input signal at 32kHz */ const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ -#ifdef HARM_FD_BWE const Word16 *yos_fx_16_orig, /* i : 16-bit MDCT coefficients of the windowed original input signal at 32kHz */ -#endif const Word32 *yos_fx, /* i : 32-bit MDCT coefficients of the windowed original input signal at 32kHz */ Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ const Word16 tilt_nb_fx, /* i : SWB tilt */ @@ -3290,9 +2062,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 inner_frame; Word16 q_shift; Word16 yos_fx_16[L_FRAME_MAX]; -#ifdef HARM_FD_BWE Word16 Q_class, Q_energy; -#endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -3319,12 +2089,10 @@ static Word16 SWB_BWE_encoding_ivas_fx( move16(); } -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy( yos_fx_16_orig, yos_fx_16, inner_frame ); } -#endif /* HF transient detect */ IsTransient = detect_transient_fx( insig_hp_fx, L_FRAME16k, Q_shb, st_fx ); @@ -3343,7 +2111,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2*Q_slb_speech - 7 / 2*Q_insig_lp - 7 */ } -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { if ( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) @@ -3358,7 +2125,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( move16(); } ELSE -#endif { if ( BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( energy_fx, 5958 /* 1/5.5f in Q15 */ ), sub( 31 + 7, shl( Q_insig_lp, 1 ) ), hBWE_FD->EnergyLF_fx, hBWE_FD->EnergyLF_exp ) > 0 ) { @@ -3392,7 +2158,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); /* Energy for the different bands and global energies */ -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); @@ -3427,7 +2192,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( } } ELSE -#endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) @@ -3520,13 +2284,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( expd = norm_l( WB_tenv_syn_fx ); den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); } ELSE -#endif { expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); } @@ -3722,7 +2484,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( ELSE { /* Energy for the different bands and global energies */ -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); @@ -3749,7 +2510,6 @@ static Word16 SWB_BWE_encoding_ivas_fx( move16(); } ELSE -#endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) @@ -3774,31 +2534,19 @@ static Word16 SWB_BWE_encoding_ivas_fx( move16(); } -#ifdef HARM_FD_BWE scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); -#endif } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ -#ifdef HARM_FD_BWE mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, Q_class, Q_shb, st_fx ); -#else - scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); - Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); - mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( add( Q_synth, scale ), Q16 ), Q_shb, st_fx ); -#endif push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); -#ifdef HARM_FD_BWE energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, Q_energy ); -#else - energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); -#endif FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { @@ -3809,13 +2557,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( { expn = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, expn ) ); -#ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expn = sub( 30, add( expn, sub( shl( Q_synth, 1 ), 5 ) ) ); } ELSE -#endif { expn = sub( 30, add( expn, q_SWB_fenv[n_band] ) ); } -- GitLab From 0647932f9995e1d513f6fda74fefe69cc1c8679e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:00:59 +0100 Subject: [PATCH 05/22] [cleanup] accept FIX_2429_POST_DECODER --- lib_com/options.h | 1 - lib_com/prot_fx.h | 13 --- lib_dec/dec_LPD_fx.c | 4 - lib_dec/ivas_mdct_core_dec_fx.c | 4 - lib_dec/ivas_tcx_core_dec_fx.c | 4 - lib_dec/post_dec_fx.c | 179 -------------------------------- lib_dec/updt_dec_fx.c | 4 - 7 files changed, 209 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7cdd81116..d31ea9064 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2429_POST_DECODER #define FIX_FLOAT_1526_DIRAC_MEM_LEAK /* FhG: float issue 1526: potential memory leak in DirAC handles in case of format switching */ #define FIX_2437_HARMONIZE_ENCODERINDEX /* FhG: basop issue 2437 EncoderIndex_ivas_fx() and EncoderIndex_fx()*/ #define FIX_2385_GETTCXONLY /* FhG: issue 2385 : harmonizing getTcxonly_ivas_fx() and getTcxonly_ivas_fx() functions */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ee086a664..a658e889b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7330,20 +7330,7 @@ Word16 FEC_pos_dec_fx( const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ ); -#ifndef FIX_2429_POST_DECODER -void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ -); - -void post_decoder_ivas_fx( -#else void post_decoder_fx( -#endif Decoder_State *st, Word16 synth_buf[], // Q0 Word16 pit_gain[], // Q14 diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index d8eb395c5..4cafdfed7 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -954,11 +954,7 @@ void decoder_LPD_fx( st->last_is_cng = 0; /* Postfiltering */ -#ifdef FIX_2429_POST_DECODER post_decoder_fx( st, synth_buf, pit_gain, pitch, signal_out, bpf_noise_buf ); -#else - post_decoder( st, synth_buf, pit_gain, pitch, signal_out, bpf_noise_buf ); -#endif IF( signal_outFB ) { diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 2da93e97c..65479c7a1 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1398,11 +1398,7 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, -Q11 ); // Q11 -> Q0 } -#ifdef FIX_2429_POST_DECODER post_decoder_fx( st, synth_buf_fx, pit_gain_fx[ch], pitch[ch], x_fx_16, st->p_bpf_noise_buf ); -#else - post_decoder_ivas_fx( st, synth_buf_fx, pit_gain_fx[ch], pitch[ch], x_fx_16, st->p_bpf_noise_buf ); -#endif IF( st->p_bpf_noise_buf_32 ) { diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 04b5a78ea..cdb2b6061 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -784,11 +784,7 @@ void stereo_tcx_core_dec_fx( /* Postfiltering */ -#ifdef FIX_2429_POST_DECODER post_decoder_fx( st, synth_buf_fx, pit_gain_fx, pitch, signal_out_fx, st->p_bpf_noise_buf ); -#else - post_decoder( st, synth_buf_fx, pit_gain_fx, pitch, signal_out_fx, st->p_bpf_noise_buf ); -#endif test(); IF( st->p_bpf_noise_buf_32 && st->tcxonly == 0 ) diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 89f4ea724..e6e839233 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -20,167 +20,7 @@ static void bass_pf_1sf_delay( Word16 *syn, Word16 *T_sf, Word16 *gainT_sf, Word * Perform post-processing *---------------------------------------------------------------------*/ -#ifndef FIX_2429_POST_DECODER -void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ -) -{ - Word16 L_frame, nb_subfr; - Word16 *synth, *synth2; - Word16 pfstat_on_previous; - Word16 pitch_gain_adjust[NB_SUBFR16k]; - Word16 tmp, tmp_noise; - Word16 synth2_pe[L_FRAME_MAX]; - Word16 synth_buf2[PIT_MAX_16k + 1 + L_FRAME_MAX + M]; - Word32 bitrate; - Word8 tmp8; - BPF_DEC_HANDLE hBPF; - Word16 coder_type = st->coder_type; - - move16(); - hBPF = st->hBPF; - L_frame = st->L_frame; - move16(); - nb_subfr = st->nb_subfr; - move16(); - pfstat_on_previous = st->hPFstat->on; - move16(); - st->hPFstat->on = 0; - move16(); - - bitrate = L_add( st->total_brate, 0 ); - if ( LE_32( st->core_brate, SID_2k40 ) ) - { - bitrate = L_add( st->last_active_brate, 0 ); - } - - - /*Adapt Bpf: copy old and current adapt bpf parameters*/ - set16_fx( pitch_gain_adjust, st->bpf_gain_param, nb_subfr ); - - synth = synth_buf + st->hTcxDec->old_synth_len; - synth2 = synth_buf2 + NBPSF_PIT_MAX; - Copy( hBPF->pst_old_syn_fx, synth_buf2, NBPSF_PIT_MAX ); - - IF( st->tcxonly != 0 ) - { - Copy( synth, synth2, L_frame ); - IF( pfstat_on_previous ) - { - Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, synth - M, M ); - Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_SUBFR, 1 ); - E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); - scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_SUBFR ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 - blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, L_SUBFR, synth2 + L_SUBFR / 2 ); -#else - blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, synth2 + L_SUBFR / 2 ); -#endif - } - } - ELSE - { - /*Formant enhancement*/ - IF( ( st->last_bwidth == NB ) ) - { - Copy( synth, synth2_pe, L_frame ); - tmp = synth[-1]; - move16(); - - preemph_copy_fx( synth2_pe, synth2_pe, st->preemph_fac, L_frame, &tmp ); - - tmp = 0; - move16(); - test(); - test(); - if ( ( GT_32( st->lp_noise, LP_NOISE_THRESH ) ) || - ( st->core != ACELP_CORE ) || - ( EQ_16( coder_type, UNVOICED ) ) ) - { - tmp = 1; - move16(); - } - - if ( pfstat_on_previous == 0 ) - { - st->hPFstat->reset = 1; - move16(); - } - IF( ( st->bwidth == NB ) ) - { - st->hPFstat->on = 1; - move16(); - tmp_noise = 0; - move16(); - nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, GENERIC, st->BER_detect, tmp ); - } - ELSE - { - st->hPFstat->on = 0; - move16(); - tmp_noise = 0; - move16(); - nb_post_filt_fx( L_frame, st->hPFstat, &tmp_noise, 0, synth2_pe, st->mem_Aq, pitch, AUDIO, st->BER_detect, tmp ); - } - Copy( synth2_pe, synth2, L_frame ); - - tmp = synth2[-1]; - move16(); - deemph_fx( synth2, st->preemph_fac, L_frame, &tmp ); - } - ELSE - { - if ( pfstat_on_previous == 0 ) - { - st->hPFstat->reset = 1; - move16(); - } - IF( GE_16( st->last_bwidth, WB ) ) - { - st->hPFstat->on = 1; - move16(); - formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); - } - ELSE - { - st->hPFstat->on = 0; - move16(); - formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); - } - } - - /*Bass Post-filter */ - tmp8 = 0; - move16(); - test(); - if ( GT_32( st->lp_noise, LP_NOISE_THRESH ) && st->narrowBand ) - { - tmp8 = 1; - move16(); - } - bass_pf_1sf_delay( synth2, pitch, pit_gain, L_frame, L_SUBFR, bpf_noise_buf, pitch_gain_adjust, - tmp8, &( st->lp_error_ener ), &( st->mem_error ) ); - } - - /* Output */ - Copy( synth2, signal_out, L_frame ); - - /* Update synth2 memory */ - Copy( synth_buf2 + L_frame, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - - return; -} - - -void post_decoder_ivas_fx( -#else void post_decoder_fx( -#endif Decoder_State *st, Word16 synth_buf[], // Q0 Word16 pit_gain[], // Q14 @@ -242,7 +82,6 @@ void post_decoder_fx( IF( pfstat_on_previous ) { Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, synth - M, M ); -#ifdef FIX_2429_POST_DECODER IF( EQ_16( st->element_mode, EVS_MONO ) ) { Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_SUBFR, 1 ); @@ -269,24 +108,6 @@ void post_decoder_fx( blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); #endif } -#else - Word16 L_subfr = idiv1616( st->L_frame, st->nb_subfr ); - Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); - E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); - scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), L_SUBFR, synth2 + shr( L_subfr, 1 ) ); - } - ELSE - { - blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), L_subfr, synth2 + shr( L_subfr, 1 ) ); - } -#else - blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); -#endif -#endif } } ELSE diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 613038875..3efd07722 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1028,11 +1028,7 @@ void update_decoder_LPD_cng( st->bpf_gain_param = 0; move16(); -#ifdef FIX_2429_POST_DECODER post_decoder_fx( st, buf_synth, pf_gain, pf_pitch, timeDomainBuffer, bpf_noise_buf ); -#else - post_decoder( st, buf_synth, pf_gain, pf_pitch, timeDomainBuffer, bpf_noise_buf ); -#endif return; } -- GitLab From 33c2396bc5dd0c1d590ca16f72810a09e0043db4 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:02:44 +0100 Subject: [PATCH 06/22] [cleanup] accept FIX_2437_HARMONIZE_ENCODERINDEX --- lib_com/ivas_prot_fx.h | 8 ------- lib_com/options.h | 2 -- lib_dec/ivas_init_dec_fx.c | 14 ------------ lib_dec/ivas_ism_dec_fx.c | 4 ---- lib_dec/ivas_ism_param_dec_fx.c | 40 --------------------------------- lib_enc/ari_hm_enc_fx.c | 30 ------------------------- lib_enc/enc_prm_fx.c | 8 ------- lib_enc/prot_fx_enc.h | 7 ------ lib_rend/ivas_dirac_rend_fx.c | 2 -- 9 files changed, 115 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f51065217..6860c86c2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4090,17 +4090,9 @@ ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec /* i/o: decoder ParamISM handle */ ); -#else -void ivas_param_ism_dec_close_fx( - PARAM_ISM_DEC_HANDLE *hParamIsmDec, /* i/o: decoder ParamISM handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); -#endif void ivas_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ diff --git a/lib_com/options.h b/lib_com/options.h index d31ea9064..a692da266 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,8 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_FLOAT_1526_DIRAC_MEM_LEAK /* FhG: float issue 1526: potential memory leak in DirAC handles in case of format switching */ -#define FIX_2437_HARMONIZE_ENCODERINDEX /* FhG: basop issue 2437 EncoderIndex_ivas_fx() and EncoderIndex_fx()*/ #define FIX_2385_GETTCXONLY /* FhG: issue 2385 : harmonizing getTcxonly_ivas_fx() and getTcxonly_ivas_fx() functions */ #define FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT /* FhG: remove unreachable code in ivas_osba_stereo_add_channels */ #define FIX_OUTPUT_FRAME /* VA: harmonize "output_frame" parameter usage to correspond to FLP */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 2a295091e..01cc0f717 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3445,7 +3445,6 @@ void ivas_destroy_dec_fx( /* ISM renderer handle */ ivas_ism_renderer_close( &( st_ivas->hIsmRendererData ) ); -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* ParamISM dec handle */ ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ) ); @@ -3453,19 +3452,6 @@ void ivas_destroy_dec_fx( ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); -#else - /* DirAC handle */ - IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) - { - ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); - } - ELSE - { - ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); - } -#endif /* SPAR handle */ ivas_spar_dec_close_fx( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 8691a6546..c57989ae7 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -173,13 +173,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_32( last_ism_mode, ISM_MODE_PARAM ) ) { /* Deallocate the ParamISM struct */ -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ) ); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); -#else - ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); -#endif test(); IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index e7affdb36..1bc479f1c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -617,18 +617,15 @@ ivas_error ivas_param_ism_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM\n" ) ); } -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* initialize sub-handles with NULL */ hParamIsmDec->hParamIsm = NULL; hParamIsmDec->hParamIsmRendering = NULL; -#endif IF( ( hSpatParamRendCom = (SPAT_PARAM_REND_COMMON_DATA_HANDLE) malloc( sizeof( SPAT_PARAM_REND_COMMON_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); } -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* initialize buffers in handle with NULL - this handle is also used by other DirAC technologies, and not every technology is initializing all buffers */ hSpatParamRendCom->azimuth = NULL; hSpatParamRendCom->elevation = NULL; @@ -640,7 +637,6 @@ ivas_error ivas_param_ism_dec_open_fx( hSpatParamRendCom->spreadCoherence_fx = NULL; hSpatParamRendCom->spreadCoherence2_fx = NULL; hSpatParamRendCom->surroundingCoherence_fx = NULL; -#endif /* Assign memory to Param Object handle */ IF( ( hParamIsmDec->hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL ) @@ -648,23 +644,19 @@ ivas_error ivas_param_ism_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM\n" ) ); } -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* initialize sub-handles with NULL */ hParamIsmDec->hParamIsm->hFbMixer = NULL; -#endif IF( ( hParamIsmDec->hParamIsmRendering = (PARAM_ISM_RENDERING_HANDLE) malloc( sizeof( PARAM_ISM_RENDERING_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ParamISM Rendering handle\n" ) ); } -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* initialize sub-handles/buffers with NULL */ hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL; hParamIsmDec->hParamIsmRendering->interpolator_fx = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL; -#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); @@ -871,17 +863,9 @@ ivas_error ivas_param_ism_dec_open_fx( * Close Param ISM handle *-------------------------------------------------------------------------*/ -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK void ivas_param_ism_dec_close_fx( PARAM_ISM_DEC_HANDLE *hParamIsmDec_out /* i/o: decoder DirAC handle */ ) -#else -void ivas_param_ism_dec_close_fx( - PARAM_ISM_DEC_HANDLE *hParamIsmDec_out, /* i/o: decoder DirAC handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ - AUDIO_CONFIG output_config /* i : output audio configuration */ -) -#endif { test(); IF( hParamIsmDec_out != NULL && *hParamIsmDec_out != NULL ) @@ -896,11 +880,6 @@ void ivas_param_ism_dec_close_fx( hParamIsmDec->hParamIsm = NULL; } -#ifndef FIX_FLOAT_1526_DIRAC_MEM_LEAK - test(); - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) - { -#endif /* Param ISM Rendering */ IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL ) { @@ -912,9 +891,6 @@ void ivas_param_ism_dec_close_fx( free( hParamIsmDec->hParamIsmRendering->proto_matrix_fx ); hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL; } -#ifndef FIX_FLOAT_1526_DIRAC_MEM_LEAK - } -#endif IF( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx != NULL ) { @@ -936,22 +912,6 @@ void ivas_param_ism_dec_close_fx( *hParamIsmDec_out = NULL; } -#ifndef FIX_FLOAT_1526_DIRAC_MEM_LEAK - test(); - IF( hSpatParamRendCom_out != NULL && *hSpatParamRendCom_out != NULL ) - { - test(); - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 1 ); - ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 2 ); - } - - free( *hSpatParamRendCom_out ); - *hSpatParamRendCom_out = NULL; - } -#endif return; } diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index f57c0639c..121d4d9c5 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -51,36 +51,6 @@ Word16 EncodeIndex_fx( return 8; } } -#ifndef FIX_2437_HARMONIZE_ENCODERINDEX -Word16 EncodeIndex_ivas_fx( - const Word16 Bandwidth, - Word16 PeriodicityIndex, - BSTR_ENC_HANDLE hBst /* i/o: bitstream handle */ -) -{ - Word16 NumRatioBitsBwLtpIndx; - - IF( s_and( PeriodicityIndex, kLtpHmFlag ) != 0 ) - { - Word16 LtpPitchIndex = shr( PeriodicityIndex, 9 ); - assert( 0 <= LtpPitchIndex && LtpPitchIndex <= 16 ); - - PeriodicityIndex = sub( PeriodicityIndex, 1 ); - assert( ( PeriodicityIndex & 0xff ) < ( 1 << NumRatioBits[Bandwidth][LtpPitchIndex] ) ); - - NumRatioBitsBwLtpIndx = NumRatioBits[Bandwidth][LtpPitchIndex]; - move16(); - - push_next_indice( hBst, s_and( PeriodicityIndex, 0xff ), NumRatioBitsBwLtpIndx ); - return NumRatioBitsBwLtpIndx; - } - ELSE - { - push_next_indice( hBst, PeriodicityIndex, 8 ); - return 8; - } -} -#endif // !FIX_2437_HARMONIZE_ENCODERINDEX /*-------------------------------------------------------------------* * SearchPeriodicityIndex_Single() * diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index c138f0e21..c08ef67e8 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -82,11 +82,7 @@ static void enc_prm_hm_ivas_fx( flag = 1; move16(); } -#ifndef FIX_2437_HARMONIZE_ENCODERINDEX - EncodeIndex_ivas_fx( flag, prm_hm[1], hBstr ); -#else EncodeIndex_fx( flag, prm_hm[1], hBstr ); -#endif // !FIX_2437_HARMONIZE_ENCODERINDEX IF( EQ_16( st->hTcxCfg->coder_type, VOICED ) ) { @@ -1253,11 +1249,7 @@ void writeTCXparam_fx( IF( prm[j] ) { -#ifndef FIX_2437_HARMONIZE_ENCODERINDEX - EncodeIndex_ivas_fx( (Word16) GE_16( hm_size, 256 ), prm[j + 1], hBstr ); -#else EncodeIndex_fx( (Word16) GE_16( hm_size, 256 ), prm[j + 1], hBstr ); -#endif // !FIX_2437_HARMONIZE_ENCODERINDEX flag_ctx_hm = 1; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index bed59ad02..ee84ffd3f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2559,13 +2559,6 @@ Word16 EncodeIndex_fx( Word16 PeriodicityIndex, BSTR_ENC_HANDLE hBst /* i/o: bitstream handle */ ); -#ifndef FIX_2437_HARMONIZE_ENCODERINDEX -Word16 EncodeIndex_ivas_fx( - const Word16 Bandwidth, /* 0: NB, 1: (S)WB */ - Word16 PeriodicityIndex, - BSTR_ENC_HANDLE hBst /* i/o: bitstream handle */ -); -#endif void enc_prm_side_Info_fx( PLC_ENC_EVS_HANDLE hPlc_Ext, Encoder_State *st ); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index bb39107fd..48a90ada5 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -226,7 +226,6 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC meta\n" ) ); } -#ifdef FIX_FLOAT_1526_DIRAC_MEM_LEAK /* initialize buffers in handle with NULL - this handle is also used by other DirAC technologies, and not every technology is initializing all buffers */ hSpatParamRendCom->azimuth = NULL; hSpatParamRendCom->elevation = NULL; @@ -238,7 +237,6 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( hSpatParamRendCom->spreadCoherence_fx = NULL; hSpatParamRendCom->spreadCoherence2_fx = NULL; hSpatParamRendCom->surroundingCoherence_fx = NULL; -#endif *hSpatParamRendCom_out = hSpatParamRendCom; } -- GitLab From f524981255648324236847b3dff40c55c1ab1802 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:03:38 +0100 Subject: [PATCH 07/22] [cleanup] accept FIX_2385_GETTCXONLY --- lib_com/core_com_config_fx.c | 166 ----------------------------------- lib_com/options.h | 1 - lib_com/prot_fx.h | 15 ---- lib_dec/core_dec_init_fx.c | 9 -- lib_dec/evs_dec_fx.c | 4 - lib_enc/core_enc_init_fx.c | 9 -- lib_enc/core_enc_switch_fx.c | 8 -- lib_enc/ivas_cpe_enc_fx.c | 4 - 8 files changed, 216 deletions(-) diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c index 79c420094..bab08fe18 100644 --- a/lib_com/core_com_config_fx.c +++ b/lib_com/core_com_config_fx.c @@ -169,7 +169,6 @@ Word16 get_codec_mode( return codec_mode; /*Q0*/ } -#ifdef FIX_2385_GETTCXONLY /*-------------------------------------------------------------------* * getTcxonly() * @@ -236,171 +235,6 @@ Word16 getTcxonly_fx( return tcxonly; /*Q0*/ } -#else -/*-------------------------------------------------------------------* - * getTcxonly_ivas() - * - * - *-------------------------------------------------------------------*/ - -Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 is_ism_format /* i : flag indicating ISM format Q0*/ -) -{ - Word16 tcxonly = 0; - move16(); - Word32 temp_flag; - if ( MCT_flag ) - { - temp_flag = IVAS_32k; - move32(); - } - else - { - temp_flag = IVAS_48k; - move32(); - } - - SWITCH( element_mode ) - { - case EVS_MONO: - if ( GT_32( total_brate, ACELP_32k ) ) - { - tcxonly = 1; - move16(); - } - BREAK; - case IVAS_SCE: - if ( is_ism_format ) - { - if ( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) ) - { - tcxonly = 1; - move16(); - } - } - else - { - if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) - { - tcxonly = 1; - move16(); - } - } - BREAK; - - case IVAS_CPE_DFT: - case IVAS_CPE_TD: - if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) - { - tcxonly = 1; - move16(); - } - BREAK; - case IVAS_CPE_MDCT: - if ( GE_32( total_brate, temp_flag ) ) - { - tcxonly = 1; - move16(); - } - BREAK; - } - - return tcxonly; /*Q0*/ -} -#endif /* FIX_2385_GETTCXONLY */ -#ifndef FIX_2385_GETTCXONLY - -Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ -) -{ - - Word16 tcxonly; - tcxonly = 0; - move16(); - if ( GT_32( total_brate, 32000 ) ) - { - tcxonly = 1; - move16(); - } - return tcxonly; /*Q0*/ -} - -Word16 getTcxonly_fx( - const Word16 element_mode, /* i : IVAS element mode Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 is_ism_format /* i : flag indicating ISM format Q0*/ -) -{ - Word16 tcxonly; - tcxonly = 0; - move16(); - - SWITCH( element_mode ) - { - case EVS_MONO: - if ( GT_32( total_brate, ACELP_32k ) ) - { - tcxonly = 1; - move16(); - } - BREAK; - case IVAS_SCE: - IF( is_ism_format ) - { - if ( GT_32( total_brate, MAX_ACELP_BRATE_ISM ) ) - { - tcxonly = 1; - move16(); - } - } - ELSE - { - if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) - { - tcxonly = 1; - move16(); - } - } - BREAK; - - case IVAS_CPE_DFT: - case IVAS_CPE_TD: - if ( GT_32( total_brate, MAX_ACELP_BRATE ) ) - { - tcxonly = 1; - move16(); - } - BREAK; - case IVAS_CPE_MDCT: - IF( MCT_flag ) - { - - if ( GE_32( total_brate, IVAS_32k ) ) - { - tcxonly = 1; - move16(); - } - } - ELSE - { - if ( GE_32( total_brate, IVAS_48k ) ) - { - tcxonly = 1; - move16(); - } - } - BREAK; - } - - return tcxonly; /*Q0*/ -} -#endif /* FIX_2385_GETTCXONLY */ /*-------------------------------------------------------------------* * getCtxHm() diff --git a/lib_com/options.h b/lib_com/options.h index a692da266..f75fe4756 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2385_GETTCXONLY /* FhG: issue 2385 : harmonizing getTcxonly_ivas_fx() and getTcxonly_ivas_fx() functions */ #define FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT /* FhG: remove unreachable code in ivas_osba_stereo_add_channels */ #define FIX_OUTPUT_FRAME /* VA: harmonize "output_frame" parameter usage to correspond to FLP */ #define HARMONIZE_ISSUE_2435_WRITETNSDATA /* FhG basop 2435: Harmonize WriteTnsData*_fx(), EncodeTnsData*_fx() */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a658e889b..fb3fc81d7 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3692,12 +3692,6 @@ Word16 get_cng_mode( Word16 get_codec_mode( const Word32 total_brate /* i : total bitrate */ ); -#ifndef FIX_2385_GETTCXONLY - -Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ -); -#endif Word16 getTcxonly_fx( const Word16 element_mode, /* i : IVAS element mode */ @@ -10157,15 +10151,6 @@ void configureFdCngEnc_ivas_fx( const Word16 bwidth, /* Q0 */ const Word32 total_brate /* Q0 */ ); -#ifndef FIX_2385_GETTCXONLY - -Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ -); -#endif void SetModeIndex_ivas_fx( Encoder_State *st, /* i : Encoder state */ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index a71fe3d3e..3f85151ef 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -32,12 +32,10 @@ void open_decoder_LPD_fx( TCX_LTP_DEC_HANDLE hTcxLtpDec; HQ_DEC_HANDLE hHQ_core; TCX_DEC_HANDLE hTcxDec; -#ifdef FIX_2385_GETTCXONLY Word16 MCT_flag; MCT_flag = 0; /* TODO: workaround for future harmonization of functions */ move16(); -#endif hBPF = st->hBPF; hBWE_TD = st->hBWE_TD; @@ -74,14 +72,7 @@ void open_decoder_LPD_fx( move16(); } -#ifdef FIX_2385_GETTCXONLY st->tcxonly = getTcxonly_fx( st->element_mode, total_brate, MCT_flag, st->is_ism_format ); -#else - st->tcxonly = getTcxonly( - st->total_brate - /*, st->is_ism_format Needed in the last version of float IVAS */ - ); -#endif move16(); /* the TD TCX PLC in MODE1 still runs with 80ms subframes */ diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index ba38ae82a..d2c589ab5 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -252,11 +252,7 @@ ivas_error evs_dec_fx( test(); test(); test(); -#ifdef FIX_2385_GETTCXONLY IF( st_fx->use_partial_copy && ( ( sub( st_fx->last_core, HQ_CORE ) == 0 ) || ( sub( st_fx->last_core, TCX_10_CORE ) == 0 ) || ( ( sub( st_fx->last_core, TCX_20_CORE ) == 0 ) && getTcxonly_fx( EVS_MONO, st_fx->last_total_brate, 0, 0 ) ) ) ) -#else - IF( st_fx->use_partial_copy && ( ( sub( st_fx->last_core, HQ_CORE ) == 0 ) || ( sub( st_fx->last_core, TCX_10_CORE ) == 0 ) || ( ( sub( st_fx->last_core, TCX_20_CORE ) == 0 ) && getTcxonly( /*EVS_MONO, */ st_fx->last_total_brate /*, 0, 0*/ ) ) ) ) -#endif { st_fx->bfi = 1; move16(); diff --git a/lib_enc/core_enc_init_fx.c b/lib_enc/core_enc_init_fx.c index 85c945f9c..3661adf8a 100644 --- a/lib_enc/core_enc_init_fx.c +++ b/lib_enc/core_enc_init_fx.c @@ -49,12 +49,7 @@ void init_coder_ace_plus_fx( TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; /* Bitrate */ -#ifdef FIX_2385_GETTCXONLY st->tcxonly = (Word8) getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); -#else - st->tcxonly = (Word8) getTcxonly( - st->total_brate ); -#endif move16(); /* Core Sampling Rate */ @@ -941,11 +936,7 @@ void init_coder_ace_plus_ivas_fx( Word16 L_subfr; /* Bitrate */ -#ifdef FIX_2385_GETTCXONLY st->tcxonly = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); -#else - st->tcxonly = getTcxonly_ivas_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); -#endif /* FIX_2385_GETTCXONLY */ move16(); /* Core Sampling Rate */ diff --git a/lib_enc/core_enc_switch_fx.c b/lib_enc/core_enc_switch_fx.c index f1ae291ef..2fe851f62 100644 --- a/lib_enc/core_enc_switch_fx.c +++ b/lib_enc/core_enc_switch_fx.c @@ -49,11 +49,7 @@ void core_coder_mode_switch_fx( switchWB = 1; /*force init when coming from MODE1*/ } -#ifdef FIX_2385_GETTCXONLY tcxonly_tmp = getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); -#else - tcxonly_tmp = getTcxonly( st->total_brate ); -#endif if ( NE_16( tcxonly_tmp, st->tcxonly ) ) { @@ -71,11 +67,7 @@ void core_coder_mode_switch_fx( move32(); st->L_frame = extract_l( Mult_32_16( st->sr_core, INV_FRAME_PER_SEC_Q15 ) ); assert( st->L_frame == st->sr_core / 50 ); -#ifdef FIX_2385_GETTCXONLY st->tcxonly = (Word8) getTcxonly_fx( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); -#else - st->tcxonly = (Word8) getTcxonly( st->total_brate ); -#endif /* st->bits_frame_nominal = (int)( (float)st->L_frame/(float)st->fscale ) * (float)FSCALE_DENOM/128.0f * (float)st->bitrate/100.0f + 0.49f ; */ /* st->bits_frame_nominal = extract_l(L_shr(Mpy_32_16_1( L_shl(st->bitrate,8), mult_r(div_s(st->fscale, shl(st->L_frame,4)), FL2WORD16(FSCALE_DENOM/12800.f))), 6)); */ tmp32 = L_shl( st->total_brate, 1 ); /* (float)st->L_frame/(float)st->fscale * (float)FSCALE_DENOM/128.0f * (float)st->bitrate */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index af1d17041..c7aea4b98 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -815,11 +815,7 @@ ivas_error ivas_cpe_enc_fx( { Word32 internal_Fs; -#ifdef FIX_2385_GETTCXONLY IF( getTcxonly_fx( IVAS_CPE_MDCT, imult1616( sts[0]->bits_frame_nominal, FRAMES_PER_SEC ), 0, sts[0]->is_ism_format ) == 0 ) -#else - IF( getTcxonly_ivas_fx( IVAS_CPE_MDCT, imult1616( sts[0]->bits_frame_nominal, FRAMES_PER_SEC ), 0, sts[0]->is_ism_format ) == 0 ) -#endif /* FIX_2385_GETTCXONLY */ { internal_Fs = INT_FS_16k; move32(); -- GitLab From ad1c57878239d2710f8443bf9bb72e0f93ef6459 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:05:07 +0100 Subject: [PATCH 08/22] [cleanup] accept FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT --- lib_com/ivas_prot_fx.h | 7 ------- lib_com/options.h | 1 - lib_dec/ivas_dec_render_fx.c | 4 ---- lib_dec/ivas_osba_dec_fx.c | 26 -------------------------- 4 files changed, 38 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6860c86c2..b8feba23d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3755,16 +3755,9 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ -#ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word32 gain, /* i : gain bed value Q11 */ -#else - const Word32 gain_bed_fx, /* i : gain bed value Q11 */ -#endif const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ -#ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT - const Word16 ism_mode, /* i : ISM mode */ -#endif const UWord16 n_samples_to_render /* i : output frame length per channel */ ); diff --git a/lib_com/options.h b/lib_com/options.h index f75fe4756..8282da1ee 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT /* FhG: remove unreachable code in ivas_osba_stereo_add_channels */ #define FIX_OUTPUT_FRAME /* VA: harmonize "output_frame" parameter usage to correspond to FLP */ #define HARMONIZE_ISSUE_2435_WRITETNSDATA /* FhG basop 2435: Harmonize WriteTnsData*_fx(), EncodeTnsData*_fx() */ #define HARM_2336_DOTP /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */ diff --git a/lib_dec/ivas_dec_render_fx.c b/lib_dec/ivas_dec_render_fx.c index 8c056a23d..ec74f595e 100644 --- a/lib_dec/ivas_dec_render_fx.c +++ b/lib_dec/ivas_dec_render_fx.c @@ -511,11 +511,7 @@ ivas_error ivas_dec_render_fx( ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); /* add already rendered SBA part */ -#ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); -#else - ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered ); -#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 2359d9e2a..c80d77af4 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -321,27 +321,14 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ -#ifdef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT const Word32 gain, /* i : gain bed value */ -#else - const Word32 gain_bed_fx, /* i : gain bed value */ -#endif const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ -#ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT - const Word16 ism_mode, /* i : ISM mode */ -#endif const UWord16 n_samples_to_render /* i : output frame length per channel */ ) { Word16 n, i; -#ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT - IF( EQ_16( ism_mode, ISM_SBA_MODE_DISC ) ) - { - Word32 gain = gain_bed_fx; - move32(); -#endif test(); IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) ) { @@ -366,19 +353,6 @@ void ivas_osba_stereo_add_channels_fx( } } } -#ifndef FIX_2196_UNREACHABLE_CODE_IN_OSBA_STEREO_OUTPUT - } - ELSE - { - FOR( n = 0; n < nchan_out; n++ ) - { - FOR( i = 0; i < n_samples_to_render; i++ ) - { - output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 - } - } - } -#endif return; -- GitLab From 05b3a000a1e6ac98c53612d6aa910a130b7b4f73 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:06:57 +0100 Subject: [PATCH 09/22] [cleanup] accept FIX_OUTPUT_FRAME --- lib_com/options.h | 1 - lib_dec/amr_wb_dec_fx.c | 5 ----- lib_dec/core_dec_init_fx.c | 14 -------------- lib_dec/core_dec_switch_fx.c | 4 ---- lib_dec/evs_dec_fx.c | 4 ---- lib_dec/lib_dec_fx.c | 7 ------- lib_dec/stat_dec.h | 3 --- 7 files changed, 38 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8282da1ee..e695e9d4e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_OUTPUT_FRAME /* VA: harmonize "output_frame" parameter usage to correspond to FLP */ #define HARMONIZE_ISSUE_2435_WRITETNSDATA /* FhG basop 2435: Harmonize WriteTnsData*_fx(), EncodeTnsData*_fx() */ #define HARM_2336_DOTP /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 00347cac7..02c3ec1d8 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -143,12 +143,7 @@ ivas_error amr_wb_dec_fx( move16(); st_fx->coder_type = GENERIC; move16(); -#ifdef FIX_OUTPUT_FRAME output_frame = extract_l( Mult_32_16( st_fx->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); -#else - output_frame = st_fx->output_frame_fx; /*Q0*/ - move16(); /* frame length of the input signal */ -#endif st_fx->bpf_off = 0; move16(); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 3f85151ef..e73fce2bc 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -738,11 +738,7 @@ void open_decoder_LPD_fx( test(); IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->last_core, HQ_CORE ) ) { -#ifdef FIX_OUTPUT_FRAME frame_ener_fx( st->hTcxDec->L_frameTCX, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); -#else - frame_ener_fx( st->output_frame_fx, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); -#endif } } ELSE @@ -1177,10 +1173,6 @@ void open_decoder_LPD_ivas_fx( { st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); move16(); -#ifndef FIX_OUTPUT_FRAME - st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */ - move16(); -#endif if ( st->ini_frame == 0 ) { st->L_frameTCX_past = st->hTcxDec->L_frameTCX; @@ -1803,13 +1795,7 @@ void open_decoder_LPD_ivas_fx( test(); IF( st->core == ACELP_CORE && EQ_16( st->last_core, HQ_CORE ) ) { -#ifdef FIX_OUTPUT_FRAME frame_ener_fx( st->hTcxDec->L_frameTCX, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); -#else - st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */ - move16(); - frame_ener_fx( st->output_frame_fx, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); -#endif } } ELSE diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index 94b4ae0b4..b5c5f4a8b 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -338,10 +338,6 @@ void mode_switch_decoder_LPD_ivas_fx( { st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */ move16(); -#ifndef FIX_OUTPUT_FRAME - st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */ - move16(); -#endif } IF( st->hTcxCfg != NULL ) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index d2c589ab5..555320a1d 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -100,11 +100,7 @@ ivas_error evs_dec_fx( move16(); } -#ifdef FIX_OUTPUT_FRAME output_frame = extract_l( Mult_32_16( st_fx->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); -#else - output_frame = st_fx->output_frame_fx; /*Q0*/ -#endif move16(); core_switching_flag = 0; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 732d3000b..d4b5024b2 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5587,14 +5587,7 @@ static ivas_error evs_dec_main_fx( hCoreCoder = st_ivas->hSCE[0]->hCoreCoder; hCoreCoder[0]->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); -#ifdef FIX_OUTPUT_FRAME nOutSamples = extract_l( Mult_32_16( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); -#else - hCoreCoder[0]->output_frame_fx = extract_l( Mult_32_16( hCoreCoder[0]->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); // Q0 - move16(); - nOutSamples = hCoreCoder[0]->output_frame_fx; - move16(); -#endif mdct_switching_dec_fx( hCoreCoder[0] ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index ff8b2d37d..548e8f048 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1034,9 +1034,6 @@ typedef struct Decoder_State Word16 amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ Word16 BER_detect; /* flag to signal detected bit error in the bitstream */ Word32 output_Fs; /* output sampling rate */ -#ifndef FIX_OUTPUT_FRAME - Word16 output_frame_fx; /* Output frame length Q0*/ -#endif Word32 total_brate; /* total bitrate in kbps of the codec */ Word32 last_total_brate; /* last total bitrate in kbps of the codec */ Word32 last_total_brate_ber; /* last total bitrate in kbps of the codec - used only when first frame is lost and BER is detected afterwards */ -- GitLab From 896c25a3aad396da1aaabdc3d52367926f1685f6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:08:49 +0100 Subject: [PATCH 10/22] [cleanup] accept HARMONIZE_ISSUE_2435_WRITETNSDATA --- lib_com/options.h | 1 - lib_com/prot_fx.h | 19 ----------- lib_enc/cod_tcx_fx.c | 4 --- lib_enc/enc_prm_fx.c | 13 -------- lib_enc/prot_fx_enc.h | 25 -------------- lib_enc/tns_base_enc_fx.c | 68 --------------------------------------- 6 files changed, 130 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e695e9d4e..1f32dae80 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define HARMONIZE_ISSUE_2435_WRITETNSDATA /* FhG basop 2435: Harmonize WriteTnsData*_fx(), EncodeTnsData*_fx() */ #define HARM_2336_DOTP /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index fb3fc81d7..ba14ac3b1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8052,15 +8052,6 @@ void GetParameters_fx( Word16 *pnBits // Q0 ); -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ -); -#else void EncodeTnsData_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ @@ -8068,7 +8059,6 @@ void EncodeTnsData_ivas_fx( Word16 *pnSize, /* o : number of written parameters Q0 */ Word16 *pnBits /* o : number of written bits Q0 */ ); -#endif void SetParameters( ParamsBitMap const *paramsBitMap, @@ -10683,15 +10673,6 @@ void ResetTnsData_flt( void ClearTnsFilterCoefficients_flt( STnsFilter *pTnsFilter ); -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - Word16 *pnBits /* o : number of written bits */ -); -#endif void WriteTnsData( const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 71d22d2a8..45b478bb8 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -5416,11 +5416,7 @@ void TNSAnalysisStereo_fx( st->hTcxEnc->tnsData[k].tnsOnWhitenedSpectra = st->hTcxEnc->bTnsOnWhithenedSpectra[k]; move16(); -#ifdef HARMONIZE_ISSUE_2435_WRITETNSDATA EncodeTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); -#else - EncodeTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, &st->hTcxEnc->tnsData[k], param_core[ch] + k * NPRM_DIV + 1 + NOISE_FILL_RANGES + LTPSIZE, tnsSize[ch] + k, tnsBits[ch] + k ); -#endif } IF( EQ_16( st->hTcxEnc->transform_type[k], TCX_5 ) ) diff --git a/lib_enc/enc_prm_fx.c b/lib_enc/enc_prm_fx.c index c08ef67e8..e789e1621 100644 --- a/lib_enc/enc_prm_fx.c +++ b/lib_enc/enc_prm_fx.c @@ -745,12 +745,7 @@ void enc_prm_fx( IF( st->hTcxCfg->fIsTNSAllowed ) { -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA - - WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st, &nTnsBits ); -#else WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st->hBstr, &nTnsBits ); -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA j = add( j, nTnsParams ); /* Q0 */ } @@ -901,11 +896,7 @@ void enc_prm_fx( { SetTnsConfig( st->hTcxCfg, 0, ( last_core == ACELP_CORE ) && ( k == 0 ) ); -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA - WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st, &nTnsBits ); -#else WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, st->hBstr, &nTnsBits ); -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA j = add( j, nTnsParams ); @@ -1215,11 +1206,7 @@ void writeTCXparam_fx( } ELSE { -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA - WriteTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, hBstr, &nTnsBits ); -#else WriteTnsData_fx( st->hTcxCfg->pCurrentTnsConfig, prm + j, &nTnsParams, hBstr, &nTnsBits ); -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA } IF( no_param_tns ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ee84ffd3f..8d8891cb6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1447,45 +1447,20 @@ Word16 DetectTnsFilt_fx( Word16 *predictionGain /* o : TNS prediction gain Q=7 */ ); -#ifdef HARMONIZE_ISSUE_2435_WRITETNSDATA void EncodeTnsData_fx( STnsConfig const *pTnsConfig, STnsData const *pTnsData, Word16 *stream, Word16 *pnSize, Word16 *pnBits ); -#else -Word16 EncodeTnsData_fx( - STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word16 *stream, - Word16 *pnSize, - Word16 *pnBits ); -#endif -#ifdef HARMONIZE_ISSUE_2435_WRITETNSDATA Word16 WriteTnsData_fx( STnsConfig const *pTnsConfig, Word16 const *stream, Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ); -#endif // HARMONIZE_ISSUE_2435_WRITETNSDATA -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -Word16 WriteTnsData_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - Encoder_State *st, - Word16 *pnBits ); -Word16 WriteTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA void subband_FFT_fx( Word32 **Sr, /*(i) real part of the CLDFB*/ Word32 **Si, /*(i) imag part of the CLDFB*/ diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 6bc31dd0a..0ad30427b 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -436,37 +436,7 @@ Word16 DetectTnsFilt_fx( return ( pTnsData->nFilters > 0 ); } -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -Word16 EncodeTnsData_fx( STnsConfig const *pTnsConfig, STnsData const *pTnsData, Word16 *stream, Word16 *pnSize, Word16 *pnBits ) -{ - - move16(); - move16(); - *pnSize = 0; - *pnBits = 0; - - IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) - { - - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - GetParameters( &tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - ELSE - { - GetParameters( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - } - ELSE - { - GetParameters( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize, pnBits ); - } - - return TNS_NO_ERROR; -} -#endif -#ifdef HARMONIZE_ISSUE_2435_WRITETNSDATA void EncodeTnsData_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ @@ -474,15 +444,6 @@ void EncodeTnsData_fx( Word16 *pnSize, /* o : number of written parameters Q0*/ Word16 *pnBits /* o : number of written bits Q0*/ ) -#else -void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ -) -#endif { *pnSize = 0; move16(); @@ -521,37 +482,8 @@ void EncodeTnsData_ivas_fx( return; } -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -Word16 WriteTnsData_fx( STnsConfig const *pTnsConfig, Word16 const *stream, Word16 *pnSize, Encoder_State *st, Word16 *pnBits ) -{ - - IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) - { - - IF( LT_16( pTnsConfig->iFilterBorders[0], 512 ) ) - { - WriteToBitstream_fx( &tnsEnabledSWBTCX10BitMap, 1, &stream, pnSize, st->hBstr, pnBits ); - } - ELSE - { - WriteToBitstream_fx( &tnsEnabledSWBTCX20BitMap, 1, &stream, pnSize, st->hBstr, pnBits ); - } - } - ELSE - { - WriteToBitstream_fx( &tnsEnabledWBTCX20BitMap, 1, &stream, pnSize, st->hBstr, pnBits ); - } - - - return TNS_NO_ERROR; -} -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA -#ifndef HARMONIZE_ISSUE_2435_WRITETNSDATA -Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, Word16 const *stream, Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ) -#else Word16 WriteTnsData_fx( STnsConfig const *pTnsConfig, Word16 const *stream, Word16 *pnSize, BSTR_ENC_HANDLE hBstr, Word16 *pnBits ) -#endif // !HARMONIZE_ISSUE_2435_WRITETNSDATA { IF( GT_16( pTnsConfig->nMaxFilters, 1 ) ) { -- GitLab From 537d685e9c622483fa3020bfa979e012089837ee Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:09:37 +0100 Subject: [PATCH 11/22] [cleanup] accept HARM_2336_DOTP --- lib_com/options.h | 1 - lib_com/prot_fx.h | 27 -------- lib_com/tools_fx.c | 103 ------------------------------ lib_enc/ivas_mct_enc_mct_fx.c | 5 -- lib_enc/speech_music_classif_fx.c | 4 -- 5 files changed, 140 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1f32dae80..e24f70326 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define HARM_2336_DOTP /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ #define FIX_MDCT_STEREO_ENC_STACK /* VA: basop issue 2428: Move IGF temporary buffers out of the highest stack */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ba14ac3b1..e28c0cf9e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5590,15 +5590,6 @@ void v_add_fx_me( const Word16 N, /* i : Vector length */ const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ ); -#ifndef HARM_2336_DOTP -void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); -#endif void v_sub_fx( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -5628,15 +5619,6 @@ Word32 dotp_fx32_o( const Word16 n, /* i : vector length */ const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ Word16 *res_q ); -#ifndef HARM_2336_DOTP -Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ -); -#endif Word32 dotp_fx_ivas_fx( const Word32 x[], /* i : vector x[] */ Word16 x_e, @@ -5650,15 +5632,6 @@ Word32 dotp_fx_guarded( const Word32 y[], /* i : vector y[] */ const Word16 n /* i : vector length */ ); -#ifndef HARM_2336_DOTP -Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ); -#endif void lsf_end_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 mode2_flag, /* Q0 */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index ea87bb5f9..3a2944c73 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -630,63 +630,6 @@ Word32 dotp_fx32_o( return W_extract_l( suma ); } -#ifndef HARM_2336_DOTP -Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ -) -{ - Word16 i; - Word64 suma; /*resultant q= q(x)+q(y)-9-x such that q<=31*/ - - suma = W_shr( W_mult_32_32( x[0], y[0] ), log_len ); - - FOR( i = 1; i < n; i++ ) - { - suma = W_add( suma, W_shr( W_mult_32_32( x[i], y[i] ), log_len ) ); - } - *res_q = add( *res_q, add( sub( *res_q, log_len ), 1 ) ); - move16(); - test(); - test(); - FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) - { - suma = W_shr( suma, 1 ); - *res_q = sub( *res_q, 1 ); - move16(); - } - return W_extract_l( suma ); -} - - -/*-------------------------------------------------------------------* - * v_add_w64() - * - * Subtraction of two vectors sample by sample - *-------------------------------------------------------------------*/ - -void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -) -{ - Word16 i; - - FOR( i = 0; i < N; i++ ) - { - y[i] = W_add( W_shr( x1[i], hdrm ), W_shr( x2[i], hdrm ) ); - move64(); - } - - return; -} -#endif /*-------------------------------------------------------------------* @@ -704,18 +647,12 @@ void v_sub_fx( ) { Word16 i; -#ifdef HARM_2336_DOTP Word32 wtmp; assert( hdrm < 31 && hdrm > 0 ); wtmp = L_shl_sat( 1, sub( 31, hdrm ) ); -#endif FOR( i = 0; i < N; i++ ) { -#ifndef HARM_2336_DOTP - y[i] = L_sub( L_shr( x1[i], hdrm ), L_shr( x2[i], hdrm ) ); -#else y[i] = Msub_32_32( Mpy_32_32( x1[i], wtmp ), x2[i], wtmp ); -#endif move32(); } @@ -5152,30 +5089,6 @@ UWord32 mvl2s_r( return noClipping; } -#ifndef HARM_2336_DOTP -Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ) -{ - Word16 i; - Word32 suma; - Word32 mul; - Word16 mul_exp = add( exp_x, exp_y ); - suma = Mpy_32_32( x[0], y[0] ); - *exp_suma = mul_exp; - FOR( i = 1; i < n; i++ ) - { - mul = Mpy_32_32( x[i], y[i] ); - suma = BASOP_Util_Add_Mant32Exp( suma, *exp_suma, mul, mul_exp, exp_suma ); // exp_x+exp_A - } - - return suma; -} -#endif Word32 dotp_fx_guarded( const Word32 x[], /* i : vector x[] */ const Word32 y[], /* i : vector y[] */ @@ -5204,21 +5117,6 @@ Word32 dotp_fx_ivas_fx( const Word16 n, /* i : vector length */ Word16 *out_e ) { -#ifndef HARM_2336_DOTP - Word16 i, exp; - Word32 suma = 0; - - exp = 31; - move16(); - - FOR( i = 0; i < n; i++ ) - { - suma = BASOP_Util_Add_Mant32Exp( suma, exp, Mpy_32_32( x[i], y[i] ), x_e + y_e, &exp ); - } - - *out_e = exp; - move16(); -#else Word16 i; Word32 suma; Word32 mul; @@ -5231,7 +5129,6 @@ Word32 dotp_fx_ivas_fx( mul = Mpy_32_32( x[i], y[i] ); suma = BASOP_Util_Add_Mant32Exp( suma, *out_e, mul, mul_exp, out_e ); // exp_x+exp_A } -#endif return suma; } diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 522e493e2..0463f710e 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -235,17 +235,12 @@ static void getCorrelationMatrix_fx( FOR( n = 0; n < nSubframes; n++ ) { -#ifndef HARM_2336_DOTP - res_q = sub( 31, sts[0]->hTcxEnc->spectrum_e[0] ); - L_tmp = dotp_fx32_fac( sts[ch1]->hTcxEnc->spectrum_fx[n], sts[ch2]->hTcxEnc->spectrum_fx[n], L_subframe, 1, &res_q ); -#else Word16 tmp_Q; res_q = sub( 31, sts[0]->hTcxEnc->spectrum_e[0] ); tmp_Q = res_q; move16(); L_tmp = dotp_fx32_o( sts[ch1]->hTcxEnc->spectrum_fx[n], sts[ch2]->hTcxEnc->spectrum_fx[n], L_subframe, 1, &res_q ); res_q = add( res_q, tmp_Q ); -#endif xCorrMatrix[ch1][ch2] = BASOP_Util_Add_Mant32Exp( xCorrMatrix[ch1][ch2], xCorrMatrix_exp[ch1][ch2], L_tmp, sub( 31, res_q ), &xCorrMatrix_exp[ch1][ch2] ); move32(); } diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index bde429c81..1e6188979 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1740,11 +1740,7 @@ Word16 ivas_smc_gmm_fx( move16(); len = mel_fb_len[i]; move16(); -#ifndef HARM_2336_DOTP - temp32 = dotp_me_fx( &PS_fx[j], pt_mel_fb_fx, len, 31 - Qfact_PS, Q1, &dotp_exp ); -#else temp32 = dotp_fx_ivas_fx( &PS_fx[j], 31 - Qfact_PS, pt_mel_fb_fx, Q1, len, &dotp_exp ); -#endif IF( LT_16( dotp_exp, -17 ) ) /*-18 is exponent of 10737:to avoid overflow when left shifting 10737*/ { temp32 = L_shr( temp32, sub( -17, dotp_exp ) ); -- GitLab From 9e4b55ae8616f98730b5d2b4a8ad37cb429ca203 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:10:39 +0100 Subject: [PATCH 12/22] [cleanup] accept FIX_2431_AVOID_CALLOC --- lib_com/cldfb_evs_fx.c | 10 ---------- lib_com/modif_fs_fx.c | 10 ---------- lib_com/options.h | 1 - lib_com/prot_fx.h | 7 ------- lib_com/wi_fx.c | 4 ---- lib_dec/amr_wb_dec_fx.c | 12 ------------ lib_dec/evs_dec_fx.c | 7 ------- lib_dec/ivas_sce_dec_fx.c | 5 ----- lib_dec/lib_dec_fx.c | 20 -------------------- lib_dec/stat_dec.h | 3 --- 10 files changed, 79 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index 211ed33c3..f319c56fc 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -1598,27 +1598,17 @@ ivas_error cldfb_save_memory( } hs->memory_length = cldfb_get_memory_length( hs ); move16(); -#ifdef FIX_2431_AVOID_CALLOC hs->memory = (Word16 *) malloc( ( hs->memory_length + CLDFB_MEM_EXPONENTS + 1 ) * sizeof( Word16 ) ); IF( hs->memory == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); } -#else - hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof( Word16 ) ); -#endif /* save the memory */ Copy( hs->FilterStates, hs->memory, hs->memory_length ); Copy( hs->FilterStates_e, hs->memory + hs->memory_length, CLDFB_MEM_EXPONENTS ); hs->memory[hs->memory_length + CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg; move16(); -#ifndef FIX_2431_AVOID_CALLOC - IF( hs->memory == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); - } -#endif return IVAS_ERR_OK; } diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 43d5bac4a..08cd1322b 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -366,11 +366,7 @@ Word16 modify_Fs_intcub3m_sup_fx( const Word16( *cu )[3] = 0; Word16 *sigin_sr, *sigOutptr, *cptr; const Word16 *uptr, *ctptr; -#ifdef FIX_2431_AVOID_CALLOC Word16 sigin_sr_tab[NS2SA( 16000, DELAY_CLDFB_NS ) + 2]; -#else - Word16 *sigin_sr_tab; -#endif Word16 lim, inc, lim2, lim3; Word32 vv32; #define QSR 2 /* right shift to avoid overflow, 2 is OK */ @@ -396,9 +392,6 @@ Word16 modify_Fs_intcub3m_sup_fx( } ELSE { -#ifndef FIX_2431_AVOID_CALLOC - sigin_sr_tab = (Word16 *) calloc( lg + 2, sizeof( *sigin_sr ) ); /*shift right*/ -#endif sigin_sr = sigin_sr_tab + 2; FOR( i = -2; i < lg; i++ ) { @@ -636,9 +629,6 @@ Word16 modify_Fs_intcub3m_sup_fx( } } -#ifndef FIX_2431_AVOID_CALLOC - free( sigin_sr_tab ); -#endif return lg_out; } diff --git a/lib_com/options.h b/lib_com/options.h index e24f70326..a8bc50a4f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ #define FIX_MDCT_STEREO_ENC_STACK /* VA: basop issue 2428: Move IGF temporary buffers out of the highest stack */ #define HARMONIZE_TBE3 /* VA: basop issue 2399: Remove duplicated code: TBE, step 3 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index e28c0cf9e..bca3b1cd4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7215,14 +7215,9 @@ void core_switching_hq_prepare_dec_fx( ); ivas_error amr_wb_dec_fx( -#ifdef FIX_2431_AVOID_CALLOC Decoder_State *st_fx, /* i/o: Decoder static variables structure */ Word16 output_sp[], /* o : synthesis output */ Word32 *mem_hp20_in_fx /* i/o: hp20 filter memory Qx*/ -#else - Word16 output_sp[], /* o : synthesis output */ - Decoder_State *st_fx /* o : Decoder static variables structure */ -#endif ); void amr_wb_dec_init_fx( @@ -8546,9 +8541,7 @@ void d_gain_pred_fx( ivas_error evs_dec_fx( Decoder_State *st_fx, /* i/o : Decoder state structure */ Word16 output_sp[], /* o : output synthesis signal */ -#ifdef FIX_2431_AVOID_CALLOC Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ -#endif FRAME_MODE frameMode /* i : Decoder frame mode */ ); diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index b8ffef305..ce5a0e7f0 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -44,11 +44,7 @@ ivas_error DTFS_new_fx( { Word16 i; DTFS_STRUCTURE *dtfs_fx = NULL; -#ifdef FIX_2431_AVOID_CALLOC dtfs_fx = (DTFS_STRUCTURE *) malloc( sizeof( DTFS_STRUCTURE ) ); -#else - dtfs_fx = (DTFS_STRUCTURE *) calloc( 1, sizeof( DTFS_STRUCTURE ) ); -#endif IF( dtfs_fx == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTFS (SC-VBR) structure\n" ) ); diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 02c3ec1d8..5eef39ba7 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -16,14 +16,9 @@ *-------------------------------------------------------------------*/ ivas_error amr_wb_dec_fx( -#ifdef FIX_2431_AVOID_CALLOC Decoder_State *st_fx, /* i/o: Decoder static variables structure */ Word16 output_sp[], /* o : synthesis output */ Word32 *mem_hp20_in_fx /* i/o: hp20 filter memory Qx*/ -#else - Word16 output_sp[], /* o : synthesis output Q_syn2*/ - Decoder_State *st_fx /* o : Decoder static variables structure */ -#endif ) { Word16 i; @@ -1078,17 +1073,10 @@ ivas_error amr_wb_dec_fx( } /* HP filter */ -#ifdef FIX_2431_AVOID_CALLOC Scale_sig32( mem_hp20_in_fx, 4, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) ); st_fx->Qprev_synth_buffer_fx = st_fx->Q_syn2; move16(); hp20( synth_out_fx, 1 /*stride*/, output_frame, mem_hp20_in_fx, st_fx->output_Fs ); -#else - Scale_sig32( st_fx->L_mem_hp_out_fx, 4, sub( st_fx->Q_syn2, st_fx->Qprev_synth_buffer_fx ) ); - st_fx->Qprev_synth_buffer_fx = st_fx->Q_syn2; - move16(); - hp20( synth_out_fx, 1 /*stride*/, output_frame, st_fx->L_mem_hp_out_fx, L_mult0( output_frame, 50 ) ); -#endif /* save synthesis for core switching */ Copy_Scale_sig( synth_out_fx + NS2SA_FX2( st_fx->output_Fs, ACELP_LOOK_NS + DELAY_BWE_TOTAL_NS ), st_fx->old_synth_sw_fx, NS2SA_FX2( st_fx->output_Fs, FRAME_SIZE_NS - ACELP_LOOK_NS - DELAY_BWE_TOTAL_NS ), sub( hHQ_core->Q_old_postdec, st_fx->Q_syn2 ) ); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 555320a1d..8e47739ca 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -18,9 +18,7 @@ ivas_error evs_dec_fx( Decoder_State *st_fx, /* i/o : Decoder state structure */ Word16 output_sp[], /* o : output synthesis signal Q0*/ -#ifdef FIX_2431_AVOID_CALLOC Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ -#endif FRAME_MODE frameMode /* i : Decoder frame mode */ ) { @@ -1345,13 +1343,8 @@ ivas_error evs_dec_fx( st_fx->Qprev_synth_buffer_fx = Qpostd; move16(); -#ifdef FIX_2431_AVOID_CALLOC Scale_sig32( mem_hp20_in_fx, 4, sub( Qpostd, Qpostd_prev ) ); /*Qpostd*/ hp20( synth_fx, 1 /*stride*/, output_frame, mem_hp20_in_fx, st_fx->output_Fs ); -#else - Scale_sig32( st_fx->L_mem_hp_out_fx, 4, sub( Qpostd, Qpostd_prev ) ); /*Qpostd*/ - hp20( synth_fx, 1 /*stride*/, output_frame, st_fx->L_mem_hp_out_fx, L_mult0( output_frame, 50 ) ); -#endif /*----------------------------------------------------------------* * Synthesis output diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index a07f5b508..22bd4094a 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -386,12 +386,7 @@ ivas_error create_sce_dec( * Core Coder, 1 instance: allocate and initialize *-----------------------------------------------------------------*/ -#ifdef FIX_2431_AVOID_CALLOC IF( ( st = (Decoder_State *) malloc( sizeof( Decoder_State ) ) ) == NULL ) -#else - // IF ( ( st = (DEC_CORE_HANDLE) calloc( sizeof( Decoder_State ) ) ) == NULL ) - IF( ( st = (Decoder_State *) calloc( 1, sizeof( Decoder_State ) ) ) == NULL ) -#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CoreCoder structure\n" ) ); } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d4b5024b2..0dd016b9d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5598,22 +5598,14 @@ static ivas_error evs_dec_main_fx( { IF( hCoreCoder[0]->Opt_AMR_WB ) { -#ifdef FIX_2431_AVOID_CALLOC IF( NE_32( ( error = amr_wb_dec_fx( hCoreCoder[0], output_16, st_ivas->mem_hp20_out_fx[0] ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = amr_wb_dec_fx( output_16, hCoreCoder[0] ) ), IVAS_ERR_OK ) ) -#endif { return error; } } ELSE { -#ifdef FIX_2431_AVOID_CALLOC IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, st_ivas->mem_hp20_out_fx[0], FRAMEMODE_NORMAL ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, FRAMEMODE_NORMAL ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -5623,33 +5615,21 @@ static ivas_error evs_dec_main_fx( { IF( hCoreCoder[0]->bfi == 0 ) { -#ifdef FIX_2431_AVOID_CALLOC IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, st_ivas->mem_hp20_out_fx[0], FRAMEMODE_NORMAL ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, FRAMEMODE_NORMAL ) ), IVAS_ERR_OK ) ) -#endif { return error; } } ELSE IF( EQ_16( hCoreCoder[0]->bfi, 2 ) ) { -#ifdef FIX_2431_AVOID_CALLOC IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, st_ivas->mem_hp20_out_fx[0], FRAMEMODE_FUTURE ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, FRAMEMODE_FUTURE ) ), IVAS_ERR_OK ) ) -#endif { return error; } } ELSE { -#ifdef FIX_2431_AVOID_CALLOC IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, st_ivas->mem_hp20_out_fx[0], FRAMEMODE_MISSING ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = evs_dec_fx( hCoreCoder[0], output_16, FRAMEMODE_MISSING ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 548e8f048..65fd7d391 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1092,9 +1092,6 @@ typedef struct Decoder_State Word32 offset_scale2_p_fx[MAX_NO_MODES_p + 1][MAX_NO_SCALES + 1]; /* offsets for LSF LVQ structure, pred. case, 2nd 8-dim subvector*/ Word16 no_scales_fx[MAX_NO_MODES][2]; /* LSF LVQ structure Q0*/ Word16 no_scales_p_fx[MAX_NO_MODES_p][2]; /* LSF LVQ structure Q0*/ -#ifndef FIX_2431_AVOID_CALLOC - Word32 L_mem_hp_out_fx[5]; /* hp filter memory for synthesis */ -#endif Word16 GSC_noisy_speech; /* AC mode (GSC) - flag to indicate GSC on SWB noisy speech */ Word16 GSC_IVAS_mode; /* AC mode (GSC) - GSC IVAS mode */ -- GitLab From 803c4d537020ec2fbd70828f4666c17c51d3288f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:11:34 +0100 Subject: [PATCH 13/22] [cleanup] accept FIX_2424_REMOVE_GAUSS_L2_ENC --- lib_com/options.h | 1 - lib_enc/cod_ace_fx.c | 5 --- lib_enc/cod_uv_fx.c | 92 ------------------------------------------- lib_enc/enc_uv_fx.c | 12 ------ lib_enc/prot_fx_enc.h | 17 -------- 5 files changed, 127 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a8bc50a4f..3d93b8eec 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ #define FIX_MDCT_STEREO_ENC_STACK /* VA: basop issue 2428: Move IGF temporary buffers out of the highest stack */ #define HARMONIZE_TBE3 /* VA: basop issue 2399: Remove duplicated code: TBE, step 3 */ #define FIX_2459_USAN_AMR_SIDSTART /* FhG: basop issue 2459: fix msan complaint */ diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 7b32f789e..f066d1c55 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -290,12 +290,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( EQ_16( acelp_cfg->gains_mode[j_subfr], 7 ) ) { -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC gauss_L2_fx( st->element_mode, h1, code2, y2, y22, &gain_code2, &g_corr, gain_pit, hLPDmem->tilt_code, p_Aq, acelp_cfg->formant_enh_num, &( st->seed_acelp ), shift ); -#else - assert( gain_pit == 0 ); - gauss_L2_fx( h1, code2, y2, y22, &gain_code2, &g_corr, gain_pit, hLPDmem->tilt_code, p_Aq, acelp_cfg->formant_enh_num, &( st->seed_acelp ), shift ); -#endif } ELSE { diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 99636b306..5ea5cec3f 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -20,9 +20,7 @@ *-------------------------------------------------------------------*/ void gauss_L2_fx( -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC const Word16 element_mode, /* i : element mode */ -#endif const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code[], /* o : gaussian excitation Q9 */ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ @@ -38,7 +36,6 @@ void gauss_L2_fx( { Word16 i, tmp16; Word32 tmp32, tmp32_2; -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC Word16 Q_fac; Q_fac = Q18; @@ -48,7 +45,6 @@ void gauss_L2_fx( Q_fac = Q16; move16(); } -#endif assert( gain_pit == 0 ); @@ -80,24 +76,16 @@ void gauss_L2_fx( move32(); /*Update correlations for gains coding */ -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - Q_fac ); /* Q_fac */ tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - Q_fac ); /* Q_fac */ -#else - tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ - tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 18 ); /* Q18 */ -#endif -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC IF( element_mode == EVS_MONO ) { -#endif FOR( i = 0; i < L_SUBFR; i++ ) { tmp32 = L_mac0_sat( tmp32, y11[i], y11[i] ); /* Q18 */ tmp32_2 = L_mac0_sat( tmp32_2, y11[i], y2[i] ); /* Q18 */ } -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC } ELSE { @@ -108,98 +96,18 @@ void gauss_L2_fx( tmp32_2 = L_mac0( tmp32_2, tmp16, shr( y2[i], 1 ) ); /* Q16 */ } } -#endif tmp16 = norm_l( tmp32 ); g_corr->y1y1 = round_fx_sat( L_shl( tmp32, tmp16 ) ); -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC g_corr->y1y1_e = sub( sub( 31, Q_fac ), tmp16 ); -#else - g_corr->y1y1_e = sub( 31 - 18, tmp16 ); -#endif move16(); move16(); tmp16 = norm_l( tmp32_2 ); g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) ); -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC g_corr->y1y2_e = sub( sub( 31, Q_fac ), tmp16 ); -#else - g_corr->y1y2_e = sub( 31 - 18, tmp16 ); -#endif move16(); move16(); return; } -#ifndef FIX_2424_REMOVE_GAUSS_L2_ENC -void gauss_L2_ivas_fx( - const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ - Word16 code[], /* o : gaussian excitation Q9 */ - const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ - Word16 y11[], /* o : zero-memory filtered gauss. excitation Q9 */ - Word32 *gain, /* o : excitation gain Q16 */ - ACELP_CbkCorr *g_corr, /*i/o : correlation structure for gain coding */ - const Word16 gain_pit, /* i : unquantized gain of code Q14 */ - const Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *Aq, /* i : quantized LPCs Q12 */ - const Word16 formant_enh_num, /* i : formant enhancement numerator factor Q15 */ - Word16 *seed_acelp, /*i/o : random seed Q0 */ - const Word16 shift ) -{ - Word16 i, tmp16; - Word32 tmp32, tmp32_2; - - - assert( gain_pit == 0 ); - - /*-----------------------------------------------------------------* - * Find new target for the Gaussian codebook - *-----------------------------------------------------------------*/ - - /*Generate white gaussian noise using central limit theorem method (N only 4 as E_util_random is not purely uniform)*/ - FOR( i = 0; i < L_SUBFR; i++ ) - { - Random( seed_acelp ); - tmp32 = L_mac( 0, *seed_acelp, 1 << 9 ); - - Random( seed_acelp ); - tmp32 = L_mac( tmp32, *seed_acelp, 1 << 9 ); - - Random( seed_acelp ); - code[i] = mac_r( tmp32, *seed_acelp, 1 << 9 ); - move16(); - } - - /*Shape the gaussian excitation*/ - cb_shape_fx( 1, 0, 0, 1, 0, formant_enh_num, FORMANT_SHARPENING_G2, Aq, code, tilt_code, 0, 1, L_SUBFR ); - - /*compute 0s memory weighted synthesis contribution and find gain*/ - E_UTIL_f_convolve( code, h, y11, L_SUBFR ); /* y11: Q8+shift */ - Scale_sig( y11, L_SUBFR, sub( 1, shift ) ); /* Q9 */ - *gain = L_deposit_l( 0 ); - move32(); - /*Update correlations for gains coding */ - tmp32 = L_shr( 21474836l /*0.01f Q31*/, 31 - 16 ); /* Q16 */ - tmp32_2 = L_shr( 21474836l /*0.01f Q31*/, 31 - 16 ); /* Q16 */ - FOR( i = 0; i < L_SUBFR; i++ ) - { - tmp16 = shr( y11[i], 1 ); - tmp32 = L_mac0( tmp32, tmp16, tmp16 ); /* Q16 */ - tmp32_2 = L_mac0( tmp32_2, tmp16, shr( y2[i], 1 ) ); /* Q16 */ - } - - tmp16 = norm_l( tmp32 ); - // To be checked - g_corr->y1y1 = round_fx_sat( L_shl( tmp32, tmp16 ) ); - g_corr->y1y1_e = sub( 31 - 16, tmp16 ); - move16(); - move16(); - - tmp16 = norm_l( tmp32_2 ); - g_corr->y1y2 = round_fx_sat( L_shl( tmp32_2, tmp16 ) ); - g_corr->y1y2_e = sub( 31 - 16, tmp16 ); - move16(); - move16(); -} -#endif diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 118fc8251..c09de6c3f 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -180,19 +180,7 @@ void encod_unvoiced_fx( move16(); move16(); -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC gauss_L2_fx( st_fx->element_mode, h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); -#else - assert( gain_pit_fx == 0 ); - IF( st_fx->element_mode == EVS_MONO ) - { - gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); - } - ELSE - { - gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); - } -#endif /*----------------------------------------------------------* * - Compute the fixed codebook gain * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 8d8891cb6..1d5ba1d00 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2014,9 +2014,7 @@ void E_ACELP_xy2_corr( Word16 exp_xn ); void gauss_L2_fx( -#ifdef FIX_2424_REMOVE_GAUSS_L2_ENC const Word16 element_mode, /* i : element mode */ -#endif const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code2[], /* o : gaussian excitation Q9 */ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ @@ -2030,21 +2028,6 @@ void gauss_L2_fx( Word16 *seed_acelp, /*i/o : random seed Q0 */ const Word16 shift ); -#ifndef FIX_2424_REMOVE_GAUSS_L2_ENC -void gauss_L2_ivas_fx( - const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ - Word16 code2[], /* o : gaussian excitation Q9 */ - const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ - Word16 y11[], /* o : zero-memory filtered gauss. excitation Q9 */ - Word32 *gain, /* o : excitation gain */ - ACELP_CbkCorr *g_corr, /*i/o : correlation structure for gain coding */ - const Word16 gain_pit, /* i : unquantized gain of code */ - const Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *Aq, /* i : quantized LPCs Q12 */ - const Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp, /*i/o : random seed Q0 */ - const Word16 shift ); -#endif Word32 SFM_Cal_fx( Word32 magn[], Word16 n ); -- GitLab From 959de23eee521708bd166bede28d828045712c62 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:12:25 +0100 Subject: [PATCH 14/22] [cleanup] accept FIX_MDCT_STEREO_ENC_STACK --- lib_com/options.h | 1 - lib_com/prot_fx.h | 2 - lib_enc/ivas_stereo_mdct_core_enc_fx.c | 157 ------------------------- lib_enc/prot_fx_enc.h | 2 - lib_enc/tcx_utils_enc_fx.c | 2 - 5 files changed, 164 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3d93b8eec..7ad260abb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -83,7 +83,6 @@ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ -#define FIX_MDCT_STEREO_ENC_STACK /* VA: basop issue 2428: Move IGF temporary buffers out of the highest stack */ #define HARMONIZE_TBE3 /* VA: basop issue 2399: Remove duplicated code: TBE, step 3 */ #define FIX_2459_USAN_AMR_SIDSTART /* FhG: basop issue 2459: fix msan complaint */ #define FIX_2458_USAN_NULLPTR_WITH_ZERO_OFFSET /* FhG: basop issue 2458: avoid indexing into null pointer */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bca3b1cd4..71bf83177 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9892,7 +9892,6 @@ void ProcessStereoIGF_fx( const Word32 element_brate, /* i : element bitrate */ const Word16 mct_on ); -#ifdef FIX_MDCT_STEREO_ENC_STACK void ProcessStereoIGF_fx_64( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ @@ -9910,7 +9909,6 @@ void ProcessStereoIGF_fx_64( const Word16 mct_on /* i : flag MCT mode */ ); -#endif void IGFEncApplyStereo_fx( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index faa0193cb..37996fe42 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -402,11 +402,7 @@ void stereo_mdct_core_enc_fx( * Power spectrum calculation *---------------------------------------------------------------*/ -#ifdef FIX_MDCT_STEREO_ENC_STACK Word16 exp, shift1, shift2, norm; -#else - Word16 length, exp, shift1, shift2, norm; -#endif Word32 mdct, mdst, imdct, imdst; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -581,47 +577,6 @@ void stereo_mdct_core_enc_fx( IF( ( NE_16( hStereoMdct->mdct_stereo_mode[n], hStereoMdct->IGFStereoMode[n] ) || EQ_16( hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) && !hStereoMdct->isSBAStereoMode ) { IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; -#ifndef FIX_MDCT_STEREO_ENC_STACK - Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS]; - Word16 exp_powSpec[CPE_CHANNELS][N_MAX], *p_exp_powSpec[CPE_CHANNELS]; - p_powerSpec_fx[0] = powerSpec_fx[0]; - p_exp_powSpec[0] = exp_powSpec[0]; - p_powerSpec_fx[1] = powerSpec_fx[1]; - p_exp_powSpec[1] = exp_powSpec[1]; - { - /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Word16 n1, nsub = 1; - length = sts[ch]->hTcxEnc->L_frameTCX; - move16(); - move16(); - IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); - nsub = NB_DIV; - move16(); - } - IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) - { - length = add( length, shr( length, 2 ) ); - } - FOR( n1 = 0; n1 < nsub; n1++ ) - { - FOR( i = 0; i < length; i++ ) - { - /* This doesn't result in saturation */ - shift1 = W_norm( powerSpec64[ch][i + n1 * length] ); - powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], shift1 ) ); // exp: exp - move32(); - exp_powSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], shift1 ); - } - } - set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); - set16_fx( exp_powSpec[ch] + length, 0, sub( N_MAX, length ) ); - } - } -#endif hIGFEnc[0] = sts[0]->hIGFEnc; hIGFEnc[1] = sts[1]->hIGFEnc; hIGFEnc[0]->spec_be_igf_e = p_orig_spectrum_e[0]; @@ -629,56 +584,12 @@ void stereo_mdct_core_enc_fx( move16(); move16(); -#ifdef FIX_MDCT_STEREO_ENC_STACK ProcessStereoIGF_fx_64( hStereoMdct, sts, ms_mask, orig_spectrum_fx, powerSpec64, exp_powerSpec64, powerSpecMsInv_fx, q_powerSpecMsInv_fx, inv_spectrum_fx, exp_inv_spectrum, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); -#else - ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ), - p_powerSpec_fx, p_exp_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv_fx, inv_spectrum_fx, exp_inv_spectrum, - n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); -#endif } ELSE { -#ifndef FIX_MDCT_STEREO_ENC_STACK - Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent - Word16 exp_powerSpec[CPE_CHANNELS][N_MAX]; - { - /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Word16 n1, nsub; - nsub = 1; - length = sts[ch]->hTcxEnc->L_frameTCX; - move16(); - move16(); - IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); - nsub = NB_DIV; - move16(); - } - IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) - { - length = add( length, shr( length, 2 ) ); - } - FOR( n1 = 0; n1 < nsub; n1++ ) - { - FOR( i = 0; i < length; i++ ) - { - norm = W_norm( powerSpec64[ch][i + n1 * length] ); - powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], norm ) ); // exp = exp_powerSpec64[ch][n1]-norm - exp_powerSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], norm ); - move32(); - move16(); - } - } - set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); - set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX, length ) ); - } - } -#endif FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -687,66 +598,13 @@ void stereo_mdct_core_enc_fx( { st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } -#ifdef FIX_MDCT_STEREO_ENC_STACK ProcessIGF_ivas_fx_64( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], p_orig_spectrum_e[ch], powerSpec64[ch], exp_powerSpec64[ch], n, hCPE->hCoreCoder[0]->sp_aud_decision0 ); -#else - L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */ - Word16 q_spectrum; - q_spectrum = sub( Q31, p_orig_spectrum_e[ch] ); - IF( st->hIGFEnc ) - { - q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); - } - - q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); - - Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ - ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif } } } } ELSE { -#ifndef FIX_MDCT_STEREO_ENC_STACK - Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent - Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; - { - /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ - FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - Word16 n1, nsub; - nsub = 1; - length = sts[ch]->hTcxEnc->L_frameTCX; - move16(); - move16(); - IF( NE_16( sts[ch]->hTcxEnc->tcxMode, TCX_20 ) ) - { - length = shr( sts[ch]->hTcxEnc->L_frameTCX, 1 ); - nsub = NB_DIV; - move16(); - } - IF( EQ_16( sts[ch]->last_core, ACELP_CORE ) ) - { - length = add( length, shr( length, 2 ) ); - } - FOR( n1 = 0; n1 < nsub; n1++ ) - { - FOR( i = 0; i < length; i++ ) - { - norm = W_norm( powerSpec64[ch][i + n1 * length] ); - powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], norm ) ); // exp = exp_powerSpec64[ch][n1]-norm - exp_powerSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], norm ); - move32(); - move16(); - } - } - set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); - set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX + L_MDCT_OVLP_MAX, length ) ); - } - } -#endif FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; @@ -769,22 +627,7 @@ void stereo_mdct_core_enc_fx( { FOR( n = 0; n < nSubframes; n++ ) { -#ifdef FIX_MDCT_STEREO_ENC_STACK ProcessIGF_ivas_fx_64( st, N_MAX, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], p_orig_spectrum_e[ch], powerSpec64[ch], exp_powerSpec64[ch], n, hCPE->hCoreCoder[0]->sp_aud_decision0 ); -#else - Word16 q_spectrum; - L_subframeTCX = idiv1616( st->hTcxEnc->L_frameTCX, nSubframes ); /* Q0 */ - q_spectrum = sub( Q31, p_orig_spectrum_e[ch] ); - IF( st->hIGFEnc ) - { - q_spectrum = s_min( q_spectrum, sub( Q31, st->hIGFEnc->spec_be_igf_e ) ); - } - - q_spectrum = sub( Q31, st->hTcxEnc->spectrum_e[n] ); - - Scale_sig32( orig_spectrum_fx[ch][n], st->hIGFEnc->infoStopLine, sub( q_spectrum, sub( Q31, p_orig_spectrum_e[ch] ) ) ); /* q_spectrum */ - ProcessIGF_ivas_fx( st, N_MAX, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); -#endif } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 1d5ba1d00..c058e943d 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1055,7 +1055,6 @@ void ProcessIGF_ivas_fx( const Word16 vad_hover_flag /* i : VAD hangover flag */ ); -#ifdef FIX_MDCT_STEREO_ENC_STACK void ProcessIGF_ivas_fx_64( Encoder_State *st, /* i/o: Encoder state */ const Word16 powerSpec_len, /* i : length of pPowerSpectrum buffer */ @@ -1068,7 +1067,6 @@ void ProcessIGF_ivas_fx_64( const Word16 sp_aud_decision0 /* i : first stage switching decision */ ); -#endif void ProcessIGF_fx( IGF_ENC_INSTANCE_HANDLE const hInstance, /**< in: instance handle of IGF Encoder */ Encoder_State *st, /**< in: Encoder state */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 1ada17a8f..d55a4cb23 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -4100,7 +4100,6 @@ void ProcessStereoIGF_fx( return; } -#ifdef FIX_MDCT_STEREO_ENC_STACK /*---------------------------------------------------------------------* * ProcessIGF_ivas_fx_64() * @@ -4251,4 +4250,3 @@ void ProcessStereoIGF_fx_64( return; } -#endif -- GitLab From 581b1f306ecb32807a73da1ca7524b7609920b3b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:13:16 +0100 Subject: [PATCH 15/22] [cleanup] accept NONBE_MR2809 --- lib_com/options.h | 1 - lib_enc/ivas_rom_enc.h | 5 ----- lib_enc/ivas_rom_enc_fx.c | 12 ------------ lib_enc/ivas_stereo_classifier_fx.c | 13 ------------- lib_enc/ivas_stereo_ica_enc_fx.c | 2 -- 5 files changed, 33 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7ad260abb..16e3a1adb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,7 +94,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#define NONBE_MR2809 #define FIX_2432_ISM_SPIKES_16KHZ /* VA: basop issue 2432: fix spikes in ISM decoding at 16kHz output sampling rate */ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ diff --git a/lib_enc/ivas_rom_enc.h b/lib_enc/ivas_rom_enc.h index fef071126..059eb67e7 100644 --- a/lib_enc/ivas_rom_enc.h +++ b/lib_enc/ivas_rom_enc.h @@ -50,13 +50,8 @@ extern const Word32 unclr_coef_td[]; extern const Word16 xtalk_isel_td[]; extern const Word32 xtalk_mean_td[]; -#ifdef NONBE_MR2809 extern const Word32 xtalk_factor_td_m[]; extern const Word16 xtalk_factor_td_e[]; -#else -extern const Word32 xtalk_scale_td[]; -extern const Word32 xtalk_coef_td[]; -#endif extern const Word16 xtalk_isel_dft[]; extern const Word32 xtalk_mean_dft_q15[]; extern const Word32 xtalk_scale_dft_q15[]; diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index 7b1c88895..514fb2cb3 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -98,7 +98,6 @@ const Word32 xtalk_mean_td[SIZE_XTALK_ISEL_TD] = /*Q15*/ 19572, 4323, 44674958, 20928, 248554, 5077, 123099, 19205, 217973, 57391, 22648, 21, 23142, 342411, 59, 612, -71224 }; -#ifdef NONBE_MR2809 const Word32 xtalk_factor_td_m[SIZE_XTALK_ISEL_TD] = { 1699245373, 1831181873, 1809297797, -1237097441, 1524499779, 1779553202, -1210195954, 1749773419, @@ -109,17 +108,6 @@ const Word16 xtalk_factor_td_e[SIZE_XTALK_ISEL_TD] = { -4, 1, -12, -1, -7, -2, -5, -4, 0, 0, -2, 6, -2, -11, 11, -7, -1 }; -#else -const Word32 xtalk_scale_td[SIZE_XTALK_ISEL_TD] = /*Q15*/ -{ - 37220, 2553, 16147962, 18786, 191263, 13110, 139310, 20547, 45408, 60617, 17627, 43, 9123, 2070239, 88, 21549, 68968 -}; - -const Word32 xtalk_coef_td[SIZE_XTALK_ISEL_TD] = /*Q15*/ -{ - 1841, 4353, 3322, -5411, 1061, 2716, -2453, 1046, 45199, -51474, -2431, -2245, 2194, -542, -135853, 99, 18138 -}; -#endif const Word16 xtalk_isel_dft[SIZE_XTALK_ISEL_DFT] = { E_clas, E_gainILD, E_gainIPD, E_angle_rot, E_g_pred, E_d_prodL_prodR, E_sum_xcorr, E_xcorr_itd_value, E_gphat_d_itd2, E_gphat_ratio_m1_m2, E_gphat_m2_m2 diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index d7e822f0f..daa23be30 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -842,11 +842,7 @@ void stereo_classifier_features_ivas_fx( ELSE { hStereoClassif->xtalk_fv_fx[E_d_ps_diff] = L_abs( L_sub( L_shr( hStereoClassif->ps_diff_ch1_fx, sub( 16, hStereoClassif->ps_diff_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_diff_ch2_fx, sub( 16, hStereoClassif->ps_diff_ch2_e ) ) /*q15*/ ) ); /*q15*/ -#ifdef NONBE_MR2809 hStereoClassif->xtalk_fv_fx[E_d_ps_sta] = L_abs( L_sub( L_shr( hStereoClassif->ps_sta_ch1_fx, sub( 16, hStereoClassif->ps_sta_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_sta_ch2_fx, sub( 16, hStereoClassif->ps_sta_ch2_e ) ) /*q15*/ ) ); /*q15*/ -#else - hStereoClassif->xtalk_fv_fx[E_d_ps_sta] = L_abs( L_sub( L_shr( hStereoClassif->ps_sta_ch1_fx, sub( 16, hStereoClassif->ps_sta_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_sta_ch2_fx, sub( 16, hStereoClassif->ps_sta_ch1_e ) ) /*q15*/ ) ); /*q15*/ -#endif } move32(); move32(); @@ -1150,21 +1146,12 @@ void xtalk_classifier_td_fx( move16(); /* mean & std removal */ -#ifdef NONBE_MR2809 fvn = L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_td[i] ); fvn = Mpy_32_32( fvn, xtalk_factor_td_m[i] ); // exp = 16 + 20 = 36 exp = add( 16, xtalk_factor_td_e[i] ); /* LR */ score = BASOP_Util_Add_Mant32Exp( score, score_exp, fvn, exp, &score_exp ); -#else - fvn = BASOP_Util_Divide3232_Scale_newton( L_sub( hStereoClassif->xtalk_fv_fx[ind], xtalk_mean_td[i] ), xtalk_scale_td[i], &exp ); - fvn = Mpy_32_32( fvn, xtalk_coef_td[i] ); // Q = 31-exp+15-31 = 15-exp - exp = add( exp, 16 ); // exp = 31-(15-exp) = 16+exp - - /* LR */ - score = BASOP_Util_Add_Mant32Exp( score, score_exp, fvn, exp, &score_exp ); -#endif } score = L_shl_sat( score, sub( score_exp, 3 ) ); // Q28 diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index feb5ad596..b6ab26c5a 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -2040,12 +2040,10 @@ void stereo_tca_enc_fx( move16(); sts[1]->q_inp32 = input_mem_loc_q; move16(); -#ifdef NONBE_MR2809 sts[0]->q_old_inp32 = input_mem_loc_q; move16(); sts[1]->q_old_inp32 = input_mem_loc_q; move16(); -#endif icaMemUpdate_fx( sts, hCPE, input_mem_loc_fx[0], input_mem_loc_fx[1], input_mem_loc_q, lMemRecalc, lMemRecalc_SCh, input_frame ); -- GitLab From cc03ad70e71ec2d56c1745d9653de0a7d17b4d90 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:14:15 +0100 Subject: [PATCH 16/22] [cleanup] accept FIX_2432_ISM_SPIKES_16KHZ --- lib_com/options.h | 1 - lib_dec/ivas_core_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 16e3a1adb..e2e0f8078 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,7 +94,6 @@ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt. TS 26.251 V3.0 */ -#define FIX_2432_ISM_SPIKES_16KHZ /* VA: basop issue 2432: fix spikes in ISM decoding at 16kHz output sampling rate */ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ #define FIX_2283_Q_CLDFB /* FhG: Fix Q format issue in CLDFB */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 5b3366df9..fbb69eb63 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1035,14 +1035,10 @@ ivas_error ivas_core_dec_fx( test(); test(); test(); -#ifdef FIX_2432_ISM_SPIKES_16KHZ test(); test(); test(); IF( ( st->core == ACELP_CORE && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->bws_cnt > 0 && flag_swb_tbe == 0 ) ) ) && flag_bwe_bws == 0 ) -#else - IF( ( st->core == ACELP_CORE && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) ) ) && flag_bwe_bws == 0 ) -#endif { set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); } -- GitLab From e88b62060083327d68a61dd2500908ca25c68239 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:15:09 +0100 Subject: [PATCH 17/22] [cleanup] accept FIX_2283_Q_CLDFB --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index e2e0f8078..35452ae4e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,6 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ -#define FIX_2283_Q_CLDFB /* FhG: Fix Q format issue in CLDFB */ #define FIX_2283_ACCU_CLDFB /* FhG: Fix to consider Q-format differences in accumulateCLDFBArrayToBuffer_fx() */ #define FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning /* FhG: Adjust non-diegetic panning law to harmonize codec levels with 3GPP reference software */ #define FIX_FLOAT_1518 /* FhG: fix issue 1518: loudness differences in OSBA decoding to mono or stereo output */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e099a28b1..63809fa3b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7212,7 +7212,6 @@ static ivas_error renderIsmToSplitBinaural( num_bands, ismInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[pos_idx + ch], &q_cldfb ); -#ifdef FIX_2283_Q_CLDFB /* scale re and im according to exp-q_cldfb */ { Word32 *realBuffer_fx = &tmpBinaural_CldfbRe[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0]; @@ -7236,7 +7235,6 @@ static ivas_error renderIsmToSplitBinaural( #endif q_cldfb = exp; } -#endif } } } -- GitLab From 132d080171cb896ee8d7278b1d652a42747ab03f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:15:43 +0100 Subject: [PATCH 18/22] [cleanup] accept FIX_2283_ACCU_CLDFB --- lib_com/options.h | 1 - lib_rend/lib_rend_fx.c | 63 ------------------------------------------ 2 files changed, 64 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 35452ae4e..4d21026dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,6 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ -#define FIX_2283_ACCU_CLDFB /* FhG: Fix to consider Q-format differences in accumulateCLDFBArrayToBuffer_fx() */ #define FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning /* FhG: Adjust non-diegetic panning law to harmonize codec levels with 3GPP reference software */ #define FIX_FLOAT_1518 /* FhG: fix issue 1518: loudness differences in OSBA decoding to mono or stereo output */ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 63809fa3b..e121b5929 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -413,40 +413,6 @@ static void copyBufferToCLDFBarray_fx( return; } -#ifndef FIX_2283_ACCU_CLDFB -static void accumulateCLDFBArrayToBuffer_fx( - Word32 re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - const IVAS_REND_AudioBuffer *buffer ) -{ - UWord32 smplIdx, slotIdx; - UWord32 numCldfbSamples, num_bands; - Word16 chnlIdx; - Word32 *writePtr; - - assert( ( buffer->config.is_cldfb == 1 ) && "for time domain input call copyBufferTo2dArray()" ); - writePtr = buffer->data_fx; - numCldfbSamples = (UWord32) shr( buffer->config.numSamplesPerChannel, 1 ); - num_bands = (UWord32) Mpy_32_32( numCldfbSamples, ONE_BY_CLDFB_NO_COL_MAX_Q31 ); - - FOR( chnlIdx = 0; chnlIdx < buffer->config.numChannels; ++chnlIdx ) - { - FOR( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; ++slotIdx ) - { - FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) - { - *writePtr++ += re[chnlIdx][slotIdx][smplIdx]; - } - FOR( smplIdx = 0; smplIdx < num_bands; ++smplIdx ) - { - *writePtr++ += im[chnlIdx][slotIdx][smplIdx]; - } - } - } - - return; -} -#else static void accumulateCLDFBArrayToBuffer_fx( Word32 re[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 im[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -518,7 +484,6 @@ static void accumulateCLDFBArrayToBuffer_fx( return; } -#endif static void copyBufferTo2dArray_fx( const IVAS_REND_AudioBuffer buffer, @@ -7218,21 +7183,12 @@ static ivas_error renderIsmToSplitBinaural( Word32 *imagBuffer_fx = &tmpBinaural_CldfbIm[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0]; Word16 noChannels = ismInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[pos_idx + ch]->no_channels; -#ifdef FIX_2283_ACCU_CLDFB Word16 scale = sub( exp, q_cldfb ); FOR( Word16 j = 0; j < noChannels; j++ ) { realBuffer_fx[j] = L_shl( realBuffer_fx[j], scale ); /*Q(exp)*/ imagBuffer_fx[j] = L_shl( imagBuffer_fx[j], scale ); /*Q(exp)*/ } -#else - Word16 scale = sub( sub( exp, q_cldfb ), 1 ); - FOR( Word16 j = 0; j < noChannels; j++ ) - { - realBuffer_fx[j] = L_shl( realBuffer_fx[j], scale ); /*Q(exp)*/ - imagBuffer_fx[j] = L_shl( imagBuffer_fx[j], scale ); /*Q(exp)*/ - } -#endif q_cldfb = exp; } } @@ -7259,11 +7215,7 @@ static ivas_error renderIsmToSplitBinaural( if ( outAudio.config.is_cldfb ) { -#ifdef FIX_2283_ACCU_CLDFB accumulateCLDFBArrayToBuffer_fx( tmpBinaural_CldfbRe, tmpBinaural_CldfbIm, exp, &outAudio ); -#else - accumulateCLDFBArrayToBuffer_fx( tmpBinaural_CldfbRe, tmpBinaural_CldfbIm, &outAudio ); -#endif } else { @@ -8508,11 +8460,7 @@ static ivas_error renderSbaToSplitBinaural( return error; } -#ifdef FIX_2283_ACCU_CLDFB accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, *outAudio.pq_fact, &outAudio ); -#else - accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); -#endif } ELSE { @@ -8562,11 +8510,7 @@ static ivas_error renderSbaToBinaural( return error; } -#ifdef FIX_2283_ACCU_CLDFB accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, *outAudio.pq_fact, &outAudio ); -#else - accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); -#endif } ELSE { @@ -9244,14 +9188,7 @@ static ivas_error renderInputMasa( ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, masaInput->base.ctx.pSplitRendWrapper, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural ); -#ifdef FIX_2283_ACCU_CLDFB accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Q6, &outAudio ); -#else - accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); - - *outAudio.pq_fact = Q6; - move16(); -#endif } ELSE { -- GitLab From 8937e1e0a3b9574aa6ce81bdf03dd957b158ccd2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:16:27 +0100 Subject: [PATCH 19/22] [cleanup] accept FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning --- lib_com/options.h | 1 - lib_dec/ivas_mono_dmx_renderer_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4d21026dc..33493f504 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,6 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ -#define FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning /* FhG: Adjust non-diegetic panning law to harmonize codec levels with 3GPP reference software */ #define FIX_FLOAT_1518 /* FhG: fix issue 1518: loudness differences in OSBA decoding to mono or stereo output */ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 97ed332be..0f8418716 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -35,9 +35,7 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" -#ifdef FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning #include "rom_com.h" -#endif #include "wmc_auto.h" @@ -323,19 +321,9 @@ void ivas_apply_non_diegetic_panning_fx( ) { -#ifdef FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning Word16 pan = add( mult_r( non_diegetic_pan_gain_fx, 32 ), 32 ); // 0.5.Q15 = 16384 // Q15 v_multc_fx_16( input_f_fx, cos_table_129[pan], output_fx[1], output_frame ); v_multc_fx_16( input_f_fx, cos_table_129[64 - pan], output_fx[0], output_frame ); -#else - Word16 pan_left_fx, pan_right_fx; - - pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384 - pan_right_fx = sub( 32767, pan_left_fx ); - - v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_fx[1], output_frame ); - v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_fx[0], output_frame ); -#endif return; -- GitLab From e4e0052e8db7d8dcaee052315be57ff0902f47d1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:17:13 +0100 Subject: [PATCH 20/22] [cleanup] accept FIX_FLOAT_1518 --- lib_com/options.h | 1 - lib_dec/ivas_cpe_dec_fx.c | 4 ---- lib_dec/ivas_dec_fx.c | 2 -- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 4 ---- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 ---- 5 files changed, 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 33493f504..533325791 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,6 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ -#define FIX_FLOAT_1518 /* FhG: fix issue 1518: loudness differences in OSBA decoding to mono or stereo output */ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index dffbb7641..28133aaa9 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -659,15 +659,11 @@ ivas_error ivas_cpe_dec_fx( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->nchan_out, 1 ) && ( is_DTXrate( ivas_total_brate ) == 0 || ( EQ_16( is_DTXrate( ivas_total_brate ), 1 ) && is_DTXrate( st_ivas->hDecoderConfig->last_ivas_total_brate ) == 0 ) ) ) { -#ifdef FIX_FLOAT_1518 test(); IF( !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) ) { -#endif applyDmxMdctStereo_fx( hCPE, output, output_frame ); -#ifdef FIX_FLOAT_1518 } -#endif } /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index d95c010c8..a844b37db 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -574,12 +574,10 @@ ivas_error ivas_dec_fx( ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); } -#ifdef FIX_FLOAT_1518 ELSE IF( EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) { v_shr( p_output_fx[0], -1, p_output_fx[0], output_frame ); } -#endif /* HP filtering */ FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 502550d3b..2f7db14e8 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -1502,12 +1502,8 @@ void ivas_sba_dirac_stereo_dec_fx( synchro_synthesis_fx( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/, q_dft[0] ); /* output scaling */ -#ifdef FIX_FLOAT_1518 test(); IF( !sba_mono_flag && !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) ) -#else - IF( !sba_mono_flag ) -#endif { v_shr( output[0], 1, output[0], output_frame ); /*0.5f*/ v_shr( output[1], 1, output[1], output_frame ); /*0.5f*/ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 2b4e57596..291515918 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -465,12 +465,8 @@ void stereo_mdct_core_dec_fx( test(); test(); -#ifdef FIX_FLOAT_1518 test(); IF( hCPE->nchan_out == 1 && ( bfi == 0 || ( bfi != 0 && sts[0]->core != ACELP_CORE && sts[1]->core != ACELP_CORE ) ) && !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) ) -#else - IF( hCPE->nchan_out == 1 && ( bfi == 0 || ( bfi != 0 && sts[0]->core != ACELP_CORE && sts[1]->core != ACELP_CORE ) ) ) -#endif { apply_dmx_weights_fx( hCPE, x_fx, sts[0]->transform_type, sts[1]->transform_type ); } -- GitLab From 105cc78b1a3c8564f762c9aa899eb97771c7071b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:18:54 +0100 Subject: [PATCH 21/22] [cleanup] accept FIX_FLOAT_1533_BLEND_SUBFR2 --- lib_com/options.h | 1 - lib_com/prot_fx.h | 2 -- lib_dec/acelp_core_dec_fx.c | 4 ---- lib_dec/acelp_core_switch_dec_fx.c | 4 ---- lib_dec/dec_post_fx.c | 8 -------- lib_dec/post_dec_fx.c | 10 ---------- 6 files changed, 29 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 533325791..ea56e9472 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,6 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ -#define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 71bf83177..5ec05ea33 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6063,9 +6063,7 @@ void scale_st_fx( void blend_subfr2_fx( Word16 *sigIn1, /* i : i signal for fade-out */ Word16 *sigIn2, /* i : i signal for fade-in */ -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 Word16 L_subfr, /* i : subframe length */ -#endif Word16 *sigOut /* o : output signal */ ); diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index eefc304e3..73ff775af 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1529,11 +1529,7 @@ ivas_error acelp_core_dec_fx( E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, L_SUBFR, psyn_fx + L_SUBFR / 2 ); -#else - blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 ); -#endif } st->hPFstat->on = 0; move16(); diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index d4ccf00f9..20343394b 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -177,11 +177,7 @@ ivas_error acelp_core_switch_dec_fx( E_UTIL_synthesis( 1, Aq, exc, bpf_error_signal, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth_intFreq, bpf_error_signal, &st_fx->hPFstat->gain_prec, L_SUBFR ); Copy( bpf_error_signal, synth_intFreq, L_SUBFR / 2 ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 blend_subfr2_fx( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, L_SUBFR, synth_intFreq + L_SUBFR / 2 ); -#else - blend_subfr2_fx( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2 ); -#endif } st_fx->hPFstat->on = 0; move16(); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index b76218055..ae3e56b87 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1517,9 +1517,7 @@ void scale_st_fx( void blend_subfr2_fx( Word16 *sigIn1, // Qx Word16 *sigIn2, // Qx -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 Word16 L_subfr, // Q0 -#endif Word16 *sigOut // Qx ) { @@ -1531,7 +1529,6 @@ void blend_subfr2_fx( move16(); move16(); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 assert( ( L_subfr == L_SUBFR ) || ( L_subfr == 2 * L_SUBFR ) ); IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) @@ -1543,15 +1540,10 @@ void blend_subfr2_fx( move16(); move16(); } -#endif -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 L_subfr_half = shr( L_subfr, 1 ); FOR( i = 0; i < L_subfr_half; i++ ) -#else - FOR( i = 0; i < L_SUBFR / 2; i++ ) -#endif { sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx fac1 = sub_sat( fac1, step ); diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index e6e839233..3b1b5336a 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -87,26 +87,16 @@ void post_decoder_fx( Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_SUBFR, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_SUBFR ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, L_SUBFR, synth2 + L_SUBFR / 2 ); -#else - blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, synth2 + L_SUBFR / 2 ); -#endif } ELSE { Word16 L_subfr = idiv1616( st->L_frame, st->nb_subfr ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 Word16 L_subfr_half = shr( L_subfr, 1 ); -#endif Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); -#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 blend_subfr2_fx( synth2 + L_subfr_half, synth + L_subfr_half, L_subfr, synth2 + L_subfr_half ); -#else - blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); -#endif } } } -- GitLab From 17d536b15ca935b33f7162dcf449d01fc3d98a34 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 4 Mar 2026 14:20:24 +0100 Subject: [PATCH 22/22] formatting --- lib_com/prot_fx.h | 16 +- lib_com/swb_bwe_com_fx.c | 6 +- lib_com/swb_tbe_com_fx.c | 6 +- lib_com/tools_fx.c | 1 - lib_dec/dec_post_fx.c | 2 +- lib_dec/er_util_fx.c | 1 - lib_dec/evs_dec_fx.c | 6 +- lib_dec/ivas_ism_param_dec_fx.c | 22 +- lib_dec/ivas_osba_dec_fx.c | 42 +-- lib_dec/stat_dec.h | 14 +- lib_enc/cod_uv_fx.c | 2 +- lib_enc/ivas_stereo_classifier_fx.c | 2 +- lib_enc/prot_fx_enc.h | 22 +- lib_enc/swb_bwe_enc_fx.c | 455 +++++++++++------------ lib_enc/swb_pre_proc_fx.c | 4 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 30 +- lib_rend/ivas_rom_TdBinauralRenderer.h | 4 +- lib_rend/ivas_stat_rend.h | 2 +- 18 files changed, 317 insertions(+), 320 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5ec05ea33..b7f81c484 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -369,9 +369,9 @@ void SWB_BWE_decoding_fx( void time_envelop_shaping_fx( const Word16 element_mode, /* i : element mode */ - Word16 werr[], /* i/o: SHB synthesis Q_synth*/ - Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ - const Word16 L, /* i : frame length */ + Word16 werr[], /* i/o: SHB synthesis Q_synth*/ + Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ + const Word16 L, /* i : frame length */ Word16 *Q_synth ); void time_reduce_pre_echo_fx( @@ -2764,7 +2764,7 @@ void GenShapedSHBExcitation_fx( const Word16 prev_bfi ); void GenShapedSHBExcitation_ivas_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word16 enc_dec, /* i : encoder/decoder flag */ Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ @@ -6064,7 +6064,7 @@ void blend_subfr2_fx( Word16 *sigIn1, /* i : i signal for fade-out */ Word16 *sigIn2, /* i : i signal for fade-in */ Word16 L_subfr, /* i : subframe length */ - Word16 *sigOut /* o : output signal */ + Word16 *sigOut /* o : output signal */ ); void init_tcx_window_cfg_fx( @@ -8537,10 +8537,10 @@ void d_gain_pred_fx( ); ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal */ + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal */ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - FRAME_MODE frameMode /* i : Decoder frame mode */ + FRAME_MODE frameMode /* i : Decoder frame mode */ ); void fft_cldfb_fx( diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 399558cbb..f7fcbca9b 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1946,9 +1946,9 @@ return; void time_envelop_shaping_fx( const Word16 element_mode, /* i : element mode */ - Word16 werr[], /* i/o: SHB synthesis Q_synth*/ - Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ - const Word16 L, /* i : frame length */ + Word16 werr[], /* i/o: SHB synthesis Q_synth*/ + Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/ + const Word16 L, /* i : frame length */ Word16 *Q_synth ) { Word16 *pit; diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 30dad09e5..8ad1288a7 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -1485,7 +1485,7 @@ void GenShapedWBExcitation_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */ // saturation not possible: excTmp2_frac[i] < MIN_16 - pow1 = L_add_sat( pow1, L_shr( L_tmp, Q_pow ) ); /* Q22 */ + pow1 = L_add_sat( pow1, L_shr( L_tmp, Q_pow ) ); /* Q22 */ } } @@ -1531,7 +1531,7 @@ void GenShapedWBExcitation_fx( FOR( i = 0; i < L_FRAME16k / 4; i++ ) { L_tmp = L_mult_sat( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */ - pow22 = L_add( pow22, L_shr( L_tmp, Q_pow ) ); /* Q22 */ + pow22 = L_add( pow22, L_shr( L_tmp, Q_pow ) ); /* Q22 */ } } @@ -2340,7 +2340,7 @@ static void synthesis_enc_dec( } void GenShapedSHBExcitation_ivas_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word16 enc_dec, /* i : encoder/decoder flag */ Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 3a2944c73..47111db3e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -631,7 +631,6 @@ Word32 dotp_fx32_o( } - /*-------------------------------------------------------------------* * v_sub_fx() * diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index ae3e56b87..e19fc5f94 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1518,7 +1518,7 @@ void blend_subfr2_fx( Word16 *sigIn1, // Qx Word16 *sigIn2, // Qx Word16 L_subfr, // Q0 - Word16 *sigOut // Qx + Word16 *sigOut // Qx ) { Word16 fac1 = 32768 - 512; // 1.Q15 - ( 1.Q15 / L_SUBFR ); diff --git a/lib_dec/er_util_fx.c b/lib_dec/er_util_fx.c index 3ea02def6..f1cb9a60a 100644 --- a/lib_dec/er_util_fx.c +++ b/lib_dec/er_util_fx.c @@ -493,4 +493,3 @@ Word16 GetPLCModeDecision_fx( return core; /*Q0*/ } - diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 8e47739ca..95345a444 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -16,10 +16,10 @@ *--------------------------------------------------------------------------*/ ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal Q0*/ + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal Q0*/ Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - FRAME_MODE frameMode /* i : Decoder frame mode */ + FRAME_MODE frameMode /* i : Decoder frame mode */ ) { Word16 i, j, output_frame; diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1bc479f1c..ca5bb4038 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -880,17 +880,17 @@ void ivas_param_ism_dec_close_fx( hParamIsmDec->hParamIsm = NULL; } - /* Param ISM Rendering */ - IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL ) - { - free( hParamIsmDec->hParamIsmRendering->interpolator_fx ); - hParamIsmDec->hParamIsmRendering->interpolator_fx = NULL; - } - IF( hParamIsmDec->hParamIsmRendering->proto_matrix_fx != NULL ) - { - free( hParamIsmDec->hParamIsmRendering->proto_matrix_fx ); - hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL; - } + /* Param ISM Rendering */ + IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->interpolator_fx ); + hParamIsmDec->hParamIsmRendering->interpolator_fx = NULL; + } + IF( hParamIsmDec->hParamIsmRendering->proto_matrix_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->proto_matrix_fx ); + hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL; + } IF( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx != NULL ) { diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index c80d77af4..590b120a4 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -319,40 +319,40 @@ ivas_error ivas_osba_render_sf_fx( *-------------------------------------------------------------------------*/ void ivas_osba_stereo_add_channels_fx( - Word32 *tc_fx[], /* i : transport channels */ - Word32 *output_fx[], /* i/o: output channels */ - const Word32 gain, /* i : gain bed value */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 nchan_ism, /* i : number of ISM channels */ + Word32 *tc_fx[], /* i : transport channels */ + Word32 *output_fx[], /* i/o: output channels */ + const Word32 gain, /* i : gain bed value */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 nchan_ism, /* i : number of ISM channels */ const UWord16 n_samples_to_render /* i : output frame length per channel */ ) { Word16 n, i; - test(); - IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) ) + test(); + IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) ) + { + FOR( n = 0; n < nchan_out; n++ ) { - FOR( n = 0; n < nchan_out; n++ ) + FOR( i = 0; i < n_samples_to_render; i++ ) { - FOR( i = 0; i < n_samples_to_render; i++ ) - { - Word32 tmp1; - tmp1 = Mpy_32_32( tc_fx[n + nchan_ism][i], gain ); // Q11 + Q29 - 31 = Q9 - tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 - output_fx[n][i] = L_add_sat( output_fx[n][i], tmp1 ); // Q11 - } + Word32 tmp1; + tmp1 = Mpy_32_32( tc_fx[n + nchan_ism][i], gain ); // Q11 + Q29 - 31 = Q9 + tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 + output_fx[n][i] = L_add_sat( output_fx[n][i], tmp1 ); // Q11 } } - ELSE + } + ELSE + { + FOR( n = 0; n < nchan_out; n++ ) { - FOR( n = 0; n < nchan_out; n++ ) + FOR( i = 0; i < n_samples_to_render; i++ ) { - FOR( i = 0; i < n_samples_to_render; i++ ) - { - output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 - } + output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 } } + } return; diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 65fd7d391..bec9811e9 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -1027,13 +1027,13 @@ typedef struct Decoder_State Word16 mdct_sw; /* MDCT switching indicator */ Word16 last_codec_mode; /* last used codec mode */ - UWord16 *bit_stream; /* pointer to bitstream buffer */ - Word16 next_bit_pos; /* position of the next bit to be read from the bitstream */ - Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ - Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ - Word16 amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ - Word16 BER_detect; /* flag to signal detected bit error in the bitstream */ - Word32 output_Fs; /* output sampling rate */ + UWord16 *bit_stream; /* pointer to bitstream buffer */ + Word16 next_bit_pos; /* position of the next bit to be read from the bitstream */ + Word16 bitstreamformat; /* Bitstream format flag (G.192/MIME/VOIP_G192_RTP/VOIP_RTPDUMP) */ + Word16 sdp_hf_only; /* RTP payload format parameter: only Header-Full format without zero padding for size collision avoidance */ + Word16 amrwb_rfc4867_flag; /* MIME from rfc4867 is used */ + Word16 BER_detect; /* flag to signal detected bit error in the bitstream */ + Word32 output_Fs; /* output sampling rate */ Word32 total_brate; /* total bitrate in kbps of the codec */ Word32 last_total_brate; /* last total bitrate in kbps of the codec */ Word32 last_total_brate_ber; /* last total bitrate in kbps of the codec - used only when first frame is lost and BER is detected afterwards */ diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 5ea5cec3f..bdf5ae1c2 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -20,7 +20,7 @@ *-------------------------------------------------------------------*/ void gauss_L2_fx( - const Word16 element_mode, /* i : element mode */ + const Word16 element_mode, /* i : element mode */ const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ Word16 code[], /* o : gaussian excitation Q9 */ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index daa23be30..621a00bd4 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -842,7 +842,7 @@ void stereo_classifier_features_ivas_fx( ELSE { hStereoClassif->xtalk_fv_fx[E_d_ps_diff] = L_abs( L_sub( L_shr( hStereoClassif->ps_diff_ch1_fx, sub( 16, hStereoClassif->ps_diff_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_diff_ch2_fx, sub( 16, hStereoClassif->ps_diff_ch2_e ) ) /*q15*/ ) ); /*q15*/ - hStereoClassif->xtalk_fv_fx[E_d_ps_sta] = L_abs( L_sub( L_shr( hStereoClassif->ps_sta_ch1_fx, sub( 16, hStereoClassif->ps_sta_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_sta_ch2_fx, sub( 16, hStereoClassif->ps_sta_ch2_e ) ) /*q15*/ ) ); /*q15*/ + hStereoClassif->xtalk_fv_fx[E_d_ps_sta] = L_abs( L_sub( L_shr( hStereoClassif->ps_sta_ch1_fx, sub( 16, hStereoClassif->ps_sta_ch1_e ) ) /*q15*/, L_shr( hStereoClassif->ps_sta_ch2_fx, sub( 16, hStereoClassif->ps_sta_ch2_e ) ) /*q15*/ ) ); /*q15*/ } move32(); move32(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c058e943d..8be5dec9b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2013,17 +2013,17 @@ void E_ACELP_xy2_corr( void gauss_L2_fx( const Word16 element_mode, /* i : element mode */ - const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ - Word16 code2[], /* o : gaussian excitation Q9 */ - const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ - Word16 y11[], /* o : zero-memory filtered gauss. excitation Q9 */ - Word32 *gain, /* o : excitation gain */ - ACELP_CbkCorr *g_corr, /*i/o : correlation structure for gain coding */ - const Word16 gain_pit, /* i : unquantized gain of code */ - const Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *Aq, /* i : quantized LPCs Q12 */ - const Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp, /*i/o : random seed Q0 */ + const Word16 h[], /* i : weighted LP filter impulse response Q14+s */ + Word16 code2[], /* o : gaussian excitation Q9 */ + const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */ + Word16 y11[], /* o : zero-memory filtered gauss. excitation Q9 */ + Word32 *gain, /* o : excitation gain */ + ACELP_CbkCorr *g_corr, /*i/o : correlation structure for gain coding */ + const Word16 gain_pit, /* i : unquantized gain of code */ + const Word16 tilt_code, /* i : tilt of code Q15 */ + const Word16 *Aq, /* i : quantized LPCs Q12 */ + const Word16 formant_enh, /* i : formant enhancement factor Q15 */ + Word16 *seed_acelp, /*i/o : random seed Q0 */ const Word16 shift ); Word32 SFM_Cal_fx( diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 4b02e8b73..b6749e80a 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -181,8 +181,7 @@ void swb_bwe_enc_fx( const Word16 Q_new_swb_speech, /* i : Q for new_swb_speech_fx */ Word16 *shb_speech_fx_Q0, /* i : SHB target signal (6-14kHz) at 16kHz Q0 */ Word16 Q_shb_speech, - Word16 Q_slb_speech -) + Word16 Q_slb_speech ) { Word16 i; Word16 *new_input_fx; @@ -271,262 +270,262 @@ void swb_bwe_enc_fx( Copy( old_input_12k8_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); } - Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); - Copy( old_input_12k8_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME - Sample_Delay_LP ); - Copy( old_input_12k8_fx + L_INP_MEM + L_FRAME - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); + Copy( old_input_12k8_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME - Sample_Delay_LP ); + Copy( old_input_12k8_fx + L_INP_MEM + L_FRAME - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + ELSE + { + delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_12k8_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); + } } ELSE { - delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_12k8_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); - } -} -ELSE -{ - Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) - { - Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); - } - Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); - IF( st_fx->element_mode > EVS_MONO ) - { - Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); - Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - - IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) + Sample_Delay_SWB_BWE = NS2SA_FX2( inner_Fs, DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ); + IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) { - Copy( old_input_16k_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); - Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); + Sample_Delay_HP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS - L_MEM_RECALC_TBE_NS ); } + Sample_Delay_LP = NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_16k_NS ); + IF( st_fx->element_mode > EVS_MONO ) + { + Sample_Delay_SWB_BWE = sub( Sample_Delay_SWB_BWE, NS2SA_FX2( inner_Fs, DELAY_FIR_RESAMPL_NS ) ); + Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) ); - Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); - Copy( old_input_16k_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME16k - Sample_Delay_LP ); - Copy( old_input_16k_fx + L_INP_MEM + L_FRAME16k - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); -} -ELSE -{ - delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_16k_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME16k, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); -} -} - -q_new_input_hp = s_min( Q_shb_speech, hBWE_FD->Q_new_input_hp ); -IF( st_fx->element_mode == EVS_MONO ) -{ - Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); - Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); -} -ELSE IF( LT_16( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ) -{ - Copy_Scale_sig( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP, sub( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ); // Q_shb_speech - Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); // Q_shb_speech -} -ELSE -{ - Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); // hBWE_FD->Q_new_input_hp - Copy_Scale_sig( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP, sub( hBWE_FD->Q_new_input_hp, Q_shb_speech ) ); // hBWE_FD->Q_new_input_hp -} - -hBWE_FD->Q_new_input_hp = Q_shb_speech; -move16(); -Copy( shb_speech_fx + L_FRAME16k - Sample_Delay_HP, hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); -new_input_fx = old_input_fx + Sample_Delay_SWB_BWE; -Copy( hBWE_FD->old_input_fx, old_input_fx, Sample_Delay_SWB_BWE ); -Copy( new_swb_speech_fx, new_input_fx, inner_frame ); -Copy( old_input_fx + inner_frame, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); - -/*----------------------------------------------------------------------* - * Calculate tilt of the input signal and the ACELP core synthesis - *----------------------------------------------------------------------*/ - -/* tilt returned in Q24 goto to Q11 */ -tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); - -/*---------------------------------------------------------------------* - * SWB BWE encoding - * FB BWE encoding - *---------------------------------------------------------------------*/ + IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) ) + { + Copy( old_input_16k_fx + L_INP_MEM - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + Copy( hBWE_TD->old_speech_shb_fx + L_LOOK_16k + L_SUBFR16k - Sample_Delay_HP, new_input_hp_fx, Sample_Delay_HP ); + } -new_input_fx_q = Q_new_swb_speech; -move16(); + Copy( hBWE_FD->old_input_lp_fx, old_input_lp_fx, Sample_Delay_LP ); + Copy( old_input_16k_fx + L_INP_MEM, &old_input_lp_fx[Sample_Delay_LP], L_FRAME16k - Sample_Delay_LP ); + Copy( old_input_16k_fx + L_INP_MEM + L_FRAME16k - Sample_Delay_LP, hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); + } + ELSE + { + delay_input_signal_fx( hBWE_FD->old_input_lp_fx, old_input_lp_fx, &old_input_16k_fx[L_INP_MEM], Sample_Delay_LP, L_FRAME16k, &hBWE_FD->prev_Q_input_lp, &Q_slb_speech ); + } + } -test(); -IF( ( EQ_16( st_fx->idchan, 1 ) ) && ( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) -{ - FOR( i = 0; i < inner_frame; i++ ) + q_new_input_hp = s_min( Q_shb_speech, hBWE_FD->Q_new_input_hp ); + IF( st_fx->element_mode == EVS_MONO ) { - hBWE_FD->L_old_wtda_swb_fx[i] = mult_r( hBWE_FD->L_old_wtda_swb_fx[i], div_s( i, inner_frame ) ); - move16(); + Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); + Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); + } + ELSE IF( LT_16( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ) + { + Copy_Scale_sig( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP, sub( Q_shb_speech, hBWE_FD->Q_new_input_hp ) ); // Q_shb_speech + Copy( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP ); // Q_shb_speech + } + ELSE + { + Copy( hBWE_FD->new_input_hp_fx, new_input_hp_fx, Sample_Delay_HP ); // hBWE_FD->Q_new_input_hp + Copy_Scale_sig( shb_speech_fx, &new_input_hp_fx[Sample_Delay_HP], L_FRAME16k - Sample_Delay_HP, sub( hBWE_FD->Q_new_input_hp, Q_shb_speech ) ); // hBWE_FD->Q_new_input_hp } -} -/* MDCT of the core synthesis signal */ -wtda_fx( old_input_fx, &new_input_fx_q, L_old_input_fx, hBWE_FD->L_old_wtda_swb_fx, &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ inner_frame ); + hBWE_FD->Q_new_input_hp = Q_shb_speech; + move16(); + Copy( shb_speech_fx + L_FRAME16k - Sample_Delay_HP, hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); + new_input_fx = old_input_fx + Sample_Delay_SWB_BWE; + Copy( hBWE_FD->old_input_fx, old_input_fx, Sample_Delay_SWB_BWE ); + Copy( new_swb_speech_fx, new_input_fx, inner_frame ); + Copy( old_input_fx + inner_frame, hBWE_FD->old_input_fx, Sample_Delay_SWB_BWE ); -/* DCT of the ACELP core synthesis */ -direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_q, st_fx->element_mode ); + /*----------------------------------------------------------------------* + * Calculate tilt of the input signal and the ACELP core synthesis + *----------------------------------------------------------------------*/ -/* high-band gain control in case of BWS */ -test(); -IF( st_fx->bwidth_sw_cnt > 0 && st_fx->element_mode > EVS_MONO ) -{ - v_multc_fx_16( &yorig_32[L_FRAME16k], div_s( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ), &yorig_32[L_FRAME16k], sub( inner_frame, L_FRAME16k ) ); -} + /* tilt returned in Q24 goto to Q11 */ + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); -/* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ -scl = sub( 16 + 8, new_input_fx_q ); -/* Possible to Upscale? */ -IF( scl > 0 ) -{ - /* Yes */ - /* Calc Room to Upscale */ - Q_synth = Find_Max_Norm32( yorig_32, inner_frame ); - /* Stay within MAX_Q_NEW_INPUT */ - scl = s_min( Q_synth, scl ); -} -Copy_Scale_sig32_16( yorig_32, yorig_fx, inner_frame, scl ); -Q_synth = add( sub( new_input_fx_q, 16 ), scl ); -max = 0; -move16(); -Q_synth_hf = 0; -move16(); -IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) -{ - scl = 300; - move16(); -} -ELSE -{ - scl = 240; - move16(); -} -FOR( i = scl; i < inner_frame; i++ ) -{ - max = s_max( max, abs_s( yorig_fx[i] ) ); -} + /*---------------------------------------------------------------------* + * SWB BWE encoding + * FB BWE encoding + *---------------------------------------------------------------------*/ -IF( max == 0 ) -{ - exp = 15; + new_input_fx_q = Q_new_swb_speech; move16(); -} -ELSE -{ - exp = norm_s( max ); -} -Copy_Scale_sig( &yorig_fx[scl], &yorig_fx[scl], sub( inner_frame, scl ), exp ); -Q_synth_hf = add( exp, Q_synth ); -test(); -IF( EQ_16( st_fx->last_extl, SWB_BWE ) || EQ_16( st_fx->last_extl, FB_BWE ) ) -{ - exp = norm_l( st_fx->EnergyLT_fx ); - IF( GT_16( add( st_fx->EnergyLT_fx_exp, exp ), shl( sub( Q_synth_hf, 4 ), 1 ) ) ) - { - Q_shb = sub( Q_synth_hf, 4 ); - st_fx->EnergyLT_fx = L_shr( st_fx->EnergyLT_fx, sub( st_fx->EnergyLT_fx_exp, shl( Q_shb, 1 ) ) ); - move32(); - } - ELSE + test(); + IF( ( EQ_16( st_fx->idchan, 1 ) ) && ( EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) { - Q_shb = shr( add( st_fx->EnergyLT_fx_exp, exp ), 1 ); - if ( EQ_16( s_and( exp, 0x0001 ), 1 ) ) + FOR( i = 0; i < inner_frame; i++ ) { - exp = sub( exp, 1 ); + hBWE_FD->L_old_wtda_swb_fx[i] = mult_r( hBWE_FD->L_old_wtda_swb_fx[i], div_s( i, inner_frame ) ); + move16(); } - st_fx->EnergyLT_fx = L_shl( st_fx->EnergyLT_fx, exp ); - move32(); } -} -ELSE -{ - Q_shb = sub( Q_synth_hf, 4 ); -} -IF( st_fx->element_mode == EVS_MONO ) -{ - Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) ); + /* MDCT of the core synthesis signal */ + wtda_fx( old_input_fx, &new_input_fx_q, L_old_input_fx, hBWE_FD->L_old_wtda_swb_fx, &st_fx->Q_old_wtda, ALDO_WINDOW, ALDO_WINDOW, /* window overlap of current frame (0: full, 2: none, or 3: half) */ inner_frame ); - Qenc_synth_hf = Q_synth_hf; - Qenc_synth = Q_synth; - move16(); - move16(); -} -ELSE -{ - Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) ); + /* DCT of the ACELP core synthesis */ + direct_transform_fx( L_old_input_fx, yorig_32, 0, inner_frame, &new_input_fx_q, st_fx->element_mode ); - Qenc_synth_hf = new_input_fx_q; - Qenc_synth = new_input_fx_q; + /* high-band gain control in case of BWS */ + test(); + IF( st_fx->bwidth_sw_cnt > 0 && st_fx->element_mode > EVS_MONO ) + { + v_multc_fx_16( &yorig_32[L_FRAME16k], div_s( st_fx->bwidth_sw_cnt, BWS_TRAN_PERIOD ), &yorig_32[L_FRAME16k], sub( inner_frame, L_FRAME16k ) ); + } + + /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ + scl = sub( 16 + 8, new_input_fx_q ); + /* Possible to Upscale? */ + IF( scl > 0 ) + { + /* Yes */ + /* Calc Room to Upscale */ + Q_synth = Find_Max_Norm32( yorig_32, inner_frame ); + /* Stay within MAX_Q_NEW_INPUT */ + scl = s_min( Q_synth, scl ); + } + Copy_Scale_sig32_16( yorig_32, yorig_fx, inner_frame, scl ); + Q_synth = add( sub( new_input_fx_q, 16 ), scl ); + max = 0; move16(); + Q_synth_hf = 0; move16(); -} - -/* SWB BWE encoding */ -IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) -{ - SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth ); -} -ELSE -{ - SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, - SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth ); -} + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + scl = 300; + move16(); + } + ELSE + { + scl = 240; + move16(); + } + FOR( i = scl; i < inner_frame; i++ ) + { + max = s_max( max, abs_s( yorig_fx[i] ) ); + } -/* FB BWE encoding */ -IF( EQ_16( st_fx->extl, FB_BWE ) ) -{ - fb_band_begin = FB_BAND_BEGIN; - move16(); - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( max == 0 ) { - fb_band_begin = FB_BAND_BEGIN_12k8; + exp = 15; move16(); } - energy_fbe_fb_fx = L_deposit_l( 0 ); - FOR( i = fb_band_begin; i < FB_BAND_END; i++ ) + ELSE { - tmp = shr( yorig_fx[i], 4 ); - energy_fbe_fb_fx = L_mac0( energy_fbe_fb_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ + exp = norm_s( max ); } - ener_low_fx = 0; - move16(); - FOR( i = fb_band_begin - FB_BAND_WIDTH; i < fb_band_begin; i++ ) + Copy_Scale_sig( &yorig_fx[scl], &yorig_fx[scl], sub( inner_frame, scl ), exp ); + Q_synth_hf = add( exp, Q_synth ); + + test(); + IF( EQ_16( st_fx->last_extl, SWB_BWE ) || EQ_16( st_fx->last_extl, FB_BWE ) ) + { + exp = norm_l( st_fx->EnergyLT_fx ); + IF( GT_16( add( st_fx->EnergyLT_fx_exp, exp ), shl( sub( Q_synth_hf, 4 ), 1 ) ) ) + { + Q_shb = sub( Q_synth_hf, 4 ); + st_fx->EnergyLT_fx = L_shr( st_fx->EnergyLT_fx, sub( st_fx->EnergyLT_fx_exp, shl( Q_shb, 1 ) ) ); + move32(); + } + ELSE + { + Q_shb = shr( add( st_fx->EnergyLT_fx_exp, exp ), 1 ); + if ( EQ_16( s_and( exp, 0x0001 ), 1 ) ) + { + exp = sub( exp, 1 ); + } + st_fx->EnergyLT_fx = L_shl( st_fx->EnergyLT_fx, exp ); + move32(); + } + } + ELSE { - tmp = shr( yorig_fx[i], 4 ); - ener_low_fx = L_mac0( ener_low_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ + Q_shb = sub( Q_synth_hf, 4 ); } - IF( energy_fbe_fb_fx != 0 ) + IF( st_fx->element_mode == EVS_MONO ) { - exp = norm_l( energy_fbe_fb_fx ); - frac = extract_h( L_shl( energy_fbe_fb_fx, exp ) ); - tmp = div_s( 16384, frac ); /*15+14-(exp+2*(Q_synth_hf-4)-16) -->45-(exp+2*(Q_synth_hf-4)) */ - L_tmp = Mult_32_16( ener_low_fx, tmp ); /*45-(exp+2*(Q_synth_hf-4)) + 2*(Q_synth_hf-4) - 15 = 30-exp */ - exp1 = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp1 ); - exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ + Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) ); + + Qenc_synth_hf = Q_synth_hf; + Qenc_synth = Q_synth; + move16(); + move16(); } ELSE { - fb_ener_adjust_fx = 0; + Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) ); + + Qenc_synth_hf = new_input_fx_q; + Qenc_synth = new_input_fx_q; + move16(); move16(); } - fb_ener_adjust_fx = s_min( fb_ener_adjust_fx, 16384 ); /*Q15 */ - idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); -} + /* SWB BWE encoding */ + IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + { + SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, + SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth ); + } + ELSE + { + SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, + SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth ); + } -/* write FB BWE frame gain to the bitstream */ -IF( EQ_16( st_fx->extl, FB_BWE ) ) -{ - push_indice( st_fx->hBstr, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); -} + /* FB BWE encoding */ + IF( EQ_16( st_fx->extl, FB_BWE ) ) + { + fb_band_begin = FB_BAND_BEGIN; + move16(); + if ( EQ_16( st_fx->L_frame, L_FRAME ) ) + { + fb_band_begin = FB_BAND_BEGIN_12k8; + move16(); + } + energy_fbe_fb_fx = L_deposit_l( 0 ); + FOR( i = fb_band_begin; i < FB_BAND_END; i++ ) + { + tmp = shr( yorig_fx[i], 4 ); + energy_fbe_fb_fx = L_mac0( energy_fbe_fb_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ + } + ener_low_fx = 0; + move16(); + FOR( i = fb_band_begin - FB_BAND_WIDTH; i < fb_band_begin; i++ ) + { + tmp = shr( yorig_fx[i], 4 ); + ener_low_fx = L_mac0( ener_low_fx, tmp, tmp ); /*2*(Q_synth_hf-4) */ + } -return; + IF( energy_fbe_fb_fx != 0 ) + { + exp = norm_l( energy_fbe_fb_fx ); + frac = extract_h( L_shl( energy_fbe_fb_fx, exp ) ); + tmp = div_s( 16384, frac ); /*15+14-(exp+2*(Q_synth_hf-4)-16) -->45-(exp+2*(Q_synth_hf-4)) */ + L_tmp = Mult_32_16( ener_low_fx, tmp ); /*45-(exp+2*(Q_synth_hf-4)) + 2*(Q_synth_hf-4) - 15 = 30-exp */ + exp1 = norm_l( L_tmp ); + L_tmp = L_shl( L_tmp, exp1 ); + exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ + } + ELSE + { + fb_ener_adjust_fx = 0; + move16(); + } + + fb_ener_adjust_fx = s_min( fb_ener_adjust_fx, 16384 ); /*Q15 */ + idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); + } + + /* write FB BWE frame gain to the bitstream */ + IF( EQ_16( st_fx->extl, FB_BWE ) ) + { + push_indice( st_fx->hBstr, IND_FB_SLOPE, idxGain, NUM_BITS_FB_FRAMEGAIN ); + } + + return; } @@ -1620,11 +1619,11 @@ static void msvq_interpol_2_fx( static void calculate_Tonality_fx( const Word16 element_mode, /* i : element mode */ - const Word16 *org, /* i : MDCT coefficients of original Q_new*/ - const Word16 *gen, /* i : MDCT coefficients of generated signal Q15*/ - Word16 *SFM_org, /* o : Spectral Flatness results Q12*/ - Word16 *SFM_gen, /* o : Spectral Flatness results Q12*/ - const Word16 length /* i : length for calculating tonality */ + const Word16 *org, /* i : MDCT coefficients of original Q_new*/ + const Word16 *gen, /* i : MDCT coefficients of generated signal Q15*/ + Word16 *SFM_org, /* o : Spectral Flatness results Q12*/ + Word16 *SFM_gen, /* o : Spectral Flatness results Q12*/ + const Word16 length /* i : length for calculating tonality */ ) { Word16 n_coeff; @@ -2020,16 +2019,16 @@ static Word16 WB_BWE_encoding_fx( *-------------------------------------------------------------------*/ static Word16 SWB_BWE_encoding_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *insig_fx, /* i : delayed original input signal at 32kHz */ - const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ - const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ - const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *insig_fx, /* i : delayed original input signal at 32kHz */ + const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ + const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ + const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ const Word16 *yos_fx_16_orig, /* i : 16-bit MDCT coefficients of the windowed original input signal at 32kHz */ - const Word32 *yos_fx, /* i : 32-bit MDCT coefficients of the windowed original input signal at 32kHz */ - Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ - const Word16 tilt_nb_fx, /* i : SWB tilt */ - const Word16 st_offset, /* i : start frequency offset for BWE envelope */ + const Word32 *yos_fx, /* i : 32-bit MDCT coefficients of the windowed original input signal at 32kHz */ + Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ + const Word16 tilt_nb_fx, /* i : SWB tilt */ + const Word16 st_offset, /* i : start frequency offset for BWE envelope */ const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 5f85b1bf9..4530bb4db 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -369,8 +369,8 @@ void swb_pre_proc_fx( Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ + const CLDFB_SCALE_FACTOR *cldfbScale, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ ) { Word16 Sample_Delay_SWB_BWE, inner_frame, delay; diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 3088d7b98..a9e73afa8 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -583,16 +583,16 @@ static void GenerateITD_fx( --------------------------------------------------------------------*/ static void getPeriodicBSplineSampVec_fx( - Word32 *BfVec_fx, /* o : values for non-zero basis functions Q30 */ - Word16 *AzIdx, /* o : indices of non-zero basis functions */ - const Word16 NumBFs, /* i : the number of basis functions = third index of Bf. */ - const Word32 t_fx, /* i : azimuth Q22 */ - Word16 *num_az_idx, /* o : Number of azimuth indices */ + Word32 *BfVec_fx, /* o : values for non-zero basis functions Q30 */ + Word16 *AzIdx, /* o : indices of non-zero basis functions */ + const Word16 NumBFs, /* i : the number of basis functions = third index of Bf. */ + const Word32 t_fx, /* i : azimuth Q22 */ + Word16 *num_az_idx, /* o : Number of azimuth indices */ const Word16 knot_interval_fx, /* i : The knot interval Q6 */ const Word16 azimKSeq_0_fx, /* i : Knot sequence Q6 */ - const Word16 azimSegSamples, /* i : Samples per segment */ - const Word16 *azimBsShape_fx, /* i : Basis shape Q15 */ - const Word16 subSampFactor /* i : Subsampling factor */ + const Word16 azimSegSamples, /* i : Samples per segment */ + const Word16 *azimBsShape_fx, /* i : Basis shape Q15 */ + const Word16 subSampFactor /* i : Subsampling factor */ ) { Word16 i, nI, d0, d; @@ -661,13 +661,13 @@ 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 */ - const Word16 *KSeq_fx, /* i : knot sequence including multiplicities Q KSeq_Q_fx */ - const Word16 KSeq_Q_fx, /* i : Q-value of knot sequence */ + 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 */ + const Word16 *KSeq_fx, /* i : knot sequence including multiplicities Q KSeq_Q_fx */ + const Word16 KSeq_Q_fx, /* i : Q-value of knot sequence */ const Word16 SegSamples, /* i : samples per segment */ const Word16 *BsLen, /* i : lengths of basis shapes */ const Word16 *BsStart, /* i : start of basis shapes */ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index b35aa18bc..34ef98e66 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -69,7 +69,7 @@ extern const Word32 defaultHRIR_rom_ER32_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28* extern const Word16 defaultHRIR_rom_E16_Q_fx; extern const Word32 defaultHRIR_rom_EL16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/ extern const Word32 defaultHRIR_rom_ER16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/ -extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q15*/ +extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q15*/ extern const Word16 defaultHRIR_rom_elevBsLen[4]; extern const Word16 defaultHRIR_rom_elevBsStart[4]; extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q15*/ @@ -80,7 +80,7 @@ extern const Word16 defaultHRIR_rom_ITD_W_fx[658]; extern const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[84]; /* Q15 */ extern const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[19]; /* Q7 */ extern const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[28]; /* Q15 */ -extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16]; /* Q8 */ +extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16]; /* Q8 */ extern const Word16 defaultHRIR_rom_ITD_model_configuration[4]; extern const Word16 defaultHRIR_rom_ITD_elevBsLen[4]; extern const Word16 defaultHRIR_rom_ITD_elevBsStart[4]; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 90833fc79..bf25e92f8 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1095,7 +1095,7 @@ typedef struct const Word16 *elevBsLen; const Word16 *elevBsStart; Word16 elevSegSamples; - Word16 resamp_factor_fx; /*Q14*/ + Word16 resamp_factor_fx; /*Q14*/ const Word16 *elevKSeq_fx; /* Array, length elevDim3-2, Q8 [-90,90] */ const Word16 *azimKSeq_fx; /* Array, length azimDim3-2 Q7 [-180,180] */ const Word16 *W_fx; /* Array, size (elevDim3*azimDim3) x K */ -- GitLab