mirror of
https://gitlab.com/ecodis/exhale.git
synced 2025-06-05 21:59:32 +02:00
code cleanup, CBR
This commit is contained in:
@ -73,7 +73,6 @@
|
|||||||
#define EA_PEAK_MIN 0.262f // 20 * log10() + EA_PEAK_NORM = -108 dbFS
|
#define EA_PEAK_MIN 0.262f // 20 * log10() + EA_PEAK_NORM = -108 dbFS
|
||||||
#define EA_USE_WORK_DIR 1 // 1: use working instead of app directory
|
#define EA_USE_WORK_DIR 1 // 1: use working instead of app directory
|
||||||
#define ENABLE_STDOUT_LOAS 0 // 1: experimental LOAS packed pipe output
|
#define ENABLE_STDOUT_LOAS 0 // 1: experimental LOAS packed pipe output
|
||||||
#define XHE_AAC_LOW_DELAY 0 // 1: allow encoding with 768 frame length
|
|
||||||
#define FULL_FRM_LOOKAHEAD // on: encoder delay = zero or frame length
|
#define FULL_FRM_LOOKAHEAD // on: encoder delay = zero or frame length
|
||||||
|
|
||||||
static const int16_t usfc2x[32] = { // 2x upsampling filter coefficients
|
static const int16_t usfc2x[32] = { // 2x upsampling filter coefficients
|
||||||
@ -95,7 +94,7 @@ static bool eaInitUpsampler2x (int32_t** upsampleBuffer, const uint16_t bitRateM
|
|||||||
{
|
{
|
||||||
const uint16_t inLength = frameSize >> 1;
|
const uint16_t inLength = frameSize >> 1;
|
||||||
const uint16_t chLength = inLength + (32 << 1);
|
const uint16_t chLength = inLength + (32 << 1);
|
||||||
const bool useUpsampler = (frameSize > (32 << 1) && bitRateMode * 4000 > sampleRate);
|
const bool useUpsampler = (frameSize > (32 << 1) && bitRateMode * 3675 > sampleRate);
|
||||||
|
|
||||||
if (useUpsampler)
|
if (useUpsampler)
|
||||||
{
|
{
|
||||||
@ -495,19 +494,11 @@ int main (const int argc, char* argv[])
|
|||||||
fprintf_s (stdout, "%s preset [inputWaveFile.wav] outputMP4File.m4a\n\n where\n\n", exeFileName);
|
fprintf_s (stdout, "%s preset [inputWaveFile.wav] outputMP4File.m4a\n\n where\n\n", exeFileName);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXHALE_APP_WIN
|
#ifdef EXHALE_APP_WIN
|
||||||
fprintf_s (stdout, " preset\t= # (0-9) low-complexity standard compliant xHE-AAC at 16<31>#+48 kbit/s\n");
|
fprintf_s (stdout, " preset\t= # (0-9) low-complexity ISO/MPEG-D Extended HE-AAC at 16<31>#+48 kbit/s\n");
|
||||||
# if XHE_AAC_LOW_DELAY
|
fprintf_s (stdout, " \t (a-g) low-complexity Extended HE-AAC using eSBR at 12<31>#+36 kbit/s\n");
|
||||||
fprintf_s (stdout, " \t (A-J) 41ms low-delay compatible xHE-AAC with BE at 16<31>#+48 kbit/s\n");
|
|
||||||
#else
|
#else
|
||||||
fprintf_s (stdout, " \t (a-g) low-complexity compliant xHE-AAC with SBR at 12<31>#+36 kbit/s\n");
|
fprintf_s (stdout, " preset\t= # (0-9) low-complexity ISO/MPEG-D Extended HE-AAC at 16*#+48 kbit/s\n");
|
||||||
# endif
|
fprintf_s (stdout, " \t (a-g) low-complexity Extended HE-AAC using eSBR at 12*#+36 kbit/s\n");
|
||||||
#else
|
|
||||||
fprintf_s (stdout, " preset\t= # (0-9) low-complexity standard compliant xHE-AAC at 16*#+48 kbit/s\n");
|
|
||||||
# if XHE_AAC_LOW_DELAY
|
|
||||||
fprintf_s (stdout, " \t (A-J) 41ms low-delay compatible xHE-AAC with BE at 16*#+48 kbit/s\n");
|
|
||||||
# else
|
|
||||||
fprintf_s (stdout, " \t (a-g) low-complexity compliant xHE-AAC with SBR at 12*#+36 kbit/s\n");
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
fprintf_s (stdout, "\n inputWaveFile.wav lossless WAVE audio input, read from stdin if not specified\n\n");
|
fprintf_s (stdout, "\n inputWaveFile.wav lossless WAVE audio input, read from stdin if not specified\n\n");
|
||||||
fprintf_s (stdout, " outputMP4File.m4a encoded MPEG-4 bit-stream, extension should be .m4a or .mp4\n\n\n");
|
fprintf_s (stdout, " outputMP4File.m4a encoded MPEG-4 bit-stream, extension should be .m4a or .mp4\n\n\n");
|
||||||
@ -536,11 +527,7 @@ int main (const int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check preset mode, derive coder config
|
// check preset mode, derive coder config
|
||||||
#if XHE_AAC_LOW_DELAY
|
|
||||||
if ((*argv[1] >= '0' && *argv[1] <= '9') || (*argv[1] >= 'A' && *argv[1] <= 'J'))
|
|
||||||
#else
|
|
||||||
if ((*argv[1] >= '0' && *argv[1] <= '9') || (*argv[1] >= 'a' && *argv[1] <= 'g'))
|
if ((*argv[1] >= '0' && *argv[1] <= '9') || (*argv[1] >= 'a' && *argv[1] <= 'g'))
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
i = (uint16_t) argv[1][0];
|
i = (uint16_t) argv[1][0];
|
||||||
compatibleExtensionFlag = (i & 0x40) >> 6;
|
compatibleExtensionFlag = (i & 0x40) >> 6;
|
||||||
@ -560,11 +547,8 @@ int main (const int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if XHE_AAC_LOW_DELAY
|
|
||||||
_ERROR2 (" ERROR reading preset mode: character %s is not supported! Use 0-9 or A-J.\n\n", argv[1]);
|
|
||||||
#else
|
|
||||||
_ERROR2 (" ERROR reading preset mode: character %s is not supported! Use 0-9 or a-g.\n\n", argv[1]);
|
_ERROR2 (" ERROR reading preset mode: character %s is not supported! Use 0-9 or a-g.\n\n", argv[1]);
|
||||||
#endif
|
|
||||||
return 16384; // preset isn't supported
|
return 16384; // preset isn't supported
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +650,7 @@ int main (const int argc, char* argv[])
|
|||||||
|
|
||||||
if (wavReader.getSampleRate () >= 1000 && wavReader.getSampleRate () < 22050 && enableSbrCoding)
|
if (wavReader.getSampleRate () >= 1000 && wavReader.getSampleRate () < 22050 && enableSbrCoding)
|
||||||
{
|
{
|
||||||
_ERROR2 (" The sampling rate is %d kHz but xHE-AAC with SBR requires at least 22 kHz.\n\n", wavReader.getSampleRate () / 1000);
|
_ERROR2 (" The sampling rate is %d kHz but encoding using eSBR requires at least 22 kHz.\n\n", wavReader.getSampleRate () / 1000);
|
||||||
}
|
}
|
||||||
i = 8192; // return value
|
i = 8192; // return value
|
||||||
|
|
||||||
@ -865,6 +849,14 @@ int main (const int argc, char* argv[])
|
|||||||
fprintf_s (stdout, " NOTE: Upsampling the input audio from %d kHz to %d kHz with preset mode %d\n\n", i / 1000, i / 500, variableCoreBitRateMode);
|
fprintf_s (stdout, " NOTE: Upsampling the input audio from %d kHz to %d kHz with preset mode %d\n\n", i / 1000, i / 500, variableCoreBitRateMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (variableCoreBitRateMode == 0)
|
||||||
|
{
|
||||||
|
if (enableSbrCoding)
|
||||||
|
_ERROR1 (" WARNING: The usage of preset mode a is not recommended since the audio quality\n resulting from preset a does not reflect the full capabilities of the Extended\n HE-AAC standard. Therefore, use the lowest bit-rate modes only when necessary!\n\n");
|
||||||
|
else
|
||||||
|
_ERROR1 (" WARNING: The usage of preset mode 0 is not recommended since the audio quality\n resulting from preset 0 does not reflect the full capabilities of the Extended\n HE-AAC standard. Therefore, use the lowest bit-rate modes only when necessary!\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
// allocate dynamic frame memory buffers
|
// allocate dynamic frame memory buffers
|
||||||
inPcmData = (int32_t*) malloc (inFrameSize * numChannels); // max frame in size
|
inPcmData = (int32_t*) malloc (inFrameSize * numChannels); // max frame in size
|
||||||
#ifdef NO_PREROLL_DATA
|
#ifdef NO_PREROLL_DATA
|
||||||
@ -965,7 +957,7 @@ int main (const int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
, indepPeriod, outAuData, bw, (time (nullptr) + 2082844800) & UINT_MAX, (char) variableCoreBitRateMode)) != 0)
|
, indepPeriod, outAuData, bw, (time (nullptr) + 2082844800) & UINT_MAX, (char) variableCoreBitRateMode)) != 0)
|
||||||
{
|
{
|
||||||
_ERROR2 (" ERROR while trying to initialize xHE-AAC encoder: error value %d was returned!\n\n", i);
|
_ERROR2 (" ERROR while trying to initialize exhale encoder: error value %d was returned!\n\n", i);
|
||||||
i <<= 2; // return value
|
i <<= 2; // return value
|
||||||
#if USE_EXHALELIB_DLL
|
#if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
@ -1029,7 +1021,7 @@ int main (const int argc, char* argv[])
|
|||||||
// initial frame, encode look-ahead AU
|
// initial frame, encode look-ahead AU
|
||||||
if ((bw = exhaleEnc.encodeLookahead ()) < 3)
|
if ((bw = exhaleEnc.encodeLookahead ()) < 3)
|
||||||
{
|
{
|
||||||
_ERROR2 ("\n ERROR while trying to create first xHE-AAC frame: error value %d was returned!\n\n", bw);
|
_ERROR2 ("\n ERROR while trying to create first audio frame: error value %d was returned!\n\n", bw);
|
||||||
i = 2; // return value
|
i = 2; // return value
|
||||||
#if USE_EXHALELIB_DLL
|
#if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
@ -1057,7 +1049,7 @@ int main (const int argc, char* argv[])
|
|||||||
// leading frame, actual look-ahead AU
|
// leading frame, actual look-ahead AU
|
||||||
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
||||||
{
|
{
|
||||||
_ERROR2 ("\n ERROR while trying to create first xHE-AAC frame: error value %d was returned!\n\n", bw);
|
_ERROR2 ("\n ERROR while trying to create first audio frame: error value %d was returned!\n\n", bw);
|
||||||
i = 2; // return value
|
i = 2; // return value
|
||||||
# if USE_EXHALELIB_DLL
|
# if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
@ -1100,7 +1092,7 @@ int main (const int argc, char* argv[])
|
|||||||
|
|
||||||
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
||||||
{
|
{
|
||||||
_ERROR2 ("\n ERROR while trying to create xHE-AAC frame: error value %d was returned!\n\n", bw);
|
_ERROR2 ("\n ERROR while trying to create audio frame: error value %d was returned!\n\n", bw);
|
||||||
i = 2; // return value
|
i = 2; // return value
|
||||||
#if USE_EXHALELIB_DLL
|
#if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
@ -1153,7 +1145,7 @@ int main (const int argc, char* argv[])
|
|||||||
|
|
||||||
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
||||||
{
|
{
|
||||||
_ERROR2 ("\n ERROR while trying to create xHE-AAC frame: error value %d was returned!\n\n", bw);
|
_ERROR2 ("\n ERROR while trying to create audio frame: error value %d was returned!\n\n", bw);
|
||||||
i = 2; // return value
|
i = 2; // return value
|
||||||
#if USE_EXHALELIB_DLL
|
#if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
@ -1212,7 +1204,7 @@ int main (const int argc, char* argv[])
|
|||||||
|
|
||||||
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
if ((bw = exhaleEnc.encodeFrame ()) < 3)
|
||||||
{
|
{
|
||||||
_ERROR2 ("\n ERROR while trying to create last xHE-AAC frame: error value %d was returned!\n\n", bw);
|
_ERROR2 ("\n ERROR while trying to create last audio frame: error value %d was returned!\n\n", bw);
|
||||||
i = 2; // return value
|
i = 2; // return value
|
||||||
#if USE_EXHALELIB_DLL
|
#if USE_EXHALELIB_DLL
|
||||||
exhaleDelete (&exhaleEnc);
|
exhaleDelete (&exhaleEnc);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
0 ICON "exhaleApp.ico"
|
0 ICON "exhaleApp.ico"
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,1,7
|
FILEVERSION 1,1,7,1
|
||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
# 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.
|
# 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.
|
||||||
##
|
##
|
||||||
|
|
||||||
add_library(exhaleLib
|
add_library(exhaleLib
|
||||||
|
@ -101,9 +101,16 @@ void BitAllocator::getChAverageTempFlat (uint8_t meanTempFlatInCh[USAC_MAX_NUM_C
|
|||||||
memcpy (meanTempFlatInCh, m_avgTempFlat, nChannels * sizeof (uint8_t));
|
memcpy (meanTempFlatInCh, m_avgTempFlat, nChannels * sizeof (uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BitAllocator::getRateCtrlFac (const int32_t rateRatio, const unsigned samplingRate, const uint32_t specFlatness)
|
uint16_t BitAllocator::getRateCtrlFac (const int32_t rateRatio, const unsigned samplingRate, const uint32_t specFlatness,
|
||||||
|
const bool prevEightShorts /*= false*/)
|
||||||
{
|
{
|
||||||
|
#if BA_MORE_CBR
|
||||||
|
const int32_t ratioFac = rateRatio * (40 - 5 * m_rateIndex);
|
||||||
|
const uint32_t brRatio = __max ((prevEightShorts ? (ratioFac * ratioFac + (1 << 16)) >> 17 : 0) - SHRT_MIN, __min (USHRT_MAX, ratioFac)) -
|
||||||
|
(m_rateIndex == 2 ? (1 << 11) : 0);
|
||||||
|
#else
|
||||||
const uint32_t brRatio = __max (1 << 15, __min (USHRT_MAX, rateRatio * (36 - 9 * m_rateIndex)));
|
const uint32_t brRatio = __max (1 << 15, __min (USHRT_MAX, rateRatio * (36 - 9 * m_rateIndex)));
|
||||||
|
#endif
|
||||||
const uint16_t mSfmSqr = (m_rateIndex < 2 && samplingRate >= 27713 ? (specFlatness * specFlatness) >> m_rateIndex : 0);
|
const uint16_t mSfmSqr = (m_rateIndex < 2 && samplingRate >= 27713 ? (specFlatness * specFlatness) >> m_rateIndex : 0);
|
||||||
const uint16_t mSfmFac = 256 - (((32 + m_rateIndex) * (specFlatness << 4) - mSfmSqr + (1 << 9)) >> 10);
|
const uint16_t mSfmFac = 256 - (((32 + m_rateIndex) * (specFlatness << 4) - mSfmSqr + (1 << 9)) >> 10);
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// constants, experimental macros
|
// constants, experimental macros
|
||||||
#define BA_EPS 1
|
#define BA_EPS 1
|
||||||
|
#define BA_MORE_CBR 0 // 1: force more constant bit-rate (CBR, experimental!)
|
||||||
|
|
||||||
// class for audio bit-allocation
|
// class for audio bit-allocation
|
||||||
class BitAllocator
|
class BitAllocator
|
||||||
@ -39,7 +40,8 @@ public:
|
|||||||
// public functions
|
// public functions
|
||||||
void getChAverageSpecFlat (uint8_t meanSpecFlatInCh[USAC_MAX_NUM_CHANNELS], const unsigned nChannels);
|
void getChAverageSpecFlat (uint8_t meanSpecFlatInCh[USAC_MAX_NUM_CHANNELS], const unsigned nChannels);
|
||||||
void getChAverageTempFlat (uint8_t meanTempFlatInCh[USAC_MAX_NUM_CHANNELS], const unsigned nChannels);
|
void getChAverageTempFlat (uint8_t meanTempFlatInCh[USAC_MAX_NUM_CHANNELS], const unsigned nChannels);
|
||||||
uint16_t getRateCtrlFac (const int32_t rateRatio, const unsigned samplingRate, const uint32_t specFlatness);
|
uint16_t getRateCtrlFac (const int32_t rateRatio, const unsigned samplingRate, const uint32_t specFlatness,
|
||||||
|
const bool prevEightShorts = false);
|
||||||
uint8_t getScaleFac (const uint32_t sfbStepSize, const int32_t* const sfbSignal, const uint8_t sfbWidth,
|
uint8_t getScaleFac (const uint32_t sfbStepSize, const int32_t* const sfbSignal, const uint8_t sfbWidth,
|
||||||
const uint32_t sfbRmsValue);
|
const uint32_t sfbRmsValue);
|
||||||
unsigned initAllocMemory (LinearPredictor* const linPredictor, const uint8_t numSwb, const uint8_t bitRateMode);
|
unsigned initAllocMemory (LinearPredictor* const linPredictor, const uint8_t numSwb, const uint8_t bitRateMode);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "exhaleLibPch.h"
|
#include "exhaleLibPch.h"
|
||||||
#include "bitStreamWriter.h"
|
#include "bitStreamWriter.h"
|
||||||
|
#include "bitAllocation.h" // define BA_MORE_CBR (more constant bit-rate, experimental!)
|
||||||
|
|
||||||
#ifndef NO_PREROLL_DATA
|
#ifndef NO_PREROLL_DATA
|
||||||
static const uint8_t zeroAu[2][14] = { // single-element AUs incl. SBR for digital silence
|
static const uint8_t zeroAu[2][14] = { // single-element AUs incl. SBR for digital silence
|
||||||
@ -1126,7 +1127,11 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData,
|
|||||||
|
|
||||||
if (framesPerSec > 0.0 && targetRate > 0 && frameCount < UINT_MAX) // running overcoding ratio
|
if (framesPerSec > 0.0 && targetRate > 0 && frameCount < UINT_MAX) // running overcoding ratio
|
||||||
{
|
{
|
||||||
|
#if BA_MORE_CBR
|
||||||
|
*rate = uint32_t (0.5 + (m_auByteCount * framesPerSec) / (__max (framesPerSec, (double) frameCount) * targetRate));
|
||||||
|
#else
|
||||||
*rate = uint32_t (0.5 + (m_auByteCount * framesPerSec) / (__max (20.0 * framesPerSec, (double) frameCount) * targetRate));
|
*rate = uint32_t (0.5 + (m_auByteCount * framesPerSec) / (__max (20.0 * framesPerSec, (double) frameCount) * targetRate));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else *rate = 0; // insufficient data
|
else *rate = 0; // insufficient data
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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"
|
#include "exhaleLibPch.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _ENTROPY_CODING_H_
|
#ifndef _ENTROPY_CODING_H_
|
||||||
|
@ -931,7 +931,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
#if !RESTRICT_TO_AAC
|
#if !RESTRICT_TO_AAC
|
||||||
const uint8_t numSwbCh = (eightShorts ? m_numSwbShort : m_numSwbLong);
|
const uint8_t numSwbCh = (eightShorts ? m_numSwbShort : m_numSwbLong);
|
||||||
#endif
|
#endif
|
||||||
const uint16_t rateFac = m_bitAllocator.getRateCtrlFac (m_priLength ? m_rateFactor : 0, samplingRate, meanSpecFlat[ci]); // RC factor
|
const uint16_t rateFac = m_bitAllocator.getRateCtrlFac (m_rateFactor, samplingRate, meanSpecFlat[ci], coreConfig.icsInfoPrev[ch].windowSequence == EIGHT_SHORT);
|
||||||
uint32_t* stepSizes = &sfbStepSizes[ci * m_numSwbShort * NUM_WINDOW_GROUPS];
|
uint32_t* stepSizes = &sfbStepSizes[ci * m_numSwbShort * NUM_WINDOW_GROUPS];
|
||||||
|
|
||||||
memset (grpData.scaleFactors, 0, (MAX_NUM_SWB_SHORT * NUM_WINDOW_GROUPS) * sizeof (uint8_t));
|
memset (grpData.scaleFactors, 0, (MAX_NUM_SWB_SHORT * NUM_WINDOW_GROUPS) * sizeof (uint8_t));
|
||||||
@ -961,13 +961,13 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
} // for gr
|
} // for gr
|
||||||
|
|
||||||
#if !RESTRICT_TO_AAC
|
#if !RESTRICT_TO_AAC
|
||||||
if ((maxSfbCh > 0) && m_noiseFilling[el] && (m_bitRateMode <= 3 || !eightShorts))
|
if ((maxSfbCh > 0) && m_noiseFilling[el] && (m_shiftValSBR > 0 || m_bitRateMode <= 3 || !eightShorts))
|
||||||
{
|
{
|
||||||
const uint32_t maxSfbCurr = (eightShorts ? (useMaxBandwidth ? 17 - (samplingRate >> 13) // was 14, good for 22.05 - 32 kHz
|
const uint32_t maxSfbCurr = (eightShorts ? (useMaxBandwidth ? __min (15, 17 - (samplingRate >> 13) + (samplingRate >> 15))
|
||||||
: brModeAndFsToMaxSfbShort (m_bitRateMode, samplingRate)) : maxSfbLong);
|
: brModeAndFsToMaxSfbShort (m_bitRateMode, samplingRate)) : maxSfbLong);
|
||||||
const bool keepMaxSfbCurr = ((samplingRate < 37566) || (samplingRate >= 46009 && samplingRate < 55426 && eightShorts));
|
const bool keepMaxSfbCurr = ((samplingRate < 37566) || (samplingRate >= 46009 && samplingRate < 55426 && eightShorts));
|
||||||
const uint8_t numSwbFrame = __min ((numSwbCh * ((maxSfbCh == maxSfbCurr) || (m_bitRateMode <= 2) || (m_shiftValSBR > 0) ? 4u : 3u)) >> 2,
|
const uint8_t numSwbFrame = __min ((numSwbCh * ((maxSfbCh == maxSfbCurr) || (m_bitRateMode <= 2) || (m_shiftValSBR > 0) ? 4u : 3u)) >> 2,
|
||||||
(eightShorts ? maxSfbCh : maxSfbLong) + (m_bitRateMode < 2 || m_bitRateMode > 3 || keepMaxSfbCurr ? 0u : 1u));
|
maxSfbCurr + (m_bitRateMode < 2 || m_bitRateMode > 3 || keepMaxSfbCurr ? 0u : 1u));
|
||||||
|
|
||||||
if ((m_bitRateMode == 0) && (m_numElements == 1) && (samplingRate < 27713) && eightShorts)
|
if ((m_bitRateMode == 0) && (m_numElements == 1) && (samplingRate < 27713) && eightShorts)
|
||||||
{
|
{
|
||||||
@ -994,8 +994,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
if (grpRms[s] < getThr (ch, sfbIdx)) grpData.scaleFactors[s + m_numSwbShort * gr] = 0;
|
if (grpRms[s] < getThr (ch, sfbIdx)) grpData.scaleFactors[s + m_numSwbShort * gr] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ((m_bitRateMode <= 4) && (meanSpecFlat[ci] <= (SCHAR_MAX >> 1))) // lo
|
||||||
if ((m_bitRateMode <= 4) && (meanSpecFlat[ci] <= (SCHAR_MAX >> 1))) // low-RMS
|
|
||||||
{
|
{
|
||||||
for (s = __max (samplingRate < 27713 ? (samplingRate < 18783 ? 17 : 24) : 22, m_specGapFiller.getFirstGapFillSfb ()); s < maxSfbCh; s++)
|
for (s = __max (samplingRate < 27713 ? (samplingRate < 18783 ? 17 : 24) : 22, m_specGapFiller.getFirstGapFillSfb ()); s < maxSfbCh; s++)
|
||||||
{
|
{
|
||||||
@ -1005,7 +1004,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
|
|
||||||
memset (&grpData.scaleFactors[maxSfbCh + m_numSwbShort * gr], 0, (numSwbFrame - maxSfbCh) * sizeof (uint8_t));
|
memset (&grpData.scaleFactors[maxSfbCh + m_numSwbShort * gr], 0, (numSwbFrame - maxSfbCh) * sizeof (uint8_t));
|
||||||
}
|
}
|
||||||
grpData.sfbsPerGroup = coreConfig.icsInfoCurr[ch].maxSfb = numSwbFrame;
|
grpData.sfbsPerGroup = coreConfig.icsInfoCurr[ch].maxSfb = __max (maxSfbCh, numSwbFrame);
|
||||||
}
|
}
|
||||||
if (ch > 0 && coreConfig.commonWindow) // resynchronize the two max_sfb for stereo
|
if (ch > 0 && coreConfig.commonWindow) // resynchronize the two max_sfb for stereo
|
||||||
{
|
{
|
||||||
@ -1023,7 +1022,7 @@ unsigned ExhaleEncoder::psychBitAllocation () // perceptual bit-allocation via s
|
|||||||
{
|
{
|
||||||
for (s = 0; s < 26; s++) m_sfbLoudMem[ch][s][m_frameCount & 31] = BA_EPS;
|
for (s = 0; s < 26; s++) m_sfbLoudMem[ch][s][m_frameCount & 31] = BA_EPS;
|
||||||
}
|
}
|
||||||
#endif // !RESTRICT_TO_AAC
|
#endif
|
||||||
ci++;
|
ci++;
|
||||||
} // for ch
|
} // for ch
|
||||||
|
|
||||||
@ -1325,7 +1324,7 @@ unsigned ExhaleEncoder::quantizationCoding () // apply MDCT quantization and en
|
|||||||
}
|
}
|
||||||
} // for el
|
} // for el
|
||||||
#if !RESTRICT_TO_AAC
|
#if !RESTRICT_TO_AAC
|
||||||
if (m_priLength) m_rateFactor = samplingRate;
|
m_rateFactor = samplingRate; // for RC
|
||||||
#endif
|
#endif
|
||||||
return (errorValue > 0 ? 0 : m_outStream.createAudioFrame (m_elementData, m_entropyCoder, m_mdctSignals, m_mdctQuantMag, m_indepFlag,
|
return (errorValue > 0 ? 0 : m_outStream.createAudioFrame (m_elementData, m_entropyCoder, m_mdctSignals, m_mdctQuantMag, m_indepFlag,
|
||||||
m_numElements, m_numSwbShort, (uint8_t* const) m_tempIntBuf,
|
m_numElements, m_numSwbShort, (uint8_t* const) m_tempIntBuf,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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_LIB_PCH_H_
|
#ifndef _EXHALE_LIB_PCH_H_
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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"
|
#include "exhaleLibPch.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _LAPPED_TRANSFORM_H_
|
#ifndef _LAPPED_TRANSFORM_H_
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/* linearPrediction.cpp - source file for class providing linear prediction capability
|
/* linearPrediction.cpp - source file for class providing linear prediction capability
|
||||||
* 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
|
* 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-
|
* 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.
|
* 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"
|
#include "exhaleLibPch.h"
|
||||||
@ -417,5 +417,5 @@ bool LinearPredictor::similarParCorCoeffs (const short* const parCorCoeffs1, con
|
|||||||
sumAbsDiff += abs (parCorCoeffs1[s] - parCorCoeffs2[s]);
|
sumAbsDiff += abs (parCorCoeffs1[s] - parCorCoeffs2[s]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (sumAbsDiff < ((4u * (unsigned) nCoeffs) << (parCorCoeffBitDepth >> 1)));
|
return (sumAbsDiff + 12u * nCoeffs < ((4u * nCoeffs) << (parCorCoeffBitDepth >> 1)));
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _LINEAR_PREDICTION_H_
|
#ifndef _LINEAR_PREDICTION_H_
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
# 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.
|
# 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.
|
||||||
##
|
##
|
||||||
|
|
||||||
# define as source code library
|
# define as source code library
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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"
|
#include "exhaleLibPch.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _QUANTIZATION_H_
|
#ifndef _QUANTIZATION_H_
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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"
|
#include "exhaleLibPch.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _SPEC_GAP_FILLING_H_
|
#ifndef _SPEC_GAP_FILLING_H_
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "exhaleLibPch.h"
|
#include "exhaleLibPch.h"
|
||||||
#include "stereoProcessing.h"
|
#include "stereoProcessing.h"
|
||||||
|
#include "bitAllocation.h" // define BA_MORE_CBR (more constant bit-rate, experimental!)
|
||||||
|
|
||||||
// static helper functions
|
// static helper functions
|
||||||
static inline uint64_t complexAbsMS (const int32_t realPart, const int32_t imagPart)
|
static inline uint64_t complexAbsMS (const int32_t realPart, const int32_t imagPart)
|
||||||
@ -363,7 +364,7 @@ unsigned StereoProcessor::applyPredJointStereo (int32_t* const mdctSpectrum1, in
|
|||||||
nonZeroPredCoef = true;
|
nonZeroPredCoef = true;
|
||||||
}
|
}
|
||||||
sfbTempVar *= sfbTempVar; // account for residual RMS reduction due to prediction
|
sfbTempVar *= sfbTempVar; // account for residual RMS reduction due to prediction
|
||||||
#if SP_MDST_PRED
|
#if SP_MDST_PRED && !(BA_MORE_CBR)
|
||||||
if (bitRateMode > 0) sfbTempVar += alphaLimit * alphaLimit; // including alpha_im
|
if (bitRateMode > 0) sfbTempVar += alphaLimit * alphaLimit; // including alpha_im
|
||||||
#endif
|
#endif
|
||||||
for (b = sfbIsOdd; b >= 0; b--)
|
for (b = sfbIsOdd; b >= 0; b--)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _STEREO_PROCESSING_H_
|
#ifndef _STEREO_PROCESSING_H_
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
* 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.
|
* 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 _TEMP_ANALYSIS_H_
|
#ifndef _TEMP_ANALYSIS_H_
|
||||||
|
Reference in New Issue
Block a user