diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c00dd2b1203eee6c8e9801c05d3a0aadb..a96fe62366c4479ecc2b6805e666fd6f4db4b456 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,10 +57,15 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; - +#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); +#else + if ( L_x > 0 ) /* There are many cases in the code where L_x == 0 */ + assert( 0 ); /* If assert fail, means input is not normalized as it should be */ + L_x = L_max( L_x, 0x40000000 ); +#endif L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index e9b94dbadab05e6867f7e01f0d4f17b0d0f7d937..2b9461b2c841cc66f08fb2a0e7fd7139a4a74be4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define FIX_2015_PREMPH_SAT_ALT_PART2 /* VA: Add missing scaling factor to be passed to AVQ_cod() */ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ - +#define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a966f70cc61a085e6badc5da51a6e3695af3eccf..ffdb1d454df4797d99cf2995e24cfa0ad814d1bd 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,6 +1125,9 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } +#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + exp = norm_l( CldfbHB_fx ); +#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) );