diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index cef466471db4f1d2d9602c057a0f60a77e888c45..1a5d0615fb8e60842886f9fb894263da641f775b 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1006,6 +1006,73 @@ Word32 div_w( Word32 L_num, Word32 L_den ) } } +#ifdef BASOP_DIVIDE3232_FHG +Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, Word32 y, Word16 *s, Word16 bits ) +{ + Word32 z; + Word16 sx; + Word16 sy; + Word32 sign; + Word16 iteration; + Flag Carry; + Word16 s_val; + + unset_carry( &Carry ); + + /* assert (x >= (Word32)0); */ + assert( y != (Word32) 0 ); + + IF( x == (Word32) 0 ) + { + *s = -31; + move16(); + return ( (Word32) 0 ); + } + + sign = L_shr( L_xor( x, y ), 31 ); + + sx = norm_l( x ); + x = L_shl( x, sx ); + x = L_shr( x, 1 ); + s_val = sub( 1, sx ); + if ( x < 0 ) + { + x = L_negate( x ); + } + + sy = norm_l( y ); + y = L_shl( y, sy ); + y = L_shr( y, 1 ); + s_val = add( s_val, sy ); + if ( y >= 0 ) + { + y = L_negate( y ); + } + + *s = s_val; + move16(); + + z = L_sub( x, x ); // z = 0 + + FOR( iteration = (Word16) 0; iteration < (Word16) bits; iteration++ ) + { + if ( L_add( x, y ) >= 0 ) + { + x = L_add_c( x, y, &Carry ); // sets always carry=1 + } + z = L_add_c( z, z, &Carry ); // sets always carry=0 + x = L_add( x, x ); + } + + if ( sign != 0 ) + { + z = L_negate( z ); + } + + return L_shl( z, sub( 31, bits ) ); +} +#endif + Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) { Word32 z; diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 92994542e564c3d6856f667be8e387e797c4071b..01ff60fa3420de0bfa344521cece10ec018d239c 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -328,6 +328,14 @@ Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ + +#ifdef BASOP_DIVIDE3232_FHG +Word32 BASOP_Util_Divide3232_Scale_FhG( Word32 x, /*!< i : Numerator*/ + Word32 y, /*!< i : Denominator*/ + Word16 *s, /*!< o : Additional scalefactor difference*/ + Word16 bits ); /*!< i : number of mantissa bits of result*/ +#endif + Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ diff --git a/lib_com/options.h b/lib_com/options.h index e58555dfea92d668b7bc416e514db5eb0a03bc2b..df90d441b8fe9dcd871035e64793543e52f534dd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_1009_OPT_PARAMMC_RENDER /* FhG: Optimize ivas_param_mc_dec_render_fx() */ #define FIX_1109_OPTIM_MCT_STEREO_IGF_DEC /* FhG: optimize mctStereoIGF_dec_fx() */ #define FIX_1110_OPTIM_DIRAC_DECORR_PROC /* FhG: optimize ivas_dirac_dec_decorr_process() */ +#define BASOP_DIVIDE3232_FHG /* FhG: scalable 32 by 32 division, use with 24 bit precision */ #define FIX_1127_IMPROVE_SBA_MLD /* Ittiam: Avoid saturation for DiRAC reference power */ #define FIX_1100_REMOVE_LPC_RESCALING /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/ #define FIX_1133_IMPROVE_MC_MLD /* Ittiam: Correcting wrong updation of exponents in ivas_mc_paramupmix_param_est_enc_fx() */