From 5a18c848a4b75d6a7c26f7f800c8063630cc173e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 3 Dec 2024 19:09:45 +0530 Subject: [PATCH 1/3] Encoder LTV crash fixes and float code disabling/cleanup --- lib_com/ACcontextMapping.c | 7 ++- lib_com/ari.c | 2 + lib_com/ari_hm.c | 10 ++++ lib_com/arith_coder.c | 17 +++---- lib_com/basop_proto_func.h | 6 +-- lib_com/basop_settings.h | 10 ++++ lib_com/basop_tcx_utils.c | 6 +-- lib_com/basop_util.c | 4 +- lib_com/enr_1_az.c | 2 + lib_com/ivas_arith.c | 8 +-- lib_com/ivas_prot.h | 2 + lib_com/lsf_msvq_ma.c | 2 + lib_com/prot.h | 32 +++++++++--- lib_com/prot_fx.h | 2 +- lib_com/rom_com.c | 5 +- lib_com/stab_est.c | 2 + lib_com/swb_bwe_com.c | 7 ++- lib_com/syn_12k8.c | 2 + lib_com/syn_filt.c | 2 + lib_com/tcx_ltp.c | 8 +-- lib_com/tcx_mdct.c | 2 + lib_com/tcx_mdct_window.c | 4 ++ lib_com/trans_direct.c | 2 + lib_com/trans_inv.c | 2 + lib_com/vlpc_2st_com.c | 2 + lib_com/weight.c | 2 + lib_com/weight_a.c | 2 + lib_com/wtda.c | 5 +- lib_dec/arith_coder_dec.c | 4 +- lib_enc/ACcontextMapping_enc.c | 8 +-- lib_enc/ACcontextMapping_enc_fx.c | 4 +- lib_enc/analy_sp_fx.c | 43 ++++++++++------ lib_enc/enc_higher_acelp.c | 3 +- lib_enc/enc_pit_exc_fx.c | 13 ++--- lib_enc/fd_cng_enc.c | 6 ++- lib_enc/find_tilt.c | 2 + lib_enc/find_uv.c | 5 +- lib_enc/gain_enc_fx.c | 4 -- lib_enc/gs_enc_fx.c | 4 +- lib_enc/hq_classifier_enc.c | 4 +- lib_enc/igf_enc.c | 21 ++++---- lib_enc/ivas_core_enc.c | 14 +++--- lib_enc/ivas_core_pre_proc_front.c | 48 +++++------------- lib_enc/ivas_corecoder_enc_reconfig.c | 18 +++---- lib_enc/ivas_cpe_enc.c | 20 ++++---- lib_enc/ivas_dirac_enc.c | 6 +-- lib_enc/ivas_enc.c | 70 ++++++++++++++------------- lib_enc/ivas_front_vad.c | 2 +- lib_enc/ivas_init_enc.c | 4 +- lib_enc/ivas_mct_core_enc.c | 6 +-- lib_enc/ivas_stat_enc.h | 4 +- lib_enc/ivas_stereo_ica_enc.c | 35 +++++++++----- lib_enc/ivas_stereo_mdct_igf_enc.c | 6 +++ lib_enc/ivas_tcx_core_enc.c | 2 +- lib_enc/pit_enc.c | 4 +- 55 files changed, 301 insertions(+), 216 deletions(-) diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c index 15dcfc0be..86c7e7bd8 100644 --- a/lib_com/ACcontextMapping.c +++ b/lib_com/ACcontextMapping.c @@ -39,6 +39,7 @@ #include "cnst.h" #include "prot.h" #include "wmc_auto.h" +#include "prot_fx.h" /*-------------------------------------------------------------------* * get_next_coeff_mapped_ivas() @@ -66,7 +67,7 @@ int16_t get_next_coeff_mapped_ivas( return hm_cfg->indexBuffer[*idx]; } #else -Word16 get_next_coeff_mapped_ivas( +Word16 get_next_coeff_mapped_ivas_fx( Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ @@ -89,6 +90,7 @@ Word16 get_next_coeff_mapped_ivas( #endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * get_next_coeff_unmapped_ivas() * @@ -106,7 +108,9 @@ int16_t get_next_coeff_unmapped_ivas( return *idx; } +#endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * update_mixed_context_ivas() * @@ -128,3 +132,4 @@ int32_t update_mixed_context_ivas( return ( ctx & 0xf ) * 16 + t + 13; } +#endif diff --git a/lib_com/ari.c b/lib_com/ari.c index f9ba6d5e5..6f13d1e97 100644 --- a/lib_com/ari.c +++ b/lib_com/ari.c @@ -42,6 +42,7 @@ #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------- Ari 14 bits common routines -------------------------------------------------------------*/ @@ -65,3 +66,4 @@ int32_t mul_sbc_14bits_ivas( /*function in line*/ } +#endif diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 159660927..f96f73b33 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -50,6 +50,7 @@ * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void UnmapIndex_ivas( const int16_t PeriodicityIndex, const int16_t Bandwidth, @@ -99,6 +100,7 @@ void UnmapIndex_ivas( return; } +#endif void UnmapIndex_fx( const Word16 PeriodicityIndex, /* Q0 */ @@ -167,6 +169,7 @@ void UnmapIndex_fx( } +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ConfigureContextHm_ivas() * @@ -241,6 +244,7 @@ void ConfigureContextHm_ivas( return; } +#endif /*-------------------------------------------------------------------* @@ -249,6 +253,7 @@ void ConfigureContextHm_ivas( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED int16_t CountIndexBits_ivas( const int16_t Bandwidth, const int16_t PeriodicityIndex ) @@ -261,6 +266,7 @@ int16_t CountIndexBits_ivas( return 8; } +#endif Word16 CountIndexBits_fx( Word16 Bandwidth, /* Q0 */ @@ -285,6 +291,7 @@ Word16 CountIndexBits_fx( #define WMC_TOOL_SKIP +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * tcx_hm_render_ivas() * @@ -343,6 +350,7 @@ Word16 tcx_hm_render_ivas( return 0; } +#endif Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ @@ -400,6 +408,7 @@ Word32 tcx_hm_render_fx( return 0; } +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * tcx_hm_modify_envelope_ivas() * @@ -446,6 +455,7 @@ void tcx_hm_modify_envelope_ivas( return; } +#endif void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c index ce16e7a7b..a3ac2d8e9 100644 --- a/lib_com/arith_coder.c +++ b/lib_com/arith_coder.c @@ -54,7 +54,7 @@ *-------------------------------------------------------*/ /*! r: Q15 */ -Word16 expfp_evs( +Word16 expfp_evs_fx( const Word16 x, /* i : mantissa Q15-e */ const Word16 x_e /* i : exponent Q0 */ ) @@ -117,7 +117,6 @@ Word16 expfp_evs( return round_fx( L_shl( y, 15 ) ); } - /*-------------------------------------------------------* * powfp_odd2_evs() * @@ -130,6 +129,7 @@ Word16 expfp_evs( * * NOTE: This function must be in sync with ari_decode_14bits_pow_ivas() */ +#ifndef IVAS_FLOAT_FIXED void powfp_odd2_evs( const Word16 base, /* Q15 */ const Word16 exp, /* Q0 */ @@ -200,7 +200,6 @@ void powfp_odd2_evs( return; } - /*------------------------------------------------------------------------ * Function: tcx_arith_scale_envelope_flt * @@ -503,7 +502,7 @@ void tcx_arith_scale_envelope_ivas( return; } - +#endif /*------------------------------------------------------------------------ * Function: tcx_arith_render_envelope_flt @@ -518,7 +517,7 @@ void tcx_arith_scale_envelope_ivas( * and decoder remain synchronized. *-------------------------------------------------------------------------*/ -void tcx_arith_render_envelope_ivas( +void tcx_arith_render_envelope_ivas_fx( const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ const Word16 L_frame, /* i : number of spectral lines Q0*/ const Word16 L_spec, /* i : length of the coded spectrum Q0*/ @@ -535,12 +534,12 @@ void tcx_arith_render_envelope_ivas( /* Compute perceptual LPC envelope, transform it into freq.-domain gains */ basop_weight_a( A_ind, tmpA, gamma_w ); - basop_lpc2mdct( tmpA, M, NULL, NULL, gainlpc, gainlpc_e ); + basop_lpc2mdct_fx( tmpA, M, NULL, NULL, gainlpc, gainlpc_e ); /* Add pre-emphasis tilt to LPC envelope, transform LPC into MDCT gains */ basop_weight_a_inv( A_ind, signal_env, gamma_uw ); basop_E_LPC_a_add_tilt( signal_env, tmpA, preemph_fac ); - basop_lpc2mdct( tmpA, M + 1, signal_env, signal_env_e, NULL, NULL ); + basop_lpc2mdct_fx( tmpA, M + 1, signal_env, signal_env_e, NULL, NULL ); /* Compute weighted signal envelope in perceptual domain */ FOR( k = 0; k < FDNS_NPTS; k++ ) @@ -558,10 +557,10 @@ void tcx_arith_render_envelope_ivas( move32(); } - basop_PsychAdaptLowFreqDeemph( env, gainlpc, gainlpc_e, NULL ); + basop_PsychAdaptLowFreqDeemph_fx( env, gainlpc, gainlpc_e, NULL ); /* Scale from FDNS_NPTS to L_frame and multiply LFE gains */ - basop_mdct_noiseShaping_interp( env, L_frame, signal_env, signal_env_e ); + basop_mdct_noiseShaping_interp_fx( env, L_frame, signal_env, signal_env_e ); FOR( k = L_frame; k < L_spec; ++k ) { diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h index 0580db98e..be8b46782 100644 --- a/lib_com/basop_proto_func.h +++ b/lib_com/basop_proto_func.h @@ -87,7 +87,7 @@ void basop_E_LPC_f_lsp_a_conversion( ); /* tcx_utils.c */ -void basop_lpc2mdct( +void basop_lpc2mdct_fx( Word16 *lpcCoeffs, /* Q12 */ Word16 lpcOrder, /* Q0 */ Word16 *mdct_gains, /* Q12 */ @@ -95,13 +95,13 @@ void basop_lpc2mdct( Word16 *mdct_inv_gains, /* Q12 */ Word16 *mdct_inv_gains_exp ); -void basop_PsychAdaptLowFreqDeemph( +void basop_PsychAdaptLowFreqDeemph_fx( Word32 x[], /* Q16 */ const Word16 lpcGains[], /* exp(lpcGains_e) */ const Word16 lpcGains_e[], Word16 lf_deemph_factors[] /* Qx */ ); -void basop_mdct_noiseShaping_interp( +void basop_mdct_noiseShaping_interp_fx( Word32 x[], /* Q16 */ Word16 lg, /* Q0 */ Word16 gains[], /* exp(gain_exp) */ diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index c5c4f967d..1c3ff783c 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -55,6 +55,7 @@ #pragma warning( disable : 4310 ) #endif +#ifndef IVAS_FLOAT_FIXED /*! \def Macro converts a float < 1 to Word32 fixed point with saturation and rounding */ @@ -66,6 +67,7 @@ */ #define FL2WORD16( val ) \ ( Word16 )( ( ( val ) >= 0 ) ? ( ( ( (double) ( val ) * ( WORD16_FIX_SCALE ) + 0.5 ) >= (double) ( MAXVAL_WORD16 ) ) ? (int32_t) ( MAXVAL_WORD16 ) : (int32_t) ( (double) ( val ) * (double) ( WORD16_FIX_SCALE ) + 0.5 ) ) : ( ( ( (double) ( val ) * (WORD16_FIX_SCALE) -0.5 ) <= (double) ( MINVAL_WORD16 ) ) ? (int32_t) ( MINVAL_WORD16 ) : (int32_t) ( (double) ( val ) * (double) (WORD16_FIX_SCALE) -0.5 ) ) ) +#endif /*! \def Macro converts a Word32 fixed point to Word16 fixed point <1 with saturation @@ -73,27 +75,35 @@ #define WORD322WORD16( val ) \ ( ( ( ( ( ( val ) >> ( WORD32_BITS - WORD16_BITS - 1 ) ) + 1 ) > ( ( (int32_t) 1 << WORD16_BITS ) - 1 ) ) && ( (int32_t) ( val ) > 0 ) ) ? (Word16) (int16_t) ( ( (int32_t) 1 << ( WORD16_BITS - 1 ) ) - 1 ) : (Word16) (int16_t) ( ( ( ( val ) >> ( WORD32_BITS - WORD16_BITS - 1 ) ) + 1 ) >> 1 ) ) +#ifndef IVAS_FLOAT_FIXED /*! \def Macro converts a Word32 fixed point < 1 to float shifts result left by scale */ #define WORD322FL_SCALE( x, scale ) ( ( (float) ( (int32_t) ( x ) ) ) / ( (int64_t) 1 << ( WORD32_BITS - 1 - ( scale ) ) ) ) +#endif +#ifndef IVAS_FLOAT_FIXED /*! \def Macro converts a float < 1 to Word32 fixed point with saturation and rounding, shifts result right by scale */ /* Note: Both x and scale must be constants at compile time, scale must be in range -31..31 */ #define FL2WORD32_SCALE( x, scale ) FL2WORD32( (double) ( x ) * ( (int64_t) 1 << ( WORD32_BITS - 1 - ( scale ) ) ) / ( (int64_t) 1 << ( WORD32_BITS - 1 ) ) ) +#endif +#ifndef IVAS_FLOAT_FIXED /*! \def Macro converts a Word16 fixed point < 1 to float shifts result left by scale */ #define WORD162FL_SCALE( x, scale ) ( ( (float) ( (int32_t) ( x ) ) ) / ( (int64_t) 1 << ( WORD16_BITS - 1 - ( scale ) ) ) ) +#endif +#ifndef IVAS_FLOAT_FIXED /*! \def Macro converts a float < 1 to Word16 fixed point with saturation and rounding, shifts result right by scale */ /* Note: At compile time, x must be a float constant and scale must be an integer constant in range -15..15 */ #define FL2WORD16_SCALE( x, scale ) FL2WORD16( (float) ( x ) * ( (int64_t) 1 << ( WORD16_BITS - 1 - ( scale ) ) ) / ( (int64_t) 1 << ( WORD16_BITS - 1 ) ) ) +#endif /* Word16 Packed Type */ diff --git a/lib_com/basop_tcx_utils.c b/lib_com/basop_tcx_utils.c index 579711080..17f0e23ba 100644 --- a/lib_com/basop_tcx_utils.c +++ b/lib_com/basop_tcx_utils.c @@ -60,7 +60,7 @@ // return tmp; // } -void basop_lpc2mdct( +void basop_lpc2mdct_fx( Word16 *lpcCoeffs, /* Q12 */ Word16 lpcOrder, /* Q0 */ Word16 *mdct_gains, /* Q12 */ @@ -219,7 +219,7 @@ void basop_lpc2mdct( } -void basop_mdct_noiseShaping_interp( +void basop_mdct_noiseShaping_interp_fx( Word32 x[], /* Q16 */ Word16 lg, /* Q0 */ Word16 gains[], /* exp(gain_exp) */ @@ -376,7 +376,7 @@ void basop_mdct_noiseShaping_interp( } -void basop_PsychAdaptLowFreqDeemph( +void basop_PsychAdaptLowFreqDeemph_fx( Word32 x[], /* Q16 */ const Word16 lpcGains[], /* exp(lpcGains_e) */ const Word16 lpcGains_e[], diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index c465428fc..c2bdd455f 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1319,14 +1319,14 @@ static Word16 fixp_sin_cos_residual_16( if ( flag_radix2 == 0 ) { - x = mult_r( x, FL2WORD16( 1.0 / EVS_PI ) ); + x = mult_r( x, 10430 /* 1 / EVS_PI in Q15 */ ); } s = shr( x, shift ); residual = s_and( x, ( 1 << shift ) - 1 ); /* We assume "2+scale" is a constant */ residual = shl( residual, 2 + scale ); - residual = mult_r( residual, FL2WORD16( EVS_PI / 4.0 ) ); + residual = mult_r( residual, EVS_PI_FX / 4 ); /* Sine sign symmetry */ ssign = s_and( s, ( 1 << LD ) << 1 ); diff --git a/lib_com/enr_1_az.c b/lib_com/enr_1_az.c index 3285c515a..eab3f49e9 100644 --- a/lib_com/enr_1_az.c +++ b/lib_com/enr_1_az.c @@ -41,6 +41,7 @@ #include "wmc_auto.h" #include "prot_fx.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * enr_1_Az() * @@ -64,6 +65,7 @@ float enr_1_Az( return enr_LP; } +#endif #ifdef BASOP_NOGLOB Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ diff --git a/lib_com/ivas_arith.c b/lib_com/ivas_arith.c index 166c8e0ed..1625340ac 100644 --- a/lib_com/ivas_arith.c +++ b/lib_com/ivas_arith.c @@ -178,8 +178,8 @@ UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe( symbol = ivas_ari_get_symbol( cum_freq, range, cum ); - high = UL_subNsD( UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol] ) ), 1 ); - low = UL_addNsD( low, mul_sbc_14bits_ivas( range, cum_freq[symbol + 1] ) ); + high = UL_subNsD( UL_addNsD( low, mul_sbc_14bits( range, cum_freq[symbol] ) ), 1 ); + low = UL_addNsD( low, mul_sbc_14bits( range, cum_freq[symbol + 1] ) ); FOR( ;; ) { @@ -502,8 +502,8 @@ void ivas_ari_encode_14bits_ext_fx( move32(); move32(); - high = L_sub( L_add( low, mul_sbc_14bits_ivas( range, cum_freq[symbol] ) ), 1 ); - low = L_add( low, mul_sbc_14bits_ivas( range, cum_freq[L_add( symbol, 1 )] ) ); + high = L_sub( L_add( low, mul_sbc_14bits( range, cum_freq[symbol] ) ), 1 ); + low = L_add( low, mul_sbc_14bits( range, cum_freq[L_add( symbol, 1 )] ) ); bits_to_follow = s->bits_to_follow; move32(); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index fcd3e2f64..da3cac148 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2067,12 +2067,14 @@ void adjustTargetSignal( * IC-BWE Stereo prototypes *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void spectral_balancer( float *signal, float *mem, const int16_t lg, const int16_t coeff_set ); +#endif void stereo_icBWE_preproc( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ diff --git a/lib_com/lsf_msvq_ma.c b/lib_com/lsf_msvq_ma.c index 52db3bbfe..69bbd40e7 100644 --- a/lib_com/lsf_msvq_ma.c +++ b/lib_com/lsf_msvq_ma.c @@ -152,6 +152,7 @@ void midlsf_dec_flt( * *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED int16_t lsf_ind_is_active_flt( const Word16 lsf_q_ind[], const float means[], @@ -173,3 +174,4 @@ int16_t lsf_ind_is_active_flt( return sub( min_distance, min_distance_thr[narrowband][cdk] ) < 0; } +#endif diff --git a/lib_com/prot.h b/lib_com/prot.h index 92e6134e9..e257bc4e1 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -4336,7 +4336,7 @@ void transf_cdbk_enc( float code_preQ[], /* o : prequantizer excitation */ int16_t *unbits /* i/o: number of AVQ unused bits */ ); - +#ifndef IVAS_FLOAT_FIXED /*! r: quantization index */ int16_t gain_quant( float *gain, /* i/o: quantized gain */ @@ -4344,7 +4344,7 @@ int16_t gain_quant( const float max_val, /* i : value of upper limit */ const int16_t bits /* i : number of bits to quantize */ ); - +#endif void deemph_lpc( float *p_Aq_cuerr, /* i : LP coefficients current frame */ float *p_Aq_old, /* i : LP coefficients previous frame */ @@ -7407,15 +7407,19 @@ int16_t get_next_coeff_mapped_ivas( CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ ); +#ifndef IVAS_FLOAT_FIXED /*! r: index of next coefficient */ int16_t get_next_coeff_unmapped_ivas( int16_t *ii, /* i/o: coefficient index */ int16_t *idx /* o : index in unmapped domain */ ); +#endif +#ifndef IVAS_FLOAT_FIXED int32_t update_mixed_context_ivas( int32_t ctx, int16_t a ); +#endif void ACcontextMapping_encode2_no_mem_s17_LC( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ @@ -7804,9 +7808,11 @@ void ari_copy_states( Tastat *source, Tastat *dest ); +#ifndef IVAS_FLOAT_FIXED int32_t mul_sbc_14bits_ivas( int32_t r, int32_t c ); +#endif void ari_start_encoding_14bits( Tastat *s ); @@ -7852,11 +7858,12 @@ void ari_decode_14bits_bit_ext_ivas( Tastat *s ); /*! r: Q15 */ -Word16 expfp_evs( +Word16 expfp_evs_fx( const Word16 x, /* i : mantissa Q15-e */ const Word16 x_e /* i : exponent Q0 */ ); +#ifndef IVAS_FLOAT_FIXED void powfp_odd2_evs( const Word16 base, /* Q15 */ const Word16 exp, /* Q0 */ @@ -7873,8 +7880,9 @@ void tcx_arith_scale_envelope_ivas( Word16 s_env[], /* o : scaled envelope Q15-e */ Word16 *s_env_e /* o : scaled envelope exponent Q0 */ ); +#endif -void tcx_arith_render_envelope_ivas( +void tcx_arith_render_envelope_ivas_fx( const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ const Word16 L_frame, /* i : number of spectral lines Q0*/ const Word16 L_spec, /* i : length of the coded spectrum Q0*/ @@ -7974,6 +7982,7 @@ void tcx_arith_decode_envelope_ivas_fx( const Word16 low_complexity /* i : low-complexity flag */ ); +#ifndef IVAS_FLOAT_FIXED void UnmapIndex_ivas( const int16_t PeriodicityIndex, const int16_t Bandwidth, @@ -7981,6 +7990,7 @@ void UnmapIndex_ivas( const int16_t SmallerLags, int16_t *FractionalResolution, int32_t *Lag ); +#endif void UnmapIndex_fx( const Word16 PeriodicityIndex, /* Q0 */ @@ -8002,6 +8012,7 @@ int16_t SearchPeriodicityIndex( float *RelativeScore /* o : Energy concentration factor */ ); +#ifndef IVAS_FLOAT_FIXED void ConfigureContextHm_ivas( const int16_t NumCoeffs, /* i : Number of coefficients */ const int16_t TargetBits, /* i : Target bit budget (excl. Done flag) */ @@ -8009,15 +8020,18 @@ void ConfigureContextHm_ivas( const int16_t LtpPitchLag, /* i : TCX-LTP pitch in F.D. */ CONTEXT_HM_CONFIG *hm_cfg /* o : Context-based harmonic model configuration */ ); +#endif int16_t EncodeIndex( const int16_t Bandwidth, /* o : NB, 1: (S)WB */ int16_t PeriodicityIndex, BSTR_ENC_HANDLE hBstr ); +#ifndef IVAS_FLOAT_FIXED int16_t CountIndexBits_ivas( const int16_t Bandwidth, /* o : NB, 1: (S)WB */ const int16_t PeriodicityIndex ); +#endif Word16 CountIndexBits_fx( Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ @@ -8032,11 +8046,13 @@ int16_t DecodeIndex( #define GET_ADJ( T, L ) GET_ADJ2( T, L, *FractionalResolution ) #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) +#ifndef IVAS_FLOAT_FIXED Word16 tcx_hm_render_ivas( const Word16 lag, /* i : pitch lag Q0*/ const Word16 fract_res, /* i : fractional resolution of the lag Q0*/ Word16 p[] /* o : harmonic model Q13*/ ); +#endif Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ @@ -8044,6 +8060,7 @@ Word32 tcx_hm_render_fx( Word16 p[] /* o: harmonic model Q13 */ ); +#ifndef IVAS_FLOAT_FIXED void tcx_hm_modify_envelope_ivas( const Word16 gain, /* i : HM gain Q11*/ const Word16 lag, /* Q0 */ @@ -8052,6 +8069,7 @@ void tcx_hm_modify_envelope_ivas( Word32 env[], /* i/o: envelope Q16*/ const Word16 L_frame /* i : number of spectral lines Q0*/ ); +#endif void tcx_hm_modify_envelope_fx( const Word16 gain, /* i: HM gain Q11 */ @@ -8524,11 +8542,13 @@ int16_t E_LPC_lsp_unweight_float( const float inv_gamma /* i : inverse weighting factor */ ); +#ifndef IVAS_FLOAT_FIXED int16_t lsf_ind_is_active_flt( const Word16 lsf_q_ind[], const float means[], const int16_t narrowband, const int16_t cdk ); +#endif void midlsf_enc( const float qlsf0[], @@ -10276,6 +10296,7 @@ int16_t IGF_MapBitRateToIndex_flt( const int16_t rf_mode /* i : flag to signal the RF mode */ ); +#ifndef IVAS_FLOAT_FIXED void IGFSCFEncoderOpen( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ H_IGF_INFO hIgfInfo, /* i : IGF info handle */ @@ -10289,7 +10310,6 @@ void IGFSCFEncoderReset( IGFSCFENC_INSTANCE_HANDLE hPublicData /* i : handle to public data or NULL in case there was no instance created */ ); -#ifndef IVAS_FLOAT_FIXED int16_t IGFSCFEncoderEncode( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -10298,7 +10318,6 @@ int16_t IGFSCFEncoderEncode( const int16_t igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ const int16_t indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ ); -#endif void IGFSCFEncoderSaveContextState( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ @@ -10309,6 +10328,7 @@ void IGFSCFEncoderRestoreContextState( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i : handle to public data or NULL in case there was no instance created */ const int16_t igfGridIdx /* i : igf grid index see declaration of IGF_GRID_IDX for details */ ); +#endif void IGFSCFDecoderOpen_ivas( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index e609a0d91..656bd173d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11024,7 +11024,7 @@ ivas_error push_next_bits( ); /*! r: index of next coefficient */ -Word16 get_next_coeff_mapped_ivas( +Word16 get_next_coeff_mapped_ivas_fx( Word16 ii[2], /* i/o: coefficient indexes Q0*/ Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ Word16 *idx, /* o : index in unmapped domain Q0*/ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 3f343a5e4..d9d7680d2 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -36557,11 +36557,10 @@ const Word16 *const Ratios_fx[2][17] =/* 7Q8 */ } }; -#define QGC(x) FL2WORD16_SCALE(x, 4) const Word16 qGains[2][1 << kTcxHmNumGainBits] = { - /* GC */ { QGC(0.75f) }, - /* VC */ { QGC(0.6f), QGC(1.4f), QGC(4.5f), QGC(10.0f) } + /* GC */ { 12 }, + /* VC */ { 10, 22, 72, 160 } }; diff --git a/lib_com/stab_est.c b/lib_com/stab_est.c index ede98a675..b08e515f7 100644 --- a/lib_com/stab_est.c +++ b/lib_com/stab_est.c @@ -42,6 +42,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -229,3 +230,4 @@ int16_t stab_est( return music_flag2; } +#endif diff --git a/lib_com/swb_bwe_com.c b/lib_com/swb_bwe_com.c index 8b1cd00ba..f080b8965 100644 --- a/lib_com/swb_bwe_com.c +++ b/lib_com/swb_bwe_com.c @@ -176,6 +176,7 @@ int16_t WB_BWE_gain_pred( } #endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * calc_normal_length() * @@ -277,7 +278,6 @@ void calc_normal_length( return; } -#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * calc_tilt_bwe() * @@ -312,7 +312,7 @@ void calc_tilt_bwe( return; } -#endif + /*-------------------------------------------------------------------* * calc_norm_envelop() @@ -426,6 +426,7 @@ static void calc_norm_envelop_lf( } return; } +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -1210,6 +1211,7 @@ void time_reduce_pre_echo( } #endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * hq_generic_hf_decoding() * @@ -1515,6 +1517,7 @@ void hq_generic_hf_decoding( } return; } +#endif #ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* diff --git a/lib_com/syn_12k8.c b/lib_com/syn_12k8.c index 57bbb42be..252300794 100644 --- a/lib_com/syn_12k8.c +++ b/lib_com/syn_12k8.c @@ -40,6 +40,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------ * syn_12k8() * @@ -67,3 +68,4 @@ void syn_12k8( return; } +#endif diff --git a/lib_com/syn_filt.c b/lib_com/syn_filt.c index 194c6ff97..612a737ac 100644 --- a/lib_com/syn_filt.c +++ b/lib_com/syn_filt.c @@ -42,6 +42,7 @@ #include "wmc_auto.h" #include +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------* * syn_filt() * @@ -168,3 +169,4 @@ void synth_mem_updt2_flt( return; } +#endif diff --git a/lib_com/tcx_ltp.c b/lib_com/tcx_ltp.c index 8bf28ca9d..6914874c2 100644 --- a/lib_com/tcx_ltp.c +++ b/lib_com/tcx_ltp.c @@ -45,6 +45,7 @@ * Local constants *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED #define ALPHA 0.85f /*------------------------------------------------------------------- @@ -53,7 +54,6 @@ * *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void tcx_ltp_get_lpc_flt( float *input, const int16_t length, @@ -161,7 +161,6 @@ static void tcx_ltp_get_zir_flt( return; } -#endif /*------------------------------------------------------------------- @@ -211,6 +210,7 @@ void predict_signal_flt( return; } +#endif /*------------------------------------------------------------------- * tcx_ltp_synth_filter_flt() @@ -489,7 +489,6 @@ static void tcx_ltp_synth_filter_fadeout_flt( return; } -#endif /*------------------------------------------------------------------- @@ -553,6 +552,7 @@ int16_t tcx_ltp_decode_params_flt( return 0; } +#endif /*------------------------------------------------------------------- *tcx_ltp_synth_filter_10_flt() @@ -684,6 +684,7 @@ static void tcx_ltp_synth_filter_01_flt( } #endif +#ifndef IVAS_FLOAT_FIXED #define MAX_TCX_LTP_FILTER_LEN 8 #define MAX_TRANSITION_LEN 240 /* L_FRAME_48K / 4 */ @@ -698,7 +699,6 @@ static void tcx_ltp_synth_filter_01_flt( * the current update interval with scaling from 0 towards non-zero gain ---------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void tcx_ltp_synth_filter_11_unequal_pitch_flt( float *out, float *in, diff --git a/lib_com/tcx_mdct.c b/lib_com/tcx_mdct.c index 734e3ba4e..72d44202b 100644 --- a/lib_com/tcx_mdct.c +++ b/lib_com/tcx_mdct.c @@ -41,6 +41,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * TCX_MDCT_flt() * @@ -253,3 +254,4 @@ void TCX_MDXT_Inverse_flt( return; } +#endif diff --git a/lib_com/tcx_mdct_window.c b/lib_com/tcx_mdct_window.c index ae72d9cc6..58d1e5895 100644 --- a/lib_com/tcx_mdct_window.c +++ b/lib_com/tcx_mdct_window.c @@ -46,6 +46,7 @@ const PWord16 *getSineWindowTable( Word16 length ); +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * mdct_window_sine_flt() * @@ -106,6 +107,7 @@ void mdct_window_sine_flt( } return; } +#endif void mdct_window_sine_IVAS_updated( @@ -237,6 +239,7 @@ void mdct_window_sine( #endif } +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * mdct_window_aldo_flt() * @@ -389,6 +392,7 @@ void mdct_window_aldo_flt( return; } +#endif void mdct_window_aldo( diff --git a/lib_com/trans_direct.c b/lib_com/trans_direct.c index 951bb5df0..982f8bd65 100644 --- a/lib_com/trans_direct.c +++ b/lib_com/trans_direct.c @@ -41,6 +41,7 @@ #include "rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------- * direct_transform() * @@ -173,3 +174,4 @@ void direct_transform( return; } +#endif diff --git a/lib_com/trans_inv.c b/lib_com/trans_inv.c index ca27480ad..1c0032bf0 100644 --- a/lib_com/trans_inv.c +++ b/lib_com/trans_inv.c @@ -42,6 +42,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * Local constants *--------------------------------------------------------------------------*/ @@ -892,3 +893,4 @@ void inverse_transform( return; } +#endif diff --git a/lib_com/vlpc_2st_com.c b/lib_com/vlpc_2st_com.c index 5fa06fc13..fd11710f1 100644 --- a/lib_com/vlpc_2st_com.c +++ b/lib_com/vlpc_2st_com.c @@ -42,6 +42,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------* * lsf_weight_2st_flt() * @@ -88,3 +89,4 @@ void lsf_weight_2st_flt( return; } +#endif diff --git a/lib_com/weight.c b/lib_com/weight.c index 3c1266b9f..6ebb2a6ca 100644 --- a/lib_com/weight.c +++ b/lib_com/weight.c @@ -41,6 +41,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * sfm2mqb() * @@ -365,3 +366,4 @@ void map_quant_weight( return; } +#endif diff --git a/lib_com/weight_a.c b/lib_com/weight_a.c index 874b0fcb3..b333ac208 100644 --- a/lib_com/weight_a.c +++ b/lib_com/weight_a.c @@ -39,6 +39,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------ * weight_a() * @@ -104,3 +105,4 @@ void weight_a_subfr( return; } +#endif diff --git a/lib_com/wtda.c b/lib_com/wtda.c index 3a9494e42..3755ebe1b 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -45,6 +45,7 @@ #include "prot_fx.h" #endif +#ifndef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * mvr2r_inv() * @@ -349,6 +350,7 @@ void wtda( return; } +#endif #ifdef IVAS_FLOAT_FIXED @@ -530,7 +532,7 @@ void wtda_fx32( #endif // IVAS_FLOAT_FIXED - +#ifndef IVAS_FLOAT_FIXED void wtda_ext( const float *new_audio, /* i : input audio */ float *wtda_audio, /* o : windowed audio */ @@ -624,3 +626,4 @@ void wtda_ext( return; } +#endif diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index f41f4f590..d144323f0 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -147,7 +147,7 @@ static Word16 tcx_arith_decode_ivas_fx( } ELSE { - exp_k = expfp_evs( negate( envelope[k] ), tmp ); + exp_k = expfp_evs_fx( negate( envelope[k] ), tmp ); } /* decode line magnitude */ @@ -359,7 +359,7 @@ void tcx_arith_decode_envelope_ivas_fx( move16(); #define WMC_TOOL_SKIP - tcx_arith_render_envelope_ivas( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); + tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env ); #undef WMC_TOOL_SKIP IF( use_hm != 0 ) diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c index 1a49c9492..ed7d7c359 100644 --- a/lib_enc/ACcontextMapping_enc.c +++ b/lib_enc/ACcontextMapping_enc.c @@ -1531,8 +1531,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS( /* Main Loop through the 2-tuples */ FOR( k = 0; k < lastnz; k += 2 ) { - a1_i = get_next_coeff_mapped_ivas( ii, &p1, &idx1, hm_cfg ); - b1_i = get_next_coeff_mapped_ivas( ii, &p2, &idx2, hm_cfg ); + a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); + b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); idx = s_min( idx1, idx2 ); @@ -1622,14 +1622,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS( IF( s_and( idx1, 1 ) ) { /* update first context */ - c[p1] = update_mixed_context_ivas( c[p1], (int16_t) abs( x[a1_i] ) ); + c[p1] = update_mixed_context_ivas_fx( c[p1], (Word16) abs( x[a1_i] ) ); move32(); } IF( s_and( idx2, 1 ) ) { /* update second context */ - c[p2] = update_mixed_context_ivas( c[p2], (int16_t) abs( x[b1_i] ) ); + c[p2] = update_mixed_context_ivas_fx( c[p2], (Word16) abs( x[b1_i] ) ); move32(); } } diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 88494bb5b..21089de9f 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -843,8 +843,8 @@ void RCcontextMapping_encode2_no_mem_s17_LCS_fx( FOR( k = 0; k < lastnz; k += 2 ) { - a1_i = get_next_coeff_mapped_ivas( ii, &p1, &idx1, hm_cfg ); - b1_i = get_next_coeff_mapped_ivas( ii, &p2, &idx2, hm_cfg ); + a1_i = get_next_coeff_mapped_ivas_fx( ii, &p1, &idx1, hm_cfg ); + b1_i = get_next_coeff_mapped_ivas_fx( ii, &p2, &idx2, hm_cfg ); idx = s_min( idx1, idx2 ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 5b900c6d0..71524f5b8 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -598,7 +598,7 @@ void ivas_analy_sp_fx_front( Word32 *pt_bands; Word32 Ltmp, LEtot; Word16 *pt_fft; - + Word32 temp32_log; /*-----------------------------------------------------------------* * Compute spectrum * find energy per critical frequency band and total energy in dB @@ -651,7 +651,19 @@ void ivas_analy_sp_fx_front( pt_bands += NB_BANDS; pt_fft += L_FFT; } - LEtot = L_shr( LEtot, Q1 ); // Q_new + Q_SCALE - 2 + + /* Average total log energy over both half-frames */ + /* *Etot = 10.0f * (float)log10(0.5f * *Etot); */ + *Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */; + move16(); + IF( LEtot != 0 ) + { + /* Q of LEtot is Q_new + Q_SCALE - 1, LEtot / 2 can be considered as LEtot in Q_new + Q_SCALE - 2*/ + temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25 + temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 + *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8 + move16(); + } } ELSE { @@ -662,23 +674,22 @@ void ivas_analy_sp_fx_front( MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); - LEtot = L_shl( LEtot, 1 ); - } - /* Average total log energy over both half-frames */ - Word32 temp32_log; - IF( LEtot == 0 ) - { + /* *Etot *= 2.f; + *Etot = 10.0f * (float)log10(0.5f * *Etot); + => *Etot = 10.0f * (float)log10(*Etot); + */ + + /* Average total log energy over both half-frames */ *Etot = -12800 /* 10.f * logf(0.00001f) in Q8 */; move16(); - } - ELSE - { - /* log10( LEtot / 2 ) = log10( LEtot ) - log10( 2 ) */ - temp32_log = L_sub( BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ), LOG10_2_Q31 >> Q6 ); // Q25 - temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 - *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8 - move16(); + IF( LEtot != 0 ) + { + temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25 + temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 + *Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8 + move16(); + } } /* Per-bin log-energy spectrum */ diff --git a/lib_enc/enc_higher_acelp.c b/lib_enc/enc_higher_acelp.c index d1eff11a2..c97dbfd40 100644 --- a/lib_enc/enc_higher_acelp.c +++ b/lib_enc/enc_higher_acelp.c @@ -344,7 +344,7 @@ static void find_cn( return; } -#endif + /*---------------------------------------------------------------* * gain_quant() * @@ -389,3 +389,4 @@ int16_t gain_quant( return ( index ); } +#endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 342abbfac..08f6a7a3b 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -557,7 +557,7 @@ void enc_pit_exc_fx( #ifdef BASOP_NOGLOB cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ #else /* BASOP_NOGLOB */ - cum_gpit = shl( cum_gpit, 1 ); /*Q15*/ + cum_gpit = shl( cum_gpit, 1 ); /*Q15*/ #endif *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } @@ -765,13 +765,10 @@ void enc_pit_exc_ivas_fx( *----------------------------------------------------------------*/ Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* condition on target (compared to float) has been put outside the loop */ -#if 1 // ndef BUG_FIX - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); -#else - find_targets_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hLPDmem->mem_w0, p_Aq, /*_DIFF_FLOAT_FIX_ --> Here I think mem_syn_tmp_fx should be used */ - res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); -#endif + + find_targets_ivas_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2, L_subfr, -2 ); Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ diff --git a/lib_enc/fd_cng_enc.c b/lib_enc/fd_cng_enc.c index 204e807b4..ed55ab7da 100644 --- a/lib_enc/fd_cng_enc.c +++ b/lib_enc/fd_cng_enc.c @@ -240,7 +240,7 @@ void configureFdCngEnc( * * Delete the instance of type FD_CNG *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void deleteFdCngEnc( HANDLE_FD_CNG_ENC *hFdCngEnc /* i/o: FD_CNG structure */ ) @@ -257,6 +257,7 @@ void deleteFdCngEnc( return; } +#endif /*-------------------------------------------------------------------* * resetFdCngEnc() @@ -327,6 +328,7 @@ void resetFdCngEnc( * * Perform noise estimation *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED void perform_noise_estimation_enc_ivas_fx( Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */ Word16 band_energies_exp, @@ -497,7 +499,7 @@ void perform_noise_estimation_enc_ivas_fx( return; } -#ifndef IVAS_FLOAT_FIXED +#else void perform_noise_estimation_enc( float *band_energies, /* i : energy in critical bands without minimum noise floor E_MIN*/ float *enerBuffer, /* i : energy buffer */ diff --git a/lib_enc/find_tilt.c b/lib_enc/find_tilt.c index 1c6083f5a..9366c7728 100644 --- a/lib_enc/find_tilt.c +++ b/lib_enc/find_tilt.c @@ -51,10 +51,12 @@ * Local constants *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED #define FACT 3.0f /* background noise energy estimation adjusting factor - to maintain the ADR about the same */ #define TH_COR 0.6f /* Minimum correlation for per bin processing */ #define TH_D 50.0f /* Difference limit between nearest harmonic and a frequency bin */ #define TH_PIT ( INT_FS_12k8 / ( 2.0f * TH_D ) ) /* Maximum pitch for per bin processing */ +#endif /*-------------------------------------------------------------------* * find_tilt() diff --git a/lib_enc/find_uv.c b/lib_enc/find_uv.c index 7acb99f49..e7d895745 100644 --- a/lib_enc/find_uv.c +++ b/lib_enc/find_uv.c @@ -50,9 +50,10 @@ * Local constants *-------------------------------------------------------------------*/ -#define L_ENR ( NB_SSF + 2 ) +#define L_ENR ( NB_SSF + 2 ) +#ifndef IVAS_FLOAT_FIXED #define VOI_THRLD 0.2f - +#endif /*-------------------------------------------------------------------* * find_ener_decrease() diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index fb98e8b7c..30caee67e 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -811,11 +811,7 @@ void gain_enc_mless_ivas_fx( qua_table = gain_qua_mless_6b_fx; if ( GT_16( element_mode, EVS_MONO ) ) { -#if 1 // def IVAS_CODE qua_table = gain_qua_mless_6b_stereo_fx; -#else - // PMTE() -#endif } move16(); if ( EQ_16( clip_gain, 1 ) ) diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index c09aa8b0a..9a8af4188 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -428,13 +428,13 @@ void encod_audio_ivas_fx( * Encode GSC attack flag (used to reduce possible pre-echo) * Encode GSC SWB speech flag *---------------------------------------------------------------*/ -#if 1 // def GSC_IVAS // TVB -->>>>>> + test(); if ( GT_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 ) { push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 ); } -#endif + IF( attack_flag > 0 ) { push_indice( hBstr, IND_GSC_ATTACK, 1, 1 ); diff --git a/lib_enc/hq_classifier_enc.c b/lib_enc/hq_classifier_enc.c index 08db72620..1aece086b 100644 --- a/lib_enc/hq_classifier_enc.c +++ b/lib_enc/hq_classifier_enc.c @@ -46,14 +46,14 @@ /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED #define SHARP_DIST_THRES 22.2f #define HALF_WIN_LENGTH 10 #define L_SPEC_HB 320 #define PEAK_THRESHOLD 0.1f #define LOW_COUNT_THRESHOLD 220 - +#endif /*-----------------------------------------------------------------* * Local function prototypes diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 7d9825db8..bbfc7b771 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -1673,16 +1673,17 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); } } - tmp_tb_fx = shr( tmp_tb_fx, 2 ); /*taking 2 guard bits so it's exponent tmp_sb_e=+2*/ - tmp_sb_fx = shr( tmp_sb_fx, 2 ); /*taking 2 guard bits so it's exponent tmp_tb_e=+2 */ - tmp_sb_e = add( tmp_sb_e, 2 ); - tmp_tb_e = add( tmp_tb_e, 2 ); - hPrivateData->SFM_tb_fx[sfb] = add( tmp_tb_fx, add( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], 2 ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], 3 ) ) ); - hPrivateData->SFM_tb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, tmp_tb_e ) ), hPrivateData->SFM_tb_fx[sfb] ) ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/ - hPrivateData->SFM_sb_fx[sfb] = add( tmp_sb_fx, add( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], 2 ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], 3 ) ) ); - hPrivateData->SFM_sb_fx[sfb] = extract_l( L_min( L_shl( 22118 /*2.7f Q13*/, sub( 2, tmp_sb_e ) ), hPrivateData->SFM_sb_fx[sfb] ) ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/ - hPrivateData->sfb_sb_e[sfb] = tmp_sb_e; - hPrivateData->sfb_tb_e[sfb] = tmp_tb_e; + tmp_tb_fx = shl_sat( tmp_tb_fx, sub( 2, tmp_tb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ + tmp_sb_fx = shl_sat( tmp_sb_fx, sub( 2, tmp_sb_e ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ + + hPrivateData->SFM_tb_fx[sfb] = add_sat( tmp_tb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_TB_fx[sfb], sub( 2, tmp_tb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_TB_fx[sfb], sub( 3, tmp_tb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ + hPrivateData->SFM_tb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_tb_fx[sfb] ); /* resultant exponent stored in hPrivateData->sfb_sb_e[sfb]*/ + hPrivateData->SFM_sb_fx[sfb] = add_sat( tmp_sb_fx, add_sat( shr( hPrivateData->prevSFM_FIR_SFB_SB_fx[sfb], sub( 2, tmp_sb_e ) ), shr( hPrivateData->prevSFM_IIR_SFB_SB_fx[sfb], sub( 3, tmp_sb_e ) ) ) ); /* Since we're limiting max value to 2.7f we can saturate to Q13 */ + hPrivateData->SFM_sb_fx[sfb] = s_min( 22118 /*2.7f Q13*/, hPrivateData->SFM_sb_fx[sfb] ); /*resultant exponent stores in hPrivateData->sfb_tb_e[sfb]*/ + hPrivateData->sfb_sb_e[sfb] = 2; + hPrivateData->sfb_tb_e[sfb] = 2; + move16(); + move16(); move16(); move16(); move16(); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index a33647bf7..c1f2a50de 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -253,18 +253,20 @@ ivas_error ivas_core_enc( } IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - IF( ( error = pre_proc_ivas( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, last_element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) { return error; } } ELSE { - IF( ( error = pre_proc_ivas( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, - &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], - vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = pre_proc_ivas( st, last_element_mode, element_brate, element_brate, input_frame, old_inp_12k8_fx[n] /* i: -1, o: Q_new - 1 */, old_inp_16k_fx[n] /* i: -1, o: Q_new - 1 */, + &inp_fx[n], &ener_fx[n], A_fx[n], Aw_fx[n], epsP_fx[n], &epsP_fx_q[n], lsp_new_fx[n], lsp_mid_fx[n], new_inp_resamp16k_fx[n], &Voicing_flag[n], old_wsp_fx[n], e_old_wsp[n], loc_harm[n], + vad_flag_dtx[n], MCT_flag, vad_hover_flag[n], flag_16k_smc, enerBuffer_fx[n], enerBuffer_fx_exp[n], fft_buff_fx[n], cor_map_sum_fx[n], &Q_new[n] ) ), + IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index f7f54891e..a882f68e1 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -915,7 +915,6 @@ ivas_error pre_proc_front_ivas_fx( const Word32 ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Encoder_State *st; IF( hSCE != NULL ) { @@ -945,7 +944,6 @@ ivas_error pre_proc_front_ivas_fx( old_inp_12k8_e = st->exp_old_inp_12k8; move16(); } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED Word16 q_tmpN_LR[CPE_CHANNELS]; Word16 q_tmpE_LR[CPE_CHANNELS]; @@ -1062,7 +1060,6 @@ ivas_error pre_proc_front_ivas_fx( #endif Word16 sf_energySum[CLDFB_NO_CHANNELS_MAX]; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 Q_to_be_looked_into = -1; move16(); Word16 headroom = 0, preemp_len = 0, inp_max = 0; @@ -1071,7 +1068,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); Word16 *preemp_start_idx = NULL; Word32 sig_out[960], max_32; -#endif /*------------------------------------------------------------------* * Initialization @@ -1219,13 +1215,11 @@ ivas_error pre_proc_front_ivas_fx( L_look = L_LOOK_12k8; /* lookahead at 12.8kHz */ move16(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Scale_sig( old_inp_12k8_fx, L_INP_12k8, sub( Q_to_be_looked_into, sub( Q15, old_inp_12k8_e ) ) ); old_inp_12k8_e = sub( Q15, Q_to_be_looked_into ); Scale_sig( st->old_inp_12k8_fx, 240, sub( Q_to_be_looked_into, sub( Q15, st->exp_old_inp_12k8 ) ) ); st->exp_old_inp_12k8 = sub( Q15, Q_to_be_looked_into ); move16(); -#endif new_inp_12k8_fx = old_inp_12k8_fx + L_INP_MEM; /* pointer to new samples of the input signal in 12.8kHz core */ inp_12k8_fx = new_inp_12k8_fx - L_look; /* pointer to the current frame of input signal in 12.8kHz core */ @@ -1441,7 +1435,7 @@ ivas_error pre_proc_front_ivas_fx( dummy_fx = st->mem_preemph_fx; move16(); // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); + PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); test(); IF( preemp_start_idx && preemp_len ) @@ -1513,7 +1507,6 @@ ivas_error pre_proc_front_ivas_fx( * Spectral analysis *--------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 *lgBin_E_fx; Word32 PS_fx[128]; Word32 band_energies_fx[2 * NB_BANDS]; @@ -1526,7 +1519,6 @@ ivas_error pre_proc_front_ivas_fx( Word16 Scale_fac[2] = { 0 }; move16(); move16(); -#endif Scale_sig32( st->Bin_E_fx, L_FFT, sub( add( Q_new, Q_SCALE - 2 ), st->q_Bin_E ) ); st->q_Bin_E = add( Q_new, Q_SCALE - 2 ); move16(); @@ -1745,7 +1737,6 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( EQ_16( element_mode, IVAS_CPE_TD ) && lr_vad_enabled && band_energies_LR_fx != NULL ) { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 normmsPeriodog_fx = Q31, zero_flag = 0; move16(); move16(); @@ -1772,7 +1763,6 @@ ivas_error pre_proc_front_ivas_fx( Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_Q ); st->hFdCngEnc->msNoiseEst_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_Q ); move16(); -#endif perform_noise_estimation_enc_ivas_fx( band_energies_LR_fx, sub( Q31, band_energies_LR_fx_q ), enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); } ELSE @@ -1814,9 +1804,6 @@ ivas_error pre_proc_front_ivas_fx( normmsperiodog = getScaleFactor32( st->hFdCngEnc->hFdCngCom->periodog, PERIODOGLEN ); } st->hFdCngEnc->hFdCngCom->exp_cldfb_periodog = sub( 31, normmsperiodog ); - /* Bug : Next line overflows. Revisit later. */ - st->hFdCngEnc->hFdCngCom->scalingFactor = (Word16) ( st->hFdCngEnc->hFdCngCom->scalingFactor * ( 1 << 30 ) ); - move16(); move16(); perform_noise_estimation_enc_ivas_fx( band_energies_fx, band_energies_fx_exp, enerBuffer_fx, *enerBuffer_fx_exp, st->hFdCngEnc, input_Fs, hCPE ); @@ -1892,11 +1879,10 @@ ivas_error pre_proc_front_ivas_fx( IF( zero_flag ) { msPeriodog_fx_Q = getScaleFactor32( st->hFdCngEnc->msPeriodog_fx, NPART ); + scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, msPeriodog_fx_Q ); + st->hFdCngEnc->msPeriodog_fx_exp = sub( st->hFdCngEnc->msPeriodog_fx_exp, msPeriodog_fx_Q ); + move16(); } - msPeriodog_fx_Q = sub( sub( 31, msPeriodog_fx_Q ), st->hFdCngEnc->msPeriodog_fx_exp ); - Scale_sig32( st->hFdCngEnc->msPeriodog_fx, NPART, sub( sub( 31, msPeriodog_fx_Q ), st->hFdCngEnc->msPeriodog_fx_exp ) ); - st->hFdCngEnc->msPeriodog_fx_exp = sub( 31, msPeriodog_fx_Q ); - move16(); Word16 energy_ho_fx_Q = Q31; move16(); @@ -1904,23 +1890,22 @@ ivas_error pre_proc_front_ivas_fx( IF( zero_flag ) { energy_ho_fx_Q = getScaleFactor32( st->hFdCngEnc->energy_ho_fx, NPART ); + scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q ); + st->hFdCngEnc->energy_ho_fx_exp = sub( st->hFdCngEnc->energy_ho_fx_exp, energy_ho_fx_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->energy_ho_fx, NPART, energy_ho_fx_Q ); - /* Bug : Next line overflows. Revisit later. */ - st->hFdCngEnc->energy_ho_fx_exp = st->hFdCngEnc->energy_ho_fx_exp - energy_ho_fx_Q; - Word16 msNoiseEst_old_Q = Q31; move16(); zero_flag = get_zero_flag( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); IF( zero_flag ) { - energy_ho_fx_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + msNoiseEst_old_Q = getScaleFactor32( st->hFdCngEnc->msNoiseEst_old_fx, NPART ); + scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, msNoiseEst_old_Q ); + st->hFdCngEnc->msNoiseEst_old_fx_exp = sub( st->hFdCngEnc->msNoiseEst_old_fx_exp, msNoiseEst_old_Q ); + move16(); } - Scale_sig32( st->hFdCngEnc->msNoiseEst_old_fx, NPART, energy_ho_fx_Q ); - /* Bug : Next line overflows. Revisit later. */ - st->hFdCngEnc->msNoiseEst_old_fx_exp = st->hFdCngEnc->msNoiseEst_old_fx_exp - msNoiseEst_old_Q; st->hFdCngEnc->msPeriodog_fx_exp_fft = st->hFdCngEnc->msPeriodog_fx_exp_cldfb = st->hFdCngEnc->msPeriodog_fx_exp; move16(); move16(); @@ -1984,10 +1969,8 @@ ivas_error pre_proc_front_ivas_fx( * Comparison of the LP coefficents to determine if it is possible * to reuse the primary channel LP coefficients in the secondary channel *----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word32 speech_buff[L_FRAME + M]; Copy_Scale_sig_16_32( inp_12k8_fx - M, speech_buff, L_FRAME + M, Q12 ); -#endif hCPE->hStereoTD->tdm_lp_reuse_flag = tdm_lp_comparison_fx( hCPE->hStereoTD, hCPE->hStereoClassif, st, &speech_buff[0], tdm_A_PCh_fx, A_fx, M, tdm_lsp_new_PCh_fx, lsp_new_fx, L_FRAME, L_sub( element_brate, imult3216( FRAMES_PER_SEC, nb_bits_metadata ) ), add( Q_new, 12 ) ); move16(); } @@ -2295,12 +2278,10 @@ ivas_error pre_proc_front_ivas_fx( * TC frame selection *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 oi12k8_fx[L_INP_12k8]; Copy_Scale_sig( old_inp_12k8_fx, oi12k8_fx, L_INP_12k8, negate( Q_new ) ); // Q0 Word16 *ni12k8_fx = oi12k8_fx + L_INP_MEM; inp_12k8_fx = ni12k8_fx - L_look; -#endif st->clas = signal_clas_fx( st, inp_12k8_fx, ee_fx, *relE_fx, L_look, tdm_SM_last_clas ); select_TC_fx( MODE1, st->tc_cnt, &st->coder_type, st->localVAD ); @@ -2316,9 +2297,7 @@ ivas_error pre_proc_front_ivas_fx( *-----------------------------------------------------------------*/ IF( hStereoClassif != NULL ) { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 max_e_Etot; -#endif // IVAS_FLOAT_FIXED_CONVERSIONS max_e_Etot = s_max( hStereoClassif->e_Etot_buf_fx, s_max( hStereoClassif->Etot_up_e, hStereoClassif->Etot_dn_e ) ); scale_sig32( hStereoClassif->Etot_buf_fx, 3, sub( hStereoClassif->e_Etot_buf_fx, max_e_Etot ) ); @@ -2441,7 +2420,6 @@ ivas_error pre_proc_front_ivas_fx( move16(); IF( flag_16k_smc ) { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS Word16 Q_old_inp_16k = -1; move16(); @@ -2454,7 +2432,6 @@ ivas_error pre_proc_front_ivas_fx( st->Q_old_wtda = -1; // This reset needs to be looked into move16(); } -#endif st->mem_preemph_enc = shl( st->mem_preemph_enc, sub( Q_old_inp_16k, sub( Q15, st->exp_mem_preemph_enc ) ) ); move16(); st->exp_mem_preemph_enc = sub( Q15, Q_old_inp_16k ); @@ -2485,9 +2462,6 @@ ivas_error pre_proc_front_ivas_fx( } ELSE { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS -#define ATT_SEG_LEN ( L_FRAME / ATT_NSEG ) -#endif Scale_sig( old_wsp_fx, L_WSP, sub( Q_new, *q_old_wsp ) ); *q_old_wsp = Q_new; move16(); diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index a121e2b61..bf415e840 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -586,7 +586,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -828,7 +828,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( FOR( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ ) { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_SCE ) ), IVAS_ERR_OK ) ) { return error; } @@ -849,7 +849,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( IF( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData == NULL ) { - IF( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -901,7 +901,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); } - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_CPE ) ), IVAS_ERR_OK ) ) { return error; } @@ -1068,21 +1068,21 @@ ivas_error ivas_corecoder_enc_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ); move16(); - IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) ) { return error; } } } - IF( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = create_mct_enc( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = mct_enc_reconfigure_fx( st_ivas, st_ivas->nchan_transport != nchan_transport_old ) ), IVAS_ERR_OK ) ) { return error; } @@ -1093,7 +1093,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( { IF( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData == NULL ) { - IF( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1131,7 +1131,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); - IF( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = IGF_Reconfig( &st_ivas->hCPE[0]->hCoreCoder[n]->hIGFEnc, st_ivas->hCPE[0]->hCoreCoder[n]->igf, 1, st_ivas->hCPE[0]->element_brate, st_ivas->hCPE[0]->hCoreCoder[n]->bwidth, st_ivas->hCPE[0]->hCoreCoder[n]->element_mode, st_ivas->hCPE[0]->hCoreCoder[n]->rf_mode ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index ec106e5cc..6e3139fb4 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -273,7 +273,7 @@ ivas_error ivas_cpe_enc_fx( } - IF( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, Etot_LR_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_fx( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands_fx, Etot_LR_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_LR_fx, NULL, NULL, Q_inp, Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) ) { return error; } @@ -310,7 +310,7 @@ ivas_error ivas_cpe_enc_fx( * dynamically allocate data structures depending on the actual stereo mode *----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED - if ( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = stereo_memory_enc_fx( hCPE, input_Fs, max_bwidth, ivas_format, st_ivas->nchan_transport ) ), IVAS_ERR_OK ) ) { return error; } @@ -346,7 +346,7 @@ ivas_error ivas_cpe_enc_fx( move16(); move16(); - if ( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = stereo_set_tdm_fx( hCPE, input_frame, Q_inp ) ), IVAS_ERR_OK ) ) { return error; } @@ -968,7 +968,7 @@ ivas_error ivas_cpe_enc_fx( #ifndef IVAS_FLOAT_FIXED if ( ( error = initMdctItdHandling( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) #else - IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) ) #endif { return error; @@ -1166,7 +1166,7 @@ ivas_error ivas_cpe_enc_fx( e_old_wsp[n] = 16; move16(); } - if ( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_core_enc( NULL, hCPE, st_ivas->hMCT, n_CoreChannels, old_inp_12k8_16fx, old_inp_16k_16fx, ener_fx, A_fx, Aw_fx, epsP_fx, epsP_fx_q, lsp_new_fx, lsp_mid_fx, vad_hover_flag, attack_flag, realBuffer_fx, imagBuffer_fx, q_re_im_buf, old_wsp_fx, e_old_wsp, loc_harm, cor_map_sum_fx, vad_flag_dtx, enerBuffer_fx, enerBuffer_fx_exp, fft_buff_fx, tdm_SM_or_LRTD_Pri, ivas_format, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -2438,7 +2438,7 @@ ivas_error create_cpe_enc_fx( IF( EQ_16( cpe_id, sub( st_ivas->nCPE, 1 ) ) ) { - IF( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_initialize_MD_bstr_enc( &( hCPE->hMetaData ), st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -2469,7 +2469,7 @@ ivas_error create_cpe_enc_fx( } st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; move16(); - IF( ( error = init_encoder_ivas_fx( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = init_encoder_ivas_fx( st, st_ivas, n, hEncoderConfig->var_SID_rate_flag, hEncoderConfig->interval_SID, 0, ISM_MODE_NONE, hCPE->element_brate ) ), IVAS_ERR_OK ) ) { return error; } @@ -2508,7 +2508,7 @@ ivas_error create_cpe_enc_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_create_fx( &( hCPE->hFrontVad[n] ), hEncoderConfig ) ), IVAS_ERR_OK ) ) { return error; } @@ -2528,7 +2528,7 @@ ivas_error create_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - IF( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = stereo_dft_enc_create_fx( &( hCPE->hStereoDft ), input_Fs, max_bwidth ) ), IVAS_ERR_OK ) ) { return error; } @@ -2592,7 +2592,7 @@ ivas_error create_cpe_enc_fx( test(); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && LE_32( element_brate, MAX_MDCT_ITD_BRATE ) && EQ_16( ivas_format, STEREO_FORMAT ) ) { - IF( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = initMdctItdHandling_fx( hCPE->hStereoMdct, input_Fs ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 70252e3d8..9ca148879 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -106,7 +106,7 @@ ivas_error ivas_dirac_enc_open_fx( st_ivas->hDirAC = hDirAC; - IF( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -334,7 +334,7 @@ ivas_error ivas_dirac_enc_reconfigure( * DirAC main configuration *-----------------------------------------------------------------*/ - IF( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_config_fx( (void *) st_ivas, ENC ) ), IVAS_ERR_OK ) ) { return error; } @@ -623,7 +623,7 @@ ivas_error ivas_dirac_enc_fx( } } - IF( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, hodirac_flag ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 883fa1223..ab7b2a7ca 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -711,14 +711,14 @@ ivas_error ivas_enc_fx( IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - IF( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sba_enc_reconfigure( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { - IF( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_osba_enc_reconfig( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -758,7 +758,7 @@ ivas_error ivas_enc_fx( { st_ivas->hCPE[0]->element_brate = ivas_total_brate; move32(); - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */ ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, 0 /* no metadata */ ) ), IVAS_ERR_OK ) ) { return error; } @@ -766,7 +766,7 @@ ivas_error ivas_enc_fx( ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) ) { /* select ISM format mode; reconfigure the ISM format encoder */ - IF( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_enc_config( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -792,7 +792,7 @@ ivas_error ivas_enc_fx( } /* Core coding of Stereo DMX */ - IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -800,7 +800,7 @@ ivas_error ivas_enc_fx( ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) { /* Analysis, decision about bitrates per channel & core coding */ - IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -830,7 +830,7 @@ ivas_error ivas_enc_fx( { ivas_masa_estimate_energy_fx( st_ivas->hMasa, data_fx, input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx ); /* energy-estimation uses TF-resolution: 4x24 */ - IF( ( error = ivas_masa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -856,7 +856,7 @@ ivas_error ivas_enc_fx( } ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) ) { - IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) ) { return error; } @@ -870,21 +870,21 @@ ivas_error ivas_enc_fx( /* core-coding of transport channels */ IF( EQ_16( st_ivas->nSCE, 1 ) ) { - IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */ { - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */ { - IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -911,7 +911,7 @@ ivas_error ivas_enc_fx( /* Estimate TF-tile energy for the input MASA stream */ ivas_masa_estimate_energy_fx( st_ivas->hMasa, &( data_fx[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport, st_ivas->q_data_fx ); - IF( ( error = ivas_omasa_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_omasa_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -955,14 +955,14 @@ ivas_error ivas_enc_fx( move16(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { - IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_separated_object_fx, q_data_separated_object, input_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) /* there are no metadata bits in SCE in this mode */ + IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_separated_object_fx, q_data_separated_object, input_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) /* there are no metadata bits in SCE in this mode */ { return error; } } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { - IF( ( error = ivas_ism_enc_fx( st_ivas, &data_separated_object_fx, q_data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, &data_separated_object_fx, q_data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -972,7 +972,7 @@ ivas_error ivas_enc_fx( flag_omasa_ener_brate = ivas_omasa_ener_brate_fx( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_fx, input_frame, sub( 31, st_ivas->q_data_fx ) ); /* Analysis, decision about bitrates per channel & core coding */ - IF( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ), IVAS_ERR_OK ) ) { return error; } @@ -990,8 +990,9 @@ ivas_error ivas_enc_fx( } /* Encode MASA parameters and write MASA metadata bitstream */ - IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, - st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ), + IVAS_ERR_OK ) ) { return error; } @@ -1050,7 +1051,7 @@ ivas_error ivas_enc_fx( } /* SBA metadata encoding and SBA metadata bitstream writing */ - IF( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, data_fx, input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) ) { return error; } @@ -1064,13 +1065,13 @@ ivas_error ivas_enc_fx( move16(); hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - IF( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -256 /* -1.0f in Q8 */, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ), IVAS_ERR_OK ) ) { return error; } /* SBA metadata encoding and SBA metadata bitstream writing */ - IF( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_enc_fx( st_ivas, &data_fx[n], input_frame, nb_bits_metadata, hMetaData ) ), IVAS_ERR_OK ) ) { return error; } @@ -1082,21 +1083,21 @@ ivas_error ivas_enc_fx( /* core-coding of transport channels */ IF( EQ_16( st_ivas->nSCE, 1 ) ) { - IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */ { - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) /* FOA/HOA format */ { - IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1105,7 +1106,7 @@ ivas_error ivas_enc_fx( ELSE IF( EQ_32( ivas_format, MC_FORMAT ) ) { /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ - IF( ( error = ivas_mc_enc_config_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mc_enc_config_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1140,7 +1141,7 @@ ivas_error ivas_enc_fx( IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { - IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -1162,7 +1163,7 @@ ivas_error ivas_enc_fx( ivas_lfe_enc_fx( st_ivas->hLFE, data_fx[LFE_CHANNEL], st_ivas->q_data_fx, input_frame, st_ivas->hLFE->hBstr ); - IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } @@ -1174,14 +1175,14 @@ ivas_error ivas_enc_fx( IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */ { - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_enc_fx( st_ivas, data_fx, st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } @@ -1216,22 +1217,23 @@ ivas_error ivas_enc_fx( scale_sig32( st_ivas->hQMetaData->q_direction[0].band_data[i].energy_ratio_fx, MAX_PARAM_SPATIAL_SUBFRAMES, -1 ); // Q31 -> Q30 } - IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ), + IVAS_ERR_OK ) ) { return error; } IF( st_ivas->hMcMasa->separateChannelEnabled ) { - IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[2], st_ivas->q_data_fx, input_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; } st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot; - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } @@ -1240,14 +1242,14 @@ ivas_error ivas_enc_fx( { IF( EQ_16( st_ivas->nSCE, 1 ) ) { - IF( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_enc_fx( st_ivas, 0, data_fx[0], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } } ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) /* Stereo DMX */ { - IF( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_enc_fx( st_ivas, 0, data_fx[0], data_fx[1], st_ivas->q_data_fx, input_frame, hMetaData->nb_bits_tot ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index d94336666..afa4d75a0 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -849,7 +849,7 @@ ivas_error front_vad_spar_fx( Scale_sig( hFrontVad->mem_decim_fx, 2 * L_FILT_MAX, sub( Q_inp, hFrontVad->q_mem_decim ) ); hFrontVad->q_mem_decim = Q_inp; move16(); - IF( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx, Etot_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_fx, &PS_fx[0], &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = front_vad_fx( NULL, st, hEncoderConfig, &hFrontVad, 0 /* MCT_flag */, input_frame, vad_flag_dtx, fr_bands_fx, Etot_fx, lf_E_fx, localVAD_HE_SAD, vad_hover_flag, band_energies_fx, &PS_fx[0], &st->lgBin_E_fx[0], Q_inp, &Q_buffer, Q_add, &front_create_flag ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index cdb4bffea..a53e33260 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1562,7 +1562,7 @@ ivas_error ivas_init_encoder_fx( { return error; } - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1717,7 +1717,7 @@ ivas_error ivas_init_encoder_fx( return error; } - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_enc_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index a2e290d49..c27e35d6f 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -1014,10 +1014,10 @@ void ivas_mct_core_enc_fx( FOR( i = 1; i < L_subframeTCX - 1; i++ ) { - mdst_fx = L_sub( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], sts[ch]->hTcxEnc->spectrum_fx[n][i - 1] ); /* An MDST estimate */ + mdst_fx = L_sub( L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i + 1], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i - 1], 1 ) ); /* An MDST estimate */ - W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), sts[ch]->hTcxEnc->spectrum_fx[n][i], sts[ch]->hTcxEnc->spectrum_fx[n][i] ); - tmp_s = sub( W_norm( W_tmp ), 1 ); + W_tmp = W_mac_32_32( W_mult_32_32( mdst_fx, mdst_fx ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ), L_shr( sts[ch]->hTcxEnc->spectrum_fx[n][i], 1 ) ); + tmp_s = W_norm( W_tmp ); W_tmp = W_shl( W_tmp, tmp_s ); powerSpec_fx[ch][add( i, imult1616( n, L_subframeTCX ) )] = W_extract_h( W_tmp ); tmp_q_powSpec[add( i, imult1616( n, L_subframeTCX ) )] = sub( add( imult1616( q_spec, 2 ), tmp_s ), 31 ); // Q = 2 * q_spec + 1 + tmp_s - 32 diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 43ef21e03..d79726f43 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -649,7 +649,9 @@ typedef struct stereo_tca_enc_data_structure Word32 C_mem_fx[2 * L_NCSHIFT_DS + 1]; Word16 C_mem_exp[2 * L_NCSHIFT_DS + 1]; Word32 E1_mem_fx, E2_mem_fx; - Word16 E1_E2_mem_exp; + // Word16 E1_E2_mem_exp; + Word16 E1_mem_exp; + Word16 E2_mem_exp; Word32 delay_0_mem_fx[MAX_DELAYREGLEN]; Word16 delay_0_mem_exp; Word32 smooth_dist_reg_prv_corr_fx; diff --git a/lib_enc/ivas_stereo_ica_enc.c b/lib_enc/ivas_stereo_ica_enc.c index caa695d9e..8cd1d01d8 100644 --- a/lib_enc/ivas_stereo_ica_enc.c +++ b/lib_enc/ivas_stereo_ica_enc.c @@ -68,6 +68,7 @@ static void unclr_calc_corr_features_fx( static void unclr_calc_corr_features( STEREO_CLASSIF_HANDLE hStereoClassif, STEREO_TCA_ENC_HANDLE hStereoTCA, const float buf1[], const float buf2[], const int16_t length, const float corrEst[], const int16_t lagSearchRange[], float *corrEst_ncorr ); #endif +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -80,6 +81,7 @@ static void unclr_calc_corr_features( STEREO_CLASSIF_HANDLE hStereoClassif, STER #define YH_DIST 9.0f #define SMOOTH_DIST_FACTOR 0.4f #define SMOOTH_ENV_FACTOR 0.6f +#endif #define XL_BIAS_FX_Q15 6554 #define XH_BIAS_FX_Q15 13107 @@ -92,11 +94,12 @@ static void unclr_calc_corr_features( STEREO_CLASSIF_HANDLE hStereoClassif, STER #define B_WIDTH_FX_Q31 32212192 #define SMOOTH_ENV_FACTOR_FX_Q15 19661 +#ifndef IVAS_FLOAT_FIXED #define A_BIAS ( ( XH_BIAS - XL_BIAS ) / ( YH_DIST - YL_DIST ) ) #define B_BIAS ( XH_BIAS - ( A_BIAS * YH_DIST ) ) #define A_WIDTH ( ( XH_WIDTH - XL_WIDTH ) / ( YH_DIST - YL_DIST ) ) #define B_WIDTH ( XH_WIDTH - ( A_WIDTH * YH_DIST ) ) - +#endif /*--------------------------------------------------------------- * tcaTargetCh_LA() @@ -459,6 +462,7 @@ void spectral_balancer_fx( } #endif // IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED void spectral_balancer( float *signal, float *mem, @@ -515,6 +519,7 @@ void spectral_balancer( return; } +#endif /*--------------------------------------------------------------- @@ -642,7 +647,7 @@ static void utilCrossCorr_mod_fx( const Word16 len ) { Word32 C, E1, E2, C_C_mem; - Word16 i, j, E1_exp, E2_exp, E1E2_exp, Inv_Tot_E_exp, k, C_exp, exp; + Word16 i, j, E1_exp, E2_exp, Inv_Tot_E_exp, k, C_exp, exp, E1_mul_exp, E2_mul_exp; Word16 Inv_Tot_E, corrEst_exp[2 * L_NCSHIFT_DS + 1]; Word64 L64_sum; @@ -653,14 +658,15 @@ static void utilCrossCorr_mod_fx( E1 = sum2_32_exp_fx( buf1, len, &E1_exp, 2 ); E2 = sum2_32_exp_fx( buf2, len, &E2_exp, 2 ); - E1E2_exp = s_max( E1_exp, E2_exp ); - E1 = L_shl( E1, sub( E1_exp, E1E2_exp ) ); - E2 = L_shl( E2, sub( E2_exp, E1E2_exp ) ); + // E1E2_exp = s_max( E1_exp, E2_exp ); + // E1 = L_shl( E1, sub( E1_exp, E1E2_exp ) ); + // E2 = L_shl( E2, sub( E2_exp, E1E2_exp ) ); + - Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1E2_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_E2_mem_exp, &E1_exp ); - Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E1E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E1_E2_mem_exp, &E2_exp ); + Word32 E1_mul = BASOP_Util_Add_Mant32Exp( E1, E1_exp, hStereoTCA->E1_mem_fx, hStereoTCA->E1_mem_exp, &E1_mul_exp ); + Word32 E2_mul = BASOP_Util_Add_Mant32Exp( E2, E2_exp, hStereoTCA->E2_mem_fx, hStereoTCA->E2_mem_exp, &E2_mul_exp ); Word32 sqr_inp = Mpy_32_32( E1_mul, E2_mul ); - Word16 sq_exp = add( E1_exp, E2_exp ); + Word16 sq_exp = add( E1_mul_exp, E2_mul_exp ); IF( sqr_inp ) { @@ -682,9 +688,10 @@ static void utilCrossCorr_mod_fx( move32(); hStereoTCA->E2_mem_fx = E2; move32(); - hStereoTCA->E1_E2_mem_exp = E1E2_exp; + hStereoTCA->E1_mem_exp = E1_exp; + move16(); + hStereoTCA->E2_mem_exp = E2_exp; move16(); - *corrEst_Exp = corrEst_exp[0]; move16(); @@ -3372,7 +3379,9 @@ void stereo_tca_init_enc_fx( move32(); hStereoTCA->E2_mem_fx = 0; move32(); - hStereoTCA->E1_E2_mem_exp = 0; + hStereoTCA->E1_mem_exp = 0; + move16(); + hStereoTCA->E2_mem_exp = 0; move16(); set32_fx( hStereoTCA->delay_0_mem_fx, 0, MAX_DELAYREGLEN ); hStereoTCA->delay_0_mem_exp = 0; @@ -3445,11 +3454,11 @@ static void unclr_calc_corr_features_fx( /* average energy of L and R channels */ hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ ); move32(); - hStereoClassif->ave_ener_L_fx_e = hStereoTCA->E1_E2_mem_exp; + hStereoClassif->ave_ener_L_fx_e = hStereoTCA->E1_mem_exp; move16(); hStereoClassif->ave_ener_R_fx = Mpy_32_32( hStereoTCA->E2_mem_fx, 13421772 /* 1/length in Q31*/ ); move32(); - hStereoClassif->ave_ener_R_fx_e = hStereoTCA->E1_E2_mem_exp; + hStereoClassif->ave_ener_R_fx_e = hStereoTCA->E2_mem_exp; move16(); /* unnormalized L/R correlation */ diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c index 30b53d7d0..fc1e3adf5 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc.c @@ -49,11 +49,17 @@ #define IGF_PATCH_MS 1 #define IGF_PATCH_LR 0 +#ifndef IVAS_FLOAT_FIXED #define TARGET_COH_THRESHOLD 0.6f +#endif #define TARGET_COH_THRESHOLD_FX 19661 +#ifndef IVAS_FLOAT_FIXED #define SOURCE_COH_THRESHOLD 0.7f +#endif #define SOURCE_COH_THRESHOLD_FX 22938 +#ifndef IVAS_FLOAT_FIXED #define PANNING_THRESHOLD 0.07f +#endif #define PANNING_THRESHOLD_FX 2294 diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 5297df659..c3c91fc39 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1715,7 +1715,7 @@ Word16 ivas_acelp_tcx20_switching_fx( e_x = add( e_x, 6 ); basop_weight_a( A_q_tcx_fx, Ap_fx, 30147 /*0.92 in Q15*/ ); - basop_lpc2mdct( Ap_fx, M, gainlpc_fx, gainlpc_e, gainlpc_noinv, gainlpc_noinv_e ); + basop_lpc2mdct_fx( Ap_fx, M, gainlpc_fx, gainlpc_e, gainlpc_noinv, gainlpc_noinv_e ); Word16 com_gainlpc_e = 0; move16(); FOR( i = 0; i < FDNS_NPTS; i++ ) diff --git a/lib_enc/pit_enc.c b/lib_enc/pit_enc.c index 1c08fe869..5d736af10 100644 --- a/lib_enc/pit_enc.c +++ b/lib_enc/pit_enc.c @@ -1115,7 +1115,7 @@ static void limit_T0_voiced2( * Close-loop pitch lag search and pitch lag quantization * Adaptive excitation construction *------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void Mode2_pit_encode( const int16_t coder_type, /* i : coding model */ const int16_t i_subfr, /* i : subframe index */ @@ -1321,7 +1321,7 @@ void Mode2_pit_encode( return; } - +#endif /*-------------------------------------------------------------------* * Mode2_abs_pit_enc: -- GitLab From 248e6b7e668f105e4b240a16cbf1524cd9be8773 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 3 Dec 2024 19:17:15 +0530 Subject: [PATCH 2/3] Clang formatting changes --- lib_enc/ivas_stat_enc.h | 2 +- lib_enc/ivas_stereo_mdct_igf_enc.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index d79726f43..c089291f8 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -649,7 +649,7 @@ typedef struct stereo_tca_enc_data_structure Word32 C_mem_fx[2 * L_NCSHIFT_DS + 1]; Word16 C_mem_exp[2 * L_NCSHIFT_DS + 1]; Word32 E1_mem_fx, E2_mem_fx; - // Word16 E1_E2_mem_exp; + // Word16 E1_E2_mem_exp; Word16 E1_mem_exp; Word16 E2_mem_exp; Word32 delay_0_mem_fx[MAX_DELAYREGLEN]; diff --git a/lib_enc/ivas_stereo_mdct_igf_enc.c b/lib_enc/ivas_stereo_mdct_igf_enc.c index fc1e3adf5..85eaa073d 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc.c @@ -47,20 +47,20 @@ * Local constants *-------------------------------------------------------------------*/ -#define IGF_PATCH_MS 1 -#define IGF_PATCH_LR 0 +#define IGF_PATCH_MS 1 +#define IGF_PATCH_LR 0 #ifndef IVAS_FLOAT_FIXED -#define TARGET_COH_THRESHOLD 0.6f +#define TARGET_COH_THRESHOLD 0.6f #endif #define TARGET_COH_THRESHOLD_FX 19661 #ifndef IVAS_FLOAT_FIXED -#define SOURCE_COH_THRESHOLD 0.7f +#define SOURCE_COH_THRESHOLD 0.7f #endif #define SOURCE_COH_THRESHOLD_FX 22938 #ifndef IVAS_FLOAT_FIXED -#define PANNING_THRESHOLD 0.07f +#define PANNING_THRESHOLD 0.07f #endif -#define PANNING_THRESHOLD_FX 2294 +#define PANNING_THRESHOLD_FX 2294 /*-------------------------------------------------------------------* -- GitLab From 483c4bcb71fc7d700a997b91ec98293c3b3f3b9c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 3 Dec 2024 20:08:55 +0530 Subject: [PATCH 3/3] EVS BE fix --- lib_com/basop_settings.h | 4 ++-- lib_com/basop_util.c | 4 ++-- lib_com/rom_com.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/basop_settings.h b/lib_com/basop_settings.h index 1c3ff783c..eb48ade52 100644 --- a/lib_com/basop_settings.h +++ b/lib_com/basop_settings.h @@ -55,7 +55,7 @@ #pragma warning( disable : 4310 ) #endif -#ifndef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED /*! \def Macro converts a float < 1 to Word32 fixed point with saturation and rounding */ @@ -97,7 +97,7 @@ #define WORD162FL_SCALE( x, scale ) ( ( (float) ( (int32_t) ( x ) ) ) / ( (int64_t) 1 << ( WORD16_BITS - 1 - ( scale ) ) ) ) #endif -#ifndef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED /*! \def Macro converts a float < 1 to Word16 fixed point with saturation and rounding, shifts result right by scale */ diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index c2bdd455f..c465428fc 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1319,14 +1319,14 @@ static Word16 fixp_sin_cos_residual_16( if ( flag_radix2 == 0 ) { - x = mult_r( x, 10430 /* 1 / EVS_PI in Q15 */ ); + x = mult_r( x, FL2WORD16( 1.0 / EVS_PI ) ); } s = shr( x, shift ); residual = s_and( x, ( 1 << shift ) - 1 ); /* We assume "2+scale" is a constant */ residual = shl( residual, 2 + scale ); - residual = mult_r( residual, EVS_PI_FX / 4 ); + residual = mult_r( residual, FL2WORD16( EVS_PI / 4.0 ) ); /* Sine sign symmetry */ ssign = s_and( s, ( 1 << LD ) << 1 ); diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index d9d7680d2..09cdf6195 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -36556,11 +36556,11 @@ const Word16 *const Ratios_fx[2][17] =/* 7Q8 */ , Ratios_WB_18_fx } }; - +#define QGC(x) FL2WORD16_SCALE(x, 4) const Word16 qGains[2][1 << kTcxHmNumGainBits] = { - /* GC */ { 12 }, - /* VC */ { 10, 22, 72, 160 } + /* GC */ { QGC(0.75f) }, + /* VC */ { QGC(0.6f), QGC(1.4f), QGC(4.5f), QGC(10.0f) } }; -- GitLab