Commit ab426b4a authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fix BASOP issue 2640 by saturating the shifts on extreme cases.

parent c88b5452
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@
#define FIX_FLOAT_1600_OMASA_WRONG_RENDER_PATH          /* Nokia: float issue 1600: fix initialization condition of stereo type detection for OMASA */
#define FIX_BASOP_1765_MASA1TC_CNG_MISMATCH             /* Nokia: BASOP issue 1765: Improve accuracy of FD CNG noise estimation */
#define FIX_BASOP_2627_PARAM_MC_ILD_REMAP_EXP           /* FhG: BASOP #2627: accumulate 10^(ILD/10) using a dynamic exponent */
#define FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT          /* Nokia: BASOP issue 2640: Fix assert by saturating shift when exponent difference is very large. */

/* ##################### End NON-BE switches ########################### */

+8 −0
Original line number Diff line number Diff line
@@ -2063,13 +2063,21 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
            subtract_target_ratio = L_sub( BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ),
                                           BASOP_Util_Log2( masa_stereo_type_detect->target_power_y_smooth_fx ) ); // Q25
            exp = sub( masa_stereo_type_detect->q_subtract_power_y_smooth, masa_stereo_type_detect->q_target_power_y_smooth );
#ifdef FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT
            L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl_sat( exp, 25 ) ), LOG10_2_Q31 ); // Q25
#else
            L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ); // Q25
#endif
        }
        ELSE
        {
            subtract_target_ratio = BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ); // Q25
            exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y_smooth );
#ifdef FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT
            L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl_sat( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25
#else
            L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25
#endif
        }
        subtract_target_ratio_db = Mpy_32_32( 1342177280 /* 10.0f * in Q27*/, L_tmp ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21