diff --git a/lib_com/prot.h b/lib_com/prot.h index 4e542b2fae2139cc8e19cdbf1cd4dded1622ef54..8a112061da7ee943f7a6d6ee4db22f02981e9fda 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2771,8 +2771,8 @@ void GenTransition_fixed( const int16_t element_mode, /* i : element mode */ const int16_t L_frame, /* i : ACELP frame length */ const int16_t rf_flag, /* i : RF flag */ - const int32_t total_brate /* i : total bitrate */ -); + const int32_t total_brate, /* i : total bitrate */ + const Word16 prev_Qx ); void GenTransition_WB( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 3caaf7c860619bd67a9b8c616d2f37a79506f478..7eeafc617435811e6f60ab5b8600326ac0519536 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -913,7 +913,7 @@ ivas_error ivas_core_dec_fx( test(); IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && ( EQ_16( st->last_extl, SWB_TBE ) || EQ_16( st->last_extl, FB_TBE ) ) ) { - GenTransition_fixed( st->hBWE_TD, hb_synth_32_fx[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate ); + GenTransition_fixed( st->hBWE_TD, hb_synth_32_fx[n], output_Fs, st->element_mode, st->L_frame, st->rf_flag, st->total_brate, st->prev_Qx ); } ELSE IF( EQ_16( st->bwidth, WB ) && EQ_16( st->last_extl, WB_TBE ) ) { @@ -1142,7 +1142,7 @@ ivas_error ivas_core_dec_fx( move16(); ivas_swb_tbe_dec_fx( st, hStereoICBWE, bwe_exc_extended_fx[n], st->Q_exc, voice_factors_fx[n], old_syn_12k8_16k_fx[n], tmp_buffer_fx /*fb_exc*/, hb_synth_32_fx[n], pitch_buf_fx[n], &Q_white_exc ); - + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->syn_overlap_fx, st->hBWE_TD->syn_overlap_fx_32, L_SHB_LAHEAD, sub( Q11, st->prev_Q_bwe_syn2 ) ); Copy_Scale_sig_32_16( st->hBWE_TD->old_tbe_synth_fx_32, st->hBWE_TD->old_tbe_synth_fx, L_SHB_TRANSITION_LENGTH, sub( st->prev_Qx, Q11 ) ); IF( GT_16( Q_white_exc, 31 ) ) @@ -1238,7 +1238,7 @@ ivas_error ivas_core_dec_fx( #endif Scale_sig( st->hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, -( Q8 - st->prev_Q_bwe_syn ) ); Scale_sig32( st->hBWE_TD->genSHBsynth_Hilbert_Mem_fx, HILBERT_MEM_SIZE, -( st->prev_Q_bwe_syn2 - Q11 ) ); - Copy_Scale_sig_16_32( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 2 * ALLPASSSECTIONS_STEEP, -( st->prev_Q_bwe_syn2 - Q11 ) ); + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 2 * ALLPASSSECTIONS_STEEP, -( st->prev_Q_bwe_syn2 - Q11 ) ); } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index e9669f4b00c928a7fd5040c3d8ea19e187ae767a..e6e65575522e10dd416583ce2964b11bacb1842d 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1057,21 +1057,23 @@ static void stereo_dft_generate_comfort_noise_fx( E0 = W_shl( E0, E0_e ); E0_e = add( sub( st->hFdCngDec->bandNoiseShape_exp, E0_e ), 32 ); E1_e = W_norm( E1 ); - E1 = W_shl( E0, E1_e ); + E1 = W_shl( E1, E1_e ); E1_e = sub( 63, add( E1_e, add( shl( q_cngNoiseLevel_upd, 1 ), 1 ) ) ); - tmp_16 = BASOP_Util_Divide3232_Scale( W_extract_h( E0 ), W_extract_h( E1 ), &q_div ); - q_div = add( q_div, sub( E0_e, E1_e ) ); - tmp_16 = Sqrt16( tmp_16, &q_div ); - IF( BASOP_Util_Cmp_Mant32Exp( tmp_16, add( 16, q_div ), MAX_32, 0 ) < 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( W_extract_h( E0 ), E0_e, W_extract_h( E1 ), E1_e ) < 0 ) { + tmp_16 = BASOP_Util_Divide3232_Scale( W_extract_h( E0 ), W_extract_h( E1 ), &q_div ); + q_div = add( q_div, sub( E0_e, E1_e ) ); + tmp_16 = Sqrt16( tmp_16, &q_div ); tmp_16 = shl( tmp_16, q_div ); hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) ); move16(); } ELSE { - tmp_16 = Inv16( tmp_16, &q_div ); + tmp_16 = BASOP_Util_Divide3232_Scale( W_extract_h( E1 ), W_extract_h( E0 ), &q_div ); + q_div = add( q_div, sub( E1_e, E0_e ) ); + tmp_16 = Sqrt16( tmp_16, &q_div ); tmp_16 = shl( tmp_16, q_div ); hStereoCng->xfade_length = sub( MAX_XFADE_FX, extract_l( L_shr( imult3216( MAX_XFADE_FX, tmp_16 ), Q15 ) ) ); move16(); diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index b238098997e621a6dc14319a992fc29b4926af57..e6e9482a65185f60f18bac1eb9cfc660ce604162 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -2660,7 +2660,7 @@ void ivas_swb_tbe_dec_fx( /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ GenSHBSynth_fx_32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); - + Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); /* resample SHB synthesis (if needed) and scale down */ @@ -4566,8 +4566,8 @@ void GenTransition_fixed( const Word16 element_mode, /* i : element mode */ const Word16 L_frame, /* i : ACELP frame length */ const Word16 rf_flag, /* i : RF flag */ - const Word32 total_brate /* i : total bitrate */ -) + const Word32 total_brate, /* i : total bitrate */ + const Word16 prev_Qx ) { Word16 i, length; @@ -4615,7 +4615,7 @@ void GenTransition_fixed( /* fill transition signal with mirrored HB synth from previous frame to fully fill delay alignment buffer gap */ FOR( ; i < length; i++ ) { - outputHB_fx[i] = hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i]; + outputHB_fx[i] = L_shl( hBWE_TD->old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH - 1 - i], sub( Q11, prev_Qx ) ); move32(); }