Commit 05bf4360 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX617_UBSAN_DIVBYZERO_STEREOCNG

parent 9b46b3ef
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -161,7 +161,6 @@



#define FIX617_UBSAN_DIVBYZERO_STEREOCNG                /* Eri: Issue 617: Decoder UBSAN: division by zero in stereo cng when inut is 16kHz and output is 32kHz */
#define FIX_279_CODE_COVERAGE                           /* Dlb : issue 279 , clean up unused function */
#define FIX_549_PARAM_ISM_BIN_GAIN                      /* FhG: Issue 549 : fix too quiet binaural output in ParamISM */
#define FIX_618_STEREO_SW_DIV_BY_ZERO                   /* VA: fix issue 618 - UBSAN: division-by-zero in stereo bitrate switching */
+0 −4
Original line number Diff line number Diff line
@@ -741,10 +741,8 @@ static void shb_CNG_decod(
    gain = (float) sqrt( pow( 10, 0.1f * ener ) * L_FRAME16k / ener_excSHB );

    st->hTdCngDec->shb_cng_gain = ener;
#ifdef FIX617_UBSAN_DIVBYZERO_STEREOCNG
#ifdef DEBUGGING
    /* note: state shb_cng_gain is actually an energy value in dB */
#endif
#endif

    for ( i = 0; i < L_FRAME16k; i++ )
@@ -789,14 +787,12 @@ void td_cng_dec_init(
    mvr2r( st->lsp_old, st->lspCNG, M );
    hTdCngDec->last_allow_cn_step = 0;
    hTdCngDec->shb_cng_ener = -6.02f;
#ifdef FIX617_UBSAN_DIVBYZERO_STEREOCNG
    if ( st->element_mode != EVS_MONO )
    {
        set_f( hTdCngDec->shb_lpcCNG, 0.0f, LPC_SHB_ORDER + 1 );
        hTdCngDec->shb_lpcCNG[0] = 1.0f;
        hTdCngDec->shb_cng_gain = -82.0; /* a  dB value approximately corresponding to  shb  index 0(used as index -15)   */
    }
#endif

    hTdCngDec->wb_cng_ener = -6.02f;
    hTdCngDec->last_wb_cng_ener = -6.02f;
+0 −15
Original line number Diff line number Diff line
@@ -342,7 +342,6 @@ static void stereo_dft_generate_comfort_noise(
        ptr0 = cngNoiseLevel_upd;
        ptr1 = ptr0 + 2;
        ptr2 = ptr1 + 1;
#ifdef FIX617_UBSAN_DIVBYZERO_STEREOCNG
        assert( st->lp_ener > 0.0f );
        factor = 2.0f * sqrtf( st->lp_ener / st->L_frame * 0.5f ); /* fixed factor  in the loop below */
        for ( i = 0; i < st->L_frame / 2 - 1; i++ )
@@ -353,14 +352,6 @@ static void stereo_dft_generate_comfort_noise(
            ptr1 += 2;
            ptr2 += 2;
        }
#else
        for ( i = 0; i < st->L_frame / 2 - 1; i++ )
        {
            *ptr0++ = 2.0f * sqrtf( st->lp_ener / st->L_frame * 0.5f ) * inv_sqrt( *ptr1 * *ptr1 + *ptr2 * *ptr2 );
            ptr1 += 2;
            ptr2 += 2;
        }
#endif

        if ( min( output_frame, L_FRAME32k ) - hFdCngCom->stopFFTbin > 0 )
        {
@@ -391,7 +382,6 @@ static void stereo_dft_generate_comfort_noise(

            for ( i = 0; i < L_FRAME16k / 2 - 1; i++ )
            {
#ifdef FIX617_UBSAN_DIVBYZERO_STEREOCNG
                ftmp = ( *ptr1 * *ptr1 + *ptr2 * *ptr2 );
                assert( ftmp > 0.0f );
                ftmp = 1.0f / ftmp;
@@ -401,9 +391,6 @@ static void stereo_dft_generate_comfort_noise(
                  in BASOP:
                    sum up  using inv_sqrt( *ptr1 * *ptr1 + *ptr2 * *ptr2 ), in this loop
                    and then sum up  enr = sum( *ptr0 * *ptr0 ),  in a subsequent MAC loop  */
#else
                ftmp = 1.0f / ( *ptr1 * *ptr1 + *ptr2 * *ptr2 );
#endif
                enr += ftmp;
                *ptr0++ = sqrtf( ftmp );
                ptr1 += 2;
@@ -481,9 +468,7 @@ static void stereo_dft_generate_comfort_noise(
            {

                /* high band generation, flipped spectrum */
#ifdef FIX617_UBSAN_DIVBYZERO_STEREOCNG
                assert( enr != 0.0f );
#endif
                scale = sqrtf( powf( 10, 0.1f * st->hTdCngDec->shb_cng_gain ) / enr );
                ptr_shb = shb_shape + L_FRAME16k / 2 - 1;
                /* Averaging for Nyquist frequency */