diff --git a/lib_com/modif_fs.c b/lib_com/modif_fs.c index 9ca37f112583d22961a345c0c94fc8eeed99b578..14254283dff1cdeee42944490b7b2a320c0888d6 100644 --- a/lib_com/modif_fs.c +++ b/lib_com/modif_fs.c @@ -774,8 +774,8 @@ void Decimate_allpass_steep_fx32( move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); - out[0] = L_shr( L_add( out[0], temp[ALLPASSSECTIONS_STEEP - 1] ), 1 ); move32(); + out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); move32(); FOR( k = 1; k < N / 2; k++ ) @@ -802,7 +802,7 @@ void Decimate_allpass_steep_fx32( move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); move32(); - out[k] = L_shr( L_add( out[k], temp[ALLPASSSECTIONS_STEEP - 1] ), 1 ); + out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 ) ); move32(); } diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 9699ef419ebc0b4816aeac987c442ef8969e1a3c..189f914fb91dc943a05bf0a308afd046567ef929 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -181,8 +181,10 @@ static Word16 ivas_imax2_jacobsen_mag_fx( /* prepare denominator real and imaginary parts */ - D_re = sub( sub( shl( y_0_re, 1 ), y_m1_re ), y_p1_re ); - D_im = sub( sub( shl( y_0_im, 1 ), y_m1_im ), y_p1_im ); + /* D_re = 2 * y_0_re - y_m1_re - y_p1_re */ + D_re = add( sub( y_0_re, y_m1_re ), sub( y_0_re, y_p1_re ) ); + /* D_im = 2 * y_0_im - y_m1_im - y_p1_im */ + D_im = add( sub( y_0_im, y_m1_im ), sub( y_0_im, y_p1_im ) ); /* REAL part of complex division */ numer = L_add( L_mult0( N_re, D_re ), L_mult0( N_im, D_im ) ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 9440774a7ce3536f9993de872c56d1e44edf4f62..fa84e2d15f1c5c4d6dea475fb79e3bd4d39e3446 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3838,8 +3838,10 @@ void decoder_tcx_ivas_fx( Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); + st->hHQ_core->Q_old_wtda = st->Q_syn; + // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); + st->hHQ_core->Q_old_wtda_LB = st->Q_syn; + // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 + st->Q_syn ) ); // Scaling to Q-2 } #endif diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index e1e630941dd0158dbe79614236377b74d80ef157..8fb13e82387f62bace4222417018c90294196501 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -2006,7 +2006,7 @@ void generate_masking_noise_ivas_fx( rand_gauss_fx( &fftBuffer_fx[0], seed, *exp_out ); // Q15 ptr_r_fx = fftBuffer_fx + 2; Word16 exp1; - exp1 = sub( 32, hFdCngCom->cngNoiseLevelExp ); + exp1 = add( hFdCngCom->cngNoiseLevelExp, 1 ); Word32 mpy1; mpy1 = Sqrt32( Mpy_32_32( scale_fx, *ptr_level_fx ), &exp1 ); // Q = noise_exp-1 mpy1 = L_shl( mpy1, exp1 ); // Q31 @@ -2026,7 +2026,7 @@ void generate_masking_noise_ivas_fx( /* Real part in FFT bins */ rand_gauss_fx( ptr_r_fx, seed, *exp_out ); // Q15 Word16 exp2; - exp2 = sub( 32, hFdCngCom->cngNoiseLevelExp ); + exp2 = add( hFdCngCom->cngNoiseLevelExp, 1 ); Word32 mpy2; mpy2 = Sqrt32( L_shr( Mpy_32_32( scale_fx, *ptr_level_fx ), 1 ), &exp2 ); // Q = noise_exp-1 ( *ptr_r_fx ) = L_shl( Mpy_32_32( *ptr_r_fx, mpy2 ), exp2 ); // Q = Q15 diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 134e47c01f5e7e1e119daa6f0eb0c877ae8ec7c7..2f7503caa4a145dc33911870f01c31ec6190125d 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2925,7 +2925,7 @@ void perform_noise_estimation_dec_ivas_fx( IF( GT_16( hFdCngDec->ms_cnt_bw_up, 0 ) && GT_16( p, 55 ) ) { alpha = Inv16( add( hFdCngDec->ms_cnt_bw_up, 1 ), &i_e ); - IF( i_e <= 0 ) + IF( i_e < 0 ) { alpha = shr( alpha, negate( i_e ) ); // Q15 } @@ -3092,6 +3092,7 @@ void perform_noise_estimation_dec_ivas_fx( IF( ( tmp_q <= 0 ) ) { diff = min_q; + move16(); } ELSE { diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 2f6a742665deb462aa870fd32cd953f1811a3f00..c1d9e2f358487e03446437a11d2c6fe2f8c137d1 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -770,11 +770,11 @@ void stereo_tcx_core_dec_fx( move16(); IF( st->tcxonly ) { - FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, GENERIC, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); + FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, GENERIC, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, 0, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); } ELSE { - FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, st->Q_syn, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); + FEC_clas_estim_fx( st, 0, st->L_frame, &st->clas_dec, st->core_ext_mode, pitch_C, synth_fx, &st->lp_ener_FER_fx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 /*st->core_brate*/, 0, NULL, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, hTcxLtpDec->tcxltp ? hTcxDec->tcxltp_last_gain_unmodified : MIN_16, CLASSIFIER_TCX, bfi, st->last_core_brate, -1 ); } st->codec_mode = prev_codec_mode; move16();