[vlc-commits] demux:mkv: use the segment Preload() rather than a local parser

Steve Lhomme git at videolan.org
Wed Jan 3 11:17:42 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jan  2 16:38:09 2018 +0100| [c7574905da49699729fcc5d095069f8d4d6cbbac] | committer: Jean-Baptiste Kempf

demux:mkv: use the segment Preload() rather than a local parser

This will avoid parsing the same data twice and avoid duplicate/different code.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c7574905da49699729fcc5d095069f8d4d6cbbac
---

 modules/demux/mkv/demux.cpp | 57 +++------------------------------------------
 1 file changed, 3 insertions(+), 54 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 42994af6fb..6cd9aff8f6 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -513,64 +513,13 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
                                 var_InheritBool( &demuxer, "mkv-use-dummy" ) );
             p_segment1->ep = ep;
             p_segment1->segment = (KaxSegment*)p_l0;
+            p_segment1->Preload();
 
-            while ((p_l1 = ep->Get()))
-            {
-                if (MKV_IS_ID(p_l1, KaxInfo))
-                {
-                    // find the families of this segment
-                    KaxInfo *p_info = static_cast<KaxInfo*>(p_l1);
-                    b_keep_segment = b_initial;
-                    if( unlikely( p_info->IsFiniteSize() && p_info->GetSize() >= SIZE_MAX ) )
-                    {
-                        msg_Err( p_demux, "KaxInfo too big aborting" );
-                        break;
-                    }
-                    try
-                    {
-                        p_info->Read(*p_estream, EBML_CLASS_CONTEXT(KaxInfo), i_upper_lvl, p_l2, true);
-                    }
-                    catch (...)
-                    {
-                        msg_Err( p_demux, "KaxInfo found but corrupted");
-                        break;
-                    }
-                    for( size_t i = 0; i < p_info->ListSize(); i++ )
-                    {
-                        EbmlElement *l = (*p_info)[i];
+            b_keep_segment = (FindSegment( *p_segment1->p_segment_uid ) == NULL);
 
-                        if( MKV_IS_ID( l, KaxSegmentUID ) )
-                        {
-                            KaxSegmentUID *p_uid = static_cast<KaxSegmentUID*>(l);
-                            b_keep_segment = (FindSegment( *p_uid ) == NULL);
-                            delete p_segment1->p_segment_uid;
-                            p_segment1->p_segment_uid = new KaxSegmentUID(*p_uid);
-                            if ( !b_keep_segment )
-                                break; // this segment is already known
-                        }
-                        else if( MKV_IS_ID( l, KaxPrevUID ) )
-                        {
-                            p_segment1->p_prev_segment_uid = new KaxPrevUID( *static_cast<KaxPrevUID*>(l) );
-                            p_segment1->b_ref_external_segments = true;
-                        }
-                        else if( MKV_IS_ID( l, KaxNextUID ) )
-                        {
-                            p_segment1->p_next_segment_uid = new KaxNextUID( *static_cast<KaxNextUID*>(l) );
-                            p_segment1->b_ref_external_segments = true;
-                        }
-                        else if( MKV_IS_ID( l, KaxSegmentFamily ) )
-                        {
-                            KaxSegmentFamily *p_fam = new KaxSegmentFamily( *static_cast<KaxSegmentFamily*>(l) );
-                            p_segment1->families.push_back( p_fam );
-                        }
-                    }
-                    if( b_keep_segment || !p_segment1->p_segment_uid )
-                        opened_segments.push_back( p_segment1 );
-                    break;
-                }
-            }
             if ( b_keep_segment || !p_segment1->p_segment_uid )
             {
+                opened_segments.push_back( p_segment1 );
                 b_keep_stream = true;
                 p_stream1->segments.push_back( p_segment1 );
             }



More information about the vlc-commits mailing list