diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-04-30 06:07:21 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-04-30 06:07:21 +0400 |
commit | a32bf57900df9d7142fd03db7ea4dbd64beeb808 (patch) | |
tree | 6b1e36e479c1c7ed0a497b89db4a60684301008e /src/filters/parser/MP4Splitter/AP4 | |
parent | 036680b38507247ae15bd93aaddb58b53dfff425 (diff) |
Add : MP4Splitter support E-AC3 audio stream;
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3057 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/parser/MP4Splitter/AP4')
3 files changed, 80 insertions, 38 deletions
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp index 794d3139b..e90e66294 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp @@ -437,8 +437,11 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream, case AP4_ATOM_TYPE_SAC3: // AC3-in-MP4 from Nero Stuff >.<
atom = DNew AP4_AC3SampleEntry(size, stream, *this);
break;
+ case AP4_ATOM_TYPE_EAC3:
+ atom = DNew AP4_EAC3SampleEntry(size, stream, *this);
+ break;
- case AP4_ATOM_TYPE_CHPL:
+ case AP4_ATOM_TYPE_CHPL:
atom = DNew AP4_ChplAtom(size, stream);
break;
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.cpp index ab75f135e..e8e3ed516 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.cpp +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.cpp @@ -1189,6 +1189,9 @@ AP4_Tx3gSampleEntry::GetFontNameById(AP4_Ordinal Id, AP4_String& Name) return AP4_FAILURE;
}
+static int freq[] = {48000, 44100, 32000, 0};
+static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
+
/*----------------------------------------------------------------------
| AP4_AC3SampleEntry::AP4_AC3SampleEntry
+---------------------------------------------------------------------*/
@@ -1229,48 +1232,13 @@ AP4_AC3SampleEntry::ReadFields(AP4_ByteStream& stream) stream.ReadUI24(data);
// fscod
- switch ((data>>22) & 0x3) {
- case 0:
- m_SampleRate = 48000;
- break;
- case 1:
- m_SampleRate = 44100;
- break;
- case 2:
- m_SampleRate = 32000;
- break;
- }
-
+ m_SampleRate = freq[(data>>22) & 0x3];
m_SampleRate <<= 16;
// acmod
- switch ((data>>11) & 0x7) {
- case 1:
- m_ChannelCount = 1;
- break;
- case 0:
- case 2:
- m_ChannelCount = 2;
- break;
- case 3:
- case 4:
- m_ChannelCount = 3;
- break;
- case 5:
- case 6:
- m_ChannelCount = 4;
- break;
- case 7:
- m_ChannelCount = 5;
- break;
- }
-
- // lfeon
- if (((data>>10) & 0x1) == 1)
- m_ChannelCount++;
+ m_ChannelCount = channels[(data>>11) & 0x7] + ((data>>10) & 0x1);
return AP4_SUCCESS;
-
}
AP4_Size
@@ -1278,3 +1246,59 @@ AP4_AC3SampleEntry::GetFieldsSize() {
return AP4_AudioSampleEntry::GetFieldsSize() + 11;
}
+
+/*----------------------------------------------------------------------
+| AP4_AC3SampleEntry::AP4_AC3SampleEntry
++---------------------------------------------------------------------*/
+AP4_EAC3SampleEntry::AP4_EAC3SampleEntry(AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory) :
+ AP4_AudioSampleEntry(AP4_ATOM_TYPE_EAC3, size)
+{
+
+ // read fields
+ ReadFields(stream);
+
+ AP4_Size fields_size = GetFieldsSize();
+
+ // read children atoms (ex: esds and maybe others)
+ ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
+}
+
+/*----------------------------------------------------------------------
+| AP4_AC3SampleEntry::ReadFields
++---------------------------------------------------------------------*/
+AP4_Result
+AP4_EAC3SampleEntry::ReadFields(AP4_ByteStream& stream)
+{
+
+ AP4_AudioSampleEntry::ReadFields(stream);
+
+ // SampleSize field from AudioSampleEntry shall be ignored
+ m_SampleSize = 0;
+
+ // AC3SpecificBox
+
+ // BoxHeader.Size, BoxHeader.Type
+ char junk[8];
+ stream.Read(junk, 8);
+
+ AP4_UI32 data;
+ stream.ReadUI24(data);
+
+ // fscod
+ m_SampleRate = freq[(data>>22) & 0x3];
+ m_SampleRate <<= 16;
+
+ // acmod
+ m_ChannelCount = channels[(data>>17) & 0x7] + ((data>>18) & 0x1);
+
+ return AP4_SUCCESS;
+}
+
+AP4_Size
+AP4_EAC3SampleEntry::GetFieldsSize()
+{
+ return AP4_AudioSampleEntry::GetFieldsSize() + 11;
+}
+
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.h index cadbe84b3..61dbda53e 100644 --- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.h +++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4SampleEntry.h @@ -389,4 +389,19 @@ class AP4_AC3SampleEntry : public AP4_AudioSampleEntry AP4_Size GetFieldsSize();
};
+/*----------------------------------------------------------------------
+| AP4_AC3SampleEntry
++---------------------------------------------------------------------*/
+class AP4_EAC3SampleEntry : public AP4_AudioSampleEntry
+{
+ public:
+ // constructors
+ AP4_EAC3SampleEntry(AP4_Size size,
+ AP4_ByteStream& stream,
+ AP4_AtomFactory& atom_factory);
+
+ AP4_Result ReadFields(AP4_ByteStream& stream);
+ AP4_Size GetFieldsSize();
+};
+
#endif // _AP4_SAMPLE_ENTRY_H_
|