Commit 46fc355e authored by multrus's avatar multrus
Browse files

[cleanup] accept NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO

parent 997961ba
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@
/* all switches in this category should start with "NONBE_" */

#define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR       /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */
#define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO            /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */

/* ##################### End NON-BE switches ########################### */

+0 −45
Original line number Diff line number Diff line
@@ -573,7 +573,6 @@ static int16_t hf_spectrum_sparseness(
        inv_rms = 0.0f;
        crest_mod = 0.0f;
        maximum( A, L_SPEC_HB, &Amax );
#ifdef NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO
        if ( Amax == 0 )
        {
            /* For all-zero input the crest is 1.0 */
@@ -626,50 +625,6 @@ static int16_t hf_spectrum_sparseness(
            crest = Amax * inv_rms;
            crest_mod = crest_mod * inv_rms;
        }
#else
        thr = Amax * PEAK_THRESHOLD;
        movmean = 0.0f;                        /* avoid uninitialized warning */
        p_num = &inv_tbl[HALF_WIN_LENGTH + 1]; /* Table for division 1./(11:21) */
        for ( i = 0; i < L_SPEC_HB; i++ )
        {
            inv_rms += A[i] * A[i];
            if ( A[i] < thr )
            {
                low_count += 1;
            }
            if ( i <= HALF_WIN_LENGTH )
            {
                if ( i == 0 )
                {
                    movmean = sum_f( &A[0], i + HALF_WIN_LENGTH + 1 ) * ( *p_num );
                }
                else
                {
                    p_num++;
                    movmean = movmean + ( A[i + HALF_WIN_LENGTH] - movmean ) * ( *p_num );
                }
            }
            else
            {
                if ( L_SPEC_HB <= i + HALF_WIN_LENGTH )
                {
                    p_num--;
                    movmean = movmean + ( movmean - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
                }
                else
                {
                    movmean = movmean + ( A[i + HALF_WIN_LENGTH] - A[i - HALF_WIN_LENGTH - 1] ) * ( *p_num );
                }
            }
            if ( crest_mod < movmean )
            {
                crest_mod = movmean;
            }
        }
        inv_rms = 1.0f / (float) sqrtf( inv_rms / L_SPEC_HB );
        crest = Amax * inv_rms;
        crest_mod = crest_mod * inv_rms;
#endif
        *crest_lp = HQ_CREST_FAC_SM * ( *crest_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest;
        *crest_mod_lp = HQ_CREST_FAC_SM * ( *crest_mod_lp ) + ( 1.0f - HQ_CREST_FAC_SM ) * crest_mod;