Commit b1164c83 authored by Jan Kiene's avatar Jan Kiene
Browse files

add proposed fix for correct power spec scaling

parent 9af190bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@
#define FIX_1139_REV_COLORATION_SHORT_T60               /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */
#define NONBE_FIX_1208_DFT_STEREO_PLC_BURST             /* Ericsson: Issue 1208, fix for overflow of sample offset counter for burst error in DFT Stereo PLC. */
#define FIX_1206_ZERO_OUT_IMDCT_BUFFERS_FOR_MCT_IGNORE  /* FhG: zero out all relevant imdct buffers in MCT decoding of channels with mct_chan_mode == MCT_CHAN_MODE_IGNORE */
#define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING

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

+13 −0
Original line number Diff line number Diff line
@@ -620,14 +620,27 @@ static void run_min_stats(
               computed only once (for ch == 0) and not again in the second run sive the outcome will be the same anyway */
            if ( ( will_estimate_noise_on_channel[0] == will_estimate_noise_on_channel[1] ) || ch == 0 )
            {
#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING
                float power_spec_scale_fac;

                /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */
                power_spec_scale_fac = 1.f / (float) ( L_FRAME16k * L_FRAME16k );
                power_spec[0] = spec_in[0] * spec_in[0] * power_spec_scale_fac;
                power_spec[L_FRAME16k - 1] = spec_in[L_FRAME16k - 1] * spec_in[L_FRAME16k - 1] * power_spec_scale_fac;
#else
                /* calculate power spectrum from MDCT coefficients and estimated MDST coeffs */
                power_spec[0] = spec_in[0] * spec_in[0];
                power_spec[L_FRAME16k - 1] = spec_in[L_FRAME16k - 1] * spec_in[L_FRAME16k - 1];
#endif
                for ( int16_t i = 1; i < L_FRAME16k - 1; i++ )
                {
                    float mdst;
                    mdst = spec_in[i + 1] - spec_in[i - 1];
#ifdef NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING
                    power_spec[i] = power_spec_scale_fac * ( spec_in[i] * spec_in[i] + mdst * mdst );
#else
                    power_spec[i] = spec_in[i] * spec_in[i] + mdst * mdst;
#endif
                }
            }