From 8993f17fb9fa55ed58e6e3c8d2fde888bd56dbe5 Mon Sep 17 00:00:00 2001 From: Hwasoo Lee Date: Tue, 15 Jun 2010 17:47:45 -0400 Subject: [PATCH] removed trailing white spaces in code Change-Id: Ifec57ab7278a6b63fd2465e32ba82c7805c359ab --- mkvparser.cpp | 174 +++++++++++++++++++++++++------------------------- mkvparser.hpp | 128 ++++++++++++++++++------------------- mkvreader.cpp | 50 +++++++-------- sample.cpp | 120 +++++++++++++++++----------------- 4 files changed, 236 insertions(+), 236 deletions(-) diff --git a/mkvparser.cpp b/mkvparser.cpp index 99800b1..b0c2b25 100644 --- a/mkvparser.cpp +++ b/mkvparser.cpp @@ -1949,8 +1949,8 @@ long Track::GetNext(const BlockEntry* pCurrEntry, const BlockEntry*& pNextEntry) //we want at all; we want the next call to PopulateSample to //return end-of-stream, not (re)start from the beginning. // - //One work-around is to send EOS immediately. We would send - //the EOS the next pass anyway, so maybe it's no great loss. The + //One work-around is to send EOS immediately. We would send + //the EOS the next pass anyway, so maybe it's no great loss. The //only problem is that if this the stream really does end one //cluster early (relative to other tracks), or the last frame //happens to be a keyframe ("CanSeekToEnd"). @@ -1960,7 +1960,7 @@ long Track::GetNext(const BlockEntry* pCurrEntry, const BlockEntry*& pNextEntry) //We need to give pCurr some value that means "you've reached EOS". //We can't synthesize the special EOS Cluster immediately //(when we first open the file, say), because we use the existance - //of that special cluster value to mean that we've read all of + //of that special cluster value to mean that we've read all of //the clusters (this is a network download, so we can't know apriori //how many we have). // @@ -1968,13 +1968,13 @@ long Track::GetNext(const BlockEntry* pCurrEntry, const BlockEntry*& pNextEntry) //object itself, to indicate that it should send EOS earlier //than when (pCurr=pStop). // - //Or, probably the best solution, when we actually load the + //Or, probably the best solution, when we actually load the //blocks into a cluster: if we notice that there's no block //for a track, we synthesize a nonce EOS block for that track. //That way we always have something to return. But that will //only work for sequential scan??? - //pNext = NULL; + //pNext = NULL; //return E_FAIL; pNextEntry = GetEOS(); return 1L; @@ -2590,41 +2590,41 @@ void Cluster::LoadBlockEntries() if (m_pEntries) return; - Load(); + Load(); assert(m_timecode >= 0); assert(m_start > 0); assert(m_size > 0); - + IMkvReader* const pReader = m_pSegment->m_pReader; - + long long pos = m_start; const long long stop = m_start + m_size; long long timecode = -1; - + long long idx = pos; m_entriesCount = 0; - + while (idx < stop) { if (Match(pReader, idx, 0x67, timecode)) assert(timecode == m_timecode); - else + else { long len; - + const long long id = ReadUInt(pReader, idx, len); assert(id >= 0); //TODO assert((idx + len) <= stop); - + idx += len; //consume id - + const long long size = ReadUInt(pReader, idx, len); assert(size >= 0); //TODO assert((idx + len) <= stop); - + idx += len; //consume size - + if (id == 0x20) //BlockGroup ID ++m_entriesCount; else if (id == 0x23) //SimpleBlock ID @@ -2633,15 +2633,15 @@ void Cluster::LoadBlockEntries() idx += size; //consume payload assert(idx <= stop); - } + } } if (m_entriesCount == 0) return; - + m_pEntries = new BlockEntry*[m_entriesCount]; size_t index = 0; - + while (pos < stop) { if (Match(pReader, pos, 0x67, timecode)) @@ -2652,15 +2652,15 @@ void Cluster::LoadBlockEntries() const long long id = ReadUInt(pReader, pos, len); assert(id >= 0); //TODO assert((pos + len) <= stop); - + pos += len; //consume id - + const long long size = ReadUInt(pReader, pos, len); assert(size >= 0); //TODO assert((pos + len) <= stop); - + pos += len; //consume size - + if (id == 0x20) //BlockGroup ID ParseBlockGroup(pos, size, index++); else if (id == 0x23) //SimpleBlock ID @@ -2670,7 +2670,7 @@ void Cluster::LoadBlockEntries() assert(pos <= stop); } } - + assert(pos == stop); assert(timecode >= 0); assert(index == m_entriesCount); @@ -2689,13 +2689,13 @@ long long Cluster::GetTime() { const long long tc = GetTimeCode(); assert(tc >= 0); - + const SegmentInfo* const pInfo = m_pSegment->GetInfo(); assert(pInfo); - + const long long scale = pInfo->GetTimeCodeScale(); assert(scale >= 1); - + const long long t = m_timecode * scale; return t; @@ -2707,10 +2707,10 @@ void Cluster::ParseBlockGroup(long long start, long long size, size_t index) assert(m_pEntries); assert(m_entriesCount); assert(index < m_entriesCount); - + BlockGroup* const pGroup = new BlockGroup(this, index, start, size); assert(pGroup); //TODO - + m_pEntries[index] = pGroup; } @@ -2724,7 +2724,7 @@ void Cluster::ParseSimpleBlock(long long start, long long size, size_t index) SimpleBlock* const pSimpleBlock = new SimpleBlock(this, index, start, size); assert(pSimpleBlock); //TODO - + m_pEntries[index] = pSimpleBlock; } @@ -2732,29 +2732,29 @@ void Cluster::ParseSimpleBlock(long long start, long long size, size_t index) const BlockEntry* Cluster::GetFirst() { LoadBlockEntries(); - + return m_pEntries[0]; } - + const BlockEntry* Cluster::GetLast() -{ +{ if (m_entriesCount == 0) return m_pEntries[0]; - + return m_pEntries[m_entriesCount-1]; } - + const BlockEntry* Cluster::GetNext(const BlockEntry* pEntry) const { assert(pEntry); - + size_t idx = pEntry->GetIndex(); - + ++idx; - if (idx == m_entriesCount) + if (idx == m_entriesCount) return NULL; return m_pEntries[idx]; @@ -2766,12 +2766,12 @@ const BlockEntry* Cluster::GetEntry(const Track* pTrack) { assert(pTrack); - + if (m_pSegment == NULL) //EOS return pTrack->GetEOS(); - + LoadBlockEntries(); - + BlockEntry* i = *m_pEntries; BlockEntry* j = *m_pEntries + m_entriesCount; while (i != j) @@ -2780,17 +2780,17 @@ const BlockEntry* Cluster::GetEntry(const Track* pTrack) i++; assert(pEntry); assert(!pEntry->EOS()); - + const Block* const pBlock = pEntry->GetBlock(); assert(pBlock); - + if (pBlock->GetTrackNumber() != pTrack->GetNumber()) continue; if (pTrack->VetEntry(pEntry)) return pEntry; } - + return pTrack->GetEOS(); //no satisfactory block found } @@ -2807,9 +2807,9 @@ BlockEntry::~BlockEntry() SimpleBlock::SimpleBlock( - Cluster* pCluster, - size_t idx, - long long start, + Cluster* pCluster, + size_t idx, + long long start, long long size) : m_pCluster(pCluster), m_index(idx), @@ -2849,9 +2849,9 @@ bool SimpleBlock::IsBFrame() const BlockGroup::BlockGroup( - Cluster* pCluster, - size_t idx, - long long start, + Cluster* pCluster, + size_t idx, + long long start, long long size_) : m_pCluster(pCluster), m_index(idx), @@ -2860,18 +2860,18 @@ BlockGroup::BlockGroup( m_pBlock(NULL) //TODO: accept multiple blocks within a block group { IMkvReader* const pReader = m_pCluster->m_pSegment->m_pReader; - + long long pos = start; const long long stop = start + size_; - + bool bSimpleBlock = false; - + while (pos < stop) { short t; - + if (Match(pReader, pos, 0x7B, t)) - { + { if (t < 0) m_prevTimeCode = t; else if (t > 0) @@ -2885,15 +2885,15 @@ BlockGroup::BlockGroup( const long long id = ReadUInt(pReader, pos, len); assert(id >= 0); //TODO assert((pos + len) <= stop); - + pos += len; //consume ID - + const long long size = ReadUInt(pReader, pos, len); assert(size >= 0); //TODO assert((pos + len) <= stop); - + pos += len; //consume size - + switch (id) { case 0x23: //SimpleBlock ID @@ -2901,21 +2901,21 @@ BlockGroup::BlockGroup( //YES, FALL THROUGH TO NEXT CASE case 0x21: //Block ID - ParseBlock(pos, size); + ParseBlock(pos, size); break; - + default: break; } - + pos += size; //consume payload assert(pos <= stop); } } - + assert(pos == stop); assert(m_pBlock); - + if (!bSimpleBlock) m_pBlock->SetKey(m_prevTimeCode >= 0); } @@ -2928,18 +2928,18 @@ BlockGroup::~BlockGroup() void BlockGroup::ParseBlock(long long start, long long size) -{ +{ IMkvReader* const pReader = m_pCluster->m_pSegment->m_pReader; - + Block* const pBlock = new Block(start, size, pReader); assert(pBlock); //TODO - //TODO: the Matroska spec says you have multiple blocks within the + //TODO: the Matroska spec says you have multiple blocks within the //same block group, with blocks ranked by priority (the flag bits). //I haven't ever seen such a file (mkvmux certainly doesn't make //one), so until then I'll just assume block groups contain a single //block. -#if 0 +#if 0 m_blocks.push_back(pBlock); #else assert(m_pBlock == NULL); @@ -2949,7 +2949,7 @@ void BlockGroup::ParseBlock(long long start, long long size) #if 0 Track* const pTrack = pBlock->GetTrack(); assert(pTrack); - + pTrack->Insert(pBlock); #endif } @@ -2988,7 +2988,7 @@ short BlockGroup::GetPrevTimeCode() const short BlockGroup::GetNextTimeCode() const { return m_nextTimeCode; -} +} bool BlockGroup::IsBFrame() const @@ -3006,31 +3006,31 @@ Block::Block(long long start, long long size_, IMkvReader* pReader) : const long long stop = start + size_; long len; - + m_track = ReadUInt(pReader, pos, len); assert(m_track > 0); assert((pos + len) <= stop); - + pos += len; //consume track number assert((stop - pos) >= 2); - + m_timecode = Unserialize2SInt(pReader, pos); pos += 2; assert((stop - pos) >= 1); - + const long hr = pReader->Read(pos, 1, &m_flags); assert(hr == 0L); ++pos; assert(pos <= stop); - + m_frameOff = pos; - + const long long frame_size = stop - pos; assert(frame_size <= 2147483647L); - + m_frameSize = static_cast(frame_size); } @@ -3038,13 +3038,13 @@ Block::Block(long long start, long long size_, IMkvReader* pReader) : long long Block::GetTimeCode(Cluster* pCluster) const { assert(pCluster); - + const long long tc0 = pCluster->GetTimeCode(); assert(tc0 >= 0); - + const long long tc = tc0 + static_cast(m_timecode); assert(tc >= 0); - + return tc; //unscaled timecode units } @@ -3052,16 +3052,16 @@ long long Block::GetTimeCode(Cluster* pCluster) const long long Block::GetTime(Cluster* pCluster) const { assert(pCluster); - + const long long tc = GetTimeCode(pCluster); - + const Segment* const pSegment = pCluster->m_pSegment; const SegmentInfo* const pInfo = pSegment->GetInfo(); assert(pInfo); - + const long long scale = pInfo->GetTimeCodeScale(); assert(scale >= 1); - + const long long ns = tc * scale; return ns; @@ -3071,7 +3071,7 @@ long long Block::GetTime(Cluster* pCluster) const unsigned long Block::GetTrackNumber() const { assert(m_track > 0); - + return static_cast(m_track); } @@ -3102,9 +3102,9 @@ long Block::Read(IMkvReader* pReader, unsigned char* buf) const assert(pReader); assert(buf); - + const long hr = pReader->Read(m_frameOff, m_frameSize, buf); - + return hr; } diff --git a/mkvparser.hpp b/mkvparser.hpp index 692b876..2857670 100644 --- a/mkvparser.hpp +++ b/mkvparser.hpp @@ -22,7 +22,7 @@ class IMkvReader { public: virtual int Read(long long position, long length, unsigned char* buffer) = 0; - virtual int Length(long long* total, long long* available) = 0; + virtual int Length(long long* total, long long* available) = 0; protected: virtual ~IMkvReader(); }; @@ -45,7 +45,7 @@ bool Match(IMkvReader*, long long&, unsigned long, short&); struct EBMLHeader { EBMLHeader(); - ~EBMLHeader(); + ~EBMLHeader(); long long m_version; long long m_readVersion; long long m_maxIdLength; @@ -53,7 +53,7 @@ struct EBMLHeader char* m_docType; long long m_docTypeVersion; long long m_docTypeReadVersion; - + long long Parse(IMkvReader*, long long&); }; @@ -70,11 +70,11 @@ class Block public: const long long m_start; const long long m_size; - + Block(long long start, long long size, IMkvReader*); - + unsigned long GetTrackNumber() const; - + long long GetTimeCode(Cluster*) const; //absolute, but not scaled long long GetTime(Cluster*) const; //absolute, and scaled (nanosecond units) bool IsKey() const; @@ -82,13 +82,13 @@ public: long GetSize() const; long Read(IMkvReader*, unsigned char*) const; - + private: long long m_track; //Track::Number() short m_timecode; //relative to cluster unsigned char m_flags; long long m_frameOff; - long m_frameSize; + long m_frameSize; }; @@ -97,7 +97,7 @@ class BlockEntry { BlockEntry(const BlockEntry&); BlockEntry& operator=(const BlockEntry&); - + public: virtual ~BlockEntry(); virtual bool EOS() const = 0; @@ -105,7 +105,7 @@ public: virtual size_t GetIndex() const = 0; virtual const Block* GetBlock() const = 0; virtual bool IsBFrame() const = 0; - + protected: BlockEntry(); @@ -121,7 +121,7 @@ public: SimpleBlock(Cluster*, size_t, long long start, long long size); bool EOS() const; - Cluster* GetCluster() const; + Cluster* GetCluster() const; size_t GetIndex() const; const Block* GetBlock() const; bool IsBFrame() const; @@ -130,7 +130,7 @@ protected: Cluster* const m_pCluster; const size_t m_index; Block m_block; - + }; @@ -142,28 +142,28 @@ class BlockGroup : public BlockEntry public: BlockGroup(Cluster*, size_t, long long, long long); ~BlockGroup(); - + bool EOS() const; - Cluster* GetCluster() const; + Cluster* GetCluster() const; size_t GetIndex() const; const Block* GetBlock() const; bool IsBFrame() const; - + short GetPrevTimeCode() const; //relative to block's time short GetNextTimeCode() const; //as above - + protected: Cluster* const m_pCluster; const size_t m_index; - + private: BlockGroup(Cluster*, size_t, unsigned long); void ParseBlock(long long start, long long size); short m_prevTimeCode; short m_nextTimeCode; - - //TODO: the Matroska spec says you can have multiple blocks within the + + //TODO: the Matroska spec says you can have multiple blocks within the //same block group, with blocks ranked by priority (the flag bits). //For now we just cache a single block. #if 0 @@ -172,7 +172,7 @@ private: #else Block* m_pBlock; #endif - + }; @@ -181,25 +181,25 @@ class Track Track(const Track&); Track& operator=(const Track&); -public: +public: Segment* const m_pSegment; virtual ~Track(); - - long long GetType() const; + + long long GetType() const; unsigned long GetNumber() const; const char* GetNameAsUTF8() const; const char* GetCodecNameAsUTF8() const; const char* GetCodecId() const; const unsigned char* GetCodecPrivate(size_t&) const; - + const BlockEntry* GetEOS() const; - - struct Settings + + struct Settings { long long start; long long size; }; - + struct Info { long long type; @@ -214,13 +214,13 @@ public: Info(); void Clear(); }; - + long GetFirst(const BlockEntry*&) const; long GetNext(const BlockEntry* pCurr, const BlockEntry*& pNext) const; virtual bool VetEntry(const BlockEntry*) const = 0; - + protected: - Track(Segment*, const Info&); + Track(Segment*, const Info&); const Info m_info; class EOSBlock : public BlockEntry @@ -228,15 +228,15 @@ protected: public: EOSBlock(); - bool EOS() const; + bool EOS() const; Cluster* GetCluster() const; size_t GetIndex() const; const Block* GetBlock() const; bool IsBFrame() const; }; - + EOSBlock m_eos; - + }; @@ -244,20 +244,20 @@ class VideoTrack : public Track { VideoTrack(const VideoTrack&); VideoTrack& operator=(const VideoTrack&); - + public: - VideoTrack(Segment*, const Info&); + VideoTrack(Segment*, const Info&); long long GetWidth() const; long long GetHeight() const; double GetFrameRate() const; - + bool VetEntry(const BlockEntry*) const; private: long long m_width; long long m_height; double m_rate; - + }; @@ -267,10 +267,10 @@ class AudioTrack : public Track AudioTrack& operator=(const AudioTrack&); public: - AudioTrack(Segment*, const Info&); + AudioTrack(Segment*, const Info&); double GetSamplingRate() const; long long GetChannels() const; - long long GetBitDepth() const; + long long GetBitDepth() const; bool VetEntry(const BlockEntry*) const; private: @@ -289,19 +289,19 @@ public: Segment* const m_pSegment; const long long m_start; const long long m_size; - + Tracks(Segment*, long long start, long long size); virtual ~Tracks(); Track* GetTrackByNumber(unsigned long tn) const; Track* GetTrackByIndex(unsigned long idx) const; - + private: - Track** m_trackEntries; + Track** m_trackEntries; Track** m_trackEntriesEnd; void ParseTrackEntry(long long, long long, Track*&); - + public: unsigned long GetTracksCount() const; }; @@ -311,12 +311,12 @@ class SegmentInfo { SegmentInfo(const SegmentInfo&); SegmentInfo& operator=(const SegmentInfo&); - + public: Segment* const m_pSegment; const long long m_start; const long long m_size; - + SegmentInfo(Segment*, long long start, long long size); ~SegmentInfo(); long long GetTimeCodeScale() const; @@ -324,7 +324,7 @@ public: const char* GetMuxingAppAsUTF8() const; const char* GetWritingAppAsUTF8() const; const char* GetTitleAsUTF8() const; - + private: long long m_timecodeScale; double m_duration; @@ -342,37 +342,37 @@ class Cluster public: Segment* const m_pSegment; const size_t m_index; - -public: + +public: static Cluster* Parse(Segment*, size_t, long long off); Cluster(); //EndOfStream ~Cluster(); - + bool EOS() const; - + long long GetTimeCode(); //absolute, but not scaled long long GetTime(); //absolute, and scaled (nanosecond units) const BlockEntry* GetFirst(); const BlockEntry* GetLast(); - const BlockEntry* GetNext(const BlockEntry*) const; + const BlockEntry* GetNext(const BlockEntry*) const; const BlockEntry* GetEntry(const Track*); -protected: +protected: Cluster(Segment*, size_t, long long off); - + private: long long m_start; - long long m_size; + long long m_size; long long m_timecode; BlockEntry** m_pEntries; size_t m_entriesCount; - + void Load(); void LoadBlockEntries(); void ParseBlockGroup(long long, long long, size_t); void ParseSimpleBlock(long long, long long, size_t); - + }; @@ -389,37 +389,37 @@ public: const long long m_start; //posn of segment payload const long long m_size; //size of segment payload Cluster m_eos; //TODO: make private? - + static long long CreateInstance(IMkvReader*, long long, Segment*&); ~Segment(); //for big-bang loading (source filter) long Load(); - //for incremental loading (splitter) + //for incremental loading (splitter) long long Unparsed() const; long long ParseHeaders(); long ParseCluster(Cluster*&, long long& newpos) const; bool AddCluster(Cluster*, long long); - Tracks* GetTracks() const; + Tracks* GetTracks() const; const SegmentInfo* const GetInfo() const; long long GetDuration() const; - + //NOTE: this turned out to be too inefficient. //long long Load(long long time_nanoseconds); Cluster* GetFirst(); Cluster* GetLast(); unsigned long GetCount() const; - + Cluster* GetNext(const Cluster*); Cluster* GetCluster(long long time_nanoseconds); - + private: - long long m_pos; //absolute file posn; what has been consumed so far + long long m_pos; //absolute file posn; what has been consumed so far SegmentInfo* m_pInfo; - Tracks* m_pTracks; + Tracks* m_pTracks; Cluster** m_clusters; size_t m_clusterCount; diff --git a/mkvreader.cpp b/mkvreader.cpp index fe25845..fbcfee9 100644 --- a/mkvreader.cpp +++ b/mkvreader.cpp @@ -24,13 +24,13 @@ int MkvReader::Open(const char* fileName) { if (fileName == NULL) return -1; - + if (m_file) return -1; #ifdef WIN32 const errno_t e = fopen_s(&m_file, fileName, "rb"); - + if (e) return -1; //error #else @@ -40,29 +40,29 @@ int MkvReader::Open(const char* fileName) return -1; #endif -#ifdef WIN32 +#ifdef WIN32 int status = _fseeki64(m_file, 0L, SEEK_END); - + if (status) return -1; //error - + m_length = _ftelli64(m_file); -#else +#else fseek(m_file, 0L, SEEK_END); m_length = ftell(m_file); -#endif - assert(m_length >= 0); - -#ifdef WIN32 +#endif + assert(m_length >= 0); + +#ifdef WIN32 status = _fseeki64(m_file, 0L, SEEK_SET); - + if (status) return -1; //error -#else +#else fseek(m_file, 0L, SEEK_SET); -#endif +#endif - return 0; + return 0; } void MkvReader::Close() @@ -81,10 +81,10 @@ int MkvReader::Length(long long* total, long long* available) if (total) *total = m_length; - + if (available) *available = m_length; - + return 0; } @@ -95,29 +95,29 @@ int MkvReader::Read(long long offset, long len, unsigned char* buffer) if (offset < 0) return -1; - + if (len < 0) return -1; - + if (len == 0) return 0; - + if (offset >= m_length) return -1; -#ifdef WIN32 +#ifdef WIN32 const int status = _fseeki64(m_file, offset, SEEK_SET); - + if (status) return -1; //error -#else +#else fseek(m_file, offset, SEEK_SET); -#endif +#endif const size_t size = fread(buffer, 1, len, m_file); - + if (size < size_t(len)) return -1; //error - + return 0; //success } diff --git a/sample.cpp b/sample.cpp index e91f705..6b3d00f 100644 --- a/sample.cpp +++ b/sample.cpp @@ -17,41 +17,41 @@ static const wchar_t* utf8towcs(const char* str) { if (str == NULL) return NULL; - - //TODO: this probably requires that the locale be + + //TODO: this probably requires that the locale be //configured somehow: - + const size_t size = mbstowcs(NULL, str, 0); - + if (size == 0) return NULL; - + wchar_t* const val = new wchar_t[size+1]; - + mbstowcs(val, str, size); val[size] = L'\0'; - + return val; } int main(int argc, char* argv[]) { - if (argc == 1) - { + if (argc == 1) + { printf("\t\t\tMkv Parser Sample Application\n"); printf("\t\t\tUsage: \n"); printf("\t\t\t ./sample [input file] \n"); - printf("\t\t\t ./sample sample.mkv \n"); + printf("\t\t\t ./sample sample.mkv \n"); return -1; } - + using namespace mkvparser; - + MkvReader reader; - + if (reader.Open(argv[1])) - { + { printf("\n Filename is invalid or error while opening.\n"); return -1; } @@ -62,31 +62,31 @@ int main(int argc, char* argv[]) ebmlHeader.Parse(&reader, pos); - printf("\t\t\t EBML Header\n"); - printf("\t\tEBML Version\t\t: %lld\n", ebmlHeader.m_version); + printf("\t\t\t EBML Header\n"); + printf("\t\tEBML Version\t\t: %lld\n", ebmlHeader.m_version); printf("\t\tEBML MaxIDLength\t: %lld\n", ebmlHeader.m_maxIdLength); printf("\t\tEBML MaxSizeLength\t: %lld\n", ebmlHeader.m_maxSizeLength); printf("\t\tDoc Type\t\t: %s\n", ebmlHeader.m_docType); - printf("\t\tPos\t\t\t: %lld\n", pos); - + printf("\t\tPos\t\t\t: %lld\n", pos); + mkvparser::Segment* pSegment; - + long long ret = mkvparser::Segment::CreateInstance(&reader, pos, pSegment); - if (ret) + if (ret) { - printf("\n Segment::CreateInstance() failed."); + printf("\n Segment::CreateInstance() failed."); return -1; } ret = pSegment->Load(); - if (ret < 0) + if (ret < 0) { - printf("\n Segment::Load() failed."); + printf("\n Segment::Load() failed."); return -1; - } - + } + const SegmentInfo* const pSegmentInfo = pSegment->GetInfo(); - + const long long timeCodeScale = pSegmentInfo->GetTimeCodeScale(); const long long duration_ns = pSegmentInfo->GetDuration(); const wchar_t* const pTitle = utf8towcs(pSegmentInfo->GetTitleAsUTF8()); @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) printf("\t\t\t Segment Info\n"); printf("\t\tTimeCodeScale\t\t: %lld \n", timeCodeScale); printf("\t\tDuration\t\t: %lld\n", duration_ns); - + const double duration_sec = double(duration_ns) / 1000000000; printf("\t\tDuration(secs)\t\t: %7.3f\n", duration_sec); @@ -105,39 +105,39 @@ int main(int argc, char* argv[]) printf("\t\tTrack Name\t\t: NULL\n"); else printf("\t\tTrack Name\t\t: %ls\n", pTitle); - + if (pMuxingApp == NULL) printf("\t\tMuxing App\t\t: NULL\n"); - else + else printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp); - if (pWritingApp == NULL) + if (pWritingApp == NULL) printf("\t\tWriting App\t\t: NULL\n"); - else + else printf("\t\tWriting App\t\t: %ls\n", pWritingApp); - printf("\t\tPosition(Segment)\t: %lld\n", pSegment->m_start); // position of segment payload - printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size); // size of segment payload + printf("\t\tPosition(Segment)\t: %lld\n", pSegment->m_start); // position of segment payload + printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size); // size of segment payload mkvparser::Tracks* const pTracks = pSegment->GetTracks(); unsigned long i = 0; const unsigned long j = pTracks->GetTracksCount(); - + enum { VIDEO_TRACK = 1, AUDIO_TRACK = 2 }; printf("\n\t\t\t Track Info\n"); - + while (i != j) { const Track* const pTrack = pTracks->GetTrackByIndex(i++); - - if (pTrack == NULL) + + if (pTrack == NULL) continue; const long long trackType_ = pTrack->GetType(); unsigned long trackType = static_cast(trackType_); - + unsigned long trackNumber = pTrack->GetNumber(); const wchar_t* const pTrackName = utf8towcs(pTrack->GetNameAsUTF8()); @@ -146,22 +146,22 @@ int main(int argc, char* argv[]) if (pTrackName == NULL) printf("\t\tTrack Name\t\t: NULL\n"); - else + else printf("\t\tTrack Name\t\t: %ls \n", pTrackName); const char* const pCodecId = pTrack->GetCodecId(); - - if (pCodecId == NULL) + + if (pCodecId == NULL) printf("\t\tCodec Id\t\t: NULL\n"); - else - printf("\t\tCodec Id\t\t: %s\n", pCodecId); + else + printf("\t\tCodec Id\t\t: %s\n", pCodecId); const wchar_t* const pCodecName = utf8towcs(pTrack->GetCodecNameAsUTF8()); - - if (pCodecName == NULL) + + if (pCodecName == NULL) printf("\t\tCodec Name\t\t: NULL\n"); - else - printf("\t\tCodec Name\t\t: %ls\n", pCodecName); + else + printf("\t\tCodec Name\t\t: %ls\n", pCodecName); if (trackType == VIDEO_TRACK) { @@ -174,7 +174,7 @@ int main(int argc, char* argv[]) printf("\t\tVideo Height\t\t: %lld\n", height); printf("\t\tVideo Rate\t\t: %f\n",rate); } - + if (trackType == AUDIO_TRACK) { const AudioTrack* const pAudioTrack = static_cast(pTrack); @@ -187,12 +187,12 @@ int main(int argc, char* argv[]) printf("\t\tAddio Sample Rate\t: %.3f\n", sampleRate); } } - + printf("\n\n\t\t\t Cluster Info\n"); const unsigned long clusterCount = pSegment->GetCount(); printf("\t\tCluster Count\t: %ld\n\n", clusterCount); - + if (clusterCount == 0) { printf("\t\tSegment has no clusters.\n"); @@ -201,32 +201,32 @@ int main(int argc, char* argv[]) } mkvparser::Cluster* pCluster = pSegment->GetFirst(); - + while ((pCluster != NULL) && !pCluster->EOS()) - { + { const long long timeCode = pCluster->GetTimeCode(); printf("\t\tCluster Time Code\t: %lld\n", timeCode); - + const long long time_ns = pCluster->GetTime(); - printf("\t\tCluster Time (ns)\t: %lld\n", time_ns); - - const BlockEntry* pBlockEntry = pCluster->GetFirst(); - + printf("\t\tCluster Time (ns)\t: %lld\n", time_ns); + + const BlockEntry* pBlockEntry = pCluster->GetFirst(); + while ((pBlockEntry != NULL) && !pBlockEntry->EOS()) { const Block* const pBlock = pBlockEntry->GetBlock(); - const unsigned long trackNum = pBlock->GetTrackNumber(); + const unsigned long trackNum = pBlock->GetTrackNumber(); const long size = pBlock->GetSize(); const long long time_ns = pBlock->GetTime(pCluster); printf("\t\t\tBlock\t\t:%s,%15ld,%s,%15lld\n", (trackNum == VIDEO_TRACK) ? "V" : "A", - size, + size, pBlock->IsKey() ? "I" : "P", time_ns); pBlockEntry = pCluster->GetNext(pBlockEntry); - } + } pCluster = pSegment->GetNext(pCluster); }