mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-31 14:37:59 +00:00
inputstream.adaptive: [ADTS] add support for AC3 and E-AC3
This commit is contained in:
parent
496e856dd5
commit
aa86c4db0b
@ -0,0 +1,595 @@
|
||||
From d2a2f40f0724925c8e91d4259a89ea98338b4a6a Mon Sep 17 00:00:00 2001
|
||||
From: Glenn Guy <glennguy@users.noreply.github.com>
|
||||
Date: Mon, 29 May 2023 10:53:46 +1000
|
||||
Subject: [PATCH 1/2] [ADTS] add support for AC3 and E-AC3
|
||||
|
||||
---
|
||||
CMakeLists.txt | 2 +
|
||||
src/ADTSReader.cpp | 149 ++++++++++++++++++------
|
||||
src/ADTSReader.h | 14 ++-
|
||||
src/parser/CodecParser.cpp | 230 +++++++++++++++++++++++++++++++++++++
|
||||
src/parser/CodecParser.h | 60 ++++++++++
|
||||
5 files changed, 417 insertions(+), 38 deletions(-)
|
||||
create mode 100644 src/parser/CodecParser.cpp
|
||||
create mode 100644 src/parser/CodecParser.h
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6225ef8bd..6601fbbc6 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -37,6 +37,7 @@ set(ADP_SOURCES
|
||||
src/common/Segment.cpp
|
||||
src/common/SegmentList.cpp
|
||||
src/common/SegTemplate.cpp
|
||||
+ src/parser/CodecParser.cpp
|
||||
src/parser/DASHTree.cpp
|
||||
src/parser/HLSTree.cpp
|
||||
src/parser/SmoothTree.cpp
|
||||
@@ -102,6 +103,7 @@ set(ADP_HEADERS
|
||||
src/common/Segment.h
|
||||
src/common/SegmentList.h
|
||||
src/common/SegTemplate.h
|
||||
+ src/parser/CodecParser.h
|
||||
src/parser/DASHTree.h
|
||||
src/parser/HLSTree.h
|
||||
src/parser/SmoothTree.h
|
||||
diff --git a/src/ADTSReader.cpp b/src/ADTSReader.cpp
|
||||
index c0256a63c..58ee74a8b 100644
|
||||
--- a/src/ADTSReader.cpp
|
||||
+++ b/src/ADTSReader.cpp
|
||||
@@ -7,9 +7,15 @@
|
||||
*/
|
||||
|
||||
#include "ADTSReader.h"
|
||||
-#include <bento4/Ap4ByteStream.h>
|
||||
+
|
||||
+#include "parser/CodecParser.h"
|
||||
+#include "utils/log.h"
|
||||
+
|
||||
#include <stdlib.h>
|
||||
|
||||
+#include <bento4/Ap4ByteStream.h>
|
||||
+using namespace adaptive;
|
||||
+
|
||||
uint64_t ID3TAG::getSize(const uint8_t *data, unsigned int len, unsigned int shift)
|
||||
{
|
||||
uint64_t size(0);
|
||||
@@ -73,62 +79,141 @@ ID3TAG::PARSECODE ID3TAG::parse(AP4_ByteStream *stream)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
|
||||
-uint64_t ADTSFrame::getBE(const uint8_t *data, unsigned int len)
|
||||
+void ADTSFrame::AdjustStreamForPadding(AP4_ByteStream* stream)
|
||||
{
|
||||
- uint64_t size(0);
|
||||
- const uint8_t *dataE(data + len);
|
||||
- for (; data < dataE; ++data)
|
||||
- size = size << 8 | *data;
|
||||
- return size;
|
||||
-};
|
||||
+ AP4_Position currentPos;
|
||||
+ AP4_Position newPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos + 16);
|
||||
+ stream->Tell(newPos);
|
||||
+ if (newPos - currentPos == 16)
|
||||
+ stream->Seek(currentPos);
|
||||
+}
|
||||
|
||||
-bool ADTSFrame::parse(AP4_ByteStream *stream)
|
||||
+bool ADTSFrame::parse(AP4_ByteStream* stream)
|
||||
{
|
||||
- uint8_t buffer[64];
|
||||
+ AdtsType adtsType = CAdaptiveAdtsHeaderParser::GetAdtsType(stream);
|
||||
+ switch (adtsType)
|
||||
+ {
|
||||
+ case AdtsType::AAC:
|
||||
+ return ParseAac(stream);
|
||||
+ case AdtsType::AC3:
|
||||
+ return ParseAc3(stream);
|
||||
+ case AdtsType::EAC3:
|
||||
+ return ParseEc3(stream);
|
||||
+ case AdtsType::AC4:
|
||||
+ return false;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
|
||||
- static const uint32_t freqTable[13] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
|
||||
+bool ADTSFrame::ParseAac(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(16);
|
||||
|
||||
- if (!AP4_SUCCEEDED(stream->Read(buffer, 2)))
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_ADTS_HEADER_SIZE)))
|
||||
return false;
|
||||
|
||||
- m_outerHeader = static_cast<uint16_t>(getBE(buffer, 2));
|
||||
- if ((m_outerHeader & 0xFFF6u) != 0xFFF0u)
|
||||
+ CAdaptiveAdtsParser parser;
|
||||
+ AP4_AacFrame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
return false;
|
||||
|
||||
- m_innerHeaderSize = (m_outerHeader & 1) ? 7 : 5; // 16 bit CRC
|
||||
- if (!AP4_SUCCEEDED(stream->Read(buffer, m_innerHeaderSize)))
|
||||
+ m_totalSize = frame.m_Info.m_FrameLength + AP4_ADTS_HEADER_SIZE;
|
||||
+ m_frameCount = 1024;
|
||||
+ m_summedFrameCount += m_frameCount;
|
||||
+ m_sampleRate = frame.m_Info.m_SamplingFrequency;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelConfiguration;
|
||||
+
|
||||
+ // rewind stream to beginning of syncframe
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_ADTS_HEADER_SIZE));
|
||||
+
|
||||
+ m_dataBuffer.SetDataSize(m_totalSize);
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
return false;
|
||||
|
||||
- m_innerHeader = getBE(buffer, m_innerHeaderSize);
|
||||
- // add 0 crc to have bits on same place for crc / nocrc
|
||||
- m_innerHeader <<= ((7 - m_innerHeaderSize) * 8);
|
||||
+ AdjustStreamForPadding(stream);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool ADTSFrame::ParseAc3(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_AC3_HEADER_SIZE);
|
||||
|
||||
- m_totalSize = (m_innerHeader >> 0x1D) & 0x1FFFu;
|
||||
- m_frameCount = ((m_innerHeader >> 0x10) & 0x3u) ? 960 : 1024;
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_AC3_HEADER_SIZE)))
|
||||
+ return false;
|
||||
+
|
||||
+ CAdaptiveAc3Parser parser;
|
||||
+ AP4_Ac3Frame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
+ return false;
|
||||
+
|
||||
+ m_totalSize = frame.m_Info.m_FrameSize;
|
||||
+ m_sampleRate = frame.m_Info.m_SampleRate;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelCount;
|
||||
+ m_frameCount = 256 * m_channelCount;
|
||||
m_summedFrameCount += m_frameCount;
|
||||
- m_sampleRate = (m_innerHeader >> 0x32) & 0xFu;
|
||||
- m_sampleRate = (m_sampleRate < 13) ? freqTable[m_sampleRate] : 0;
|
||||
- m_channelConfig = (m_innerHeader >> 0x2E) & 0x7u;
|
||||
|
||||
+ // rewind stream to beginning of syncframe
|
||||
AP4_Position currentPos;
|
||||
stream->Tell(currentPos);
|
||||
- stream->Seek(currentPos - (m_innerHeaderSize + 2));
|
||||
+ stream->Seek(currentPos - (AP4_AC3_HEADER_SIZE));
|
||||
|
||||
m_dataBuffer.SetDataSize(m_totalSize);
|
||||
if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
return false;
|
||||
|
||||
- //ADTS Streams have padding, at EOF
|
||||
- AP4_Position pos, posNew;
|
||||
- stream->Tell(pos);
|
||||
- stream->Seek(pos + 16);
|
||||
- stream->Tell(posNew);
|
||||
- if (posNew - pos == 16)
|
||||
- stream->Seek(pos);
|
||||
+ AdjustStreamForPadding(stream);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool ADTSFrame::ParseEc3(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_EAC3_HEADER_SIZE);
|
||||
+
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_EAC3_HEADER_SIZE)))
|
||||
+ return false;
|
||||
+
|
||||
+ CAdaptiveEac3Parser parser;
|
||||
+ AP4_Eac3Frame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
+ return false;
|
||||
|
||||
+ m_totalSize = frame.m_Info.m_FrameSize;
|
||||
+ m_sampleRate = frame.m_Info.m_SampleRate;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelCount;
|
||||
+ m_frameCount = 256 * m_channelCount;
|
||||
+ m_summedFrameCount += m_frameCount;
|
||||
+
|
||||
+ // rewind stream to beginning of syncframe
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_EAC3_HEADER_SIZE));
|
||||
+
|
||||
+ m_dataBuffer.SetDataSize(m_totalSize);
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
+ return false;
|
||||
+
|
||||
+ AdjustStreamForPadding(stream);
|
||||
return true;
|
||||
}
|
||||
|
||||
+
|
||||
/**********************************************************************************************************************************/
|
||||
|
||||
|
||||
diff --git a/src/ADTSReader.h b/src/ADTSReader.h
|
||||
index e5ba05431..8f1af5d95 100644
|
||||
--- a/src/ADTSReader.h
|
||||
+++ b/src/ADTSReader.h
|
||||
@@ -42,7 +42,14 @@ class ATTR_DLL_LOCAL ID3TAG
|
||||
class ATTR_DLL_LOCAL ADTSFrame
|
||||
{
|
||||
public:
|
||||
+ /*! \brief Adjust the stream position to advance over padding if neccessary (end of file)
|
||||
+ * \param stream The stream to check
|
||||
+ */
|
||||
+ void AdjustStreamForPadding(AP4_ByteStream* stream);
|
||||
bool parse(AP4_ByteStream *stream);
|
||||
+ bool ParseAac(AP4_ByteStream* stream);
|
||||
+ bool ParseAc3(AP4_ByteStream* stream);
|
||||
+ bool ParseEc3(AP4_ByteStream* stream);
|
||||
void reset() { m_summedFrameCount = 0; m_frameCount = 0; m_dataBuffer.SetDataSize(0); }
|
||||
void resetFrameCount() { m_summedFrameCount = 0; }
|
||||
uint64_t getPtsOffset() const { return m_sampleRate ? (static_cast<uint64_t>(m_summedFrameCount) * 90000) / m_sampleRate : 0; }
|
||||
@@ -50,16 +57,11 @@ class ATTR_DLL_LOCAL ADTSFrame
|
||||
const AP4_Byte *getData() const { return m_dataBuffer.GetData(); }
|
||||
AP4_Size getDataSize() const { return m_dataBuffer.GetDataSize(); }
|
||||
private:
|
||||
- uint64_t getBE(const uint8_t *data, unsigned int len);
|
||||
- uint16_t m_outerHeader;
|
||||
- uint64_t m_innerHeader;
|
||||
- long m_innerHeaderSize;
|
||||
-
|
||||
uint32_t m_totalSize = 0;
|
||||
uint32_t m_summedFrameCount = 0;
|
||||
uint32_t m_frameCount = 0;
|
||||
uint32_t m_sampleRate = 0;
|
||||
- uint32_t m_channelConfig = 0;
|
||||
+ uint32_t m_channelCount = 0;
|
||||
|
||||
AP4_DataBuffer m_dataBuffer;
|
||||
};
|
||||
diff --git a/src/parser/CodecParser.cpp b/src/parser/CodecParser.cpp
|
||||
new file mode 100644
|
||||
index 000000000..2ee7a6456
|
||||
--- /dev/null
|
||||
+++ b/src/parser/CodecParser.cpp
|
||||
@@ -0,0 +1,230 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2023 Team Kodi
|
||||
+ * This file is part of Kodi - https://kodi.tv
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+ * See LICENSES/README.md for more information.
|
||||
+ */
|
||||
+
|
||||
+#include "CodecParser.h"
|
||||
+
|
||||
+#include <bento4/Ap4Utils.h>
|
||||
+using namespace adaptive;
|
||||
+
|
||||
+AdtsType CAdaptiveAdtsHeaderParser::GetAdtsType(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_EAC3_HEADER_SIZE); // max header size is 64 (E-AC3)
|
||||
+ AdtsType adtsType = AdtsType::NONE;
|
||||
+
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_EAC3_HEADER_SIZE)))
|
||||
+ return adtsType;
|
||||
+
|
||||
+ AP4_BitReader bits(buffer.GetData(), AP4_EAC3_HEADER_SIZE);
|
||||
+ AP4_UI32 syncWord = bits.ReadBits(16);
|
||||
+ if ((syncWord & AP4_ADTS_SYNC_MASK) == AP4_ADTS_SYNC_PATTERN)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AAC;
|
||||
+ }
|
||||
+ else if ((syncWord & AP4_AC4_SYNC_MASK) == AP4_AC4_SYNC_PATTERN)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AC4;
|
||||
+ }
|
||||
+ else if (syncWord == AP4_AC3_SYNC_PATTERN)
|
||||
+ {
|
||||
+ bits.SkipBits(24);
|
||||
+ AP4_UI32 bitStreamID = bits.ReadBits(5);
|
||||
+ if ((bitStreamID > 10) && (bitStreamID <= 16))
|
||||
+ {
|
||||
+ adtsType = AdtsType::EAC3;
|
||||
+ }
|
||||
+ else if (bitStreamID <= 10)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AC3;
|
||||
+ }
|
||||
+ }
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_EAC3_HEADER_SIZE));
|
||||
+ return adtsType;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveAdtsParser::FindFrameHeader(AP4_AacFrame& frame)
|
||||
+{
|
||||
+ unsigned char raw_header[AP4_ADTS_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_AdtsHeader adts_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = adts_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+
|
||||
+ m_Bits.SkipBytes(AP4_ADTS_HEADER_SIZE);
|
||||
+
|
||||
+ /* fill in the frame info */
|
||||
+ frame.m_Info.m_Standard =
|
||||
+ (adts_header.m_Id == 1 ? AP4_AAC_STANDARD_MPEG2 : AP4_AAC_STANDARD_MPEG4);
|
||||
+ switch (adts_header.m_ProfileObjectType)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_MAIN;
|
||||
+ break;
|
||||
+
|
||||
+ case 1:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LC;
|
||||
+ break;
|
||||
+
|
||||
+ case 2:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_SSR;
|
||||
+ break;
|
||||
+
|
||||
+ case 3:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LTP;
|
||||
+ }
|
||||
+ frame.m_Info.m_FrameLength = adts_header.m_FrameLength - AP4_ADTS_HEADER_SIZE;
|
||||
+ frame.m_Info.m_ChannelConfiguration = adts_header.m_ChannelConfiguration;
|
||||
+ frame.m_Info.m_SamplingFrequencyIndex = adts_header.m_SamplingFrequencyIndex;
|
||||
+ frame.m_Info.m_SamplingFrequency =
|
||||
+ AP4_AdtsSamplingFrequencyTable[adts_header.m_SamplingFrequencyIndex];
|
||||
+
|
||||
+ /* skip crc if present */
|
||||
+ if (adts_header.m_ProtectionAbsent == 0)
|
||||
+ {
|
||||
+ m_Bits.SkipBits(16);
|
||||
+ }
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveAc3Parser::FindFrameHeader(AP4_Ac3Frame& frame)
|
||||
+{
|
||||
+ unsigned char raw_header[AP4_AC3_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ if (m_LittleEndian)
|
||||
+ {
|
||||
+ AP4_ByteSwap16(raw_header, AP4_AC3_HEADER_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_Ac3Header ac3_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = ac3_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ {
|
||||
+ m_Bits.SkipBytes(2);
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+ }
|
||||
+
|
||||
+ frame.m_Info.m_ChannelCount = ac3_header.m_ChannelCount;
|
||||
+ frame.m_Info.m_SampleRate = FSCOD_AC3[ac3_header.m_Fscod];
|
||||
+ frame.m_Info.m_FrameSize = ac3_header.m_FrameSize;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.fscod = ac3_header.m_Fscod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bsid = ac3_header.m_Bsid;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bsmod = ac3_header.m_Bsmod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.acmod = ac3_header.m_Acmod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.lfeon = ac3_header.m_Lfeon;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bit_rate_code = ac3_header.m_Frmsizecod / 2;
|
||||
+
|
||||
+ frame.m_LittleEndian = m_LittleEndian;
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveEac3Parser::FindFrameHeader(AP4_Eac3Frame& frame)
|
||||
+{
|
||||
+ bool dependent_stream_exist = false;
|
||||
+ unsigned int dependent_stream_chan_loc = 0;
|
||||
+ unsigned int dependent_stream_length = 0;
|
||||
+ unsigned int skip_size = 0;
|
||||
+ unsigned char raw_header[AP4_EAC3_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header, skip_size);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ if (m_LittleEndian)
|
||||
+ {
|
||||
+ AP4_ByteSwap16(raw_header, AP4_EAC3_HEADER_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_Eac3Header eac3_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = eac3_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+
|
||||
+ /* fill in the frame info */
|
||||
+ frame.m_Info.m_ChannelCount = eac3_header.m_ChannelCount;
|
||||
+ if (dependent_stream_exist)
|
||||
+ {
|
||||
+ frame.m_Info.m_FrameSize = eac3_header.m_FrameSize + dependent_stream_length;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ frame.m_Info.m_FrameSize = eac3_header.m_FrameSize;
|
||||
+ }
|
||||
+ frame.m_Info.m_SampleRate = EAC3_SAMPLE_RATE_ARY[eac3_header.m_Fscod];
|
||||
+ frame.m_Info.m_Eac3SubStream.fscod = eac3_header.m_Fscod;
|
||||
+ frame.m_Info.m_Eac3SubStream.bsid = eac3_header.m_Bsid;
|
||||
+ frame.m_Info.m_Eac3SubStream.bsmod = eac3_header.m_Bsmod;
|
||||
+ frame.m_Info.m_Eac3SubStream.acmod = eac3_header.m_Acmod;
|
||||
+ frame.m_Info.m_Eac3SubStream.lfeon = eac3_header.m_Lfeon;
|
||||
+ if (dependent_stream_exist)
|
||||
+ {
|
||||
+ frame.m_Info.m_Eac3SubStream.num_dep_sub = 1;
|
||||
+ frame.m_Info.m_Eac3SubStream.chan_loc = dependent_stream_chan_loc;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ frame.m_Info.m_Eac3SubStream.num_dep_sub = 0;
|
||||
+ frame.m_Info.m_Eac3SubStream.chan_loc = 0;
|
||||
+ }
|
||||
+
|
||||
+ frame.m_Info.complexity_index_type_a = 0;
|
||||
+ if (eac3_header.m_Addbsie && (eac3_header.m_Addbsil == 1) && (eac3_header.m_Addbsi[0] == 0x1))
|
||||
+ {
|
||||
+ frame.m_Info.complexity_index_type_a = eac3_header.m_Addbsi[1];
|
||||
+ }
|
||||
+
|
||||
+ /* set the little endian flag */
|
||||
+ frame.m_LittleEndian = m_LittleEndian;
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
diff --git a/src/parser/CodecParser.h b/src/parser/CodecParser.h
|
||||
new file mode 100644
|
||||
index 000000000..d7e1fbba8
|
||||
--- /dev/null
|
||||
+++ b/src/parser/CodecParser.h
|
||||
@@ -0,0 +1,60 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2023 Team Kodi
|
||||
+ * This file is part of Kodi - https://kodi.tv
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+ * See LICENSES/README.md for more information.
|
||||
+ */
|
||||
+
|
||||
+#include <bento4/Ap4Ac3Parser.h>
|
||||
+#include <bento4/Ap4AdtsParser.h>
|
||||
+#include <bento4/Ap4Eac3Parser.h>
|
||||
+#include <kodi/addon-instance/Inputstream.h>
|
||||
+
|
||||
+namespace adaptive
|
||||
+{
|
||||
+
|
||||
+constexpr AP4_UI32 AP4_ADTS_HEADER_SIZE = 7;
|
||||
+constexpr AP4_UI32 AP4_ADTS_SYNC_MASK = 0xFFF6;
|
||||
+constexpr AP4_UI32 AP4_ADTS_SYNC_PATTERN = 0xFFF0;
|
||||
+constexpr AP4_UI32 AP4_AC3_SYNC_PATTERN = 0x0B77;
|
||||
+constexpr AP4_UI32 AP4_AC4_SYNC_MASK = 0xFFF0;
|
||||
+constexpr AP4_UI32 AP4_AC4_SYNC_PATTERN = 0x0AC40;
|
||||
+
|
||||
+enum class ATTR_DLL_LOCAL AdtsType
|
||||
+{
|
||||
+ NONE,
|
||||
+ AAC,
|
||||
+ AC3,
|
||||
+ EAC3,
|
||||
+ AC4
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAdtsParser : public AP4_AdtsParser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveAdtsParser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_AacFrame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAc3Parser : public AP4_Ac3Parser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveAc3Parser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_Ac3Frame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveEac3Parser : public AP4_Eac3Parser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveEac3Parser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_Eac3Frame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAdtsHeaderParser
|
||||
+{
|
||||
+public:
|
||||
+ static AdtsType GetAdtsType(AP4_ByteStream* stream);
|
||||
+};
|
||||
+
|
||||
+} // namespace adaptive
|
||||
|
||||
From fed26ca2307a6587c4e584b63345e1d141b7c320 Mon Sep 17 00:00:00 2001
|
||||
From: Glenn Guy <glennguy@users.noreply.github.com>
|
||||
Date: Thu, 1 Jun 2023 18:54:38 +1000
|
||||
Subject: [PATCH 2/2] Bump Bento4
|
||||
|
||||
---
|
||||
depends/common/bento4/bento4.sha256 | 2 +-
|
||||
depends/common/bento4/bento4.txt | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/depends/common/bento4/bento4.sha256 b/depends/common/bento4/bento4.sha256
|
||||
index 673bab692..04e05c87c 100644
|
||||
--- a/depends/common/bento4/bento4.sha256
|
||||
+++ b/depends/common/bento4/bento4.sha256
|
||||
@@ -1 +1 @@
|
||||
-4464cd47b597e6dedbfc231bb6eb097c45cfe5ee0051082460d9ac53e9d74dc3
|
||||
\ No newline at end of file
|
||||
+d7fc48e52f0037ce977d7f54c49d4f8936cca0e58447c9ce7c55ab64d268e23d
|
||||
\ No newline at end of file
|
||||
diff --git a/depends/common/bento4/bento4.txt b/depends/common/bento4/bento4.txt
|
||||
index d04bc8382..6128dc1a5 100644
|
||||
--- a/depends/common/bento4/bento4.txt
|
||||
+++ b/depends/common/bento4/bento4.txt
|
||||
@@ -1 +1 @@
|
||||
-bento4 https://github.com/xbmc/Bento4/archive/refs/tags/1.6.0-639-7-Omega.tar.gz
|
||||
+bento4 https://github.com/xbmc/Bento4/archive/refs/tags/1.6.0-639-8-Omega.tar.gz
|
Loading…
x
Reference in New Issue
Block a user