libwebm: refactor BlockEntry class
Change-Id: I68d799d5b928de0ff7be293731ab73750c7cbb86
This commit is contained in:
parent
00ed87aad6
commit
7b07758854
101
mkvparser.cpp
101
mkvparser.cpp
@ -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
|
const Block* Track::EOSBlock::GetBlock() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Track::EOSBlock::IsBFrame() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VideoTrack::VideoTrack(
|
VideoTrack::VideoTrack(
|
||||||
Segment* pSegment,
|
Segment* pSegment,
|
||||||
const Info& i,
|
const Info& i,
|
||||||
@ -7996,7 +7972,9 @@ const BlockEntry* Cluster::GetMaxKey(const VideoTrack* pTrack) const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
BlockEntry::BlockEntry()
|
BlockEntry::BlockEntry(Cluster* p, long idx) :
|
||||||
|
m_pCluster(p),
|
||||||
|
m_index(idx)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8006,33 +7984,35 @@ BlockEntry::~BlockEntry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SimpleBlock::SimpleBlock(
|
bool BlockEntry::EOS() const
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
return (m_index == LONG_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SimpleBlock::EOS() const
|
const Cluster* BlockEntry::GetCluster() const
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Cluster* SimpleBlock::GetCluster() const
|
|
||||||
{
|
{
|
||||||
return m_pCluster;
|
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(
|
BlockGroup::BlockGroup(
|
||||||
Cluster* pCluster,
|
Cluster* pCluster,
|
||||||
size_t idx,
|
long idx,
|
||||||
long long start,
|
long long start,
|
||||||
long long size_) :
|
long long size_) :
|
||||||
m_pCluster(pCluster),
|
BlockEntry(pCluster, idx),
|
||||||
m_index(idx),
|
|
||||||
m_prevTimeCode(0),
|
m_prevTimeCode(0),
|
||||||
m_nextTimeCode(0),
|
m_nextTimeCode(0),
|
||||||
m_pBlock(NULL) //TODO: accept multiple blocks within a block group
|
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
|
const Block* BlockGroup::GetBlock() const
|
||||||
{
|
{
|
||||||
return m_pBlock;
|
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) :
|
Block::Block(long long start, long long size_, IMkvReader* pReader) :
|
||||||
m_start(start),
|
m_start(start),
|
||||||
m_size(size_)
|
m_size(size_)
|
||||||
|
@ -111,16 +111,19 @@ class BlockEntry
|
|||||||
BlockEntry(const BlockEntry&);
|
BlockEntry(const BlockEntry&);
|
||||||
BlockEntry& operator=(const BlockEntry&);
|
BlockEntry& operator=(const BlockEntry&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BlockEntry(Cluster*, long index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~BlockEntry();
|
virtual ~BlockEntry();
|
||||||
virtual bool EOS() const = 0;
|
bool EOS() const;
|
||||||
virtual const Cluster* GetCluster() const = 0;
|
const Cluster* GetCluster() const;
|
||||||
virtual long GetIndex() const = 0;
|
long GetIndex() const;
|
||||||
virtual const Block* GetBlock() const = 0;
|
virtual const Block* GetBlock() const = 0;
|
||||||
//virtual bool IsBFrame() const = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlockEntry();
|
Cluster* const m_pCluster;
|
||||||
|
const long m_index;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -131,17 +134,14 @@ class SimpleBlock : public BlockEntry
|
|||||||
SimpleBlock& operator=(const SimpleBlock&);
|
SimpleBlock& operator=(const SimpleBlock&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleBlock(Cluster*, size_t, long long start, long long size);
|
SimpleBlock(Cluster*, long index, long long start, long long size);
|
||||||
|
|
||||||
bool EOS() const;
|
//bool EOS() const;
|
||||||
const Cluster* GetCluster() const;
|
//const Cluster* GetCluster() const;
|
||||||
long GetIndex() const;
|
//long GetIndex() const;
|
||||||
const Block* GetBlock() const;
|
const Block* GetBlock() const;
|
||||||
//bool IsBFrame() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Cluster* const m_pCluster;
|
|
||||||
const size_t m_index;
|
|
||||||
Block m_block;
|
Block m_block;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -153,22 +153,17 @@ class BlockGroup : public BlockEntry
|
|||||||
BlockGroup& operator=(const BlockGroup&);
|
BlockGroup& operator=(const BlockGroup&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BlockGroup(Cluster*, size_t, long long, long long);
|
BlockGroup(Cluster*, long index, long long, long long);
|
||||||
~BlockGroup();
|
~BlockGroup();
|
||||||
|
|
||||||
bool EOS() const;
|
//bool EOS() const;
|
||||||
const Cluster* GetCluster() const;
|
//const Cluster* GetCluster() const;
|
||||||
long GetIndex() const;
|
//long GetIndex() const;
|
||||||
const Block* GetBlock() const;
|
const Block* GetBlock() const;
|
||||||
//bool IsBFrame() const;
|
|
||||||
|
|
||||||
short GetPrevTimeCode() const; //relative to block's time
|
short GetPrevTimeCode() const; //relative to block's time
|
||||||
short GetNextTimeCode() const; //as above
|
short GetNextTimeCode() const; //as above
|
||||||
|
|
||||||
protected:
|
|
||||||
Cluster* const m_pCluster;
|
|
||||||
const size_t m_index;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlockGroup(Cluster*, size_t, unsigned long);
|
BlockGroup(Cluster*, size_t, unsigned long);
|
||||||
void ParseBlock(long long start, long long size);
|
void ParseBlock(long long start, long long size);
|
||||||
@ -252,11 +247,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
EOSBlock();
|
EOSBlock();
|
||||||
|
|
||||||
bool EOS() const;
|
//bool EOS() const;
|
||||||
const Cluster* GetCluster() const;
|
//const Cluster* GetCluster() const;
|
||||||
long GetIndex() const;
|
//long GetIndex() const;
|
||||||
const Block* GetBlock() const;
|
const Block* GetBlock() const;
|
||||||
bool IsBFrame() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EOSBlock m_eos;
|
EOSBlock m_eos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user