Skip to content

Commit 2107a9d

Browse files
committed
wip
1 parent 10a65ef commit 2107a9d

File tree

6 files changed

+531
-299
lines changed

6 files changed

+531
-299
lines changed

src/Session.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ void SESSION::CSession::UpdateStream(CStream& stream)
572572
stream.m_info.SetCodecName(CODEC::NAME_DTS);
573573
else if (CODEC::Contains(codecs, CODEC::FOURCC_AC_3, codecStr))
574574
stream.m_info.SetCodecName(CODEC::NAME_AC3);
575+
else if (CODEC::Contains(codecs, CODEC::FOURCC_AC_4, codecStr))
576+
stream.m_info.SetCodecName(CODEC::NAME_AC4);
575577
else if (CODEC::Contains(codecs, CODEC::FOURCC_EC_3, codecStr))
576578
{
577579
stream.m_info.SetCodecName(CODEC::NAME_EAC3);

src/demuxers/ADTSReader.cpp

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ ADTSFrame::ADTSFrameInfo ADTSFrame::GetFrameInfo(AP4_ByteStream* stream)
137137
case AdtsType::AC3:
138138
ParseAc3Header(stream, frameInfo);
139139
break;
140+
case AdtsType::AC4:
141+
ParseAc4Header(stream, frameInfo);
142+
break;
140143
case AdtsType::EAC3:
141144
ParseEc3Header(stream, frameInfo);
142145
break;
143-
case AdtsType::AC4:
144-
break;
145146
default:
146147
break;
147148
}
@@ -157,10 +158,10 @@ bool ADTSFrame::parse(AP4_ByteStream* stream)
157158
return ParseAac(stream);
158159
case AdtsType::AC3:
159160
return ParseAc3(stream);
161+
case AdtsType::AC4:
162+
return ParseAc4(stream);
160163
case AdtsType::EAC3:
161164
return ParseEc3(stream);
162-
case AdtsType::AC4:
163-
return false;
164165
default:
165166
return false;
166167
}
@@ -255,6 +256,50 @@ bool ADTSFrame::ParseAc3Header(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo)
255256
return true;
256257
}
257258

259+
bool ADTSFrame::ParseAc4(AP4_ByteStream* stream)
260+
{
261+
if (!ParseAc4Header(stream, m_frameInfo))
262+
return false;
263+
264+
m_summedFrameCount += m_frameInfo.m_frameCount;
265+
266+
// rewind stream to beginning of syncframe
267+
AP4_Position currentPos;
268+
stream->Tell(currentPos);
269+
stream->Seek(currentPos - (AP4_AC4_HEADER_SIZE));
270+
271+
m_dataBuffer.SetDataSize(m_frameInfo.m_frameSize);
272+
if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
273+
return false;
274+
275+
AdjustStreamForPadding(stream);
276+
return true;
277+
}
278+
279+
bool ADTSFrame::ParseAc4Header(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo)
280+
{
281+
AP4_DataBuffer buffer;
282+
buffer.SetDataSize(AP4_AC3_HEADER_SIZE);
283+
284+
if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_AC3_HEADER_SIZE)))
285+
return false;
286+
287+
CAdaptiveAc3Parser parser;
288+
AP4_Size sz = buffer.GetDataSize();
289+
parser.Feed(buffer.GetData(), &sz);
290+
291+
AP4_Ac3Frame frame;
292+
AP4_Result result = parser.FindFrameHeader(frame);
293+
if (!AP4_SUCCEEDED(result))
294+
return false;
295+
296+
frameInfo.m_frameSize = frame.m_Info.m_FrameSize;
297+
frameInfo.m_frameCount = 256u * frame.m_Info.m_ChannelCount;
298+
frameInfo.m_sampleRate = frame.m_Info.m_SampleRate;
299+
frameInfo.m_channels = frame.m_Info.m_ChannelCount;
300+
return true;
301+
}
302+
258303
bool ADTSFrame::ParseEc3(AP4_ByteStream* stream)
259304
{
260305
if (!ParseEc3Header(stream, m_frameInfo))
@@ -379,6 +424,10 @@ bool ADTSReader::GetInformation(kodi::addon::InputstreamInfo& info)
379424
{
380425
codecName = CODEC::NAME_AC3;
381426
}
427+
else if (frameInfo.m_codecType == AdtsType::AC4)
428+
{
429+
codecName = CODEC::NAME_AC4;
430+
}
382431
else if (frameInfo.m_codecType == AdtsType::EAC3)
383432
{
384433
codecName = CODEC::NAME_EAC3;

src/demuxers/ADTSReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class ATTR_DLL_LOCAL ADTSFrame
8080
bool ParseAacHeader(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo);
8181
bool ParseAc3(AP4_ByteStream* stream);
8282
bool ParseAc3Header(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo);
83+
bool ParseAc4(AP4_ByteStream* stream);
84+
bool ParseAc4Header(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo);
8385
bool ParseEc3(AP4_ByteStream* stream);
8486
bool ParseEc3Header(AP4_ByteStream* stream, ADTSFrameInfo& frameInfo);
8587
void reset();

0 commit comments

Comments
 (0)