From dd7e30dc7994ac38b26bdb7d14c879d6555edb0d Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 18 Jun 2024 17:12:48 +0200 Subject: [PATCH 1/2] prevent R[0] from being zero --- lib_com/options.h | 1 + lib_enc/swb_tbe_enc.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cdff54f506..10de6b53cc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,7 @@ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ #define REVERT_ZERO_FLUSH_TRESH /* FhG: issue 1069: revert threshold value introduced with !1518 due to significant complexity increase*/ #define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ +#define NONBE_FIX_1130_DIV_ZERO_LEV_DUR /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 758fa4fe76..9df90fa119 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -280,6 +280,15 @@ void wb_tbe_enc( } autocorr( hb_old_speech, R, LPC_SHB_ORDER_WB + 1, ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16, win_lpc_hb_wb, 0, 1, 1 ); + +#ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR + if ( st->element_mode > EVS_MONO ) + { + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + R[0] = max( R[0], 1.0e-8f ); + } +#endif + lev_dur( lpc_wb_temp, R, LPC_SHB_ORDER_WB, ervec_temp ); a2lsp( lsp_wb_temp, lpc_wb_temp, LPC_SHB_ORDER_WB ); lsp_spacing = 0.5f; @@ -638,7 +647,7 @@ void swb_tbe_enc( mvr2r( shb_old_speech + L_FRAME16k, hBWE_TD->old_speech_shb, delay ); autocorr( shb_old_speech, R, LPC_SHB_ORDER + 1, NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k + L_FRAME16k, win_lpc_shb, 0, 1, 1 ); - + /* Spectral smoothing of autocorrelation coefficients */ if ( st->rf_mode || st->extl_brate == SWB_TBE_0k95 || st->extl_brate == SWB_TBE_1k10 ) { -- GitLab From a240b368ffa1189de2cb77cac90d88e9d2015818 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 18 Jun 2024 17:22:54 +0200 Subject: [PATCH 2/2] clang format --- lib_enc/swb_tbe_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 9df90fa119..1cf69fab8a 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -284,7 +284,7 @@ void wb_tbe_enc( #ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR if ( st->element_mode > EVS_MONO ) { - /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ R[0] = max( R[0], 1.0e-8f ); } #endif @@ -647,7 +647,7 @@ void swb_tbe_enc( mvr2r( shb_old_speech + L_FRAME16k, hBWE_TD->old_speech_shb, delay ); autocorr( shb_old_speech, R, LPC_SHB_ORDER + 1, NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k + L_FRAME16k, win_lpc_shb, 0, 1, 1 ); - + /* Spectral smoothing of autocorrelation coefficients */ if ( st->rf_mode || st->extl_brate == SWB_TBE_0k95 || st->extl_brate == SWB_TBE_1k10 ) { -- GitLab