low-rate tuning

This commit is contained in:
Christian R. Helmrich 2020-03-12 02:00:00 +01:00
parent c497a38a5f
commit 2e17beffc4
3 changed files with 23 additions and 4 deletions

View File

@ -535,7 +535,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
const unsigned samplingRate = toSamplingRate (m_frequencyIdx);
const unsigned lfeChannelIndex = (m_channelConf >= CCI_6_CH ? __max (5, nChannels - 1) : USAC_MAX_NUM_CHANNELS);
const uint32_t maxSfbLong = (samplingRate < 37566 ? 51 /*32 kHz*/ : brModeAndFsToMaxSfbLong (m_bitRateMode, samplingRate));
const uint64_t scaleSr = (samplingRate < 27713 ? 37 - m_bitRateMode : 38 - (m_bitRateMode > 2 ? 1 : 0));
const uint64_t scaleSr = (samplingRate < 27713 ? 38 - m_bitRateMode : 38 - (m_bitRateMode > 2 ? 1 : 0));
const uint64_t scaleBr = (m_bitRateMode == 0 ? 32 : scaleSr - eightTimesSqrt256Minus[256 - m_bitRateMode] - ((m_bitRateMode - 1) >> 1));
uint32_t* sfbStepSizes = (uint32_t*) m_tempIntBuf;
uint8_t meanSpecFlat[USAC_MAX_NUM_CHANNELS];

View File

@ -38,7 +38,7 @@ static inline short getBitCount (EntropyCoder& entrCoder, const int sfIndex, con
#if EC_TRELLIS_OPT_CODING && !EC_TRAIN
static inline double getLagrangeValue (const uint16_t rateIndex) // RD optimization constant
{
return (108.0 + rateIndex * rateIndex) * 0.0009765625; // /1024
return (95.0 + rateIndex * rateIndex) * 0.0009765625; // / 1024
}
#endif
@ -191,14 +191,33 @@ uint8_t SfbQuantizer::quantizeMagnSfb (const unsigned* const coeffMagn, const ui
// re-compute least-squares optimal scale factor modifier
if (dNum > SF_THRESH_POS * dDen) sf++;
#if !SFB_QUANT_PERCEPT_OPT
else
if (dNum < SF_THRESH_NEG * dDen) sf--;
if (dNum < SF_THRESH_NEG * dDen) sf--; // reduces SFB RMS
#endif
} // if nonzero
if (sigMaxQ) *sigMaxQ = (numQ > 0 ? maxQ : 0); // a new max
if (sigNumQ) *sigNumQ = numQ; // a new nonzero coeff. count
}
}
#endif // EC_TRELLIS_OPT_CODING
#if SFB_QUANT_PERCEPT_OPT
if ((numQ > 0) && (sf > 0 && sf <= scaleFactor)) // recover RMS
{
const double magnNormDiv = m_lutSfNorm[sf];
dNum = 0.0; // dDen has normalized energy after quantization
for (int i = numCoeffs - 1; i >= 0; i--)
{
const double normalizedMagn = (double) coeffMagn[i] * magnNormDiv;
dNum += normalizedMagn * normalizedMagn; // TODO: use SIMD?
}
if (dNum > SF_THRESH_POS * SF_THRESH_POS * dDen) sf++;
}
#endif
return (uint8_t) __max (0, sf); // optimized scale factor index
}

View File

@ -165,7 +165,7 @@ uint8_t SpecGapFiller::getSpecGapFillParams (const SfbQuantizer& sfbQuantizer, c
}
s = 0;
#endif
u = __min (7, uint16_t (14.47118288 + 9.965784285 * log10 (magnSum / (double) u)));
u = __min (7 + (specFlat >> 5), uint16_t (14.47118288 + 9.965784285 * log10 (magnSum / (double) u)));
u = __max (1, u - int (specFlat >> 5)); // SFM-adaptive reduction
magnSum = pow (2.0, (14 - u) / 3.0); // noiseVal^-1, 23003-3, 7.2