Commit 8280bc66 authored by multrus's avatar multrus
Browse files

Merge branch...

Merge branch '1836-replace-overflow-basop-operators-by-overflow-free-variants-in-lib_com' into 'main'

Resolve "Replace Overflow BASOP-Operators by overflow-free variants in lib_com"

Closes #1836

See merge request !2103
parents 690df7cd ad3f9caa
Loading
Loading
Loading
Loading
Loading
+247 −247

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8

    /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */
#ifdef ISSUE_1836_replace_overflow_libcom
    len = mult_r( add_sat( pitch[2], pitch[3] ), 256 ); //??sat
    len = mult_r( add_sat( pitch[2], pitch[3] ), 256 );
#else
    len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 );
#endif
@@ -285,13 +285,13 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8
    /*add ld(2^exp1)=exp1 but check format, first*/
    tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/
#ifdef ISSUE_1836_replace_overflow_libcom
    Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ //??sat
    Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/
#else
    Ltmp = L_shr_o( Ltmp, tmp16, &Overflow );                               /*Q25, tmp16*/
#endif
    exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/
#ifdef ISSUE_1836_replace_overflow_libcom
    Ltmp = L_add_sat( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ) ); /*Q25, tmp16, normalized*/ //??sat
    Ltmp = L_add_sat( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ) ); /*Q25, tmp16, normalized*/
#else
    Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow );    /*Q25, tmp16, normalized*/
#endif
@@ -299,9 +299,9 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8
    /*make 10*log10 out of log2*/
    Ltmp = Mpy_32_16_1( Ltmp, LG10 ); /*Q25,tmp16 * Q13 = Q23, tmp16*/
#ifdef ISSUE_1836_replace_overflow_libcom
    *frame_ener = extract_h( L_shl_sat( Ltmp, add( tmp16, 1 ) ) ); /*Q8*/ //??sat
    *frame_ener = extract_h( L_shl_sat( Ltmp, add( tmp16, 1 ) ) ); /*Q8*/
    move16();
    enern = sub_sat( *frame_ener, lp_speech ); /*Q8*/ //??sat
    enern = sub_sat( *frame_ener, lp_speech ); /*Q8*/
#else
    *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/
    move16();
+3 −3
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed)
    tener = Dot_productSq16HQ( 0, y, n, &exp_e );

#ifdef ISSUE_1836_replace_overflow_libcom
    BASOP_Util_Divide_MantExp( round_fx_sat( tcorr ), exp_c, s_max( round_fx_sat( tener ), 1 ), exp_e, &tmp, &exp ); //??sat
    BASOP_Util_Divide_MantExp( round_fx_sat( tcorr ), exp_c, s_max( round_fx_sat( tener ), 1 ), exp_e, &tmp, &exp );
    Lgain = L_shl_sat( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ) ) /*Q16*/; //?sat
#else
    BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp );
@@ -140,7 +140,7 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)
    Q_corr = sub( Q_corr, Q_ener );

#ifdef ISSUE_1836_replace_overflow_libcom
    Lgain = L_shl_sat( L_deposit_l( m_corr ), add( Q_corr, 1 ) ); /* Lgain in Q16 */ //??sat
    Lgain = L_shl_sat( L_deposit_l( m_corr ), add( Q_corr, 1 ) ); /* Lgain in Q16 */
#else
    Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */
#endif
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ void bands_and_bit_alloc_fx(

    /* To adapt current energy band to PVQ freq band for sorting*/
#ifdef ISSUE_1836_replace_overflow_libcom
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ //??sat
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */
#else
    ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */
#endif
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ void bands_and_bit_alloc_ivas_fx(

    /* To adapt current energy band to PVQ freq band for sorting*/
#ifdef ISSUE_1836_replace_overflow_libcom
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ //??sat
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */
#else
    ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */
#endif
Loading