diff --git a/lib_com/options.h b/lib_com/options.h index 458b1690dfbcfe18424b460508ce4ba05964da68..fe5c38761de177cd18f035750d67843b426e97cd 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,7 @@ #define NONBE_FIX_1056_ISM_RATE_SWITCH /* FhG: Fix #1056: fix TC buffer udpate on a ISM rate switch */ #define NONBE_FIX_1075 /* FhG: fix segfault for bitrate switching + BINAURAL_ROOM_REVERB output in MC */ #define NON_BE_FIX_1041_USE_OLD_CNG_LSPS_IF_NONSTAB /* FhG: fix bug in TD MDCT-Stereo concealment */ - +#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index e0c599e235c098b8275f8bd8bcda333a9c2bb884..1b5b46d66e167a2729c068a6f16788938c4e82b8 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -916,7 +916,7 @@ void concealment_decode_fix( Word16 i; Word16 N = hPlcInfo->L_frameTCX; Word16 *seed = &( hPlcInfo->seed ); - Word16 sign; + Word16 sign = 0; move16(); IF( hPlcInfo->concealment_method == TCX_NONTONAL ) /* #define TCX_NONTONAL 0 */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 44434f78f6e060b8590e40f47e6f02c4de0ea724..373f4287ba0a60d36a6fe9615f63afe4970d228b 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -973,7 +973,10 @@ void stereo_dft_enc_compute_itd_fx( Word32 cng_xcorr_filt; Word16 cng_xcorr_filt_e; - +#ifdef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG + Word32 sum_nrg_delta; + Word16 sum_nrg_delta_e; +#endif Word16 prev_itd_max; Word16 itd_max_flip; @@ -1237,7 +1240,9 @@ void stereo_dft_enc_compute_itd_fx( move32(); xcorr_abs[i] = Sqrt32( xcorr_abs[i], &xcorr_abs_e[i] ); move32(); +#ifndef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VM: prod_LL tends to overflow, better to replace with sum(log(prod_L)) and retrain the classifier */ +#endif prod_LL = prod_L; move32(); prod_LL_e = prod_L_e; @@ -1385,13 +1390,29 @@ void stereo_dft_enc_compute_itd_fx( hStereoClassif->xtalk_fv_fx[E_gainIPD] = L_shr_r( g_IPD, 10 ); // Q15 move32(); +#ifdef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG + sum_nrg_delta = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, L_negate( sum_nrg_R ), sum_nrg_R_e, &sum_nrg_delta_e ); + IF( GE_32( sum_nrg_delta, 0 ) ) + { + sum_nrg_delta = L_max( sum_nrg_delta, L_shl_sat( 1, sum_nrg_delta_e ) ); + } + ELSE + { + sum_nrg_delta = L_min( sum_nrg_delta, L_negate( L_shl_sat( 1, sum_nrg_delta_e ) ) ); + } + // angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / sum_nrg_delta ) ); + L_temp2 = BASOP_Util_Divide3232_Scale_newton( grand_dot_prod_real, sum_nrg_delta, &L_temp2_e ); + L_temp2_e = add( L_temp2_e, sub( add( grand_dot_prod_real_e, 1 ), sum_nrg_delta_e ) ); + angle_rot = L_abs( BASOP_util_atan( L_shr_r_sat( L_temp2, ( sub( 6, L_temp2_e ) ) ) ) ); // Q14 +#else // angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / ( sum_nrg_L - sum_nrg_R + 1.0f ) ) ); L_temp = BASOP_Util_Add_Mant32Exp( sum_nrg_L, sum_nrg_L_e, L_negate( sum_nrg_R ), sum_nrg_R_e, &L_temp_e ); L_temp = BASOP_Util_Add_Mant32Exp( L_temp, L_temp_e, MAX_32, 0, &L_temp_e ); L_temp2 = BASOP_Util_Divide3232_Scale_newton( grand_dot_prod_real, L_temp, &L_temp2_e ); L_temp2_e = add( L_temp2_e, sub( add( grand_dot_prod_real_e, 1 ), L_temp_e ) ); angle_rot = L_abs( BASOP_util_atan( L_shr_r_sat( L_temp2, ( sub( 6, L_temp2_e ) ) ) ) ); // Q14 - // angle_rot = L_abs( BASOP_util_atan2( grand_dot_prod_real, L_temp, sub( add( grand_dot_prod_real_e, 1 ), L_temp_e ) ) ); // Q13 + // angle_rot = L_abs( BASOP_util_atan2( grand_dot_prod_real, L_temp, sub( add( grand_dot_prod_real_e, 1 ), L_temp_e ) ) ); // Q13 +#endif hStereoClassif->unclr_fv_fx[E_angle_rot] = L_shl( angle_rot, 1 ); // Q15 move32();