diff --git a/lib_com/options.h b/lib_com/options.h index c214af0ca9026c4b36299e06aa742c3d55f09617..ec5b35f4628187c27bea3f812638916323db1714 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -68,6 +68,7 @@ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif +#define FIX_732_MS_PERIODOG_FLOOR /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */ #define FIX_867_CLDFB_NRG_SCALE diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 1d8185601ba218240914687524c94644bfb6c305..adf838f42066905f3d6054ba5f55b036807a91c9 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1500,6 +1500,9 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; +#ifdef FIX_732_MS_PERIODOG_FLOOR + Word32 msPeriodog_floor; +#endif Word32 *msNoiseEst; Word32 *reIter; Word32 rescale_fac = 0; @@ -1508,6 +1511,10 @@ void perform_noise_estimation_dec_ivas_fx( Word16 q_shift; Word32 max_l; Word16 norm_shift; +#ifdef FIX_732_MS_PERIODOG_FLOOR + Word16 check = 0; + move16(); +#endif /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -1706,12 +1713,38 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); +#ifdef FIX_732_MS_PERIODOG_FLOOR + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/ + IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) +#else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) +#endif { +#ifdef FIX_732_MS_PERIODOG_FLOOR + msPeriodog[p] = msPeriodog_floor; + move32(); +#else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); +#endif } } +#ifdef FIX_732_MS_PERIODOG_FLOOR + FOR( p = 0; p < npart; p++ ) + { + IF( GT_32( msPeriodog[p], 1 ) ) + { + check = 1; + move16(); + BREAK; + } + } + IF( check == 0 ) + { + hFdCngDec->msPeriodog_exp = 14; /* msPeriodog buffer will have minimum value as 1e-5f */ + move16(); + } +#endif } /* calculate total energy (short-term and long-term) */