Commit 47f4992d authored by Manuel Jander's avatar Manuel Jander
Browse files

Add fix proposal for extract_l() overflow in estDownmixGain_fx().

parent add528fa
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@
#define FIX_2479_HARM_PITCH_GAIN                        /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */
#define HARMONIZE_2481_EXTEND_SHRINK                    /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */
#define FIX_2493_CHECK_EXTRACT_L                        /* FhG: Verify that extract_l, W_extract_l etc. do not encounter an overflow. */
#define NONBE_FIX_2493_CHECK_EXTRACT_L_estDownmixGain_fx /* FhG: Fix extract_l overflow inside estDownmixGain_fx() */

/* #################### End BE switches ################################## */

+8 −0
Original line number Diff line number Diff line
@@ -1320,6 +1320,13 @@ static void estDownmixGain_fx(
    currentGain_log10 = BASOP_Util_Log10( L_deposit_h( currentGain ), currentGain_e ); // Output in Q25
    // multiplication result will be Q25 should be fit to Q15 hence right shift by 10.
    // Q25 - Q10 = Q15
#ifdef NONBE_FIX_2493_CHECK_EXTRACT_L_estDownmixGain_fx
    Word32 temp32;
    temp32 = L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 );
    currentGain_e = sub( norm_l( temp32 ), 1 );
    currentGain = round_fx( L_shl( temp32, currentGain_e ) );
    currentGain_e = sub( 16, currentGain_e );
#else
#ifdef FIX_2493_CHECK_EXTRACT_L
    currentGain = extract_l2( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) ); /* Q15 */
#else
@@ -1327,6 +1334,7 @@ static void estDownmixGain_fx(
#endif
    currentGain_e = 0;
    move16();
#endif

    test();
    IF( EQ_16( element_mode, IVAS_CPE_TD ) && hStereoClassif != NULL )