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

Port fix FIX_963_USAN_ERROR to resolve division-by-zero in Stereo CNG

parent 5e45ee71
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@
#define FIX_929_RENDERER_CMDL                           /* Nokia: issue #929: renderer command line option */
#define NONBE_FIX_BINAURAL_ROOM_IR_REVERBERATOR               /* FhG: re-enable acidentially disabled reverberator for BINAURAL_ROOM_IR */
#define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM   /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */
#define FIX_963_USAN_ERROR                              /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */

/* #################### End BASOP porting switches ############################ */

+22 −0
Original line number Diff line number Diff line
@@ -914,7 +914,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++ )
                {
@@ -949,7 +960,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;
            }