mirror of
https://gitlab.com/ecodis/exhale.git
synced 2025-01-06 20:21:06 +01:00
finish 1.1.2 release
This commit is contained in:
parent
44f6b15bb8
commit
0b14fafc2d
@ -96,13 +96,12 @@ int BasicMP4Writer::finishFile (const unsigned avgBitrate, const unsigned maxBit
|
||||
const uint32_t stszAtomSize = STSX_BSIZE + 4 /*bytes for sampleSize*/ + m_frameCount * 4;
|
||||
const uint32_t stscAtomSize = STSX_BSIZE + (numFramesFinalPeriod == 0 ? 12 : 24);
|
||||
const uint32_t stcoAtomSize = STSX_BSIZE + (uint32_t) m_rndAccOffsets.size () * 4;
|
||||
#ifndef NO_FIX_FOR_ISSUE_1
|
||||
# ifndef NO_FIX_FOR_ISSUE_13
|
||||
const uint32_t chunkCount = (m_frameCount + m_rndAccPeriod - 1) / m_rndAccPeriod;
|
||||
const uint32_t stssAtomSize = STSX_BSIZE + chunkCount * 4; // NOTE: must equal stcoAtomSize
|
||||
# else
|
||||
#ifdef NO_PREROLL_DATA
|
||||
const uint32_t stssAtomSize = STSX_BSIZE + 4;
|
||||
# endif
|
||||
#else
|
||||
const uint32_t preRollCount = (m_frameCount + (m_rndAccPeriod << 1) - 1) / (m_rndAccPeriod << 1);
|
||||
const uint32_t stssAtomSize = STSX_BSIZE + preRollCount * 4;
|
||||
#endif
|
||||
// The following code creates a 'prol' sample group with a repeating pattern of membership,
|
||||
// indicating that the first sample in each increment of m_rndAccPeriod samples is a member
|
||||
// and therefore an independent frame (IF), and the remainder are not.
|
||||
@ -115,9 +114,6 @@ int BasicMP4Writer::finishFile (const unsigned avgBitrate, const unsigned maxBit
|
||||
const uint32_t sampleCountSize = (m_frameCount > UINT16_MAX ? 4 : (m_frameCount > UINT8_MAX ? 2 : 1));
|
||||
const uint32_t csgpAtomSize = STSX_BSIZE + 4 /*patternCount == 1*/ + patternLengthSize + sampleCountSize + compPatternLength;
|
||||
const uint32_t stblIncrSize = m_ascSizeM5 + stszAtomSize + stscAtomSize + stcoAtomSize + stssAtomSize + sgpdAtomSize + csgpAtomSize;
|
||||
#else
|
||||
const uint32_t stblIncrSize = m_ascSizeM5 + stszAtomSize + stscAtomSize + stcoAtomSize;
|
||||
#endif
|
||||
const uint32_t moovAtomSize = toBigEndian (toUShortValue (MOOV_BSIZE) + stblIncrSize);
|
||||
const uint32_t trakAtomSize = toBigEndian (toUShortValue (TRAK_BSIZE) + stblIncrSize);
|
||||
const uint32_t mdiaAtomSize = toBigEndian (toUShortValue (MDIA_BSIZE) + stblIncrSize);
|
||||
@ -232,7 +228,7 @@ int BasicMP4Writer::finishFile (const unsigned avgBitrate, const unsigned maxBit
|
||||
m_dynamicHeader.push_back ((rndAccOffset >> 8) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ( rndAccOffset & UCHAR_MAX);
|
||||
}
|
||||
#ifndef NO_FIX_FOR_ISSUE_1
|
||||
|
||||
m_dynamicHeader.push_back ((stssAtomSize >> 24) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((stssAtomSize >> 16) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((stssAtomSize >> 8) & UCHAR_MAX);
|
||||
@ -241,24 +237,24 @@ int BasicMP4Writer::finishFile (const unsigned avgBitrate, const unsigned maxBit
|
||||
m_dynamicHeader.push_back (0x73); m_dynamicHeader.push_back (0x73); // stss
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
# ifndef NO_FIX_FOR_ISSUE_13
|
||||
m_dynamicHeader.push_back ((chunkCount >> 24) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((chunkCount >> 16) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((chunkCount >> 8) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ( chunkCount & UCHAR_MAX);
|
||||
for (uint32_t i = 1; i <= m_frameCount; i += m_rndAccPeriod)
|
||||
#ifdef NO_PREROLL_DATA
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x01); // 1 entry
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x01); // 1st AU
|
||||
#else
|
||||
m_dynamicHeader.push_back ((preRollCount >> 24) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((preRollCount >> 16) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((preRollCount >> 8) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ( preRollCount & UCHAR_MAX);
|
||||
for (uint32_t i = 1; i <= m_frameCount; i += (m_rndAccPeriod << 1))
|
||||
{
|
||||
m_dynamicHeader.push_back ((i >> 24) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((i >> 16) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((i >> 8) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ( i & UCHAR_MAX);
|
||||
}
|
||||
# else
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x01); // 1 entry
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x00);
|
||||
m_dynamicHeader.push_back (0x00); m_dynamicHeader.push_back (0x01); // 1st AU
|
||||
# endif
|
||||
#endif
|
||||
m_dynamicHeader.push_back ((sgpdAtomSize >> 24) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((sgpdAtomSize >> 16) & UCHAR_MAX);
|
||||
m_dynamicHeader.push_back ((sgpdAtomSize >> 8) & UCHAR_MAX);
|
||||
@ -307,7 +303,6 @@ int BasicMP4Writer::finishFile (const unsigned avgBitrate, const unsigned maxBit
|
||||
{
|
||||
m_dynamicHeader.push_back (0x00); // remaining 4-bit pairs of non-members
|
||||
}
|
||||
#endif
|
||||
|
||||
const uint32_t moovAndMdatOverhead = STAT_HEADER_SIZE + (uint32_t) m_dynamicHeader.size () + 8;
|
||||
const uint32_t headerPaddingLength = uint32_t (m_mediaOffset - moovAndMdatOverhead);
|
||||
@ -371,15 +366,12 @@ int BasicMP4Writer::initHeader (const uint32_t audioLength) // reserve bytes for
|
||||
#endif
|
||||
const unsigned chunkCount = ((frameCount + m_rndAccPeriod - 1) / m_rndAccPeriod);
|
||||
const unsigned finalChunk = (frameCount <= m_rndAccPeriod ? 0 : frameCount % m_rndAccPeriod);
|
||||
#ifndef NO_FIX_FOR_ISSUE_1
|
||||
const unsigned smpGrpSize = 10 /*sgpd*/ + (m_rndAccPeriod > UINT8_MAX ? 10 : 9) + ((m_rndAccPeriod + 1) >> 1) /*csgp*/;
|
||||
# ifndef NO_FIX_FOR_ISSUE_13
|
||||
const int estimHeaderSize = STAT_HEADER_SIZE + m_ascSizeM5 + 6+4 + frameCount * 4 /*stsz*/ + STSX_BSIZE * 6 + smpGrpSize + chunkCount * 4 /*stss*/ +
|
||||
# else
|
||||
const int estimHeaderSize = STAT_HEADER_SIZE + m_ascSizeM5 + 6+4 + frameCount * 4 /*stsz*/ + STSX_BSIZE * 6 + smpGrpSize + 4 /*stss*/ +
|
||||
# endif
|
||||
const int estimHeaderSize = STAT_HEADER_SIZE + m_ascSizeM5 + 6 + 4 + frameCount * 4 /*stsz*/ + STSX_BSIZE * 6 + smpGrpSize +
|
||||
#ifdef NO_PREROLL_DATA
|
||||
4 /*minimum stss*/ +
|
||||
#else
|
||||
const int estimHeaderSize = STAT_HEADER_SIZE + m_ascSizeM5 + 6+4 + frameCount * 4 /*stsz*/ + STSX_BSIZE * 3 +
|
||||
((chunkCount + 1) >> 1) * 4 /*stss*/ +
|
||||
#endif
|
||||
(finalChunk == 0 ? 12 : 24) /*stsc*/ + chunkCount * 4 /*stco*/ + 8 /*mdat*/;
|
||||
int bytesWritten = 0;
|
||||
@ -411,11 +403,7 @@ unsigned BasicMP4Writer::open (const int mp4FileHandle, const unsigned sampleRat
|
||||
}
|
||||
|
||||
m_fileHandle = mp4FileHandle;
|
||||
#ifndef NO_FIX_FOR_ISSUE_1
|
||||
reset (frameLength, pregapLength, __min (USHRT_MAX, raPeriod));
|
||||
#else
|
||||
reset (frameLength, pregapLength, raPeriod);
|
||||
#endif
|
||||
|
||||
// create fixed-length 576-byte part of MPEG-4 file header
|
||||
memcpy (m_staticHeader, staticHeaderTemplate, STAT_HEADER_SIZE * sizeof (uint8_t));
|
||||
|
@ -834,25 +834,24 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData,
|
||||
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
|
||||
const uint8_t ipf = (frameCount == 1 ? 2 : ((frameCount % (indepPeriod << 1)) == 1 ? 1 : 0));
|
||||
#endif
|
||||
unsigned bitCount = 1, ci = 0;
|
||||
|
||||
if ((elementData == nullptr) || (entropyCoder == nullptr) || (tempBuffer == nullptr) || (sbrInfoAndData == nullptr) ||
|
||||
(mdctSignals == nullptr) || (mdctQuantMag == nullptr) || (accessUnit == nullptr) || (nSamplesInFrame > 2048) ||
|
||||
#if !RESTRICT_TO_AAC
|
||||
(noiseFilling == nullptr) || (tw_mdct == nullptr) || (ipf && !usacIndependencyFlag) ||
|
||||
(noiseFilling == nullptr) || (tw_mdct == nullptr) ||
|
||||
# ifndef NO_PREROLL_DATA
|
||||
(ipf && !usacIndependencyFlag) ||
|
||||
# endif
|
||||
#endif
|
||||
(numElements == 0) || (numElements > USAC_MAX_NUM_ELEMENTS) || (numSwbShort < MIN_NUM_SWB_SHORT) || (numSwbShort > MAX_NUM_SWB_SHORT))
|
||||
{
|
||||
return 0; // invalid arguments error
|
||||
}
|
||||
#ifndef NO_PREROLL_DATA
|
||||
if ((ipf == 2) || (ipf == 1 && (numElements > 1 || !noiseFilling[0]))) // previous AU
|
||||
if ((ipf == 2) || (ipf == 1 && (numElements > 1 || !noiseFilling[0])))
|
||||
{
|
||||
bitCount = __min (nSamplesInFrame << 2, (uint32_t) m_auBitStream.stream.size ());
|
||||
memcpy (tempBuffer, &m_auBitStream.stream.front (), bitCount);
|
||||
@ -874,7 +873,7 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData,
|
||||
|
||||
m_auBitStream.write (0, 1); // usacExtElementUseDefaultLength = 0 (variable)
|
||||
m_auBitStream.write (CLIP_UCHAR (payloadLength), 8);
|
||||
if (payloadLength > 254) m_auBitStream.write (payloadLength - 253, 16); // valueAdd
|
||||
if (payloadLength > 254) m_auBitStream.write (payloadLength - 253, 16);
|
||||
|
||||
m_auBitStream.write (0, 6); // start AudioPreRoll - configLen = reserved = 0
|
||||
m_auBitStream.write (1, 2); // numPreRollFrames, only one supported for now!
|
||||
@ -894,10 +893,10 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData,
|
||||
}
|
||||
while (ci < bitCount) m_auBitStream.write (tempBuffer[ci++], 8); // write AU
|
||||
ci = 0;
|
||||
bitCount = (payloadLength > 254 ? 26 : 10) + (payloadLength << 3); // for ext. bits
|
||||
bitCount = (payloadLength > 254 ? 26 : 10) + (payloadLength << 3); // for PR
|
||||
}
|
||||
bitCount++; // for ElementPresent flag
|
||||
#endif
|
||||
#endif // !NO_PREROLL_DATA
|
||||
for (unsigned el = 0; el < numElements; el++) // el element loop
|
||||
{
|
||||
const CoreCoderData* const elData = elementData[el];
|
||||
@ -998,7 +997,7 @@ unsigned BitStreamWriter::createAudioFrame (CoreCoderData** const elementData,
|
||||
bitCount += (8 - m_auBitStream.heldBitCount) & 7;
|
||||
writeByteAlignment (); // flush bytes
|
||||
|
||||
#if RESTRICT_TO_AAC
|
||||
#if RESTRICT_TO_AAC || defined (NO_PREROLL_DATA)
|
||||
memcpy (accessUnit, &m_auBitStream.stream.front (), __min (768 * ci, bitCount >> 3));
|
||||
#else
|
||||
memcpy (accessUnit, &m_auBitStream.stream.front (), __min (ci * (ipf ? 1152 : 768), bitCount >> 3));
|
||||
|
@ -1640,10 +1640,10 @@ unsigned ExhaleEncoder::temporalProcessing () // determine time-domain aspects o
|
||||
m_tempAnalyzer.getTempAnalysisStats (m_tempAnaNext, nChannels);
|
||||
m_tempAnalyzer.getTransientAndPitch (m_tranLocNext, nChannels);
|
||||
|
||||
#ifndef NO_FIX_FOR_ISSUE_1
|
||||
m_indepFlag = (((m_frameCount++) % m_indepPeriod) <= 1); // configure usacIndependencyFlag
|
||||
#else
|
||||
#ifdef NO_PREROLL_DATA
|
||||
m_indepFlag = (((m_frameCount++) % m_indepPeriod) == 0); // configure usacIndependencyFlag
|
||||
#else
|
||||
m_indepFlag = (((m_frameCount++) % m_indepPeriod) <= 1); // configure usacIndependencyFlag
|
||||
#endif
|
||||
|
||||
for (unsigned el = 0; el < m_numElements; el++) // element loop
|
||||
@ -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 ? USHRT_MAX : indepPeriod); // RAP signaled using usacIndependencyFlag
|
||||
m_indepPeriod = (indepPeriod == 0 ? USHRT_MAX : __min (USHRT_MAX, indepPeriod)); // random-access period
|
||||
#if !RESTRICT_TO_AAC
|
||||
m_nonMpegExt = useEcodisExt;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user