diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-16 16:52:56 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-16 16:52:56 +0400 |
commit | 60af42a80edbf24004c1662591721b9db454c248 (patch) | |
tree | 05dc675a3f427e5c05cdac9165745c149df7980f /src/filters/muxer/MatroskaMuxer | |
parent | 34c461761913564627c15458506eb1d33f23f0a3 (diff) |
muxers: applied astyle formatting
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2252 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/muxer/MatroskaMuxer')
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp | 22 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/MatroskaFile.h | 699 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp | 356 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h | 43 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/resource.h | 2 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/stdafx.cpp | 17 | ||||
-rw-r--r-- | src/filters/muxer/MatroskaMuxer/stdafx.h | 20 |
7 files changed, 615 insertions, 544 deletions
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp index 1de7b2956..d1af9a3e4 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp +++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp @@ -1,20 +1,20 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -156,7 +156,7 @@ MatroskaWriter::QWORD CUInt::Size(bool fWithHeader) {
if(((0xffi64<<((i-1)*8))&m_val))
{
- len += i;
+ len += i;
break;
}
}
@@ -194,7 +194,7 @@ MatroskaWriter::QWORD CInt::Size(bool fWithHeader) {
if(((0xffi64<<((i-1)*8))&val))
{
- len += i;
+ len += i;
if(m_val < 0 && !(m_val&(0x80<<(i-1))))
len++;
break;
@@ -227,7 +227,7 @@ MatroskaWriter::QWORD CLength::Size(bool fWithHeader) {
if(!(m_len&(~((1i64<<(7*i))-1))) && (m_len&((1i64<<(7*i))-1)) != ((1i64<<(7*i))-1))
{
- len += i;
+ len += i;
break;
}
}
@@ -245,7 +245,7 @@ HRESULT CLength::Write(IStream* pStream) //
-EBML::EBML(DWORD id)
+EBML::EBML(DWORD id)
: CID(id)
, EBMLVersion(0x4286)
, EBMLReadVersion(0x42F7)
@@ -379,7 +379,7 @@ HRESULT Track::Write(IStream* pStream) return S_OK;
}
-TrackEntry::TrackEntry(DWORD id)
+TrackEntry::TrackEntry(DWORD id)
: CID(id)
, TrackNumber(0xD7)
, TrackUID(0x73C5)
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h index 80273dd76..feb94cd6c 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h +++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h @@ -1,20 +1,20 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -26,264 +26,293 @@ namespace MatroskaWriter
{
- typedef unsigned __int64 QWORD;
+typedef unsigned __int64 QWORD;
- class CID
- {
- protected:
- DWORD m_id;
- QWORD HeaderSize(QWORD len);
- HRESULT HeaderWrite(IStream* pStream);
-
- public:
- CID(DWORD id);
- DWORD GetID() const {return m_id;}
- virtual QWORD Size(bool fWithHeader = true);
- virtual HRESULT Write(IStream* pStream);
- };
-
- class CLength : public CID
- {
- UINT64 m_len;
- public:
- CLength(UINT64 len = 0) : CID(0), m_len(len) {}
- operator UINT64() {return m_len;}
- QWORD Size(bool fWithHeader = false);
- HRESULT Write(IStream* pStream);
- };
-
- class CBinary : public CAtlArray<BYTE>, public CID
- {
- public:
- CBinary(DWORD id) : CID(id) {}
- CBinary& operator = (const CBinary& b) {Copy(b); return(*this);}
- operator BYTE*() {return (BYTE*)GetData();}
- CBinary& Set(CStringA str) {SetCount(str.GetLength()+1); strcpy((char*)GetData(), str); return(*this);}
+class CID
+{
+protected:
+ DWORD m_id;
+ QWORD HeaderSize(QWORD len);
+ HRESULT HeaderWrite(IStream* pStream);
+
+public:
+ CID(DWORD id);
+ DWORD GetID() const {
+ return m_id;
+ }
+ virtual QWORD Size(bool fWithHeader = true);
+ virtual HRESULT Write(IStream* pStream);
+};
+
+class CLength : public CID
+{
+ UINT64 m_len;
+public:
+ CLength(UINT64 len = 0) : CID(0), m_len(len) {}
+ operator UINT64() {
+ return m_len;
+ }
+ QWORD Size(bool fWithHeader = false);
+ HRESULT Write(IStream* pStream);
+};
+
+class CBinary : public CAtlArray<BYTE>, public CID
+{
+public:
+ CBinary(DWORD id) : CID(id) {}
+ CBinary& operator = (const CBinary& b) {
+ Copy(b);
+ return(*this);
+ }
+ operator BYTE*() {
+ return (BYTE*)GetData();
+ }
+ CBinary& Set(CStringA str) {
+ SetCount(str.GetLength()+1);
+ strcpy((char*)GetData(), str);
+ return(*this);
+ }
// CBinary& Set(CStringA str) {SetCount(str.GetLength()); memcpy((char*)GetData(), str, str.GetLength()); return(*this);}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class CANSI : public CStringA, public CID
- {
- public:
- CANSI(DWORD id) : CID(id) {}
- CANSI& Set(CStringA str) {CStringA::operator = (str); return(*this);}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CUTF8 : public CStringW, public CID
- {
- public:
- CUTF8(DWORD id) : CID(id) {}
- CUTF8& Set(CStringW str) {CStringW::operator = (str); return(*this);}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- template<class T, class BASE>
- class CSimpleVar : public CID
- {
- protected:
- T m_val;
- bool m_fSet;
- public:
- explicit CSimpleVar(DWORD id, T val = 0) : CID(id), m_val(val) {m_fSet = !!val;}
- operator T() {return m_val;}
- BASE& Set(T val) {m_val = val; m_fSet = true; return(*(BASE*)this);}
- void UnSet() {m_fSet = false;}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CUInt : public CSimpleVar<UINT64, CUInt>
- {
- public:
- explicit CUInt(DWORD id, UINT64 val = 0) : CSimpleVar<UINT64, CUInt>(id, val) {}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+class CANSI : public CStringA, public CID
+{
+public:
+ CANSI(DWORD id) : CID(id) {}
+ CANSI& Set(CStringA str) {
+ CStringA::operator = (str);
+ return(*this);
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class CUTF8 : public CStringW, public CID
+{
+public:
+ CUTF8(DWORD id) : CID(id) {}
+ CUTF8& Set(CStringW str) {
+ CStringW::operator = (str);
+ return(*this);
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+template<class T, class BASE>
+class CSimpleVar : public CID
+{
+protected:
+ T m_val;
+ bool m_fSet;
+public:
+ explicit CSimpleVar(DWORD id, T val = 0) : CID(id), m_val(val) {
+ m_fSet = !!val;
+ }
+ operator T() {
+ return m_val;
+ }
+ BASE& Set(T val) {
+ m_val = val;
+ m_fSet = true;
+ return(*(BASE*)this);
+ }
+ void UnSet() {
+ m_fSet = false;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class CUInt : public CSimpleVar<UINT64, CUInt>
+{
+public:
+ explicit CUInt(DWORD id, UINT64 val = 0) : CSimpleVar<UINT64, CUInt>(id, val) {}
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class CInt : public CSimpleVar<INT64, CInt>
- {
- public:
- explicit CInt(DWORD id, INT64 val = 0) : CSimpleVar<INT64, CInt>(id, val) {}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+class CInt : public CSimpleVar<INT64, CInt>
+{
+public:
+ explicit CInt(DWORD id, INT64 val = 0) : CSimpleVar<INT64, CInt>(id, val) {}
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class CByte : public CSimpleVar<BYTE, CByte>
- {
- public:
- explicit CByte(DWORD id, BYTE val = 0) : CSimpleVar<BYTE, CByte>(id, val) {}
- };
+class CByte : public CSimpleVar<BYTE, CByte>
+{
+public:
+ explicit CByte(DWORD id, BYTE val = 0) : CSimpleVar<BYTE, CByte>(id, val) {}
+};
- class CShort : public CSimpleVar<short, CShort>
- {
- public:
- explicit CShort(DWORD id, short val = 0) : CSimpleVar<short, CShort>(id, val) {}
- };
+class CShort : public CSimpleVar<short, CShort>
+{
+public:
+ explicit CShort(DWORD id, short val = 0) : CSimpleVar<short, CShort>(id, val) {}
+};
- class CFloat : public CSimpleVar<float, CFloat>
- {
- public:
- explicit CFloat(DWORD id, float val = 0) : CSimpleVar<float, CFloat>(id, val) {}
- };
+class CFloat : public CSimpleVar<float, CFloat>
+{
+public:
+ explicit CFloat(DWORD id, float val = 0) : CSimpleVar<float, CFloat>(id, val) {}
+};
- template<class T>
- class CNode : public CAutoPtrList<T>
+template<class T>
+class CNode : public CAutoPtrList<T>
+{
+public:
+ QWORD Size(bool fWithHeader = true)
{
- public:
- QWORD Size(bool fWithHeader = true)
- {
- QWORD len = 0;
- POSITION pos = GetHeadPosition();
- while(pos) len += GetNext(pos)->Size(fWithHeader);
- return len;
- }
- HRESULT Write(IStream* pStream)
- {
- HRESULT hr;
- POSITION pos = GetHeadPosition();
- while(pos) if(FAILED(hr = GetNext(pos)->Write(pStream))) return hr;
- return S_OK;
- }
- };
-
- class EBML : public CID
+ QWORD len = 0;
+ POSITION pos = GetHeadPosition();
+ while(pos) len += GetNext(pos)->Size(fWithHeader);
+ return len;
+ }
+ HRESULT Write(IStream* pStream)
{
- public:
- CUInt EBMLVersion, EBMLReadVersion;
- CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
- CANSI DocType;
- CUInt DocTypeVersion, DocTypeReadVersion;
-
- EBML(DWORD id = 0x1A45DFA3);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Info : public CID
- {
- public:
- CBinary SegmentUID, PrevUID, NextUID;
- CUTF8 SegmentFilename, PrevFilename, NextFilename;
- CUInt TimeCodeScale; // [ns], default: 1.000.000
- CFloat Duration;
- CInt DateUTC;
- CUTF8 Title, MuxingApp, WritingApp;
-
- Info(DWORD id = 0x1549A966);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Video : public CID
- {
- public:
- CUInt FlagInterlaced, StereoMode;
- CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
- CUInt AspectRatioType;
- CUInt ColourSpace;
- CFloat GammaValue;
- CFloat FramePerSec;
-
- Video(DWORD id = 0xE0);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Audio : public CID
- {
- public:
- CFloat SamplingFrequency;
- CFloat OutputSamplingFrequency;
- CUInt Channels;
- CBinary ChannelPositions;
- CUInt BitDepth;
-
- Audio(DWORD id = 0xE1);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class TrackEntry : public CID
- {
- public:
- enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
- CUInt TrackNumber, TrackUID, TrackType;
- CUInt FlagEnabled, FlagDefault, FlagLacing;
- CUInt MinCache, MaxCache;
- CUTF8 Name;
- CANSI Language;
- CBinary CodecID;
- CBinary CodecPrivate;
- CUTF8 CodecName;
- CUTF8 CodecSettings;
- CANSI CodecInfoURL;
- CANSI CodecDownloadURL;
- CUInt CodecDecodeAll;
- CUInt TrackOverlay;
- CUInt DefaultDuration;
- enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
- int DescType;
- Video v;
- Audio a;
-
- TrackEntry(DWORD id = 0xAE);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Track : public CID
- {
- public:
- CNode<TrackEntry> TrackEntries;
-
- Track(DWORD id = 0x1654AE6B);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CBlock : public CID
- {
- public:
- CLength TrackNumber;
- REFERENCE_TIME TimeCode, TimeCodeStop;
- CNode<CBinary> BlockData;
-
- CBlock(DWORD id = 0xA1);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class BlockGroup : public CID
- {
- public:
- CUInt BlockDuration;
- CUInt ReferencePriority;
- CInt ReferenceBlock;
- CInt ReferenceVirtual;
- CBinary CodecState;
- CBlock Block;
+ HRESULT hr;
+ POSITION pos = GetHeadPosition();
+ while(pos) if(FAILED(hr = GetNext(pos)->Write(pStream))) return hr;
+ return S_OK;
+ }
+};
+
+class EBML : public CID
+{
+public:
+ CUInt EBMLVersion, EBMLReadVersion;
+ CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
+ CANSI DocType;
+ CUInt DocTypeVersion, DocTypeReadVersion;
+
+ EBML(DWORD id = 0x1A45DFA3);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Info : public CID
+{
+public:
+ CBinary SegmentUID, PrevUID, NextUID;
+ CUTF8 SegmentFilename, PrevFilename, NextFilename;
+ CUInt TimeCodeScale; // [ns], default: 1.000.000
+ CFloat Duration;
+ CInt DateUTC;
+ CUTF8 Title, MuxingApp, WritingApp;
+
+ Info(DWORD id = 0x1549A966);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Video : public CID
+{
+public:
+ CUInt FlagInterlaced, StereoMode;
+ CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
+ CUInt AspectRatioType;
+ CUInt ColourSpace;
+ CFloat GammaValue;
+ CFloat FramePerSec;
+
+ Video(DWORD id = 0xE0);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Audio : public CID
+{
+public:
+ CFloat SamplingFrequency;
+ CFloat OutputSamplingFrequency;
+ CUInt Channels;
+ CBinary ChannelPositions;
+ CUInt BitDepth;
+
+ Audio(DWORD id = 0xE1);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class TrackEntry : public CID
+{
+public:
+ enum {TypeVideo = 1, TypeAudio = 2, TypeComplex = 3, TypeLogo = 0x10, TypeSubtitle = 0x11, TypeControl = 0x20};
+ CUInt TrackNumber, TrackUID, TrackType;
+ CUInt FlagEnabled, FlagDefault, FlagLacing;
+ CUInt MinCache, MaxCache;
+ CUTF8 Name;
+ CANSI Language;
+ CBinary CodecID;
+ CBinary CodecPrivate;
+ CUTF8 CodecName;
+ CUTF8 CodecSettings;
+ CANSI CodecInfoURL;
+ CANSI CodecDownloadURL;
+ CUInt CodecDecodeAll;
+ CUInt TrackOverlay;
+ CUInt DefaultDuration;
+ enum {NoDesc = 0, DescVideo = 1, DescAudio = 2};
+ int DescType;
+ Video v;
+ Audio a;
+
+ TrackEntry(DWORD id = 0xAE);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Track : public CID
+{
+public:
+ CNode<TrackEntry> TrackEntries;
+
+ Track(DWORD id = 0x1654AE6B);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class CBlock : public CID
+{
+public:
+ CLength TrackNumber;
+ REFERENCE_TIME TimeCode, TimeCodeStop;
+ CNode<CBinary> BlockData;
+
+ CBlock(DWORD id = 0xA1);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class BlockGroup : public CID
+{
+public:
+ CUInt BlockDuration;
+ CUInt ReferencePriority;
+ CInt ReferenceBlock;
+ CInt ReferenceVirtual;
+ CBinary CodecState;
+ CBlock Block;
// CNode<TimeSlice> TimeSlices;
- BlockGroup(DWORD id = 0xA0);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ BlockGroup(DWORD id = 0xA0);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class Cluster : public CID
- {
- public:
- CUInt TimeCode, Position, PrevSize;
- CNode<BlockGroup> BlockGroups;
+class Cluster : public CID
+{
+public:
+ CUInt TimeCode, Position, PrevSize;
+ CNode<BlockGroup> BlockGroups;
- Cluster(DWORD id = 0x1F43B675);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ Cluster(DWORD id = 0x1F43B675);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
/* class CueReference : public CID
{
@@ -295,93 +324,95 @@ namespace MatroskaWriter HRESULT Write(IStream* pStream);
};
*/
- class CueTrackPosition : public CID
- {
- public:
- CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
+class CueTrackPosition : public CID
+{
+public:
+ CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
// CNode<CueReference> CueReferences;
- CueTrackPosition(DWORD id = 0xB7);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class CuePoint : public CID
- {
- public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
-
- CuePoint(DWORD id = 0xBB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Cue : public CID
- {
- public:
- CNode<CuePoint> CuePoints;
-
- Cue(DWORD id = 0x1C53BB6B);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class SeekID : public CID
- {
- CID m_id;
- public:
- SeekID(DWORD id = 0x53AB);
- void Set(DWORD id) {m_id = id;}
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class SeekHead : public CID
- {
- public:
- SeekID ID;
- CUInt Position;
-
- SeekHead(DWORD id = 0x4DBB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Seek : public CID
- {
- public:
- CNode<SeekHead> SeekHeads;
-
- Seek(DWORD id = 0x114D9B74);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
-
- class Segment : public CID
- {
- public:
- Segment(DWORD id = 0x18538067);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ CueTrackPosition(DWORD id = 0xB7);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class Tags : public CID
- {
- public:
- // TODO
+class CuePoint : public CID
+{
+public:
+ CUInt CueTime;
+ CNode<CueTrackPosition> CueTrackPositions;
- Tags(DWORD id = 0x1254C367);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+ CuePoint(DWORD id = 0xBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
- class Void : public CID
- {
- QWORD m_len;
- public:
- Void(QWORD len, DWORD id = 0xEC);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
- };
+class Cue : public CID
+{
+public:
+ CNode<CuePoint> CuePoints;
+
+ Cue(DWORD id = 0x1C53BB6B);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class SeekID : public CID
+{
+ CID m_id;
+public:
+ SeekID(DWORD id = 0x53AB);
+ void Set(DWORD id) {
+ m_id = id;
+ }
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class SeekHead : public CID
+{
+public:
+ SeekID ID;
+ CUInt Position;
+
+ SeekHead(DWORD id = 0x4DBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Seek : public CID
+{
+public:
+ CNode<SeekHead> SeekHeads;
+
+ Seek(DWORD id = 0x114D9B74);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Segment : public CID
+{
+public:
+ Segment(DWORD id = 0x18538067);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Tags : public CID
+{
+public:
+ // TODO
+
+ Tags(DWORD id = 0x1254C367);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
+
+class Void : public CID
+{
+ QWORD m_len;
+public:
+ Void(QWORD len, DWORD id = 0xEC);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+};
}
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp index 4ed4217d6..68d3b89d2 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp +++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp @@ -1,20 +1,20 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -38,8 +38,8 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = const AMOVIESETUP_PIN sudpPins[] =
{
- {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
+ {L"Input", FALSE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, 0, NULL},
+ {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
const AMOVIESETUP_FILTER sudFilter[] =
@@ -99,7 +99,7 @@ STDMETHODIMP CMatroskaMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void *ppv = NULL;
- return
+ return
// QI(IAMFilterMiscFlags)
QI(IMediaSeeking)
QI(IMatroskaMuxer)
@@ -132,7 +132,7 @@ void CMatroskaMuxerFilter::AddInput() CStringW name;
name.Format(L"Track %d", m_pInputs.GetCount()+1);
-
+
HRESULT hr;
CAutoPtr<CMatroskaMuxerInputPin> pPin(DNew CMatroskaMuxerInputPin(name, this, this, &hr));
m_pInputs.AddTail(pPin);
@@ -145,7 +145,7 @@ int CMatroskaMuxerFilter::GetPinCount() CBasePin* CMatroskaMuxerFilter::GetPin(int n)
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
if(n >= 0 && n < (int)m_pInputs.GetCount())
{
@@ -166,7 +166,7 @@ STDMETHODIMP CMatroskaMuxerFilter::Stop() CAutoLock cAutoLock(this);
HRESULT hr;
-
+
if(FAILED(hr = __super::Stop()))
return hr;
@@ -218,9 +218,9 @@ STDMETHODIMP_(ULONG) CMatroskaMuxerFilter::GetMiscFlags() STDMETHODIMP CMatroskaMuxerFilter::GetCapabilities(DWORD* pCapabilities)
{
- return pCapabilities ? *pCapabilities =
- AM_SEEKING_CanGetDuration|
- AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
+ return pCapabilities ? *pCapabilities =
+ AM_SEEKING_CanGetDuration|
+ AM_SEEKING_CanGetCurrentPos, S_OK : E_POINTER;
}
STDMETHODIMP CMatroskaMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
@@ -231,35 +231,64 @@ STDMETHODIMP CMatroskaMuxerFilter::CheckCapabilities(DWORD* pCapabilities) caps &= *pCapabilities;
return caps == 0 ? E_FAIL : caps == *pCapabilities ? S_OK : S_FALSE;
}
-STDMETHODIMP CMatroskaMuxerFilter::IsFormatSupported(const GUID* pFormat) {return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;}
-STDMETHODIMP CMatroskaMuxerFilter::QueryPreferredFormat(GUID* pFormat) {return GetTimeFormat(pFormat);}
-STDMETHODIMP CMatroskaMuxerFilter::GetTimeFormat(GUID* pFormat) {return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;}
-STDMETHODIMP CMatroskaMuxerFilter::IsUsingTimeFormat(const GUID* pFormat) {return IsFormatSupported(pFormat);}
-STDMETHODIMP CMatroskaMuxerFilter::SetTimeFormat(const GUID* pFormat) {return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;}
+STDMETHODIMP CMatroskaMuxerFilter::IsFormatSupported(const GUID* pFormat) {
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+}
+STDMETHODIMP CMatroskaMuxerFilter::QueryPreferredFormat(GUID* pFormat) {
+ return GetTimeFormat(pFormat);
+}
+STDMETHODIMP CMatroskaMuxerFilter::GetTimeFormat(GUID* pFormat) {
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+}
+STDMETHODIMP CMatroskaMuxerFilter::IsUsingTimeFormat(const GUID* pFormat) {
+ return IsFormatSupported(pFormat);
+}
+STDMETHODIMP CMatroskaMuxerFilter::SetTimeFormat(const GUID* pFormat) {
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+}
STDMETHODIMP CMatroskaMuxerFilter::GetDuration(LONGLONG* pDuration)
{
CheckPointer(pDuration, E_POINTER);
*pDuration = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) {REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur; if(rt > *pDuration) *pDuration = rt;}
+ while(pos) {
+ REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur;
+ if(rt > *pDuration) *pDuration = rt;
+ }
return S_OK;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetStopPosition(LONGLONG* pStop) {return E_NOTIMPL;}
+STDMETHODIMP CMatroskaMuxerFilter::GetStopPosition(LONGLONG* pStop) {
+ return E_NOTIMPL;
+}
STDMETHODIMP CMatroskaMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
CheckPointer(pCurrent, E_POINTER);
*pCurrent = m_rtCurrent;
return S_OK;
}
-STDMETHODIMP CMatroskaMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::SetRate(double dRate) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::GetRate(double* pdRate) {return E_NOTIMPL;}
-STDMETHODIMP CMatroskaMuxerFilter::GetPreroll(LONGLONG* pllPreroll) {return E_NOTIMPL;}
+STDMETHODIMP CMatroskaMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::SetRate(double dRate) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::GetRate(double* pdRate) {
+ return E_NOTIMPL;
+}
+STDMETHODIMP CMatroskaMuxerFilter::GetPreroll(LONGLONG* pllPreroll) {
+ return E_NOTIMPL;
+}
-// IMatroskaMuxer
+// IMatroskaMuxer
STDMETHODIMP CMatroskaMuxerFilter::CorrectTimeOffset(bool fNegative, bool fPositive)
{
@@ -290,7 +319,7 @@ ULONGLONG SetStreamPosition(IStream* pStream, ULONGLONG seekpos) DWORD CMatroskaMuxerFilter::ThreadProc()
{
CComQIPtr<IStream> pStream;
-
+
if(!m_pOutput || !(pStream = m_pOutput->GetConnected()))
{
while(1)
@@ -359,26 +388,26 @@ DWORD CMatroskaMuxerFilter::ThreadProc() seek.SeekHeads.AddTail(sh);
UINT64 TrackNumber = 0;
-/*
- CNode<Track> Tracks;
- CAutoPtr<Track> pT(DNew Track());
- POSITION pos = m_pInputs.GetHeadPosition();
- for(int i = 1; pos; i++)
- {
- CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if(!pPin->IsConnected()) continue;
-
- CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
- *pTE = *pPin->GetTrackEntry();
- if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
- TrackNumber = pTE->TrackNumber;
- pT->TrackEntries.AddTail(pTE);
- }
- Tracks.AddTail(pT);
- Tracks.Write(pStream);
+ /*
+ CNode<Track> Tracks;
+ CAutoPtr<Track> pT(DNew Track());
+ POSITION pos = m_pInputs.GetHeadPosition();
+ for(int i = 1; pos; i++)
+ {
+ CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
+ if(!pPin->IsConnected()) continue;
+
+ CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
+ *pTE = *pPin->GetTrackEntry();
+ if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
+ TrackNumber = pTE->TrackNumber;
+ pT->TrackEntries.AddTail(pTE);
+ }
+ Tracks.AddTail(pT);
+ Tracks.Write(pStream);
- if(TrackNumber == 0) TrackNumber = 1;
-*/
+ if(TrackNumber == 0) TrackNumber = 1;
+ */
bool fTracksWritten = false;
//
@@ -454,7 +483,10 @@ DWORD CMatroskaMuxerFilter::ThreadProc() if(pTmp->m_blocks.GetCount() > 0)
{
REFERENCE_TIME rt = pTmp->m_blocks.GetHead()->Block.TimeCode;
- if(rt < rtMin) {rtMin = rt; pPin = pTmp;}
+ if(rt < rtMin) {
+ rtMin = rt;
+ pPin = pTmp;
+ }
}
}
}
@@ -481,7 +513,7 @@ DWORD CMatroskaMuxerFilter::ThreadProc() CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
*pTE = *pPin->GetTrackEntry();
- if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
+ if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
TrackNumber = pTE->TrackNumber;
pT->TrackEntries.AddTail(pTE);
}
@@ -514,14 +546,17 @@ DWORD CMatroskaMuxerFilter::ThreadProc() b->Block.TimeCode -= firstTimeCode;
b->Block.TimeCodeStop -= firstTimeCode;
-/*
-TRACE(_T("Muxing (%d): %I64d-%I64d dur=%I64d (c=%d, co=%dms), cnt=%d, ref=%d\n"),
- GetTrackNumber(pPin),
- (INT64)b->Block.TimeCode, (INT64)b->Block.TimeCodeStop, (UINT64)b->BlockDuration,
- (int)((b->Block.TimeCode)/MAXCLUSTERTIME), (int)(b->Block.TimeCode%MAXCLUSTERTIME),
- b->Block.BlockData.GetCount(), (int)b->ReferenceBlock);
-*/
- if(b->Block.TimeCode < SHRT_MIN /*0*/) {ASSERT(0); continue;}
+ /*
+ TRACE(_T("Muxing (%d): %I64d-%I64d dur=%I64d (c=%d, co=%dms), cnt=%d, ref=%d\n"),
+ GetTrackNumber(pPin),
+ (INT64)b->Block.TimeCode, (INT64)b->Block.TimeCodeStop, (UINT64)b->BlockDuration,
+ (int)((b->Block.TimeCode)/MAXCLUSTERTIME), (int)(b->Block.TimeCode%MAXCLUSTERTIME),
+ b->Block.BlockData.GetCount(), (int)b->ReferenceBlock);
+ */
+ if(b->Block.TimeCode < SHRT_MIN /*0*/) {
+ ASSERT(0);
+ continue;
+ }
while((INT64)(c.TimeCode + MAXCLUSTERTIME) < b->Block.TimeCode)
{
@@ -600,7 +635,7 @@ TRACE(_T("Muxing (%d): %I64d-%I64d dur=%I64d (c=%d, co=%dms), cnt=%d, ref=%d\n") sh->Position.Set(GetStreamPosition(pStream) - segpos);
seek.SeekHeads.AddTail(sh);
- tags.Write(pStream);
+ tags.Write(pStream);
}
SetStreamPosition(pStream, voidpos);
@@ -666,13 +701,13 @@ STDMETHODIMP CMatroskaMuxerInputPin::NonDelegatingQueryInterface(REFIID riid, vo {
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMatroskaMuxerInputPin::CheckMediaType(const CMediaType* pmt)
{
- return pmt->majortype == MEDIATYPE_Video && (pmt->formattype == FORMAT_VideoInfo
+ return pmt->majortype == MEDIATYPE_Video && (pmt->formattype == FORMAT_VideoInfo
|| pmt->formattype == FORMAT_VideoInfo2)
// || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG1Payload && pmt->formattype == FORMAT_MPEGVideo
// || pmt->majortype == MEDIATYPE_Video && pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO && pmt->formattype == FORMAT_MPEG2_VIDEO
@@ -730,7 +765,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) {
m_pTE->TrackType.Set(TrackEntry::TypeVideo);
- if(m_mt.formattype == FORMAT_VideoInfo
+ if(m_mt.formattype == FORMAT_VideoInfo
&& m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
|| m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40)
{
@@ -745,12 +780,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER));
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER), m_pTE->CodecPrivate.GetCount());
}
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
if(vih->AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
}
else if(m_mt.formattype == FORMAT_VideoInfo2)
{
@@ -760,12 +795,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - sizeof(VIDEOINFOHEADER2));
memcpy(m_pTE->CodecPrivate, m_mt.pbFormat + sizeof(VIDEOINFOHEADER2), m_pTE->CodecPrivate.GetCount());
}
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
if(vih->AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
}
@@ -784,12 +819,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
m_pTE->CodecPrivate.SetCount(m_mt.cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
memcpy(m_pTE->CodecPrivate, &vih->bmiHeader, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
+ m_pTE->DefaultDuration.Set(vih->AvgTimePerFrame*100);
m_pTE->DescType = TrackEntry::DescVideo;
m_pTE->v.PixelWidth.Set(vih->bmiHeader.biWidth);
m_pTE->v.PixelHeight.Set(abs(vih->bmiHeader.biHeight));
if(vih->AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
hr = S_OK;
}
@@ -807,7 +842,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
if(vih->AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
hr = S_OK;
}
@@ -825,50 +860,50 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) // m_pTE->v.DisplayWidth.Set(vih->dwPictAspectRatioX);
// m_pTE->v.DisplayHeight.Set(vih->dwPictAspectRatioY);
if(vih->hdr.AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
-
- hr = S_OK;
- }
-/*
- else if(m_mt.formattype == FORMAT_MPEGVideo)
- {
- m_pTE->CodecID.Set("V_DSHOW/MPEG1VIDEO"); // V_MPEG1
-
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(pm1vi->hdr.AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(pm1vi->hdr.bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(pm1vi->hdr.bmiHeader.biHeight));
- if(pm1vi->hdr.AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm1vi->hdr.AvgTimePerFrame));
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
hr = S_OK;
}
- else if(m_mt.formattype == FORMAT_MPEG2_VIDEO)
- {
- m_pTE->CodecID.Set("V_DSHOW/MPEG2VIDEO"); // V_MPEG2
-
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)m_mt.pbFormat;
- m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
- memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
- m_pTE->DefaultDuration.Set(pm2vi->hdr.AvgTimePerFrame*100);
- m_pTE->DescType = TrackEntry::DescVideo;
- m_pTE->v.PixelWidth.Set(pm2vi->hdr.bmiHeader.biWidth);
- m_pTE->v.PixelHeight.Set(abs(pm2vi->hdr.bmiHeader.biHeight));
- if(pm2vi->hdr.AvgTimePerFrame > 0)
- m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm2vi->hdr.AvgTimePerFrame));
-
- hr = S_OK;
- }
-*/
+ /*
+ else if(m_mt.formattype == FORMAT_MPEGVideo)
+ {
+ m_pTE->CodecID.Set("V_DSHOW/MPEG1VIDEO"); // V_MPEG1
+
+ MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(pm1vi->hdr.AvgTimePerFrame*100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(pm1vi->hdr.bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(pm1vi->hdr.bmiHeader.biHeight));
+ if(pm1vi->hdr.AvgTimePerFrame > 0)
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm1vi->hdr.AvgTimePerFrame));
+
+ hr = S_OK;
+ }
+ else if(m_mt.formattype == FORMAT_MPEG2_VIDEO)
+ {
+ m_pTE->CodecID.Set("V_DSHOW/MPEG2VIDEO"); // V_MPEG2
+
+ MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)m_mt.pbFormat;
+ m_pTE->CodecPrivate.SetCount(m_mt.FormatLength());
+ memcpy(m_pTE->CodecPrivate, m_mt.pbFormat, m_pTE->CodecPrivate.GetCount());
+ m_pTE->DefaultDuration.Set(pm2vi->hdr.AvgTimePerFrame*100);
+ m_pTE->DescType = TrackEntry::DescVideo;
+ m_pTE->v.PixelWidth.Set(pm2vi->hdr.bmiHeader.biWidth);
+ m_pTE->v.PixelHeight.Set(abs(pm2vi->hdr.bmiHeader.biHeight));
+ if(pm2vi->hdr.AvgTimePerFrame > 0)
+ m_pTE->v.FramePerSec.Set((float)(10000000.0 / pm2vi->hdr.AvgTimePerFrame));
+
+ hr = S_OK;
+ }
+ */
}
else if(m_mt.majortype == MEDIATYPE_Audio)
{
m_pTE->TrackType.Set(TrackEntry::TypeAudio);
- if(m_mt.formattype == FORMAT_WaveFormatEx
+ if(m_mt.formattype == FORMAT_WaveFormatEx
&& ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_AAC
&& m_mt.cbFormat >= sizeof(WAVEFORMATEX)+2)
{
@@ -903,11 +938,21 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) switch(profile)
{
default:
- case 0: m_pTE->CodecID.Set("A_AAC/MPEG2/MAIN"); break;
- case 1: m_pTE->CodecID.Set("A_AAC/MPEG2/LC"); break;
- case 2: m_pTE->CodecID.Set("A_AAC/MPEG2/SSR"); break;
- case 3: m_pTE->CodecID.Set("A_AAC/MPEG4/LTP"); break;
- case 4: m_pTE->CodecID.Set("A_AAC/MPEG4/LC/SBR"); break;
+ case 0:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/MAIN");
+ break;
+ case 1:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/LC");
+ break;
+ case 2:
+ m_pTE->CodecID.Set("A_AAC/MPEG2/SSR");
+ break;
+ case 3:
+ m_pTE->CodecID.Set("A_AAC/MPEG4/LTP");
+ break;
+ case 4:
+ m_pTE->CodecID.Set("A_AAC/MPEG4/LC/SBR");
+ break;
}
ASSERT(channels == wfe->nChannels);
@@ -918,8 +963,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_WaveFormatEx
+ }
+ else if(m_mt.formattype == FORMAT_WaveFormatEx
&& ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3)
{
m_pTE->CodecID.Set("A_AC3");
@@ -931,8 +976,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_WaveFormatEx
+ }
+ else if(m_mt.formattype == FORMAT_WaveFormatEx
&& ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS)
{
m_pTE->CodecID.Set("A_DTS");
@@ -964,7 +1009,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) hr = S_OK;
}
- else if(m_mt.formattype == FORMAT_WaveFormatEx
+ else if(m_mt.formattype == FORMAT_WaveFormatEx
&& (m_mt.subtype == MEDIASUBTYPE_14_4
|| m_mt.subtype == MEDIASUBTYPE_28_8
|| m_mt.subtype == MEDIASUBTYPE_ATRC
@@ -973,7 +1018,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) || m_mt.subtype == MEDIASUBTYPE_SIPR))
{
CStringA id;
- id.Format("A_REAL/%c%c%c%c",
+ id.Format("A_REAL/%c%c%c%c",
(char)((m_mt.subtype.Data1>>0)&0xff),
(char)((m_mt.subtype.Data1>>8)&0xff),
(char)((m_mt.subtype.Data1>>16)&0xff),
@@ -1007,7 +1052,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- }
+ }
else if(m_mt.formattype == FORMAT_WaveFormatEx)
{
m_pTE->CodecID.Set("A_MS/ACM");
@@ -1058,14 +1103,14 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin) for(int len = pvf2->HeaderSize[i]; len >= 0; len -= 255)
*dst++ = min(len, 255);
- memcpy(dst, src, pvf2->HeaderSize[0]);
- dst += pvf2->HeaderSize[0];
+ memcpy(dst, src, pvf2->HeaderSize[0]);
+ dst += pvf2->HeaderSize[0];
src += pvf2->HeaderSize[0];
- memcpy(dst, src, pvf2->HeaderSize[1]);
- dst += pvf2->HeaderSize[1];
+ memcpy(dst, src, pvf2->HeaderSize[1]);
+ dst += pvf2->HeaderSize[1];
src += pvf2->HeaderSize[1];
- memcpy(dst, src, pvf2->HeaderSize[2]);
- dst += pvf2->HeaderSize[2];
+ memcpy(dst, src, pvf2->HeaderSize[2]);
+ dst += pvf2->HeaderSize[2];
src += pvf2->HeaderSize[2];
ASSERT(src <= m_mt.pbFormat + m_mt.cbFormat);
@@ -1152,7 +1197,10 @@ STDMETHODIMP CMatroskaMuxerInputPin::EndFlush() STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
{
- if(m_fEndOfStreamReceived) {/*ASSERT(0);*/ return S_FALSE;}
+ if(m_fEndOfStreamReceived) {
+ /*ASSERT(0);*/
+ return S_FALSE;
+ }
CAutoLock cAutoLock(&m_csReceive);
@@ -1192,14 +1240,14 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) // rtStart += m_tStart;
// rtStop += m_tStart;
-/**/
- TRACE(_T("Received (%d): %I64d-%I64d (c=%d, co=%dms), len=%d, d%d p%d s%d\n"),
- (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this),
- rtStart, rtStop, (int)((rtStart/10000)/MAXCLUSTERTIME), (int)((rtStart/10000)%MAXCLUSTERTIME),
- len,
- pSample->IsDiscontinuity() == S_OK ? 1 : 0,
- pSample->IsPreroll() == S_OK ? 1 : 0,
- pSample->IsSyncPoint() == S_OK ? 1 : 0);
+ /**/
+ TRACE(_T("Received (%d): %I64d-%I64d (c=%d, co=%dms), len=%d, d%d p%d s%d\n"),
+ (static_cast<CMatroskaMuxerFilter*>(m_pFilter))->GetTrackNumber(this),
+ rtStart, rtStop, (int)((rtStart/10000)/MAXCLUSTERTIME), (int)((rtStart/10000)%MAXCLUSTERTIME),
+ len,
+ pSample->IsDiscontinuity() == S_OK ? 1 : 0,
+ pSample->IsPreroll() == S_OK ? 1 : 0,
+ pSample->IsSyncPoint() == S_OK ? 1 : 0);
if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3)
{
@@ -1225,26 +1273,26 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample) for(int i = 0; i < 3; i++)
{
memcpy(dst, m_pVorbisHdrs[i]->GetData(), m_pVorbisHdrs[i]->GetCount());
- dst += m_pVorbisHdrs[i]->GetCount();
+ dst += m_pVorbisHdrs[i]->GetCount();
}
}
return S_OK;
}
- if(m_mt.formattype == FORMAT_WaveFormatEx
+ if(m_mt.formattype == FORMAT_WaveFormatEx
&& (((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_PCM
|| ((WAVEFORMATEX*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_MPEGLAYER3))
pSample->SetSyncPoint(TRUE); // HACK: some capture filters don't set this
CAutoPtr<BlockGroup> b(DNew BlockGroup());
/*
- // TODO: test this with a longer capture (pcm, mp3)
- if(S_OK == pSample->IsSyncPoint() && rtStart < m_rtLastStart)
- {
- TRACE(_T("!!! timestamp went backwards, dropping this frame !!! rtStart (%I64) < m_rtLastStart (%I64)"), rtStart, m_rtLastStart);
- return S_OK;
- }
+ // TODO: test this with a longer capture (pcm, mp3)
+ if(S_OK == pSample->IsSyncPoint() && rtStart < m_rtLastStart)
+ {
+ TRACE(_T("!!! timestamp went backwards, dropping this frame !!! rtStart (%I64) < m_rtLastStart (%I64)"), rtStart, m_rtLastStart);
+ return S_OK;
+ }
*/
if((S_OK != pSample->IsSyncPoint() || m_rtLastStart == rtStart) && m_rtLastStart >= 0 /*&& m_rtLastStart < rtStart*/)
{
@@ -1308,39 +1356,39 @@ STDMETHODIMP CMatroskaMuxerOutputPin::NonDelegatingQueryInterface(REFIID riid, v {
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CMatroskaMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = 1;
pProperties->cbBuffer = 1;
- ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ ALLOCATOR_PROPERTIES Actual;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
+ if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
+ ASSERT(Actual.cBuffers == pProperties->cBuffers);
- return NOERROR;
+ return NOERROR;
}
HRESULT CMatroskaMuxerOutputPin::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_Matroska
- ? S_OK
- : E_INVALIDARG;
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CMatroskaMuxerOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
if(iPosition < 0) return E_INVALIDARG;
if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h index 21f259901..4a29b8bb5 100644 --- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h +++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h @@ -1,20 +1,20 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -43,9 +43,11 @@ public: virtual ~CMatroskaMuxerInputPin();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- MatroskaWriter::TrackEntry* GetTrackEntry() {return m_pTE;}
+ MatroskaWriter::TrackEntry* GetTrackEntry() {
+ return m_pTE;
+ }
REFERENCE_TIME m_rtDur;
@@ -53,17 +55,17 @@ public: CAutoPtrList<MatroskaWriter::BlockGroup> m_blocks;
bool m_fEndOfStreamReceived;
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT BreakConnect();
- HRESULT CompleteConnect(IPin* pPin);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT BreakConnect();
+ HRESULT CompleteConnect(IPin* pPin);
HRESULT Active(), Inactive();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
STDMETHODIMP Receive(IMediaSample* pSample);
- STDMETHODIMP EndOfStream();
+ STDMETHODIMP EndOfStream();
};
class CMatroskaMuxerOutputPin : public CBaseOutputPin
@@ -73,25 +75,26 @@ public: virtual ~CMatroskaMuxerOutputPin();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
interface __declspec(uuid("38E2D43D-915D-493C-B373-888DB16EE3DC"))
-IMatroskaMuxer : public IUnknown
+IMatroskaMuxer :
+public IUnknown
{
STDMETHOD (CorrectTimeOffset) (bool fNegative, bool fPositive) = 0;
// TODO: chapters
};
class __declspec(uuid("1E1299A2-9D42-4F12-8791-D79E376F4143"))
-CMatroskaMuxerFilter
+ CMatroskaMuxerFilter
: public CBaseFilter
, public CCritSec
, public CAMThread
@@ -115,7 +118,7 @@ public: virtual ~CMatroskaMuxerFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
void AddInput();
UINT GetTrackNumber(CBasePin* pPin);
diff --git a/src/filters/muxer/MatroskaMuxer/resource.h b/src/filters/muxer/MatroskaMuxer/resource.h index cfa5a212d..22bd5aaf8 100644 --- a/src/filters/muxer/MatroskaMuxer/resource.h +++ b/src/filters/muxer/MatroskaMuxer/resource.h @@ -3,7 +3,7 @@ // Used by MatroskaMuxer.rc
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
diff --git a/src/filters/muxer/MatroskaMuxer/stdafx.cpp b/src/filters/muxer/MatroskaMuxer/stdafx.cpp index 6927dbf9c..4bbe643da 100644 --- a/src/filters/muxer/MatroskaMuxer/stdafx.cpp +++ b/src/filters/muxer/MatroskaMuxer/stdafx.cpp @@ -1,29 +1,24 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
-// stdafx.cpp : source file that includes just the standard includes
-// MatroskaMuxer.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/src/filters/muxer/MatroskaMuxer/stdafx.h b/src/filters/muxer/MatroskaMuxer/stdafx.h index 22cb54295..a24b77625 100644 --- a/src/filters/muxer/MatroskaMuxer/stdafx.h +++ b/src/filters/muxer/MatroskaMuxer/stdafx.h @@ -1,28 +1,24 @@ -/*
- * Copyright (C) 2003-2006 Gabest
- * http://www.gabest.org
+/*
+ * Copyright (C) 2003-2006 Gabest
+ * http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
#pragma once
#include "../../../DSUtil/SharedInclude.h"
@@ -35,9 +31,7 @@ #endif
#include <afx.h>
-#include <afxwin.h> // MFC core and standard components
-
-// TODO: reference additional headers your program requires here
+#include <afxwin.h> // MFC core and standard components
#include <dshow.h>
#include <streams.h>
|