From 2d0fa2f10d5accc7ebf5b15ae7f7ddbf0d41b952 Mon Sep 17 00:00:00 2001 From: "Christian R. Helmrich" Date: Sat, 6 Mar 2021 13:00:00 +0100 Subject: [PATCH] some fine-tuning --- src/app/exhaleApp.cpp | 3 +-- src/lib/bitStreamWriter.cpp | 2 +- src/lib/exhaleEnc.cpp | 2 +- src/lib/exhaleEnc.h | 2 +- src/lib/tempAnalysis.cpp | 20 ++++++++++++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/app/exhaleApp.cpp b/src/app/exhaleApp.cpp index 8551660..ff19d6a 100644 --- a/src/app/exhaleApp.cpp +++ b/src/app/exhaleApp.cpp @@ -677,8 +677,7 @@ int main (const int argc, char* argv[]) // enforce executable specific constraints i = __min (USHRT_MAX, wavReader.getSampleRate ()); - if ((wavReader.getNumChannels () > 3 || coreSbrFrameLengthIndex >= 3) && (i == 57600 || i == 51200 || i == 40000 || i == 38400 || - i == 34150 || i == 28800 || i == 25600 || i == 20000 || i == 19200 || i == 17075 || i == 14400 || i == 12800 || i == 9600)) + if ((wavReader.getNumChannels () > 3 || coreSbrFrameLengthIndex >= 3) && (i == 57600 || i == 38400 || i == 19200)) // BL USAC { fprintf_s (stderr, " ERROR: exhale does not support %d-channel coding with %d Hz sampling rate.\n\n", wavReader.getNumChannels (), i); diff --git a/src/lib/bitStreamWriter.cpp b/src/lib/bitStreamWriter.cpp index cb1b9e2..777507e 100644 --- a/src/lib/bitStreamWriter.cpp +++ b/src/lib/bitStreamWriter.cpp @@ -821,7 +821,7 @@ unsigned BitStreamWriter::createAudioConfig (const char samplingFrequencyIndex, writeByteAlignment (); // flush bytes auLen = __min (18u + fli, bitCount >> 3); #ifndef NO_PREROLL_DATA - m_usacConfigLen = uint16_t (__max (9, auLen - ucOffset)); // excl. ASC payload + m_usacConfigLen = uint16_t (__max (15, auLen - ucOffset)); // excl ASC payload memcpy (m_usacConfig, &m_auBitStream.stream.at (ucOffset), auLen - ucOffset); #endif memcpy (audioConfig, &m_auBitStream.stream.front (), auLen); diff --git a/src/lib/exhaleEnc.cpp b/src/lib/exhaleEnc.cpp index f9a6149..5986208 100644 --- a/src/lib/exhaleEnc.cpp +++ b/src/lib/exhaleEnc.cpp @@ -1686,7 +1686,7 @@ unsigned ExhaleEncoder::temporalProcessing () // determine time-domain aspects o const unsigned plNext = abs (m_tranLocNext[ci]) & ((1024 << m_shiftValSBR) - 1); const unsigned sfNext = (m_tempAnaNext[ci] >> 24) & UCHAR_MAX; const unsigned tfNext = (m_tempAnaNext[ci] >> 16) & UCHAR_MAX; - const unsigned tThresh = UCHAR_MAX * (__max (plCurr, plNext) < 614 /*0.6 * 1024*/ ? 16 : 15 - (m_bitRateMode >> 2)); + const unsigned tThresh = UCHAR_MAX * (__max (plCurr, plNext) < 614 /*0.6 * 1024*/ ? 16 : 15 - (m_bitRateMode >> 3)); tsCurr[ch] = (m_tempAnaCurr[ci] /*R*/) & UCHAR_MAX; tsNext[ch] = (m_tempAnaNext[ci] >> 8) & UCHAR_MAX; diff --git a/src/lib/exhaleEnc.h b/src/lib/exhaleEnc.h index 6e2a0a2..eff7e36 100644 --- a/src/lib/exhaleEnc.h +++ b/src/lib/exhaleEnc.h @@ -5,7 +5,7 @@ * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- * party rights, including patent rights. No such rights are granted under this License. * - * Copyright (c) 2018-2020 Christian R. Helmrich, project ecodis. All rights reserved. + * Copyright (c) 2018-2021 Christian R. Helmrich, project ecodis. All rights reserved. */ #ifndef _EXHALE_ENC_H_ diff --git a/src/lib/tempAnalysis.cpp b/src/lib/tempAnalysis.cpp index 1bc4c85..2b7616d 100644 --- a/src/lib/tempAnalysis.cpp +++ b/src/lib/tempAnalysis.cpp @@ -1,11 +1,11 @@ /* tempAnalysis.cpp - source file for class providing temporal analysis of PCM signals - * written by C. R. Helmrich, last modified in 2020 - see License.htm for legal notices + * written by C. R. Helmrich, last modified in 2021 - see License.htm for legal notices * * The copyright in this software is being made available under the exhale Copyright License * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- * party rights, including patent rights. No such rights are granted under this License. * - * Copyright (c) 2018-2020 Christian R. Helmrich, project ecodis. All rights reserved. + * Copyright (c) 2018-2021 Christian R. Helmrich, project ecodis. All rights reserved. */ #include "exhaleLibPch.h" @@ -154,6 +154,7 @@ unsigned TempAnalyzer::temporalAnalysis (const int32_t* const timeSignals[USAC_M int splitPtL = 0; int splitPtC = halfFrameOffset; int splitPtR = nSamplesInFrame; + uint64_t ue[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // sub-fr. unit energies unsigned uL0 = abs (chSig[splitPtL ] - chSigM1[splitPtL ]); unsigned uL1 = abs (chSig[splitPtC - 1] - chSigM1[splitPtC - 1]); unsigned uR0 = abs (chSig[splitPtC ] - chSigM1[splitPtC ]); @@ -164,7 +165,6 @@ unsigned TempAnalyzer::temporalAnalysis (const int32_t* const timeSignals[USAC_M { /*LF*/int32_t* lrSig = &lrCoreTimeSignals[ch][resamplerOffset >> sbrShift]; const int32_t* hrSig = &timeSignals[ch][resamplerOffset]; - /*MF*/uint64_t ue[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // unit energies int64_t* const rPrev = m_filtSampPrev[ch]; uint64_t subSumL = 0, subSumM = 0, subSumH = 0; @@ -366,6 +366,18 @@ unsigned TempAnalyzer::temporalAnalysis (const int32_t* const timeSignals[USAC_M maxAbsValR = maxHfrLevR; m_maxAbsHpPrev[ch] = m_maxHfLevPrev[ch]; } + else + { + memset (ue, 0, 8 * sizeof (uint64_t)); + for (u = nSamplesInFrame - 1; u > 0; u--) ue[u >> 8] += abs (chSig[u] - chSigM1[u]); + + sumAbsValL = ue[0]; + sumAbsValR = (uint64_t) maxAbsValL + (uint64_t) maxAbsValR; + for (u = (nSamplesInFrame >> 8) - 1; u > 0; u--) sumAbsValL = __min (sumAbsValL, ue[u]); + + u = maxAbsValR; + if (sumAbsValL < sumAbsValR * (1u + (nSamplesInFrame >> 10)) && m_maxAbsHpPrev[ch] > TA_EPS) m_maxAbsHpPrev[ch] = TA_EPS; + } m_transientLoc[ch] = packTransLocWithPitchLag (maxAbsValL, maxAbsValR, m_maxAbsHpPrev[ch], maxAbsIdxL, maxAbsIdxR, __max (1, pLagBestR)); // update stats history for this channel @@ -376,7 +388,7 @@ unsigned TempAnalyzer::temporalAnalysis (const int32_t* const timeSignals[USAC_M } // if sumAbsValL == 0 && sumAbsValR == 0 if (applyResampler) m_maxHfLevPrev[ch] = maxHfrLevR; - } // for ch + } // ch return 0; // no error }