Commit 3ea42c3c authored by norvell's avatar norvell
Browse files

Add FIX_963_USAN_ERROR to address division by zero

parent 0d466098
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@
#define FIX_955_FASTCONV_REND_IN_ISM                    /* VA: put FastConv rendering call under DEBUGGING */
#define FIX_969_USAN_IGF_ARITH                          /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */
#define FIX_959_MASA_LINEAR_REND                        /* VA: issue 959: remove unused calling of ivas_sba_linear_renderer() in MASA rendering */
#define FIX_963_USAN_ERROR                              /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */

/* #################### End BE switches ################################## */

+22 −0
Original line number Diff line number Diff line
@@ -908,7 +908,18 @@ void stereo_dft_enc_compute_itd(
                {
                    hStereoDft->expectedNumUpdates += 1 + min( hCPE->hFrontVad[0]->rem_dtx_ho, hCPE->hFrontVad[1]->rem_dtx_ho );
                }
#ifdef FIX_963_USAN_ERROR
                if ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates == 0 )
                {
                    cng_xcorr_filt = max( CORR_FILT, sfm_L );
                }
                else
                {
                    cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
                }
#else
                cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
#endif
                hStereoDft->currentNumUpdates++;
                for ( i = 1; i < NFFT / 2; i++ )
                {
@@ -943,7 +954,18 @@ void stereo_dft_enc_compute_itd(
            if ( vad_flag_dtx[0] == 0 )
            {
                /* expectedNumUpdates updated after call to dtx() in SID frames */
#ifdef FIX_963_USAN_ERROR
                if ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates == 0 )
                {
                    cng_xcorr_filt = max( CORR_FILT, sfm_L );
                }
                else
                {
                    cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
                }
#else
                cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L );
#endif
                hStereoDft->currentNumUpdates++;
                hStereoDft->sfm = cng_xcorr_filt;
            }