diff --git a/lib_com/options.h b/lib_com/options.h index 3e11805fcc15d132eae7fadd29420369ba9e6ad5..830289a97bd2621d269c4977d31f0790b1482dd7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,6 +81,7 @@ #define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */ #define FIX_1978_SAT_MISSING_IN_GAIN_ENC /* VA: Fix add saturation missing that lead to a crash in P800-10 */ +#define FIX_1981_MAXIMUM_EXP_FX /* FhG: Fix bug in function to find maximum value in vector */ #define FIX_1979_SAT_MISSING_IN_LSF_ENC /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */ #define FIX_1946_CRASH_JBM_PROCESSING /* FhG: Increased guard bits of DFT_fx */ diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index f175f14b644b782859475161298002d10f123d95..4dd405b248a1d36317932b40d64437997ca3c1fb 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1219,6 +1219,26 @@ Word16 maximum_exp_fx( /* o : index of the maximum value const Word16 *exp_vec, /* i : exponents of input vector */ const Word16 lvec_fx /* i : length of input vector */ ) +#ifdef FIX_1981_MAXIMUM_EXP_FX +{ + Word16 j, ind; + ind = 0; + move16(); + + FOR( j = 1; j < lvec_fx; j++ ) + { + /* if(vec[j] > vec[ind]) //means */ + /* if( GT_32( L_shr_sat( L_deposit_l( vec_fx[j])), sub( exp_vec[ind], exp_vec[j] ) , L_deposit_l( vec_fx[ind] ))) //is like */ + if ( L_mac0_sat( L_shl_sat( L_deposit_l( vec_fx[j] ), sub( exp_vec[j], exp_vec[ind] ) ), vec_fx[ind], -0x0001 ) > 0 ) + { + ind = j; + move16(); + } + } + + return ind; +} +#else { Word16 j, ind; Word16 tmp, exp; @@ -1244,6 +1264,7 @@ Word16 maximum_exp_fx( /* o : index of the maximum value return ind; } +#endif /*---------------------------------------------------------------------* * maximum_abs_16_fx()