Compare commits

..

6 Commits

Author SHA1 Message Date
matthewjheaney
a977a2b536 libwebm: changed version to 1.0.0.15
Change-Id: I70c6b22d75defcb11fecbbcd8763659cca7f77e0
2011-01-28 16:56:27 -05:00
matthewjheaney
5e72a2dfc2 libwebm: changed signature of CuePoint::GetTime
Change-Id: Ia80da8af5607c7067e848bafd453842cfe8cfcca
2011-01-28 00:52:13 -05:00
matthewjheaney
056b0d96a8 libwebm: changed version to 1.0.0.14
Change-Id: Id8147672e7fb761b2a69ff0d1ec05705e34eefc1
2011-01-26 19:08:43 -05:00
matthewjheaney
dbc58d0510 libwebm: make unserialize operations endian-neutral
Change-Id: I0c754ea8192020886dac14e3a0bd6a74c3165a92
2011-01-26 18:50:07 -05:00
matthewjheaney
a131a01446 libwebm: incrementally load block entries
Change-Id: I566df5979e7638b6a5411a3338bbb0cf7d9ad111
2011-01-25 23:01:51 -05:00
Hwasoo Lee
b8cb358204 fixed build error in sample
Change-Id: Id6ac66f5e625952918857c3e13e655452c32abc8
2011-01-25 11:31:20 -05:00
3 changed files with 144 additions and 28 deletions

View File

