mode 1 tuning

This commit is contained in:
Christian R. Helmrich 2020-05-12 00:00:38 +02:00
parent eceadce255
commit ea74e998f3
2 changed files with 14 additions and 15 deletions

View File

@ -84,14 +84,14 @@ int main (const int argc, char* argv[])
}
// print program header with compile info in plain text if we pass -V
if (argc > 1 && (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "-v") == 0))
if ((argc > 1) && (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "-v") == 0))
{
#if defined (_WIN64) || defined (WIN64) || defined (_LP64) || defined (__LP64__) || defined (__x86_64) || defined (__x86_64__)
fprintf_s(stdout, "exhale %s.%s%s (x64)\n",
fprintf_s (stdout, "exhale %s.%s%s (x64)\n",
#else // 32-bit OS
fprintf_s(stdout, "exhale %s.%s%s (x86)\n",
fprintf_s (stdout, "exhale %s.%s%s (x86)\n",
#endif
EXHALELIB_VERSION_MAJOR, EXHALELIB_VERSION_MINOR, EXHALELIB_VERSION_BUGFIX);
EXHALELIB_VERSION_MAJOR, EXHALELIB_VERSION_MINOR, EXHALELIB_VERSION_BUGFIX);
return 0;
}
@ -397,7 +397,7 @@ int main (const int argc, char* argv[])
#else
ExhaleEncoder exhaleEnc (inPcmData, outAuData, sampleRate, numChannels, frameLength, indepPeriod, variableCoreBitRateMode +
#endif
(sampleRate > 24000 ? 0 : 1 - (variableCoreBitRateMode >> 2)) // compensate for low sampling rates
(sampleRate > 16000 ? 0 : 1 - (variableCoreBitRateMode >> 2)) // compensate for low sampling rates
#if !RESTRICT_TO_AAC
, true /*noise filling*/, compatibleExtensionFlag > 0
#endif

View File

@ -681,7 +681,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 : 37) - (m_bitRateMode > 1 ? nChannels >> 1 : 0);
const uint64_t scaleSr = (samplingRate < 27713 ? (samplingRate < 24000 ? 32 : 34) - m_bitRateMode : 37) - (nChannels >> 1);
const uint64_t scaleBr = (m_bitRateMode == 0 ? 32 : scaleSr - eightTimesSqrt256Minus[256 - m_bitRateMode] - __min (3, (m_bitRateMode - 1) >> 1));
uint32_t* sfbStepSizes = (uint32_t*) m_tempIntBuf;
uint8_t meanSpecFlat[USAC_MAX_NUM_CHANNELS];
@ -1272,7 +1272,7 @@ unsigned ExhaleEncoder::spectralProcessing () // complete ics_info(), calc TNS
if ((int) s == steAnaStats * -1) coreConfig.stereoConfig = 2; // 2: S>M, pred_dir=1
if (s > (UCHAR_MAX * 3) / 4) coreConfig.stereoMode = 2; // 2: all, ms_mask_present=2
if (s >= UCHAR_MAX) coreConfig.stereoConfig |= 8; // coding of mono-in-stereo signal
if (s >= UCHAR_MAX - 1) coreConfig.stereoConfig |= 8; // true: mono-in-stereo signal
}
else if (nrChannels > 1) m_perCorrHCurr[el] = m_perCorrLCurr[el] = 128; // "mid" value
@ -1390,9 +1390,9 @@ unsigned ExhaleEncoder::spectralProcessing () // complete ics_info(), calc TNS
coreConfig.commonTnsData = (*coeff0 == *coeff1); // first four coeffs the same
}
if (coreConfig.commonTnsData) // synch TNS start SFB
if (coreConfig.commonTnsData || (abs (tnsStart[0] - tnsStart[1]) <= (UCHAR_MAX >> 5)))
{
const uint32_t avgTnsStart = (tnsStart[0] + tnsStart[1]) >> 1; // mean offset
const uint32_t avgTnsStart = (tnsStart[0] + tnsStart[1]) >> 1; // synch start
sa0 = (sa0 & (UINT_MAX - 31)) | avgTnsStart; // is used by applyTnsToWinGroup
sa1 = (sa1 & (UINT_MAX - 31)) | avgTnsStart;
@ -1419,20 +1419,19 @@ unsigned ExhaleEncoder::spectralProcessing () // complete ics_info(), calc TNS
const uint16_t* grpSO = grpData.sfbOffsets;
const IcsInfo& icsCurr = coreConfig.icsInfoCurr[ch];
const bool eightShorts = (icsCurr.windowSequence == EIGHT_SHORT);
unsigned grpEndLine = 0;
if (eightShorts) // map grouping table idx to scale_factor_grouping idx for bit-stream
{
coreConfig.icsInfoCurr[ch].windowGrouping = scaleFactorGrouping[icsCurr.windowGrouping];
}
s = 0;
for (uint16_t gr = 0; gr < grpData.numWindowGroups; gr++)
{
const unsigned grpSOStart = grpSO[grpData.sfbsPerGroup + m_numSwbShort * gr];
const unsigned grMax = grpSO[grpData.sfbsPerGroup + m_numSwbShort * gr];
grpEndLine += (eightShorts ? nSamplesInShort : nSamplesInFrame) * grpData.windowGroupLength[gr];
memset (&m_mdctSignals[ci][grpSOStart], 0, (grpEndLine - grpSOStart) * sizeof (int32_t));
memset (&m_mdstSignals[ci][grpSOStart], 0, (grpEndLine - grpSOStart) * sizeof (int32_t));
s += (eightShorts ? nSamplesInShort : nSamplesInFrame) * grpData.windowGroupLength[gr];
memset (&m_mdctSignals[ci][grMax], 0, (s - grMax) * sizeof (int32_t));
memset (&m_mdstSignals[ci][grMax], 0, (s - grMax) * sizeof (int32_t));
}
memset (grpData.sfbRmsValues, 0, (MAX_NUM_SWB_SHORT * NUM_WINDOW_GROUPS) * sizeof (uint32_t));