Commit 3445a9e8 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

prevent ratio from being < 1.0 to avoid log2(<1.0)

parent 6a18db23
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@
#define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER           /* Qualcomm: issue 953: fix order or ER channels in LC mode*/
#define NONBE_FIX_949_MC_5MS_FRAMING                          /* Dlb: issue 949: fix for issue 949, distorted output in MC mode with 5ms framing*/
#define NONBE_FIX_952_MC_PARAMUPMIX_5MS                       /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/
#define NONBE_FIX_971_LOG2_IDX_GAIN_0                         /* VA: prevent -Inf due to log2(ratio==0) */

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

+6 −0
Original line number Diff line number Diff line
@@ -2738,6 +2738,12 @@ void fb_tbe_enc(
    hBWE_TD->prev_fb_energy = sum2_f( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 );
    fb_exc_energy = sum2_f( fb_exc, L_FRAME16k ) + EPSILON;
    ratio = (float) sqrt( temp2 / fb_exc_energy );
#ifdef NONBE_FIX_971_LOG2_IDX_GAIN_0
    if (ratio < 1.0f)
    {
        ratio = 1.0f;
    }
#endif
    idxGain = (int16_t) ( log2_f( (float) ratio ) + 0.5f );
    idxGain = max( 0, min( 15, idxGain ) );
    ratio = (float) ( 1 << idxGain );