@@ -59,17 +59,13 @@ static inline void Block_Transform_CalculatePsychoacoustics(
5959 for (n = 0 ;n < SubBlockSize ;n ++ ) if ((v = BufferAmp2 [n ]) > Norm ) Norm = v ;
6060 if (Norm != 0.0f ) {
6161 //! Get the window bandwidth scaling constants
62+ //! NOTE: The tonal masking component (calculated in MaskSum) seems
63+ //! to not directly correlate with sampling rate, only the floor
64+ //! level estimation, so the former constants are fixed values.
6265 int RangeScaleFxp = 16 ;
63- int LoRangeScale ; {
64- float s = (2 * 20000.0f ) / RateHz ;
65- if (s >= 1.0f ) s = 0x1.FFFFFEp-1f ; //! <- Ensure this is always < 1.0
66- LoRangeScale = (int )floorf ((1 <<RangeScaleFxp ) * s );
67- }
68- int HiRangeScale ; {
69- float s = RateHz * (1.0f / (2 * 18000.0f ));
70- if (s < 1.0f ) s = 1.0f ; //! <- Ensure this is always >= 1.0
71- HiRangeScale = (int )ceilf ((1 <<RangeScaleFxp ) * s );
72- }
66+ int LoRangeScale = (int )floorf ((1 <<RangeScaleFxp ) * 0.91f );
67+ int HiRangeScale = (int )ceilf ((1 <<RangeScaleFxp ) * 1.23f );
68+ int FloorRangePerLine = (int )ceilf ((1 <<RangeScaleFxp ) * (16000.0f / RateHz ));
7369
7470 //! Normalize the energy and convert to fixed-point
7571 //! This normalization step forces the sums to be as precise as
@@ -138,7 +134,7 @@ static inline void Block_Transform_CalculatePsychoacoustics(
138134 //! cause strange artifacts at higher frequencies, so we use the
139135 //! theoretical number of bands that would be in that bandwidth.
140136 int64_t Mask = MaskSum / MaskSumW ;
141- int64_t Floor = ((int64_t )FloorSum << RangeScaleFxp ) / (MaskEnd - MaskBeg );
137+ int64_t Floor = ((int64_t )FloorSum << RangeScaleFxp ) / (( n + 1 ) * FloorRangePerLine );
142138 MaskingNp [n ] = (2 * Mask - Floor )* InvLogScale + LogNorm ;
143139 }
144140 }
0 commit comments