diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c00dd2b1203eee6c8e9801c05d3a0aadb..42b1f1b3daf82918abff7e2568a1888b02ea57d2 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( L_x >= 0x40000000 ); /* 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 cb66d2f1b67b70dd3d723a094f1fba13a15c69c3..3fb0d94b3d9595c1a9cccda4d9fafa05704c7392 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ #define FIX_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */ #define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */ +#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 ########################### */ 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 ) );