From 9033c999ef57a067248fee4386c054d3090524c4 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Fri, 16 Jun 2023 11:02:21 +0200 Subject: [PATCH] fix #563, ILD limiter overshoot when coming from silence w/o a transient frame being detected, fix combining of cov matrices in the encoder in transient frames --- lib_com/ivas_cnst.h | 3 +++ lib_com/options.h | 1 + lib_enc/ivas_mc_param_enc.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a4b7e1c5d5..1a44c0f6b8 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1420,6 +1420,9 @@ typedef enum #define PARAM_MC_MAX_BAND_ABS_COV_DEC 10 #define PARAM_MC_ENER_LIMIT_INTRAFRAME (1.5f) #define PARAM_MC_ENER_LIMIT_INTERFRAME (2.0f) +#ifdef FIX_563_PARAMMC_LIMITER +#define PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC (15.0f) +#endif #define PARAM_MC_LFE_ON_THRESH (8000.0f) #define PARAM_MC_BAND_TO_MDCT_BAND_RATIO 16 /* Ratio of resolution of CLDFB Bands to MDCT Bands */ #define PARAM_MC_SLOT_ENC_NS 2500000L diff --git a/lib_com/options.h b/lib_com/options.h index 58c62593b3..ea2d08e7e5 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_547_NAN_IGF_DEC /* FhG: issue 547: fix possible nan in IGF decoder */ #define FIX_529_BWD_ISSUE /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */ +#define FIX_563_PARAMMC_LIMITER /* FhG: issue 563: fix ILD limiter when coming from silence w/o transient set */ #define IGF_TUNING_96 /* FhG: Issue 546: slight tuning of IGF config used in 96 kbps stereo, 128 kbps SBA and others */ diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index 9a82da9a27..715d3fe248 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -856,7 +856,11 @@ static void ivas_param_mc_param_est_enc( for ( ; cur_param_band < num_parameter_bands; cur_param_band += 2 ) { +#ifdef FIX_563_PARAMMC_LIMITER + if ( cur_param_band < num_parameter_bands ) +#else if ( cur_param_band + 1 < num_parameter_bands ) +#endif { for ( ch_idx1 = 0; ch_idx1 < nchan_transport; ++ch_idx1 ) { @@ -1252,7 +1256,11 @@ static void ivas_param_mc_quantize_ilds( ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); delta_fac = ener_fac - hParamMC->ener_fac[freq_idx]; +#ifdef FIX_563_PARAMMC_LIMITER + if ( !hParamMC->hMetadataPMC.bAttackPresent && ( delta_fac > PARAM_MC_ENER_LIMIT_INTERFRAME ) && ( delta_fac < PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC ) ) +#else if ( !hParamMC->hMetadataPMC.bAttackPresent && ( delta_fac > PARAM_MC_ENER_LIMIT_INTERFRAME ) ) +#endif { float limit_fac; limit_fac = powf( 10.0f, ( ( 0.3f * logf( delta_fac - PARAM_MC_ENER_LIMIT_INTERFRAME + 1.0f ) - ( delta_fac - PARAM_MC_ENER_LIMIT_INTERFRAME ) ) / 10.0f ) ); @@ -1261,6 +1269,13 @@ static void ivas_param_mc_quantize_ilds( } hParamMC->ener_fac[freq_idx] = ener_fac; +#ifdef FIX_563_PARAMMC_LIMITER + /* update also combined bands ener_fac when in transient frame */ + if ( hParamMC->hMetadataPMC.bAttackPresent && ( ( freq_idx + 1 ) < hParamMC->hMetadataPMC.nbands_coded ) ) + { + hParamMC->ener_fac[freq_idx + 1] = ener_fac; + } +#endif for ( k = 0; k < num_ilds_to_code; ++k ) { -- GitLab