diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index b45b78ad18430f32bf1f29e162d51e7e7142a381..5afceff55e25ce86ed5b7042e6e4d5f2379bdc99 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -1563,9 +1563,12 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( move16(); Word32 y = concealment_noise[l]; // concealment_noise_e move32(); - last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld - y = L_negate( Mpy_32_32( y, y ) ); // Q31-2* concealment_noise_e - hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, 2 * concealment_noise_e, &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp + shift1 = norm_l( y ); + y = L_shl( y, shift1 ); + + last_block_nrg_correct = L_add( last_block_nrg_correct, Mpy_32_16_1( L_msu( 0, x, fac ), x ) ); // exp = 2 * x_exp + ld + y = L_negate( Mpy_32_32( y, y ) ); // Q31-(2* concealment_noise_e + shift1) + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, y, shl( sub( concealment_noise_e, shift1 ), 1 ), &hTonalMDCTConc->curr_noise_nrg_exp ); // Q31- hTonalMDCTConc->curr_noise_nrg_exp move32(); } } @@ -1631,29 +1634,9 @@ void TonalMDCTConceal_InsertNoise_ivas_fx( /* actual fadeout is done in this case */ ELSE { - Word32 num, den; - Word16 exp_num, exp_den; - - exp_num = cngLevelBackgroundTrace_bfi_e; - move16(); - exp_den = hTonalMDCTConc->curr_noise_nrg_exp; - move16(); + tmp = BASOP_Util_Divide3232_Scale( cngLevelBackgroundTrace_bfi, hTonalMDCTConc->curr_noise_nrg, &exp ); + exp = add( exp, sub( cngLevelBackgroundTrace_bfi_e, hTonalMDCTConc->curr_noise_nrg_exp ) ); - ld = norm_l( cngLevelBackgroundTrace_bfi ); - num = L_shl( cngLevelBackgroundTrace_bfi, ld ); // Q15 - exp_num + ld - exp_num = sub( exp_num, ld ); - ld = norm_l( hTonalMDCTConc->curr_noise_nrg ); - den = L_shl( hTonalMDCTConc->curr_noise_nrg, ld ); // Q15 - exp_den + ld - exp_den = sub( exp_den, ld ); - - exp = sub( exp_num, exp_den ); - - IF( GT_32( num, den ) ) - { - num = L_shr( num, 1 ); // Q31- exp -1 - exp = add( exp, 1 ); - } - tmp = div_l( num, round_fx( den ) ); tmp = Sqrt16( tmp, &exp ); g = mult_r( g, tmp ); // exponent of g = exp diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 22eacdb32b9eab6291c8a29388e2a20ca12a0cc1..0c996b25a1355a5bb6a73ca6f5559d0a11b0fbce 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -1613,9 +1613,22 @@ static void ivas_param_mc_quantize_ilds_fx( { dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, Cx_fx[k][k], Cx_e[k][k], &dmx_ener_e ); } + /* ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); */ + IF( tot_ener_fx == 0 ) + { + tot_ener_fx = 9223; // 1e-15(EPSILON) in Q63 + tot_ener_e = -32; + move32(); + move16(); + } + IF( dmx_ener_fx == 0 ) + { + dmx_ener_fx = 9223; // 1e-15(EPSILON) in Q63 + dmx_ener_e = -32; + move32(); + move16(); + } - tot_ener_fx = BASOP_Util_Add_Mant32Exp( tot_ener_fx, tot_ener_e, EPSILON_FX, 0, &tot_ener_e ); - dmx_ener_fx = BASOP_Util_Add_Mant32Exp( dmx_ener_fx, dmx_ener_e, EPSILON_FX, 0, &dmx_ener_e ); L_tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tot_ener_fx, dmx_ener_fx, &tmp_e ) ); tmp_e = add( sub( tot_ener_e, dmx_ener_e ), tmp_e ); ener_fac_fx = BASOP_Util_Log10( L_tmp, tmp_e ); // Q25 diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 9212e3d235c09646fabc37080558851d6201c17f..622ebf89a5870bba79198fdd5f6c3aebf723be70 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4016,10 +4016,11 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { + Flag overFlow; lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shl_r( lfeGain_fx, lfeGain_fx_exp ); // Q15 + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) {