Commit 799175a9 authored by vaillancour's avatar vaillancour
Browse files

fix possible ovf

parent 7901bdd1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -101,4 +101,7 @@
#define TEST_HR
#define REMOVE_EVS_DUPLICATES                   /* remove core-coder duplicated functions, ACELP low-band decoder */

#define FIX_OVERFLOW           /* Decoder possible overflow */
#define FIX_OVERFLOW_ENC           /* Encoder possible overflow */

#endif
+5 −1
Original line number Diff line number Diff line
@@ -5220,7 +5220,11 @@ void decoder_tcx_imdct_fx(

    FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ )
    {
#ifdef FIX_OVERFLOW
        xn_bufFB_fx_16[ind] = extract_h( L_shl_sat( xn_bufFB_fx[ind], sub( 16, shift_q ) ) );   // q_x
#else
        xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) );                  // q_x
#endif
        move16();
    }

+4 −0
Original line number Diff line number Diff line
@@ -3810,7 +3810,11 @@ static void stereo_dft_adapt_sf_delay_fx(
    }

    /* Adapt the stereo filling delay by interpolating between two delay taps, one at the shortest delay and one at the longest delay */
#ifdef FIX_OVERFLOW
    hStereoDft->stefi_short_gain_fx = extract_h( L_shl_sat( L_sub( L_shl( STEREO_DFT_STEFFI_DELAY_LONG, Q15 ), target_delay ), 16 - 1 ) ); /* Q15 */
#else
    hStereoDft->stefi_short_gain_fx = extract_l( L_shr( L_sub( L_shl( STEREO_DFT_STEFFI_DELAY_LONG, Q15 ), target_delay ), 1 ) ); /* Q15 */
#endif
    q_sqrt = 0;
    move16();
    IF( EQ_16( hStereoDft->stefi_short_gain_fx, MIN_16 ) )
+7 −2
Original line number Diff line number Diff line
@@ -396,12 +396,17 @@ void bw_detect_fx(
            move16();
            cldfb_ener_offset_32 = L_deposit_l( cldfb_ener_offset );       /* Q14 in 32bit var */
            cldfb_ener_offset_32 = L_shl( cldfb_ener_offset_32, 25 - 14 ); /* Q14 -> Q25 */

#ifdef FIX_OVERFLOW_ENC
            mean_NB = extract_h( L_shl_sat( L_add( mean_NB32, cldfb_ener_offset_32 ), 16 - ( 25 - 11 ) ) ); /* (Q25 + Q25) -> Q11 */
            max_NB = extract_h( L_shl_sat( L_add( max_NB32, cldfb_ener_offset_32 ), 16 - ( 25 - 11 ) ) );   /* (Q25 + Q25) -> Q11 */
            mean_WB = extract_h( L_shl_sat( L_add( mean_WB32, cldfb_ener_offset_32 ), 16 - ( 25 - 11 ) ) ); /* (Q25 + Q25) -> Q11 */
            max_WB = extract_h( L_shl_sat( L_add( max_WB32, cldfb_ener_offset_32 ), 16 - ( 25 - 11 ) ) );   /* (Q25 + Q25) -> Q11 */
#else
            mean_NB = extract_l( L_shr( L_add( mean_NB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */
            max_NB = extract_l( L_shr( L_add( max_NB32, cldfb_ener_offset_32 ), 25 - 11 ) );   /* (Q25 + Q25) -> Q11 */
            mean_WB = extract_l( L_shr( L_add( mean_WB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */
            max_WB = extract_l( L_shr( L_add( max_WB32, cldfb_ener_offset_32 ), 25 - 11 ) );   /* (Q25 + Q25) -> Q11 */

#endif

            /*if WB */
            IF( EQ_32( st->input_Fs, 16000 ) )
+4 −0
Original line number Diff line number Diff line
@@ -411,7 +411,11 @@ void acelp_fast_fx(
        {
            s64 = W_mac0_16_16( s64, H[j], H[j - i] ); /* Q = shift + 6*/
        }
#ifdef FIX_OVERFLOW_ENC
        *alp = extract_h( W_sat_l( W_shr( s64, sub( 16, shift ) ) ) ); /*Q6*/
#else
        *alp = extract_l( W_extract_l( W_shr( s64, shift ) ) ); /*Q6*/
#endif
        move16();
        alp_buf[L_subfr - i] = *alp++; /*Q6*/
        move16();
Loading