Commit 2876b031 authored by Steve Lhomme's avatar Steve Lhomme

demux:mkv: add a mode to the parser so it doesn't read over it's top element

It should probably become the default mode in the future, especially since the
elements we find outside of our scope are lost and read again...
parent 621a467e
......@@ -128,11 +128,12 @@ const EbmlSemanticContext Context_KaxSegmentVLC = EbmlSemanticContext(KaxSegment
GetEbmlNoGlobal_Context,
KaxSegment_Context.GetMaster());
EbmlElement *EbmlParser::Get()
EbmlElement *EbmlParser::Get( bool allow_overshoot )
{
int i_ulev = 0;
int n_call = 0;
EbmlElement *p_prev = NULL;
bool do_read = true;
if( mi_user_level != mi_level )
{
......@@ -176,7 +177,13 @@ next:
while ( size_lvl && m_el[size_lvl-1]->IsFiniteSize() && m_el[size_lvl]->IsFiniteSize() &&
m_el[size_lvl-1]->GetEndPosition() == m_el[size_lvl]->GetEndPosition() )
size_lvl--;
if (size_lvl == 0 || !m_el[size_lvl-1]->IsFiniteSize() || !m_el[size_lvl]->IsFiniteSize() )
if (size_lvl == 0 && !allow_overshoot)
{
i_ulev = mi_level; // trick to go all the way up
m_el[mi_level] = NULL;
do_read = false;
}
else if (size_lvl == 0 || !m_el[size_lvl-1]->IsFiniteSize() || !m_el[size_lvl]->IsFiniteSize() )
i_max_read = UINT64_MAX;
else {
uint64 top = m_el[size_lvl-1]->GetEndPosition();
......@@ -185,6 +192,8 @@ next:
}
}
if (do_read)
{
// If the parent is a segment, use the segment context when creating children
// (to prolong their lifetime), otherwise just continue as normal
EbmlSemanticContext e_context =
......@@ -206,6 +215,7 @@ next:
i_ulev = 1;
}
}
}
if( i_ulev > 0 )
{
......
......@@ -41,7 +41,7 @@ class EbmlParser
void Up( void );
void Down( void );
void Reset( demux_t *p_demux );
EbmlElement *Get( void );
EbmlElement *Get( bool allow_overshoot = true );
void Keep( void );
void Unkeep( void );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment