libwebm: refactor BlockEntry class

Change-Id: I68d799d5b928de0ff7be293731ab73750c7cbb86
This commit is contained in:
matthewjheaney 2011-04-03 11:16:27 -05:00
parent 00ed87aad6
commit 7b07758854
2 changed files with 44 additions and 101 deletions

View File

@ -5145,41 +5145,17 @@ long Track::GetNext(
}
Track::EOSBlock::EOSBlock()
Track::EOSBlock::EOSBlock() : BlockEntry(NULL, LONG_MIN)
{
}
bool Track::EOSBlock::EOS() const
{
return true;
}
const Cluster* Track::EOSBlock::GetCluster() const
{
return NULL;
}
long Track::EOSBlock::GetIndex() const
{
return -1;
}
const Block* Track::EOSBlock::GetBlock() const
{
return NULL;
}
bool Track::EOSBlock::IsBFrame() const
{
return false;
}
VideoTrack::VideoTrack(
Segment* pSegment,
const Info& i,
@ -7996,7 +7972,9 @@ const BlockEntry* Cluster::GetMaxKey(const VideoTrack* pTrack) const
#endif
BlockEntry::BlockEntry()
BlockEntry::BlockEntry(Cluster* p, long idx) :
m_pCluster(p),
m_index(idx)
{
}
@ -8006,33 +7984,35 @@ BlockEntry::~BlockEntry()
}
SimpleBlock::SimpleBlock(
Cluster* pCluster,
size_t idx,
long long start,
long long size) :
m_pCluster(pCluster),
m_index(idx),
m_block(start, size, pCluster->m_pSegment->m_pReader)
bool BlockEntry::EOS() const
{
return (m_index == LONG_MIN);
}
bool SimpleBlock::EOS() const
{
return false;
}
const Cluster* SimpleBlock::GetCluster() const
const Cluster* BlockEntry::GetCluster() const
{
return m_pCluster;
}
long SimpleBlock::GetIndex() const
long BlockEntry::GetIndex() const
{
if (m_index == LONG_MIN) //EOS
return -1;
return labs(m_index);
}
SimpleBlock::SimpleBlock(
Cluster* pCluster,
long idx,
long long start,
long long size) :
BlockEntry(pCluster, idx),
m_block(start, size, pCluster->m_pSegment->m_pReader)
{
return m_index;
}
@ -8042,19 +8022,12 @@ const Block* SimpleBlock::GetBlock() const
}
//bool SimpleBlock::IsBFrame() const
//{
// return false;
//}
BlockGroup::BlockGroup(
Cluster* pCluster,
size_t idx,
long idx,
long long start,
long long size_) :
m_pCluster(pCluster),
m_index(idx),
BlockEntry(pCluster, idx),
m_prevTimeCode(0),
m_nextTimeCode(0),
m_pBlock(NULL) //TODO: accept multiple blocks within a block group
@ -8145,24 +8118,6 @@ void BlockGroup::ParseBlock(long long start, long long size)
}
bool BlockGroup::EOS() const
{
return false;
}
const Cluster* BlockGroup::GetCluster() const
{
return m_pCluster;
}
long BlockGroup::GetIndex() const
{
return m_index;
}
const Block* BlockGroup::GetBlock() const
{
return m_pBlock;
@ -8181,12 +8136,6 @@ short BlockGroup::GetNextTimeCode() const
}
//bool BlockGroup::IsBFrame() const
//{
// return (m_nextTimeCode > 0);
//}
Block::Block(long long start, long long size_, IMkvReader* pReader) :
m_start(start),
m_size(size_)

View File

@ -111,16 +111,19 @@ class BlockEntry
BlockEntry(const BlockEntry&);
BlockEntry& operator=(const BlockEntry&);
protected:
BlockEntry(Cluster*, long index);
public:
virtual ~BlockEntry();
virtual bool EOS() const = 0;
virtual const Cluster* GetCluster() const = 0;
virtual long GetIndex() const = 0;
bool EOS() const;
const Cluster* GetCluster() const;
long GetIndex() const;
virtual const Block* GetBlock() const = 0;
//virtual bool IsBFrame() const = 0;
protected:
BlockEntry();
Cluster* const m_pCluster;
const long m_index;
};
@ -131,17 +134,14 @@ class SimpleBlock : public BlockEntry
SimpleBlock& operator=(const SimpleBlock&);
public:
SimpleBlock(Cluster*, size_t, long long start, long long size);
SimpleBlock(Cluster*, long index, long long start, long long size);
bool EOS() const;
const Cluster* GetCluster() const;
long GetIndex() const;
//bool EOS() const;
//const Cluster* GetCluster() const;
//long GetIndex() const;
const Block* GetBlock() const;
//bool IsBFrame() const;
protected:
Cluster* const m_pCluster;
const size_t m_index;
Block m_block;
};
@ -153,22 +153,17 @@ class BlockGroup : public BlockEntry
BlockGroup& operator=(const BlockGroup&);
public:
BlockGroup(Cluster*, size_t, long long, long long);
BlockGroup(Cluster*, long index, long long, long long);
~BlockGroup();
bool EOS() const;
const Cluster* GetCluster() const;
long GetIndex() const;
//bool EOS() const;
//const Cluster* GetCluster() const;
//long 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);
@ -252,11 +247,10 @@ protected:
public:
EOSBlock();
bool EOS() const;
const Cluster* GetCluster() const;
long GetIndex() const;
//bool EOS() const;
//const Cluster* GetCluster() const;
//long GetIndex() const;
const Block* GetBlock() const;
bool IsBFrame() const;
};
EOSBlock m_eos;