mirror of
https://gitlab.com/ecodis/exhale.git
synced 2025-06-05 21:59:32 +02:00
SBR bit allocation
This commit is contained in:
@ -419,7 +419,7 @@ unsigned BitAllocator::imprSfbStepSizes (const SfbGroupData* const groupData[USA
|
|||||||
const uint8_t* const sfbStereoData /*= nullptr*/, const uint8_t stereoConfig /*= 0*/)
|
const uint8_t* const sfbStereoData /*= nullptr*/, const uint8_t stereoConfig /*= 0*/)
|
||||||
{
|
{
|
||||||
const uint8_t maxSfbL16k = 16 + __min (4 + (samplingRate >> 10), (9 << 17) / __max (1, samplingRate)); // SFB index at 15.8 kHz
|
const uint8_t maxSfbL16k = 16 + __min (4 + (samplingRate >> 10), (9 << 17) / __max (1, samplingRate)); // SFB index at 15.8 kHz
|
||||||
const uint32_t redFactor = __max ((samplingRate < 27713 ? 2 : 1), __min (3, m_rateIndex)) - (stereoConfig >> 3);
|
const uint32_t redFactor = __max ((samplingRate < 25495 ? 2 : 1), __min (3, m_rateIndex)) - (stereoConfig >> 3);
|
||||||
const uint32_t redWeight = __min (4, 9 - __min (9, m_rateIndex));
|
const uint32_t redWeight = __min (4, 9 - __min (9, m_rateIndex));
|
||||||
short* const tempCoeffs = (short* const) m_tempSfbValue;
|
short* const tempCoeffs = (short* const) m_tempSfbValue;
|
||||||
|
|
||||||
|
@ -768,7 +768,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
const unsigned lfeChannelIndex = (m_channelConf >= CCI_6_CH ? __max (5, nChannels - 1) : USAC_MAX_NUM_CHANNELS);
|
const unsigned lfeChannelIndex = (m_channelConf >= CCI_6_CH ? __max (5, nChannels - 1) : USAC_MAX_NUM_CHANNELS);
|
||||||
const bool useMaxBandwidth = (samplingRate < 37566 || m_shiftValSBR > 0);
|
const bool useMaxBandwidth = (samplingRate < 37566 || m_shiftValSBR > 0);
|
||||||
const uint32_t maxSfbLong = (useMaxBandwidth ? m_numSwbLong : brModeAndFsToMaxSfbLong (m_bitRateMode, samplingRate));
|
const uint32_t maxSfbLong = (useMaxBandwidth ? m_numSwbLong : brModeAndFsToMaxSfbLong (m_bitRateMode, samplingRate));
|
||||||
const uint32_t scaleSBR = (m_shiftValSBR > 0 || m_nonMpegExt ? (samplingRate < 23004 || m_bitRateMode == 0 ? 8 : 6 + ((m_bitRateMode + 1) >> 2)) : 0); // -25% rate
|
const uint32_t scaleSBR = (m_shiftValSBR > 0 || m_nonMpegExt ? (m_bitRateMode == 0 ? 8 : 6 + ((m_bitRateMode + 2 - samplingRate/24000) >> 2)) : 0); // -25% rate
|
||||||
const uint64_t scaleSr = (samplingRate < 27713 ? (samplingRate < 23004 ? 32 : 34) - __min (3 << m_shiftValSBR, m_bitRateMode)
|
const uint64_t scaleSr = (samplingRate < 27713 ? (samplingRate < 23004 ? 32 : 34) - __min (3 << m_shiftValSBR, m_bitRateMode)
|
||||||
: (samplingRate < 37566 && m_bitRateMode != 3u ? 36 : 37)) - (nChannels >> 1);
|
: (samplingRate < 37566 && m_bitRateMode != 3u ? 36 : 37)) - (nChannels >> 1);
|
||||||
const uint64_t scaleBr = (m_bitRateMode == 0 ? __min (32, 3 + (samplingRate >> 10) + (samplingRate >> 13) - (nChannels >> 1))
|
const uint64_t scaleBr = (m_bitRateMode == 0 ? __min (32, 3 + (samplingRate >> 10) + (samplingRate >> 13) - (nChannels >> 1))
|
||||||
@ -1172,7 +1172,8 @@ unsigned ExhaleEncoder::quantizationCoding () // apply MDCT quantization and en
|
|||||||
const uint16_t peakIndex = (shortWinCurr ? 0 : (m_specAnaCurr[ci] >> 5) & 2047);
|
const uint16_t peakIndex = (shortWinCurr ? 0 : (m_specAnaCurr[ci] >> 5) & 2047);
|
||||||
const unsigned sfmBasedSfbStart = (shortWinCurr ? maxSfbShort - 2 + (meanSpecFlat[ci] >> 6) : maxSfbLong - 6 + (meanSpecFlat[ci] >> 5)) +
|
const unsigned sfmBasedSfbStart = (shortWinCurr ? maxSfbShort - 2 + (meanSpecFlat[ci] >> 6) : maxSfbLong - 6 + (meanSpecFlat[ci] >> 5)) +
|
||||||
(shortWinCurr ? -3 + (((1 << 5) + meanTempFlat[ci]) >> 6) : -7 + (((1 << 4) + meanTempFlat[ci]) >> 5));
|
(shortWinCurr ? -3 + (((1 << 5) + meanTempFlat[ci]) >> 6) : -7 + (((1 << 4) + meanTempFlat[ci]) >> 5));
|
||||||
const unsigned targetBitCount25 = ((60000 + 20000 * m_bitRateMode) * nSamplesInFrame) / (samplingRate * ((grpData.numWindowGroups + 1) >> 1));
|
const unsigned targetBitCount25 = ((60000 + 20000 * (m_bitRateMode + m_shiftValSBR)) * nSamplesInFrame) /
|
||||||
|
(samplingRate * ((grpData.numWindowGroups + 1) >> 1));
|
||||||
unsigned b = grpData.sfbsPerGroup - 1;
|
unsigned b = grpData.sfbsPerGroup - 1;
|
||||||
|
|
||||||
if ((grpRms[b] >> 16) > 0) lastSfb = b;
|
if ((grpRms[b] >> 16) > 0) lastSfb = b;
|
||||||
@ -1319,9 +1320,9 @@ unsigned ExhaleEncoder::quantizationCoding () // apply MDCT quantization and en
|
|||||||
|
|
||||||
if (ch > 0 && coreConfig.stereoMode > 0) // synch. sbr_grid(), sbr_invf() for stereo
|
if (ch > 0 && coreConfig.stereoMode > 0) // synch. sbr_grid(), sbr_invf() for stereo
|
||||||
{
|
{
|
||||||
tmpValSynch = (m_coreSignals[ci - 1][0] >> 21) & 3; // nEnv, bits 23-22
|
tmpValSynch = (m_coreSignals[s][0] >> 21) & 3; // nEnv, bits 23-22
|
||||||
m_coreSignals[ci][0] |= m_coreSignals[ci - 1][0] & 0x10000F; // bits 21
|
m_coreSignals[ci][0] |= m_coreSignals[s][0] & 0x10000F; // bits 21
|
||||||
m_coreSignals[ci - 1][0] |= m_coreSignals[ci][0] & 0x10000F; // and 4-1
|
m_coreSignals[s][0] |= m_coreSignals[ci][0] & 0x10000F; // and 4-1
|
||||||
}
|
}
|
||||||
m_coreSignals[ci][0] |= getSbrEnvelopeAndNoise (&m_coreSignals[ci][nSamplesTempAna - 64 + nSamplesInFrame], msfVal,
|
m_coreSignals[ci][0] |= getSbrEnvelopeAndNoise (&m_coreSignals[ci][nSamplesTempAna - 64 + nSamplesInFrame], msfVal,
|
||||||
__max (m_meanTempPrev[ci], meanTempFlat[ci]) >> 3, m_bitRateMode == 0,
|
__max (m_meanTempPrev[ci], meanTempFlat[ci]) >> 3, m_bitRateMode == 0,
|
||||||
|
@ -136,8 +136,8 @@ int32_t getSbrEnvelopeAndNoise (int32_t* const sbrLevels, const uint8_t specFlat
|
|||||||
sbrArray[7] = quantizeSbrEnvelopeLevel (envTmp3[7], frameSize, specFlat5b);
|
sbrArray[7] = quantizeSbrEnvelopeLevel (envTmp3[7], frameSize, specFlat5b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// quantized noise level for up to two temporal units, 31 = no noise
|
// quantized noise level for up to two temporal units, 30 = no noise
|
||||||
t = __max (specFlat5b, specFlatSte);
|
t = __min (30, __max (specFlat5b, specFlatSte));
|
||||||
sbrArray[8] = ((int32_t) t << 13) | ((int32_t) t << 26);
|
sbrArray[8] = ((int32_t) t << 13) | ((int32_t) t << 26);
|
||||||
#if ENABLE_INTERTES
|
#if ENABLE_INTERTES
|
||||||
if ((t < 12) && (tempFlat5b > (lowBitRateMode ? 15 : 26)) && (tmpBest < 3))
|
if ((t < 12) && (tempFlat5b > (lowBitRateMode ? 15 : 26)) && (tmpBest < 3))
|
||||||
|
Reference in New Issue
Block a user