Compare commits
16 Commits
libwebm-1.
...
libwebm-1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91dbee4b6e | ||
|
|
1e6c5cbaf7 | ||
|
|
c62b9f8a21 | ||
|
|
5dd6000dc7 | ||
|
|
3ea595b132 | ||
|
|
14e42cf98b | ||
|
|
6c9f4d11a1 | ||
|
|
95c134ad53 | ||
|
|
30bf3472bf | ||
|
|
7adec5248a | ||
|
|
093b78faf2 | ||
|
|
ed90de0d52 | ||
|
|
a01e568293 | ||
|
|
d7ce23a019 | ||
|
|
acf7ddb273 | ||
|
|
fc12207e15 |
28
RELEASE.TXT
28
RELEASE.TXT
@@ -1,3 +1,29 @@
|
||||
1.0.0.5
|
||||
* Handled case when no duration
|
||||
* Handled empty clusters
|
||||
* Handled empty clusters when seeking
|
||||
* Implemented check lacing bits
|
||||
|
||||
1.0.0.4
|
||||
* Made Cues member variables mutables
|
||||
* Defined against badly-formatted cue points
|
||||
* Segment::GetCluster returns CuePoint too
|
||||
* Separated cue-based searches
|
||||
|
||||
1.0.0.3
|
||||
* Added Block::GetOffset() to get a frame's offset in a block
|
||||
* Changed cluster count type from size_t to long
|
||||
* Parsed SeekHead to find cues
|
||||
* Allowed seeking beyond end of cluster cache
|
||||
* Added not to attempt to reparse cues element
|
||||
* Restructured Segment::LoadCluster
|
||||
* Marked position of cues without parsing cues element
|
||||
* Allowed cue points to be loaded incrementally
|
||||
* Implemented to load lazily cue points as they're searched
|
||||
* Merged Cues::LoadCuePoint into Cues::Find
|
||||
* Lazy init cues
|
||||
* Loaded cue point during find
|
||||
|
||||
1.0.0.2
|
||||
* added support for Cues element
|
||||
* seeking was improved
|
||||
@@ -5,4 +31,4 @@
|
||||
1.0.0.1
|
||||
* fixed item 141
|
||||
* added item 142
|
||||
* added this file, RELEASE.TXT, to repository
|
||||
* added this file, RELEASE.TXT, to repository
|
||||
|
||||
545
mkvparser.cpp
545
mkvparser.cpp
@@ -10,6 +10,7 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <climits>
|
||||
//#include <windows.h>
|
||||
//#include "odbgstream.hpp"
|
||||
//using std::endl;
|
||||
@@ -24,7 +25,7 @@ void mkvparser::GetVersion(int& major, int& minor, int& build, int& revision)
|
||||
major = 1;
|
||||
minor = 0;
|
||||
build = 0;
|
||||
revision = 4;
|
||||
revision = 7;
|
||||
}
|
||||
|
||||
|
||||
@@ -706,6 +707,7 @@ long long EBMLHeader::Parse(
|
||||
|
||||
if ((total - pos) < len)
|
||||
return E_FILE_FORMAT_INVALID;
|
||||
|
||||
if ((available - pos) < len)
|
||||
return pos + len; //try again later
|
||||
|
||||
@@ -768,7 +770,6 @@ long long EBMLHeader::Parse(
|
||||
}
|
||||
|
||||
assert(pos == end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1028,17 +1029,15 @@ long long Segment::ParseHeaders()
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
||||
long Segment::ParseCluster(long long& off, long long& new_pos) const
|
||||
{
|
||||
pCluster = NULL;
|
||||
pos_ = -1;
|
||||
off = -1;
|
||||
new_pos = -1;
|
||||
|
||||
const long long stop = m_start + m_size;
|
||||
assert(m_pos <= stop);
|
||||
|
||||
long long pos = m_pos;
|
||||
long long off = -1;
|
||||
|
||||
while (pos < stop)
|
||||
{
|
||||
@@ -1088,8 +1087,8 @@ long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
||||
|
||||
if (off < 0) //we did not found any more clusters
|
||||
{
|
||||
pos_ = stop; //pos_ >= 0 here means EOF (cluster is NULL)
|
||||
return 0; //TODO: confirm this return value
|
||||
new_pos = stop; //pos >= 0 here means EOF (cluster is NULL)
|
||||
return 0; //TODO: confirm this return value
|
||||
}
|
||||
|
||||
//We found a cluster. Now read something, to ensure that it is
|
||||
@@ -1121,7 +1120,7 @@ long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
||||
const int result = m_pReader->Read(pos - 1, 1, &b);
|
||||
assert(result == 0);
|
||||
|
||||
pos_ = stop;
|
||||
new_pos = stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1144,33 +1143,26 @@ long Segment::ParseCluster(Cluster*& pCluster, long long& pos_) const
|
||||
if (size < 0) //error
|
||||
return static_cast<long>(size);
|
||||
|
||||
pos_ = idpos;
|
||||
new_pos = idpos;
|
||||
}
|
||||
|
||||
//We found a cluster, and it has been completely loaded into the
|
||||
//network cache. (We can guarantee this because we actually read
|
||||
//the EBML tag that follows the cluster, or, if we reached EOF,
|
||||
//because we actually read the last byte of the cluster).
|
||||
|
||||
Segment* const this_ = const_cast<Segment*>(this);
|
||||
|
||||
pCluster = Cluster::Parse(this_, m_clusterCount, off);
|
||||
assert(pCluster);
|
||||
assert(pCluster->m_index == m_clusterCount);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Segment::AddCluster(Cluster* pCluster, long long pos)
|
||||
bool Segment::AddCluster(long long off, long long pos)
|
||||
{
|
||||
assert(pos >= m_start);
|
||||
|
||||
const long long stop = m_start + m_size;
|
||||
assert(pos <= stop);
|
||||
|
||||
if (pCluster)
|
||||
if (off >= 0)
|
||||
{
|
||||
Cluster* const pCluster = Cluster::Parse(this, m_clusterCount, off);
|
||||
assert(pCluster);
|
||||
assert(pCluster->m_index == m_clusterCount);
|
||||
|
||||
AppendCluster(pCluster);
|
||||
assert(m_clusters);
|
||||
assert(m_clusterSize > pCluster->m_index);
|
||||
@@ -1181,7 +1173,6 @@ bool Segment::AddCluster(Cluster* pCluster, long long pos)
|
||||
|
||||
return (pos >= stop);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
long Segment::LoadCluster()
|
||||
@@ -2033,6 +2024,50 @@ bool Cues::FindNext(
|
||||
#endif
|
||||
|
||||
|
||||
const CuePoint* Cues::GetFirst() const
|
||||
{
|
||||
LoadCuePoint(); //init cues
|
||||
|
||||
const size_t count = m_count + m_preload_count;
|
||||
|
||||
if (count == 0) //weird
|
||||
return NULL;
|
||||
|
||||
CuePoint* const* const pp = m_cue_points;
|
||||
assert(pp);
|
||||
|
||||
CuePoint* const pCP = pp[0];
|
||||
assert(pCP);
|
||||
assert(pCP->GetTimeCode() >= 0);
|
||||
|
||||
return pCP;
|
||||
}
|
||||
|
||||
|
||||
const CuePoint* Cues::GetLast() const
|
||||
{
|
||||
LoadCuePoint(); //init cues
|
||||
|
||||
const size_t count = m_count + m_preload_count;
|
||||
|
||||
if (count == 0) //weird
|
||||
return NULL;
|
||||
|
||||
const size_t index = count - 1;
|
||||
|
||||
CuePoint* const* const pp = m_cue_points;
|
||||
assert(pp);
|
||||
|
||||
CuePoint* const pCP = pp[index];
|
||||
assert(pCP);
|
||||
|
||||
pCP->Load(m_pSegment->m_pReader);
|
||||
assert(pCP->GetTimeCode() >= 0);
|
||||
|
||||
return pCP;
|
||||
}
|
||||
|
||||
|
||||
const CuePoint* Cues::GetNext(const CuePoint* pCurr) const
|
||||
{
|
||||
if (pCurr == NULL)
|
||||
@@ -2304,7 +2339,7 @@ void CuePoint::TrackPosition::Parse(
|
||||
}
|
||||
|
||||
assert(m_pos >= 0);
|
||||
//assert(m_track > 0);
|
||||
assert(m_track > 0);
|
||||
//assert(m_block > 0);
|
||||
}
|
||||
|
||||
@@ -2363,7 +2398,7 @@ long long Segment::Unparsed() const
|
||||
}
|
||||
|
||||
|
||||
Cluster* Segment::GetFirst()
|
||||
const Cluster* Segment::GetFirst() const
|
||||
{
|
||||
if ((m_clusters == NULL) || (m_clusterCount <= 0))
|
||||
return &m_eos;
|
||||
@@ -2375,7 +2410,7 @@ Cluster* Segment::GetFirst()
|
||||
}
|
||||
|
||||
|
||||
Cluster* Segment::GetLast()
|
||||
const Cluster* Segment::GetLast() const
|
||||
{
|
||||
if ((m_clusters == NULL) || (m_clusterCount <= 0))
|
||||
return &m_eos;
|
||||
@@ -2395,7 +2430,7 @@ unsigned long Segment::GetCount() const
|
||||
}
|
||||
|
||||
|
||||
Cluster* Segment::GetNext(const Cluster* pCurr)
|
||||
const Cluster* Segment::GetNext(const Cluster* pCurr)
|
||||
{
|
||||
assert(pCurr);
|
||||
assert(pCurr != &m_eos);
|
||||
@@ -2551,7 +2586,7 @@ Cluster* Segment::GetNext(const Cluster* pCurr)
|
||||
}
|
||||
|
||||
|
||||
Cluster* Segment::FindCluster(long long time_ns)
|
||||
const Cluster* Segment::FindCluster(long long time_ns) const
|
||||
{
|
||||
if ((m_clusters == NULL) || (m_clusterCount <= 0))
|
||||
return &m_eos;
|
||||
@@ -2611,7 +2646,7 @@ Cluster* Segment::FindCluster(long long time_ns)
|
||||
|
||||
const BlockEntry* Segment::Seek(
|
||||
long long time_ns,
|
||||
const Track* pTrack)
|
||||
const Track* pTrack) const
|
||||
{
|
||||
assert(pTrack);
|
||||
|
||||
@@ -2672,11 +2707,21 @@ const BlockEntry* Segment::Seek(
|
||||
assert(lo > i);
|
||||
assert(lo <= j);
|
||||
|
||||
Cluster* const pCluster = *--lo;
|
||||
assert(pCluster);
|
||||
assert(pCluster->GetTime() <= time_ns);
|
||||
while (lo > i)
|
||||
{
|
||||
Cluster* const pCluster = *--lo;
|
||||
assert(pCluster);
|
||||
assert(pCluster->GetTime() <= time_ns);
|
||||
|
||||
return pCluster->GetEntry(pTrack);
|
||||
const BlockEntry* const pBE = pCluster->GetEntry(pTrack);
|
||||
|
||||
if ((pBE != 0) && !pBE->EOS())
|
||||
return pBE;
|
||||
|
||||
//landed on empty cluster (no entries)
|
||||
}
|
||||
|
||||
return pTrack->GetEOS(); //weird
|
||||
}
|
||||
|
||||
assert(pTrack->GetType() == 1); //video
|
||||
@@ -2717,17 +2762,16 @@ const BlockEntry* Segment::Seek(
|
||||
|
||||
{
|
||||
const BlockEntry* const pBlockEntry = pCluster->GetEntry(pTrack);
|
||||
assert(pBlockEntry);
|
||||
|
||||
if (!pBlockEntry->EOS()) //found a keyframe
|
||||
if ((pBlockEntry != 0) && !pBlockEntry->EOS()) //found a keyframe
|
||||
{
|
||||
const Block* const pBlock = pBlockEntry->GetBlock();
|
||||
assert(pBlock);
|
||||
|
||||
//TODO: this isn't necessarily the keyframe we want,
|
||||
//NOTE: this isn't necessarily the keyframe we want,
|
||||
//since there might another keyframe on this same
|
||||
//cluster with a greater timecode that but that is
|
||||
//still less than the requested time. For now we
|
||||
//cluster with a greater timecode, that is still
|
||||
//less than the requested time. For now we
|
||||
//simply return the first keyframe we find.
|
||||
|
||||
if (pBlock->GetTime(pCluster) <= time_ns)
|
||||
@@ -2744,9 +2788,8 @@ const BlockEntry* Segment::Seek(
|
||||
assert(pCluster->GetTime() <= time_ns);
|
||||
|
||||
const BlockEntry* const pBlockEntry = pCluster->GetMaxKey(pVideo);
|
||||
assert(pBlockEntry);
|
||||
|
||||
if (!pBlockEntry->EOS())
|
||||
if ((pBlockEntry != 0) && !pBlockEntry->EOS())
|
||||
return pBlockEntry;
|
||||
}
|
||||
|
||||
@@ -2827,7 +2870,7 @@ SegmentInfo::SegmentInfo(Segment* pSegment, long long start, long long size_) :
|
||||
const long long stop = start + size_;
|
||||
|
||||
m_timecodeScale = 1000000;
|
||||
m_duration = 0;
|
||||
m_duration = -1;
|
||||
|
||||
while (pos < stop)
|
||||
{
|
||||
@@ -2843,8 +2886,9 @@ SegmentInfo::SegmentInfo(Segment* pSegment, long long start, long long size_) :
|
||||
else if (Match(pReader, pos, 0x1741, m_pWritingAppAsUTF8)) //[57][41]
|
||||
assert(m_pWritingAppAsUTF8);
|
||||
|
||||
else if (Match(pReader, pos, 0x3BA9, m_pTitleAsUTF8)) //[7B][A9]
|
||||
else if (Match(pReader, pos, 0x3BA9, m_pTitleAsUTF8)) //[7B][A9]
|
||||
assert(m_pTitleAsUTF8);
|
||||
|
||||
else
|
||||
{
|
||||
long len;
|
||||
@@ -2898,7 +2942,9 @@ long long SegmentInfo::GetTimeCodeScale() const
|
||||
|
||||
long long SegmentInfo::GetDuration() const
|
||||
{
|
||||
assert(m_duration >= 0);
|
||||
if (m_duration < 0)
|
||||
return -1;
|
||||
|
||||
assert(m_timecodeScale >= 1);
|
||||
|
||||
const double dd = double(m_duration) * double(m_timecodeScale);
|
||||
@@ -2944,6 +2990,7 @@ Track::Info::Info():
|
||||
codecPrivate(NULL),
|
||||
codecPrivateSize(0),
|
||||
codecNameAsUTF8(NULL)
|
||||
//lacing(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3003,9 +3050,15 @@ const unsigned char* Track::GetCodecPrivate(size_t& size) const
|
||||
}
|
||||
|
||||
|
||||
bool Track::GetLacing() const
|
||||
{
|
||||
return m_info.lacing;
|
||||
}
|
||||
|
||||
|
||||
long Track::GetFirst(const BlockEntry*& pBlockEntry) const
|
||||
{
|
||||
Cluster* pCluster = m_pSegment->GetFirst();
|
||||
const Cluster* pCluster = m_pSegment->GetFirst();
|
||||
|
||||
//If Segment::GetFirst returns NULL, then this must be a network
|
||||
//download, and we haven't loaded any clusters yet. In this case,
|
||||
@@ -3066,13 +3119,13 @@ long Track::GetNext(
|
||||
const Block* const pCurrBlock = pCurrEntry->GetBlock();
|
||||
assert(pCurrBlock->GetTrackNumber() == m_info.number);
|
||||
|
||||
Cluster* pCluster = pCurrEntry->GetCluster();
|
||||
const Cluster* pCluster = pCurrEntry->GetCluster();
|
||||
assert(pCluster);
|
||||
assert(!pCluster->EOS());
|
||||
|
||||
pNextEntry = pCluster->GetNext(pCurrEntry);
|
||||
|
||||
for (int i = 0; i < 100; ++i) //arbitrary upper bound to search
|
||||
for (int i = 0; ; )
|
||||
{
|
||||
while (pNextEntry)
|
||||
{
|
||||
@@ -3118,6 +3171,14 @@ long Track::GetNext(
|
||||
}
|
||||
|
||||
pNextEntry = pCluster->GetFirst();
|
||||
|
||||
if (pNextEntry == NULL) //empty cluster
|
||||
continue;
|
||||
|
||||
++i;
|
||||
|
||||
if (i >= 100)
|
||||
break;
|
||||
}
|
||||
|
||||
//NOTE: if we get here, it means that we didn't find a block with
|
||||
@@ -3140,7 +3201,7 @@ bool Track::EOSBlock::EOS() const
|
||||
}
|
||||
|
||||
|
||||
Cluster* Track::EOSBlock::GetCluster() const
|
||||
const Cluster* Track::EOSBlock::GetCluster() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -3406,7 +3467,13 @@ Tracks::Tracks(Segment* pSegment, long long start, long long size_) :
|
||||
//pos now desinates start of element
|
||||
|
||||
if (id == 0x2E) //TrackEntry ID
|
||||
ParseTrackEntry(pos, size1, *m_trackEntriesEnd++);
|
||||
{
|
||||
Track*& pTrack = *m_trackEntriesEnd;
|
||||
ParseTrackEntry(pos, size1, pTrack);
|
||||
|
||||
if (pTrack)
|
||||
++m_trackEntriesEnd;
|
||||
}
|
||||
|
||||
pos += size1; //consume payload
|
||||
assert(pos <= stop);
|
||||
@@ -3441,6 +3508,8 @@ void Tracks::ParseTrackEntry(
|
||||
Track::Settings audioSettings;
|
||||
audioSettings.start = -1;
|
||||
|
||||
long long lacing = 1; //default is true
|
||||
|
||||
while (pos < stop)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
@@ -3459,6 +3528,8 @@ void Tracks::ParseTrackEntry(
|
||||
assert(i.nameAsUTF8);
|
||||
else if (Match(pReader, pos, 0x06, i.codecId))
|
||||
;
|
||||
else if (Match(pReader, pos, 0x1C, lacing))
|
||||
assert(lacing <= 1);
|
||||
else if (Match(pReader,
|
||||
pos,
|
||||
0x23A2,
|
||||
@@ -3505,6 +3576,8 @@ void Tracks::ParseTrackEntry(
|
||||
//and that it is unique among all tracks.
|
||||
assert(i.number > 0);
|
||||
|
||||
i.lacing = (lacing > 0) ? true : false;
|
||||
|
||||
//TODO: vet settings, to ensure that video settings (0x60)
|
||||
//were specified when type = 1, and that audio settings (0x61)
|
||||
//were specified when type = 2.
|
||||
@@ -3558,7 +3631,7 @@ Tracks::~Tracks()
|
||||
}
|
||||
|
||||
|
||||
Track* Tracks::GetTrackByNumber(unsigned long tn_) const
|
||||
const Track* Tracks::GetTrackByNumber(unsigned long tn_) const
|
||||
{
|
||||
const long long tn = tn_;
|
||||
|
||||
@@ -3580,7 +3653,7 @@ Track* Tracks::GetTrackByNumber(unsigned long tn_) const
|
||||
}
|
||||
|
||||
|
||||
Track* Tracks::GetTrackByIndex(unsigned long idx) const
|
||||
const Track* Tracks::GetTrackByIndex(unsigned long idx) const
|
||||
{
|
||||
const ptrdiff_t count = m_trackEntriesEnd - m_trackEntries;
|
||||
|
||||
@@ -3591,7 +3664,7 @@ Track* Tracks::GetTrackByIndex(unsigned long idx) const
|
||||
}
|
||||
|
||||
|
||||
void Cluster::Load()
|
||||
void Cluster::Load() const
|
||||
{
|
||||
assert(m_pSegment);
|
||||
assert(m_pos);
|
||||
@@ -3733,7 +3806,7 @@ bool Cluster::EOS() const
|
||||
}
|
||||
|
||||
|
||||
void Cluster::LoadBlockEntries()
|
||||
void Cluster::LoadBlockEntries() const
|
||||
{
|
||||
if (m_entries)
|
||||
return;
|
||||
@@ -3861,14 +3934,14 @@ void Cluster::LoadBlockEntries()
|
||||
|
||||
|
||||
|
||||
long long Cluster::GetTimeCode()
|
||||
long long Cluster::GetTimeCode() const
|
||||
{
|
||||
Load();
|
||||
return m_timecode;
|
||||
}
|
||||
|
||||
|
||||
long long Cluster::GetTime()
|
||||
long long Cluster::GetTime() const
|
||||
{
|
||||
const long long tc = GetTimeCode();
|
||||
assert(tc >= 0);
|
||||
@@ -3885,7 +3958,7 @@ long long Cluster::GetTime()
|
||||
}
|
||||
|
||||
|
||||
long long Cluster::GetFirstTime()
|
||||
long long Cluster::GetFirstTime() const
|
||||
{
|
||||
const BlockEntry* const pEntry = GetFirst();
|
||||
|
||||
@@ -3899,43 +3972,57 @@ long long Cluster::GetFirstTime()
|
||||
}
|
||||
|
||||
|
||||
long long Cluster::GetLastTime() const
|
||||
{
|
||||
const BlockEntry* const pEntry = GetLast();
|
||||
|
||||
void Cluster::ParseBlockGroup(long long start, long long size, size_t index)
|
||||
if (pEntry == NULL) //empty cluster
|
||||
return GetTime();
|
||||
|
||||
const Block* const pBlock = pEntry->GetBlock();
|
||||
assert(pBlock);
|
||||
|
||||
return pBlock->GetTime(this);
|
||||
}
|
||||
|
||||
|
||||
void Cluster::ParseBlockGroup(long long st, long long sz, size_t idx) const
|
||||
{
|
||||
assert(m_entries);
|
||||
assert(m_entriesCount);
|
||||
assert(index < m_entriesCount);
|
||||
assert(idx < m_entriesCount);
|
||||
|
||||
BlockGroup* const pGroup =
|
||||
new (std::nothrow) BlockGroup(this, index, start, size);
|
||||
assert(pGroup); //TODO
|
||||
Cluster* const this_ = const_cast<Cluster*>(this);
|
||||
|
||||
m_entries[index] = pGroup;
|
||||
BlockGroup* const e = new (std::nothrow) BlockGroup(this_, idx, st, sz);
|
||||
assert(e); //TODO
|
||||
|
||||
m_entries[idx] = e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Cluster::ParseSimpleBlock(long long start, long long size, size_t index)
|
||||
void Cluster::ParseSimpleBlock(long long st, long long sz, size_t idx) const
|
||||
{
|
||||
assert(m_entries);
|
||||
assert(m_entriesCount);
|
||||
assert(index < m_entriesCount);
|
||||
assert(idx < m_entriesCount);
|
||||
|
||||
SimpleBlock* const pSimpleBlock =
|
||||
new (std::nothrow) SimpleBlock(this, index, start, size);
|
||||
assert(pSimpleBlock); //TODO
|
||||
Cluster* const this_ = const_cast<Cluster*>(this);
|
||||
|
||||
m_entries[index] = pSimpleBlock;
|
||||
SimpleBlock* const e = new (std::nothrow) SimpleBlock(this_, idx, st, sz);
|
||||
assert(e); //TODO
|
||||
|
||||
m_entries[idx] = e;
|
||||
}
|
||||
|
||||
|
||||
const BlockEntry* Cluster::GetFirst()
|
||||
const BlockEntry* Cluster::GetFirst() const
|
||||
{
|
||||
//TODO: handle empty cluster
|
||||
|
||||
LoadBlockEntries();
|
||||
assert(m_entries);
|
||||
assert(m_entriesCount >= 1);
|
||||
|
||||
if ((m_entries == NULL) || (m_entriesCount == 0))
|
||||
return NULL;
|
||||
|
||||
const BlockEntry* const pFirst = m_entries[0];
|
||||
assert(pFirst);
|
||||
@@ -3944,13 +4031,12 @@ const BlockEntry* Cluster::GetFirst()
|
||||
}
|
||||
|
||||
|
||||
const BlockEntry* Cluster::GetLast()
|
||||
const BlockEntry* Cluster::GetLast() const
|
||||
{
|
||||
//TODO: handle empty cluster
|
||||
|
||||
LoadBlockEntries();
|
||||
assert(m_entries);
|
||||
assert(m_entriesCount >= 1);
|
||||
|
||||
if ((m_entries == NULL) || (m_entriesCount == 0))
|
||||
return NULL;
|
||||
|
||||
const size_t idx = m_entriesCount - 1;
|
||||
|
||||
@@ -3980,7 +4066,7 @@ const BlockEntry* Cluster::GetNext(const BlockEntry* pEntry) const
|
||||
}
|
||||
|
||||
|
||||
const BlockEntry* Cluster::GetEntry(const Track* pTrack)
|
||||
const BlockEntry* Cluster::GetEntry(const Track* pTrack) const
|
||||
{
|
||||
assert(pTrack);
|
||||
|
||||
@@ -3989,6 +4075,9 @@ const BlockEntry* Cluster::GetEntry(const Track* pTrack)
|
||||
|
||||
LoadBlockEntries();
|
||||
|
||||
if ((m_entries == NULL) || (m_entriesCount == 0))
|
||||
return NULL;
|
||||
|
||||
BlockEntry** i = m_entries;
|
||||
assert(i);
|
||||
|
||||
@@ -4017,7 +4106,7 @@ const BlockEntry* Cluster::GetEntry(const Track* pTrack)
|
||||
const BlockEntry*
|
||||
Cluster::GetEntry(
|
||||
const CuePoint& cp,
|
||||
const CuePoint::TrackPosition& tp)
|
||||
const CuePoint::TrackPosition& tp) const
|
||||
{
|
||||
assert(m_pSegment);
|
||||
|
||||
@@ -4057,6 +4146,11 @@ Cluster::GetEntry(
|
||||
|
||||
while (i != j)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
const ptrdiff_t idx = i - m_entries;
|
||||
idx;
|
||||
#endif
|
||||
|
||||
const BlockEntry* const pEntry = *i++;
|
||||
assert(pEntry);
|
||||
assert(!pEntry->EOS());
|
||||
@@ -4102,7 +4196,7 @@ Cluster::GetEntry(
|
||||
}
|
||||
|
||||
|
||||
const BlockEntry* Cluster::GetMaxKey(const VideoTrack* pTrack)
|
||||
const BlockEntry* Cluster::GetMaxKey(const VideoTrack* pTrack) const
|
||||
{
|
||||
assert(pTrack);
|
||||
|
||||
@@ -4110,7 +4204,6 @@ const BlockEntry* Cluster::GetMaxKey(const VideoTrack* pTrack)
|
||||
return pTrack->GetEOS();
|
||||
|
||||
LoadBlockEntries();
|
||||
assert(m_entries);
|
||||
|
||||
BlockEntry** i = m_entries + m_entriesCount;
|
||||
BlockEntry** const j = m_entries;
|
||||
@@ -4164,7 +4257,7 @@ bool SimpleBlock::EOS() const
|
||||
}
|
||||
|
||||
|
||||
Cluster* SimpleBlock::GetCluster() const
|
||||
const Cluster* SimpleBlock::GetCluster() const
|
||||
{
|
||||
return m_pCluster;
|
||||
}
|
||||
@@ -4182,10 +4275,10 @@ const Block* SimpleBlock::GetBlock() const
|
||||
}
|
||||
|
||||
|
||||
bool SimpleBlock::IsBFrame() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//bool SimpleBlock::IsBFrame() const
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
||||
BlockGroup::BlockGroup(
|
||||
@@ -4291,7 +4384,7 @@ bool BlockGroup::EOS() const
|
||||
}
|
||||
|
||||
|
||||
Cluster* BlockGroup::GetCluster() const
|
||||
const Cluster* BlockGroup::GetCluster() const
|
||||
{
|
||||
return m_pCluster;
|
||||
}
|
||||
@@ -4321,11 +4414,10 @@ short BlockGroup::GetNextTimeCode() const
|
||||
}
|
||||
|
||||
|
||||
bool BlockGroup::IsBFrame() const
|
||||
{
|
||||
return (m_nextTimeCode > 0);
|
||||
}
|
||||
|
||||
//bool BlockGroup::IsBFrame() const
|
||||
//{
|
||||
// return (m_nextTimeCode > 0);
|
||||
//}
|
||||
|
||||
|
||||
Block::Block(long long start, long long size_, IMkvReader* pReader) :
|
||||
@@ -4349,23 +4441,238 @@ Block::Block(long long start, long long size_, IMkvReader* pReader) :
|
||||
pos += 2;
|
||||
assert((stop - pos) >= 1);
|
||||
|
||||
const long hr = pReader->Read(pos, 1, &m_flags);
|
||||
assert(hr == 0L);
|
||||
long status = pReader->Read(pos, 1, &m_flags);
|
||||
assert(status == 0);
|
||||
|
||||
++pos;
|
||||
const int invisible = int(m_flags & 0x08) >> 3;
|
||||
invisible;
|
||||
assert(!invisible); //TODO
|
||||
|
||||
const int lacing = int(m_flags & 0x06) >> 1;
|
||||
|
||||
++pos; //consume flags byte
|
||||
assert(pos <= stop);
|
||||
|
||||
m_frameOff = pos;
|
||||
if (lacing == 0) //no lacing
|
||||
{
|
||||
m_frame_count = 1;
|
||||
m_frames = new Frame[m_frame_count];
|
||||
|
||||
const long long frame_size = stop - pos;
|
||||
Frame& f = m_frames[0];
|
||||
f.pos = pos;
|
||||
|
||||
assert(frame_size <= 2147483647L);
|
||||
const long long frame_size = stop - pos;
|
||||
assert(frame_size <= LONG_MAX);
|
||||
|
||||
m_frameSize = static_cast<long>(frame_size);
|
||||
f.len = static_cast<long>(frame_size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pos < stop);
|
||||
|
||||
unsigned char count;
|
||||
|
||||
status = pReader->Read(pos, 1, &count);
|
||||
assert(status == 0);
|
||||
|
||||
++pos; //consume frame count
|
||||
assert(pos <= stop);
|
||||
|
||||
m_frame_count = ++count;
|
||||
m_frames = new Frame[m_frame_count];
|
||||
|
||||
if (lacing == 1) //Xiph
|
||||
{
|
||||
Frame* pf = m_frames;
|
||||
Frame* const pf_end = pf + m_frame_count;
|
||||
|
||||
long size = 0;
|
||||
|
||||
while (count > 1)
|
||||
{
|
||||
long frame_size = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
unsigned char val;
|
||||
|
||||
status = pReader->Read(pos, 1, &val);
|
||||
assert(status == 0);
|
||||
|
||||
++pos; //consume xiph size byte
|
||||
|
||||
frame_size += val;
|
||||
|
||||
if (val < 255)
|
||||
break;
|
||||
}
|
||||
|
||||
Frame& f = *pf++;
|
||||
assert(pf < pf_end);
|
||||
|
||||
f.len = frame_size;
|
||||
size += frame_size; //contribution of this frame
|
||||
|
||||
--count;
|
||||
}
|
||||
|
||||
assert(pf < pf_end);
|
||||
assert(pos < stop);
|
||||
|
||||
{
|
||||
Frame& f = *pf++;
|
||||
assert(pf == pf_end);
|
||||
|
||||
const long long total_size = stop - pos;
|
||||
assert(total_size > size);
|
||||
|
||||
const long long frame_size = total_size - size;
|
||||
assert(frame_size <= LONG_MAX);
|
||||
|
||||
f.len = static_cast<long>(frame_size);
|
||||
}
|
||||
|
||||
pf = m_frames;
|
||||
while (pf != pf_end)
|
||||
{
|
||||
Frame& f = *pf++;
|
||||
assert((pos + f.len) <= stop);
|
||||
|
||||
f.pos = pos;
|
||||
pos += f.len;
|
||||
}
|
||||
|
||||
assert(pos == stop);
|
||||
}
|
||||
else if (lacing == 2) //fixed-size lacing
|
||||
{
|
||||
const long long total_size = stop - pos;
|
||||
assert((total_size % m_frame_count) == 0);
|
||||
|
||||
const long long frame_size = total_size / m_frame_count;
|
||||
assert(frame_size <= LONG_MAX);
|
||||
|
||||
Frame* pf = m_frames;
|
||||
Frame* const pf_end = pf + m_frame_count;
|
||||
|
||||
while (pf != pf_end)
|
||||
{
|
||||
assert((pos + frame_size) <= stop);
|
||||
|
||||
Frame& f = *pf++;
|
||||
|
||||
f.pos = pos;
|
||||
f.len = static_cast<long>(frame_size);
|
||||
|
||||
pos += frame_size;
|
||||
}
|
||||
|
||||
assert(pos == stop);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(lacing == 3); //EBML lacing
|
||||
assert(pos < stop);
|
||||
|
||||
long size = 0;
|
||||
|
||||
long long frame_size = ReadUInt(pReader, pos, len);
|
||||
assert(frame_size > 0);
|
||||
assert(frame_size <= LONG_MAX);
|
||||
assert((pos + len) <= stop);
|
||||
|
||||
pos += len; //consume length of size of first frame
|
||||
assert((pos + frame_size) <= stop);
|
||||
|
||||
Frame* pf = m_frames;
|
||||
Frame* const pf_end = pf + m_frame_count;
|
||||
|
||||
{
|
||||
Frame& curr = *pf;
|
||||
|
||||
curr.len = static_cast<long>(frame_size);
|
||||
size += curr.len; //contribution of this frame
|
||||
}
|
||||
|
||||
--count;
|
||||
|
||||
while (count > 1)
|
||||
{
|
||||
assert(pos < stop);
|
||||
assert(pf < pf_end);
|
||||
|
||||
const Frame& prev = *pf++;
|
||||
assert(pf < pf_end);
|
||||
assert(prev.len == frame_size);
|
||||
|
||||
Frame& curr = *pf;
|
||||
|
||||
const long long delta_size_ = ReadUInt(pReader, pos, len);
|
||||
assert(delta_size_ >= 0);
|
||||
assert((pos + len) <= stop);
|
||||
|
||||
pos += len; //consume length of (delta) size
|
||||
assert(pos <= stop);
|
||||
|
||||
const int exp = 7*len - 1;
|
||||
const long long bias = (1LL << exp) - 1LL;
|
||||
const long long delta_size = delta_size_ - bias;
|
||||
|
||||
frame_size += delta_size;
|
||||
assert(frame_size > 0);
|
||||
assert(frame_size <= LONG_MAX);
|
||||
|
||||
curr.len = static_cast<long>(frame_size);
|
||||
size += curr.len; //contribution of this frame
|
||||
|
||||
--count;
|
||||
}
|
||||
|
||||
{
|
||||
assert(pos < stop);
|
||||
assert(pf < pf_end);
|
||||
|
||||
const Frame& prev = *pf++;
|
||||
assert(pf < pf_end);
|
||||
assert(prev.len == frame_size);
|
||||
|
||||
Frame& curr = *pf++;
|
||||
assert(pf == pf_end);
|
||||
|
||||
const long long total_size = stop - pos;
|
||||
assert(total_size > 0);
|
||||
assert(total_size > size);
|
||||
|
||||
frame_size = total_size - size;
|
||||
assert(frame_size > 0);
|
||||
assert(frame_size <= LONG_MAX);
|
||||
|
||||
curr.len = static_cast<long>(frame_size);
|
||||
}
|
||||
|
||||
pf = m_frames;
|
||||
while (pf != pf_end)
|
||||
{
|
||||
Frame& f = *pf++;
|
||||
assert((pos + f.len) <= stop);
|
||||
|
||||
f.pos = pos;
|
||||
pos += f.len;
|
||||
}
|
||||
|
||||
assert(pos == stop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long long Block::GetTimeCode(Cluster* pCluster) const
|
||||
Block::~Block()
|
||||
{
|
||||
delete[] m_frames;
|
||||
}
|
||||
|
||||
|
||||
long long Block::GetTimeCode(const Cluster* pCluster) const
|
||||
{
|
||||
assert(pCluster);
|
||||
|
||||
@@ -4379,7 +4686,7 @@ long long Block::GetTimeCode(Cluster* pCluster) const
|
||||
}
|
||||
|
||||
|
||||
long long Block::GetTime(Cluster* pCluster) const
|
||||
long long Block::GetTime(const Cluster* pCluster) const
|
||||
{
|
||||
assert(pCluster);
|
||||
|
||||
@@ -4419,6 +4726,7 @@ void Block::SetKey(bool bKey)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
long long Block::GetOffset() const
|
||||
{
|
||||
return m_frameOff;
|
||||
@@ -4430,10 +4738,8 @@ long Block::GetSize() const
|
||||
return m_frameSize;
|
||||
}
|
||||
|
||||
|
||||
long Block::Read(IMkvReader* pReader, unsigned char* buf) const
|
||||
{
|
||||
|
||||
assert(pReader);
|
||||
assert(buf);
|
||||
|
||||
@@ -4441,6 +4747,35 @@ long Block::Read(IMkvReader* pReader, unsigned char* buf) const
|
||||
|
||||
return hr;
|
||||
}
|
||||
#else
|
||||
int Block::GetFrameCount() const
|
||||
{
|
||||
return m_frame_count;
|
||||
}
|
||||
|
||||
|
||||
const Block::Frame& Block::GetFrame(int idx) const
|
||||
{
|
||||
assert(idx >= 0);
|
||||
assert(idx < m_frame_count);
|
||||
|
||||
const Frame& f = m_frames[idx];
|
||||
assert(f.pos > 0);
|
||||
assert(f.len > 0);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
long Block::Frame::Read(IMkvReader* pReader, unsigned char* buf) const
|
||||
{
|
||||
assert(pReader);
|
||||
assert(buf);
|
||||
|
||||
const long status = pReader->Read(pos, len, buf);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} //end namespace mkvparser
|
||||
|
||||
102
mkvparser.hpp
102
mkvparser.hpp
@@ -73,23 +73,44 @@ public:
|
||||
const long long m_size;
|
||||
|
||||
Block(long long start, long long size, IMkvReader*);
|
||||
~Block();
|
||||
|
||||
long long GetTrackNumber() const;
|
||||
long long GetTimeCode(Cluster*) const; //absolute, but not scaled
|
||||
long long GetTime(Cluster*) const; //absolute, and scaled (ns units)
|
||||
long long GetTimeCode(const Cluster*) const; //absolute, but not scaled
|
||||
long long GetTime(const Cluster*) const; //absolute, and scaled (ns)
|
||||
bool IsKey() const;
|
||||
void SetKey(bool);
|
||||
|
||||
int GetFrameCount() const; //to index frames: [0, count)
|
||||
|
||||
struct Frame
|
||||
{
|
||||
long long pos; //absolute offset
|
||||
long len;
|
||||
|
||||
long Read(IMkvReader*, unsigned char*) const;
|
||||
};
|
||||
|
||||
#if 0
|
||||
long long GetOffset() const;
|
||||
long GetSize() const;
|
||||
long Read(IMkvReader*, unsigned char*) const;
|
||||
#else
|
||||
const Frame& GetFrame(int frame_index) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
long long m_track; //Track::Number()
|
||||
short m_timecode; //relative to cluster
|
||||
unsigned char m_flags;
|
||||
|
||||
#if 0
|
||||
long long m_frameOff;
|
||||
long m_frameSize;
|
||||
#else
|
||||
Frame* m_frames;
|
||||
int m_frame_count;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
@@ -102,10 +123,10 @@ class BlockEntry
|
||||
public:
|
||||
virtual ~BlockEntry();
|
||||
virtual bool EOS() const = 0;
|
||||
virtual Cluster* GetCluster() const = 0;
|
||||
virtual const Cluster* GetCluster() const = 0;
|
||||
virtual size_t GetIndex() const = 0;
|
||||
virtual const Block* GetBlock() const = 0;
|
||||
virtual bool IsBFrame() const = 0;
|
||||
//virtual bool IsBFrame() const = 0;
|
||||
|
||||
protected:
|
||||
BlockEntry();
|
||||
@@ -122,10 +143,10 @@ public:
|
||||
SimpleBlock(Cluster*, size_t, long long start, long long size);
|
||||
|
||||
bool EOS() const;
|
||||
Cluster* GetCluster() const;
|
||||
const Cluster* GetCluster() const;
|
||||
size_t GetIndex() const;
|
||||
const Block* GetBlock() const;
|
||||
bool IsBFrame() const;
|
||||
//bool IsBFrame() const;
|
||||
|
||||
protected:
|
||||
Cluster* const m_pCluster;
|
||||
@@ -145,10 +166,10 @@ public:
|
||||
~BlockGroup();
|
||||
|
||||
bool EOS() const;
|
||||
Cluster* GetCluster() const;
|
||||
const Cluster* GetCluster() const;
|
||||
size_t GetIndex() const;
|
||||
const Block* GetBlock() const;
|
||||
bool IsBFrame() const;
|
||||
//bool IsBFrame() const;
|
||||
|
||||
short GetPrevTimeCode() const; //relative to block's time
|
||||
short GetNextTimeCode() const; //as above
|
||||
@@ -192,6 +213,7 @@ public:
|
||||
const char* GetCodecNameAsUTF8() const;
|
||||
const char* GetCodecId() const;
|
||||
const unsigned char* GetCodecPrivate(size_t&) const;
|
||||
bool GetLacing() const;
|
||||
|
||||
const BlockEntry* GetEOS() const;
|
||||
|
||||
@@ -211,7 +233,9 @@ public:
|
||||
unsigned char* codecPrivate;
|
||||
size_t codecPrivateSize;
|
||||
char* codecNameAsUTF8;
|
||||
bool lacing;
|
||||
Settings settings;
|
||||
|
||||
Info();
|
||||
void Clear();
|
||||
};
|
||||
@@ -230,7 +254,7 @@ protected:
|
||||
EOSBlock();
|
||||
|
||||
bool EOS() const;
|
||||
Cluster* GetCluster() const;
|
||||
const Cluster* GetCluster() const;
|
||||
size_t GetIndex() const;
|
||||
const Block* GetBlock() const;
|
||||
bool IsBFrame() const;
|
||||
@@ -294,8 +318,8 @@ public:
|
||||
Tracks(Segment*, long long start, long long size);
|
||||
virtual ~Tracks();
|
||||
|
||||
Track* GetTrackByNumber(unsigned long tn) const;
|
||||
Track* GetTrackByIndex(unsigned long idx) const;
|
||||
const Track* GetTrackByNumber(unsigned long tn) const;
|
||||
const Track* GetTrackByIndex(unsigned long idx) const;
|
||||
|
||||
private:
|
||||
Track** m_trackEntries;
|
||||
@@ -403,6 +427,8 @@ public:
|
||||
const CuePoint::TrackPosition*&) const;
|
||||
#endif
|
||||
|
||||
const CuePoint* GetFirst() const;
|
||||
const CuePoint* GetLast() const;
|
||||
const CuePoint* GetNext(const CuePoint*) const;
|
||||
|
||||
const BlockEntry* GetBlock(
|
||||
@@ -429,7 +455,6 @@ class Cluster
|
||||
|
||||
public:
|
||||
Segment* const m_pSegment;
|
||||
long m_index;
|
||||
|
||||
public:
|
||||
static Cluster* Parse(Segment*, long, long long off);
|
||||
@@ -439,35 +464,38 @@ public:
|
||||
|
||||
bool EOS() const;
|
||||
|
||||
long long GetTimeCode(); //absolute, but not scaled
|
||||
long long GetTime(); //absolute, and scaled (nanosecond units)
|
||||
long long GetFirstTime(); //time (ns) of first (earliest) block
|
||||
long long GetTimeCode() const; //absolute, but not scaled
|
||||
long long GetTime() const; //absolute, and scaled (nanosecond units)
|
||||
long long GetFirstTime() const; //time (ns) of first (earliest) block
|
||||
long long GetLastTime() const; //time (ns) of last (latest) block
|
||||
|
||||
const BlockEntry* GetFirst();
|
||||
const BlockEntry* GetLast();
|
||||
const BlockEntry* GetFirst() const;
|
||||
const BlockEntry* GetLast() const;
|
||||
const BlockEntry* GetNext(const BlockEntry*) const;
|
||||
const BlockEntry* GetEntry(const Track*);
|
||||
const BlockEntry* GetEntry(const Track*) const;
|
||||
const BlockEntry* GetEntry(
|
||||
const CuePoint&,
|
||||
const CuePoint::TrackPosition&);
|
||||
const BlockEntry* GetMaxKey(const VideoTrack*);
|
||||
const CuePoint::TrackPosition&) const;
|
||||
const BlockEntry* GetMaxKey(const VideoTrack*) const;
|
||||
|
||||
protected:
|
||||
Cluster(Segment*, long, long long off);
|
||||
|
||||
public:
|
||||
long long m_pos;
|
||||
long long m_size;
|
||||
//TODO: these should all be private, with public selector functions
|
||||
long m_index;
|
||||
mutable long long m_pos;
|
||||
mutable long long m_size;
|
||||
|
||||
private:
|
||||
long long m_timecode;
|
||||
BlockEntry** m_entries;
|
||||
size_t m_entriesCount;
|
||||
mutable long long m_timecode;
|
||||
mutable BlockEntry** m_entries;
|
||||
mutable size_t m_entriesCount;
|
||||
|
||||
void Load();
|
||||
void LoadBlockEntries();
|
||||
void ParseBlockGroup(long long, long long, size_t);
|
||||
void ParseSimpleBlock(long long, long long, size_t);
|
||||
void Load() const;
|
||||
void LoadBlockEntries() const;
|
||||
void ParseBlockGroup(long long, long long, size_t) const;
|
||||
void ParseSimpleBlock(long long, long long, size_t) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -498,12 +526,10 @@ public:
|
||||
long long ParseHeaders(); //stops when first cluster is found
|
||||
long LoadCluster(); //loads one cluster
|
||||
|
||||
#if 0
|
||||
//This pair parses one cluster, but only changes the state of the
|
||||
//segment object when the cluster is actually added to the index.
|
||||
long ParseCluster(Cluster*&, long long& newpos) const;
|
||||
bool AddCluster(Cluster*, long long);
|
||||
#endif
|
||||
long ParseCluster(long long& cluster_pos, long long& new_pos) const;
|
||||
bool AddCluster(long long cluster_pos, long long new_pos);
|
||||
|
||||
Tracks* GetTracks() const;
|
||||
const SegmentInfo* GetInfo() const;
|
||||
@@ -512,12 +538,12 @@ public:
|
||||
long long GetDuration() const;
|
||||
|
||||
unsigned long GetCount() const;
|
||||
Cluster* GetFirst();
|
||||
Cluster* GetLast();
|
||||
Cluster* GetNext(const Cluster*);
|
||||
const Cluster* GetFirst() const;
|
||||
const Cluster* GetLast() const;
|
||||
const Cluster* GetNext(const Cluster*);
|
||||
|
||||
Cluster* FindCluster(long long time_nanoseconds);
|
||||
const BlockEntry* Seek(long long time_nanoseconds, const Track*);
|
||||
const Cluster* FindCluster(long long time_nanoseconds) const;
|
||||
const BlockEntry* Seek(long long time_nanoseconds, const Track*) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
15
sample.cpp
15
sample.cpp
@@ -220,7 +220,7 @@ int main(int argc, char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
mkvparser::Cluster* pCluster = pSegment->GetFirst();
|
||||
const mkvparser::Cluster* pCluster = pSegment->GetFirst();
|
||||
|
||||
while ((pCluster != NULL) && !pCluster->EOS())
|
||||
{
|
||||
@@ -238,15 +238,22 @@ int main(int argc, char* argv[])
|
||||
const unsigned long trackNum = pBlock->GetTrackNumber();
|
||||
const Track* const pTrack = pTracks->GetTrackByNumber(trackNum);
|
||||
const long long trackType = pTrack->GetType();
|
||||
const long size = pBlock->GetSize();
|
||||
const int frameCount = pBlock->GetFrameCount();
|
||||
const long long time_ns = pBlock->GetTime(pCluster);
|
||||
|
||||
printf("\t\t\tBlock\t\t:%s,%15ld,%s,%15lld\n",
|
||||
printf("\t\t\tBlock\t\t:%s,%s,%15lld\n",
|
||||
(trackType == VIDEO_TRACK) ? "V" : "A",
|
||||
size,
|
||||
pBlock->IsKey() ? "I" : "P",
|
||||
time_ns);
|
||||
|
||||
for (int i = 0; i < frameCount; ++i)
|
||||
{
|
||||
const Block::Frame& theFrame = pBlock->GetFrame(i);
|
||||
const long size = theFrame.len;
|
||||
const long offset = theFrame.pos;
|
||||
printf("\t\t\t %15ld,%15lx\n", size, offset);
|
||||
}
|
||||
|
||||
pBlockEntry = pCluster->GetNext(pBlockEntry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user