Commit bc40dbf0 authored by vaclav's avatar vaclav
Browse files

port NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG

parent 2498b3d5
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@

#define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX      /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/
#define FIX_969_USAN_IGF_ARITH                          /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */
#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 ############################ */

+17 −1
Original line number Diff line number Diff line
@@ -951,7 +951,9 @@ 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;
#endif
    Word16 prev_itd_max;
    Word16 itd_max_flip;

@@ -1215,7 +1217,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;
@@ -1363,7 +1367,19 @@ 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
        IF( L_sub( sum_nrg_L, sum_nrg_R ) >= 0 )
        {
            sum_nrg_delta = L_max( L_sub( sum_nrg_L, sum_nrg_R ), 1 << sum_nrg_L_e );
        }
        ELSE
        {
            sum_nrg_delta = L_min( L_sub( sum_nrg_L, sum_nrg_R ), L_negate( 1 << sum_nrg_L_e ) );
        }
        //angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / sum_nrg_delta ) );
#else
        // angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / ( sum_nrg_L - sum_nrg_R + 1.0f ) ) );
#endif
        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_cadence( grand_dot_prod_real, L_temp, &L_temp2_e );