Commit 69be8947 authored by multrus's avatar multrus
Browse files

JBM Cross-Corr (iusse 834): use operator with overflow handling, to deal with allowed overflows

parent b80a2de2
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@
#define FIX_846_TILT_BWE                        /* VA : Proposed fix to 846, to solve saturation */
#define FIX_843_LOW_RATE_BWE                    /* VA : Proposed fix to 843 to solve mid band noise */
#define FIX851_RANGE_DEC_PRECISION              /* VA : 851 Proposed fix to keep precision during UL_div*/
#define FX_834_OVFL_JBM_CROSSCORR               /* FhG: Proposed fix to 834, allow overflows in calculation */

/* ################## End DEVELOPMENT switches ######################### */

+8 −0
Original line number Diff line number Diff line
@@ -233,13 +233,21 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal,

    IF( sqrtXY != 0 )
    {
#ifdef FX_834_OVFL_JBM_CROSSCORR
        Flag Overflow = 0;
        move16();
#endif
        normCC = 0;
        move16();
        cc = BASOP_Util_Divide3216_Scale( sumXY, sqrtXY, &normCC );
        normCC = add( normCC, 16 );
        /* scale to Q15 with saturation */
        BASOP_SATURATE_WARNING_OFF
#ifdef FX_834_OVFL_JBM_CROSSCORR
        cc = shl_ro( cc, add( normXY, normCC ), &Overflow );
#else
        cc = shl_r( cc, add( normXY, normCC ) );
#endif
        BASOP_SATURATE_WARNING_ON
        *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY );
    }