@@ -21,7 +21,7 @@ void mkvparser::GetVersion(int& major, int& minor, int& build, int& revision)
major = 1;
minor = 0;
build = 0;
revision = 13;
revision = 15;
}
long long mkvparser::ReadUInt(IMkvReader* pReader, long long pos, long& len)
@@ -228,13 +228,16 @@ float mkvparser::Unserialize4Float(
assert(pReader);
assert(pos >= 0);
#ifdef _DEBUG
long long total, available;
long hr = pReader->Length(&total, &available);
assert(hr >= 0);
assert(available <= total);
assert((pos + 4) <= available);
#endif
#if 0
float result;
unsigned char* const p = (unsigned char*)&result;
@@ -250,6 +253,32 @@ float mkvparser::Unserialize4Float(
++pos;
}
#else
union
{
float result;
unsigned long buf;
};
buf = 0;
for (int i = 0;;)
{
unsigned char b;
const int status = pReader->Read(pos++, 1, &b);
if (status < 0) //error
return static_cast<float>(status);
buf |= b;
if (++i >= 4)
break;
buf <<= 8;
}
#endif
return result;
}
@@ -262,6 +291,7 @@ double mkvparser::Unserialize8Double(
assert(pReader);
assert(pos >= 0);
#if 0
double result;
unsigned char* const p = (unsigned char*)&result;
@@ -277,6 +307,32 @@ double mkvparser::Unserialize8Double(
++pos;
}
#else
union
{
double result;
long long buf;
};
buf = 0;
for (int i = 0;;)
{
unsigned char b;
const int status = pReader->Read(pos++, 1, &b);
if (status < 0) //error
return static_cast<double>(status);
buf |= b;
if (++i >= 8)
break;
buf <<= 8;
}
#endif
return result;
}
@@ -288,17 +344,20 @@ signed char mkvparser::Unserialize1SInt(
assert(pReader);
assert(pos >= 0);
#ifdef _DEBUG
long long total, available;
long hr = pReader->Length(&total, &available);
assert(hr == 0);
assert(available <= total);
assert(pos < available);
#endif
signed char result;
unsigned char& b = reinterpret_cast<unsigned char&>(result);
hr = pReader->Read(pos, 1, (unsigned char*)&result);
assert(hr == 0);
const int status = pReader->Read(pos, 1, &b);
assert(status == 0); //TODO: must be handled somehow
return result;
}
@@ -310,13 +369,16 @@ short mkvparser::Unserialize2SInt(
assert(pReader);
assert(pos >= 0);
#ifdef _DEBUG
long long total, available;
long hr = pReader->Length(&total, &available);
assert(hr >= 0);
assert(available <= total);
assert((pos + 2) <= available);
#endif
#if 0
short result;
unsigned char* const p = (unsigned char*)&result;
@@ -332,6 +394,24 @@ short mkvparser::Unserialize2SInt(
++pos;
}
#else
short result = 0;
for (int i = 0;;)
{
unsigned char b;
const int status = pReader->Read(pos++, 1, &b);
assert(status == 0); //TODO: must be handled somehow
result |= b;
if (++i >= 2)
break;
result <<= 8;
}
#endif
return result;
}
@@ -1308,7 +1388,7 @@ long Segment::LoadCluster(
{
long long total, avail;
const int status = m_pReader->Length(&total, &avail);
long status = m_pReader->Length(&total, &avail);
if (status < 0) //error
return status;
@@ -1450,11 +1530,12 @@ long Segment::LoadCluster(
++m_clusterCount;
--m_clusterPreloadCount;
pCluster->Load(); //establish invariant
m_pos = pos + size; //consume payload
assert(m_pos <= stop);
status = pCluster->LoadBlockEntries(pos, len);
assert(status == 0); //TODO
return 0; //we have a new cluster
}
}
@@ -1476,7 +1557,8 @@ long Segment::LoadCluster(
assert(idx < m_clusterSize);
assert(m_clusters[idx] == pCluster);
pCluster->Load(); //establish invariant
status = pCluster->LoadBlockEntries(pos, len);
assert(status == 0); //TODO
return 0; //we have a new cluster
}
@@ -2988,7 +3070,7 @@ long long CuePoint::GetTimeCode() const
return m_timecode;
}
long long CuePoint::GetTime(Segment* pSegment) const
long long CuePoint::GetTime(const Segment* pSegment) const
{
assert(pSegment);
assert(m_timecode >= 0);
@@ -3261,7 +3343,7 @@ long Segment::ParseNext(
long long total, avail;
const int status = m_pReader->Length(&total, &avail);
long status = m_pReader->Length(&total, &avail);
if (status < 0) //error
return status;
@@ -3473,10 +3555,8 @@ long Segment::ParseNext(
len = static_cast<long>(size);
#if 1 //TODO: get rid of this
if (element_stop > avail)
return E_BUFFER_NOT_FULL;
#endif
if (Cluster::HasBlockEntries(this, idoff)) //relative
{
@@ -3527,6 +3607,9 @@ long Segment::ParseNext(
j = k;
else
{
status = pNext->LoadBlockEntries(pos, len);
assert(status == 0);
pResult = pNext;
return 0; //success
}
@@ -3548,7 +3631,8 @@ long Segment::ParseNext(
assert(idx_next < m_clusterSize);
assert(m_clusters[idx_next] == pNext);
pNext->Load(); //because we need this now
status = pNext->LoadBlockEntries(pos, len);
assert(status == 0); //TODO
pResult = pNext;
return 0; //success
@@ -4966,23 +5050,24 @@ void Cluster::Load() const
}
long Cluster::Load(long long& pos, long& len) const
long Cluster::LoadBlockEntries(long long& pos, long& len) const
{
assert(m_pSegment);
assert(m_pos);
assert(m_size);
if (m_pos > 0) //loaded
{
assert(m_size > 0);
assert(m_timecode >= 0);
return 0;
}
assert(m_pos < 0); //not loaded yet
assert(m_size < 0);
assert(m_timecode < 0);
//if (m_pos > 0) //loaded
//{
// assert(m_size > 0);
// assert(m_timecode >= 0);
// assert(m_entries_count >= 0);
//
// return 0;
//}
//
//assert(m_pos < 0); //not loaded yet
//assert(m_size < 0);
//assert(m_timecode < 0);
IMkvReader* const pReader = m_pSegment->m_pReader;
@@ -4998,6 +5083,28 @@ long Cluster::Load(long long& pos, long& len) const
const long long segment_stop = m_pSegment->m_start + m_pSegment->m_size;
if (m_pos > 0) //at least partially loaded
{
assert(m_size > 0);
if (m_entries_count >= 0)
return 0;
pos = m_pSegment->m_start + m_pos; //absolute pos of payload
const long long cluster_stop = pos + m_size;
len = static_cast<long>(m_size);
if (cluster_stop > avail)
return E_BUFFER_NOT_FULL;
LoadBlockEntries(); //TODO
assert(m_entries_count >= 0);
return 0;
}
//m_pos *= -1; //relative to segment
pos = m_pSegment->m_start - m_pos; //absolute
@@ -5151,6 +5258,8 @@ long Cluster::Load(long long& pos, long& len) const
m_size = size_; // m_size > 0 means we're partially loaded
m_timecode = timecode; // m_timecode >= 0 means we're partially loaded
LoadBlockEntries(); //TODO
return 0;
}
@@ -5564,6 +5673,12 @@ const BlockEntry* Cluster::GetNext(const BlockEntry* pEntry) const
}
long Cluster::GetEntryCount() const
{
return m_entries_count;
}
const BlockEntry* Cluster::GetEntry(
const Track* pTrack,
long long time_ns) const

View File

@@ -449,7 +449,7 @@ public:
void Load(IMkvReader*);
long long GetTimeCode() const; //absolute but unscaled
long long GetTime(Segment*) const; //absolute and scaled (ns units)
long long GetTime(const Segment*) const; //absolute and scaled (ns units)
struct TrackPosition
{
@@ -568,9 +568,11 @@ public:
const BlockEntry* GetMaxKey(const VideoTrack*) const;
static bool HasBlockEntries(const Segment*, long long);
long GetEntryCount() const;
void Load() const;
long Load(long long& pos, long& size) const;
void LoadBlockEntries() const;
long LoadBlockEntries(long long& pos, long& size) const;
protected:
Cluster(
@@ -593,7 +595,6 @@ private:
mutable BlockEntry** m_entries;
mutable long m_entries_count;
void LoadBlockEntries() const;
void ParseBlockGroup(long long, long long, size_t) const;
void ParseSimpleBlock(long long, long long, size_t) const;

View File

@@ -142,7 +142,7 @@ int main(int argc, char* argv[])
// size of segment payload
printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size);
mkvparser::Tracks* const pTracks = pSegment->GetTracks();
const mkvparser::Tracks* pTracks = pSegment->GetTracks();
unsigned long i = 0;
const unsigned long j = pTracks->GetTracksCount();