diff --git a/CMakeLists.txt b/CMakeLists.txt index bb06e18..0533d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ ## CMakeLists.txt - Main CMake file that defines how cmake should process and generate the necessary build files - # written by C. D. Degawa, last modified in 2020 - see License.htm for legal notices + # written by C. D. Degawa, 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. ## cmake_minimum_required(VERSION 3.5) # Default version of cmake on Ubuntu 16.04 @@ -16,7 +16,7 @@ if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") endif() -project(exhale VERSION 1.1.1 LANGUAGES CXX) +project(exhale VERSION 1.1.2 LANGUAGES CXX) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE Release diff --git a/README.md b/README.md index 0a2580b..c447b21 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ ____________________________________________________________________ Copyright --------- -(c) 2020 Christian R. Helmrich, project ecodis. All rights reserved. +(c) 2021 Christian R. Helmrich, project ecodis. All rights reserved. License @@ -33,7 +33,7 @@ exhale is being made available under an open-source license which is based on the 3-clause BSD license but modified to address particular aspects dictated by the nature and the output of this application. -The license text and release notes for the current version 1.1.1 can +The license text and release notes for the current version 1.1.2 can be found in the `include` subdirectory of the exhale distribution. diff --git a/include/version.h b/include/version.h index 1795086..a93f027 100644 --- a/include/version.h +++ b/include/version.h @@ -1,11 +1,11 @@ /* version.h - header file with major and minor library version numbers as characters - * 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. */ #ifndef EXHALELIB_VERSION_MAJOR diff --git a/src/app/basicMP4Writer.cpp b/src/app/basicMP4Writer.cpp index 7acb573..b35a64a 100644 --- a/src/app/basicMP4Writer.cpp +++ b/src/app/basicMP4Writer.cpp @@ -1,5 +1,5 @@ /* basicMP4Writer.cpp - source file for class with basic MPEG-4 file writing 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 * pre-roll serializer and related code added by J. Calhoun in 2020, see merge request 4 * * The copyright in this software is being made available under the exhale Copyright License diff --git a/src/app/exhaleApp.cpp b/src/app/exhaleApp.cpp index e1169ee..ba3c8aa 100644 --- a/src/app/exhaleApp.cpp +++ b/src/app/exhaleApp.cpp @@ -1,5 +1,5 @@ /* exhaleApp.cpp - source file with main() routine for exhale application executable - * 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- @@ -362,7 +362,7 @@ int main (const int argc, char* argv[]) // check arg. list, print usage if needed if ((argc < 3) || (argc > 4) || (argc > 1 && argv[1][1] != 0)) { - fprintf_s (stdout, " Copyright 2018-2020 C.R.Helmrich, project ecodis. See License.htm for details.\n\n"); + fprintf_s (stdout, " Copyright 2018-2021 C.R.Helmrich, project ecodis. See License.htm for details.\n\n"); fprintf_s (stdout, " This software is made available under the exhale Copyright License and comes\n"); fprintf_s (stdout, " with ABSOLUTELY NO WARRANTY. This software may be subject to other third-party\n"); diff --git a/src/app/exhaleApp.rc b/src/app/exhaleApp.rc index 11e513c..9968b6f 100644 --- a/src/app/exhaleApp.rc +++ b/src/app/exhaleApp.rc @@ -1,11 +1,11 @@ /* exhaleApp.rc - resource file for exhale application binaries compiled under Windows - * 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 "..\..\include\version.h" // for EXHALELIB_VERSION_... strings @@ -13,7 +13,7 @@ 0 ICON "exhaleApp.ico" VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,1,1 +FILEVERSION 1,1,2 BEGIN BLOCK "StringFileInfo" BEGIN @@ -22,7 +22,7 @@ BEGIN VALUE "CompanyName", "ecodis" VALUE "FileDescription", "exhale - ecodis extended high-efficiency and low-complexity encoder" VALUE "InternalName", "exhaleApp.exe" - VALUE "LegalCopyright", "© 2018-2020 C. R. Helmrich, ecodis" + VALUE "LegalCopyright", "© 2018-2021 C. R. Helmrich, ecodis" VALUE "OriginalFilename", "exhale.exe" VALUE "ProductName", "exhaleApp" VALUE "ProductVersion", EXHALELIB_VERSION_MAJOR "." EXHALELIB_VERSION_MINOR EXHALELIB_VERSION_BUGFIX diff --git a/src/lib/bitStreamWriter.cpp b/src/lib/bitStreamWriter.cpp index 2444f28..760bb3b 100644 --- a/src/lib/bitStreamWriter.cpp +++ b/src/lib/bitStreamWriter.cpp @@ -1,5 +1,5 @@ /* bitStreamWriter.cpp - source file for class with basic bit-stream writing 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 * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- @@ -11,6 +11,13 @@ #include "exhaleLibPch.h" #include "bitStreamWriter.h" +#ifndef NO_PREROLL_DATA +static const uint8_t zeroAu[2][14] = { // single-element AUs incl. SBR for digital silence + {132, 0, 2, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // SCE, 8 bytes + {132, 129, 16, 0, 8, 0, 0, 32, 0, 0, 0, 0, 0, 0} // CPE, 14 bytes +}; +#endif + // static helper functions static inline int getPredCoefPrevGrp (const uint8_t aqIdxPrevGrp) { @@ -820,11 +827,19 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData, const bool usacIndependencyFlag, const uint8_t numElements, const uint8_t numSwbShort, uint8_t* const tempBuffer, #if !RESTRICT_TO_AAC - const bool* const tw_mdct /*N/A*/, const bool* const noiseFilling, const bool ipf, + const bool* const tw_mdct /*N/A*/, const bool* const noiseFilling, + const uint32_t frameCount, const uint32_t indepPeriod, #endif const uint8_t sbrRatioShiftValue, int32_t** const sbrInfoAndData, unsigned char* const accessUnit, const unsigned nSamplesInFrame /*= 1024*/) { +#ifndef NO_PREROLL_DATA +# if RESTRICT_TO_AAC + const uint8_t ipf = 0; +# else + const uint8_t ipf = (frameCount == 1 ? 2 : ((frameCount % indepPeriod) == 1 ? 1 : 0)); +# endif +#endif unsigned bitCount = 1, ci = 0; if ((elementData == nullptr) || (entropyCoder == nullptr) || (tempBuffer == nullptr) || (sbrInfoAndData == nullptr) || @@ -853,7 +868,9 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData, m_auBitStream.write (ipf ? 1 : 0, 1); // UsacExtElement, usacExtElementPresent if (ipf) { - const unsigned payloadLength = bitCount + 3; // ext. payload size, in bytes! + const uint16_t idxPreRollExt = (uint16_t) elementData[0]->elementType; + const bool lowRatePreRollExt = (ipf == 1 && numElements == 1 && idxPreRollExt < ID_USAC_LFE); + const unsigned payloadLength = (lowRatePreRollExt ? 8 + idxPreRollExt * 6 : bitCount) + 3; // in bytes! m_auBitStream.write (0, 1); // usacExtElementUseDefaultLength = 0 (variable) m_auBitStream.write (CLIP_UCHAR (payloadLength), 8); @@ -861,9 +878,16 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData, m_auBitStream.write (0, 6); // start AudioPreRoll - configLen = reserved = 0 m_auBitStream.write (1, 2); // numPreRollFrames, only one supported for now! - m_auBitStream.write (bitCount, 16); // auLen + m_auBitStream.write (payloadLength - 3, 16); // auLen - while (ci < bitCount) m_auBitStream.write (tempBuffer[ci++], 8); // write AU + if (lowRatePreRollExt) + { + while (ci < payloadLength - 3) m_auBitStream.write (zeroAu[idxPreRollExt][ci++], 8); + } + else + { + while (ci < bitCount) m_auBitStream.write (tempBuffer[ci++], 8); // write last AU + } ci = 0; bitCount = (payloadLength > 254 ? 26 : 10) + (payloadLength << 3); // for ext. bits } diff --git a/src/lib/bitStreamWriter.h b/src/lib/bitStreamWriter.h index 4605cd4..b747c37 100644 --- a/src/lib/bitStreamWriter.h +++ b/src/lib/bitStreamWriter.h @@ -1,5 +1,5 @@ /* bitStreamWriter.h - header file for class with basic bit-stream writing 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 * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- @@ -68,7 +68,8 @@ public: const bool usacIndependencyFlag, const uint8_t numElements, const uint8_t numSwbShort, uint8_t* const tempBuffer, #if !RESTRICT_TO_AAC - const bool* const tw_mdct /*N/A*/, const bool* const noiseFilling, const bool ipf, + const bool* const tw_mdct /*N/A*/, const bool* const noiseFilling, + const uint32_t frameCount, const uint32_t indepPeriod, #endif const uint8_t sbrRatioShiftValue, int32_t** const sbrInfoAndData, unsigned char* const accessUnit, const unsigned nSamplesInFrame = 1024); diff --git a/src/lib/exhaleEnc.cpp b/src/lib/exhaleEnc.cpp index 50bbbfd..0098cb1 100644 --- a/src/lib/exhaleEnc.cpp +++ b/src/lib/exhaleEnc.cpp @@ -1,5 +1,5 @@ /* exhaleEnc.cpp - source file for class providing Extended HE-AAC encoding 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 * and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third- @@ -1327,7 +1327,7 @@ unsigned ExhaleEncoder::quantizationCoding () // apply MDCT quantization and en m_coreSignals[ci][0] |= getSbrEnvelopeAndNoise (&m_coreSignals[ci][nSamplesTempAna - 64 + nSamplesInFrame], msfVal, __max (m_meanTempPrev[ci], meanTempFlat[ci]) >> 3, m_bitRateMode == 0, m_indepFlag, msfSte, tmpValSynch, nSamplesInFrame, &m_coreSignals[ci][1]); - if (ch + 1 == nrChannels) // update flatness histories - TODO: coupling + if (ch + 1 == nrChannels) // update the flatness histories { m_meanSpecPrev[ci] = meanSpecFlat[ci]; m_meanSpecPrev[s] = meanSpecFlat[s]; m_meanTempPrev[ci] = meanTempFlat[ci]; m_meanTempPrev[s] = meanTempFlat[s]; @@ -1340,7 +1340,7 @@ unsigned ExhaleEncoder::quantizationCoding () // apply MDCT quantization and en 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, #if !RESTRICT_TO_AAC - m_timeWarping, m_noiseFilling, (m_frameCount == 2), + m_timeWarping, m_noiseFilling, m_frameCount - 1u, m_indepPeriod, #endif m_shiftValSBR, m_coreSignals, m_outAuData, nSamplesInFrame)); // returns AU size } @@ -1841,7 +1841,7 @@ ExhaleEncoder::ExhaleEncoder (int32_t* const inputPcmData, unsigned ch m_frameLength = USAC_CCFL (frameLength >> m_shiftValSBR); // ccfl signaled using coreSbrFrameLengthIndex m_frequencyIdx = toSamplingFrequencyIndex (sampleRate >> m_shiftValSBR); // as usacSamplingFrequencyIndex m_indepFlag = true; // usacIndependencyFlag in UsacFrame(), will be set per frame, true in first frame - m_indepPeriod = (indepPeriod == 0 ? UINT_MAX : indepPeriod); // RAP, signaled using usacIndependencyFlag + m_indepPeriod = (indepPeriod == 0 ? USHRT_MAX : indepPeriod); // RAP signaled using usacIndependencyFlag #if !RESTRICT_TO_AAC m_nonMpegExt = useEcodisExt; #endif