Commit 76f26117 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '1751-replace-shl_ro-by-overflow-free-alternatives' into 'main'

Resolve "Replace shl_ro by overflow-free alternatives"

Closes #1751

See merge request !1801
parents f0ed36cc e4f9d88c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -99,5 +99,6 @@
#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE                    /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */

#define FIX_1762_COMPILER_ISSUE                 /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */
#define ISSUE_1751_replace_shl_ro               /*FhG: replace shl_ro by overflow-free alternatives*/

#endif
+9 −4
Original line number Diff line number Diff line
@@ -106,10 +106,6 @@ ivas_error decod_gen_voic_fx(
    gain_inov_fx = 0;
    error_fx = 0;
    gain_preQ_fx = 0;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
    move16();
    move32();
    move32();
@@ -467,11 +463,20 @@ ivas_error decod_gen_voic_fx(
        test();
        test();
        test();
#ifdef ISSUE_1751_replace_shl_ro
        IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) &&       /*compare with 0.25 in Q15*/
            LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) &&      /*compare with 15.0 in Q10*/
            GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/
            LT_16( st_fx->bfi_pitch_fx, 9600 ) &&                             /*Q6*/
            LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) )                /*Q6*/
#else
        Flag Overflow;
        IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) &&       /*compare with 0.25 in Q15*/
            LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) &&      /*compare with 15.0 in Q10*/
            GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/
            LT_16( st_fx->bfi_pitch_fx, 9600 ) &&                                     /*Q6*/
            LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) )                        /*Q6*/
#endif
        {
            IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) )
            {
+5 −1
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal,

    IF( sqrtXY != 0 )
    {
        Flag Overflow = 0;
        move32();
        normCC = 0;
        move16();
@@ -136,7 +135,12 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal,
        normCC = add( normCC, 16 );
        /* scale to Q15 with saturation */
        BASOP_SATURATE_WARNING_OFF
#ifdef ISSUE_1751_replace_shl_ro
        cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) );
#else
        Flag Overflow;
        cc = shl_ro( cc, add( normXY, normCC ), &Overflow );
#endif
        BASOP_SATURATE_WARNING_ON
        *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY );
    }
+14 −6
Original line number Diff line number Diff line
@@ -4258,11 +4258,15 @@ void ivas_lfe_synth_with_filters_fx(
        }
        ELSE
        {
            Flag overFlow;
            lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/
            lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp );
            lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp
            lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15
#ifdef ISSUE_1751_replace_shl_ro
            lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15
#else
            Flag Overflow;
            lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &Overflow ); // Q15
#endif
        }
        IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) )
        {
@@ -4271,11 +4275,15 @@ void ivas_lfe_synth_with_filters_fx(
        }
        ELSE
        {
            Flag overFlow;
            transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/
            transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp );
            transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp
            transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &overFlow ); // Q15
#ifdef ISSUE_1751_replace_shl_ro
            transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15
#else
            Flag Overflow;
            transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &Overflow ); // Q15
#endif
        }
        j = 0;
        move16();