Commit 7008e8f9 authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

Using rounding in multiplication to improve precision in cngNoiseLevel[]

parent bb36f0c1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@


#define NONBE_FIX_ISSUE_2232_CHECK_CLDFB_STATES             /* FhG: Adjust scaleFactor according to st->cldfbSyn->cldfb_state_fx too to avoid overflow in cldfbSynthesis_ivas_fx() */

#define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES          /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */
/* ################### End FIXES switches ########################### */

/* #################### Start BASOP porting switches ############################ */
+26 −6
Original line number Diff line number Diff line
@@ -1092,7 +1092,11 @@ Word16 ApplyFdCng_fx(
                        s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) );
                        FOR( ; j <= hFdCngCom->part[k]; j++ )
                        {
#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#else
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s );                                            /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#endif
                            move32();
                        }
                    }
@@ -1182,7 +1186,11 @@ Word16 ApplyFdCng_fx(
                        s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) );
                        FOR( ; j <= hFdCngCom->part[k]; j++ )
                        {
#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_r( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#else
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s );                                            /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#endif
                            move32();
                        }
                    }
@@ -1793,7 +1801,11 @@ void perform_noise_estimation_dec_ivas_fx(
                    FOR( p = 0; p < npart; p++ )
                    {
                        temp = L_shl( msPeriodog[p], q_shift );
#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
                        msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
#else
                        msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], sub( MAX_16, alpha ) ), temp, alpha );                                        /*Q31 - hFdCngDec->msNoiseEst_exp*/
#endif
                        move32();
                    }
                }
@@ -1871,7 +1883,11 @@ void perform_noise_estimation_dec_ivas_fx(
                        L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) );
                        IF( LT_32( L_tmp, msNoiseEst[p] ) )
                        {
#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
                            msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/
#else
                            msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], wght ), L_tmp, (Word16) L_sub( shr( MAX_16, sub( 15, scale ) ), wght ) ); /*temp_q_msNoiseEst[p]*/
#endif
                            move32();
                            temp_q_msNoiseEst[p] = sub( add( hFdCngDec->msNoiseEst_exp, scale ), 15 );
                            move16();
@@ -1894,7 +1910,11 @@ void perform_noise_estimation_dec_ivas_fx(
                        L_tmp = L_shr_sat( hFdCngDec->msPeriodog_ST_fx[p], sub( hFdCngDec->msNoiseEst_exp, hFdCngDec->msPeriodog_ST_exp ) ); /*Q31 - hFdCngDec->msPeriodog_ST_exp*/
                        IF( LT_32( L_tmp, msNoiseEst[p] ) )
                        {
#ifdef FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES
                            msNoiseEst[p] = Madd_32_16( Mpy_32_16_r( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 ); /*Q31 - hFdCngDec->msNoiseEst_exp*/
#else
                            msNoiseEst[p] = Madd_32_16( Mpy_32_16_1( msNoiseEst[p], CNA_ACT_DN_FACT_Q15 ), L_tmp, ONE_IN_Q15 - CNA_ACT_DN_FACT_Q15 );         /*Q31 - hFdCngDec->msNoiseEst_exp*/
#endif
                            move32();
                        }
                    }