From 3445a9e81c71a9a56ef05def3d2c845fe4f9678d Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 25 Jan 2024 13:23:02 +0100 Subject: [PATCH 1/3] prevent ratio from being < 1.0 to avoid log2(<1.0) --- lib_com/options.h | 1 + lib_enc/swb_tbe_enc.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 820383e905..03f27097df 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,6 +176,7 @@ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define NONBE_FIX_949_MC_5MS_FRAMING /* Dlb: issue 949: fix for issue 949, distorted output in MC mode with 5ms framing*/ #define NONBE_FIX_952_MC_PARAMUPMIX_5MS /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/ +#define NONBE_FIX_971_LOG2_IDX_GAIN_0 /* VA: prevent -Inf due to log2(ratio==0) */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 135e856a99..5e353cc4f7 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -2738,6 +2738,12 @@ void fb_tbe_enc( hBWE_TD->prev_fb_energy = sum2_f( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON; ratio = (float) sqrt( temp2 / fb_exc_energy ); +#ifdef NONBE_FIX_971_LOG2_IDX_GAIN_0 + if (ratio < 1.0f) + { + ratio = 1.0f; + } +#endif idxGain = (int16_t) ( log2_f( (float) ratio ) + 0.5f ); idxGain = max( 0, min( 15, idxGain ) ); ratio = (float) ( 1 << idxGain ); -- GitLab From 6873f1ab256bfe65631f5849719b3b0d6f10b48a Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Thu, 25 Jan 2024 14:44:23 +0100 Subject: [PATCH 2/3] clang format --- lib_enc/swb_tbe_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 5e353cc4f7..277443dd61 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -2739,7 +2739,7 @@ void fb_tbe_enc( fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON; ratio = (float) sqrt( temp2 / fb_exc_energy ); #ifdef NONBE_FIX_971_LOG2_IDX_GAIN_0 - if (ratio < 1.0f) + if ( ratio < 1.0f ) { ratio = 1.0f; } -- GitLab From 8e1fd10b0a1a6456b2c80c73d8efdb42b79f104a Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 30 Jan 2024 08:45:10 +0100 Subject: [PATCH 3/3] rename to a BE switch --- lib_com/options.h | 2 +- lib_enc/swb_tbe_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a5793344bb..f8ffc2dad4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural reverb*/ #define FIX_20_MS_FRAME_LEN_TABLES_CONVERTER /* Orange : generate_tables_converter tools can generate rom for 5 and 20 ms frame length */ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ +#define FIX_971_LOG2_IDX_GAIN_0 /* VA: prevent -Inf due to log2(ratio==0) */ /* #################### End BE switches ################################## */ @@ -170,7 +171,6 @@ #define NONBE_FIX_967_ISM_MONO_DMX /* FhG: issue 967: accumulating energies in ISM mono DMX */ #define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/ #define NONBE_FIX_977_OSBA_GAIN_MISMATCH /* Dlb : issue 977 : Output gain mismatch for different bit rates in OSBA */ -#define NONBE_FIX_971_LOG2_IDX_GAIN_0 /* VA: prevent -Inf due to log2(ratio==0) */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 277443dd61..9fab9da438 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -2738,7 +2738,7 @@ void fb_tbe_enc( hBWE_TD->prev_fb_energy = sum2_f( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON; ratio = (float) sqrt( temp2 / fb_exc_energy ); -#ifdef NONBE_FIX_971_LOG2_IDX_GAIN_0 +#ifdef FIX_971_LOG2_IDX_GAIN_0 if ( ratio < 1.0f ) { ratio = 1.0f; -- GitLab