[vlc-commits] Fix seek in mka

Denis Charmet git at videolan.org
Sat Feb 18 15:15:50 CET 2012


vlc/vlc-2.0 | branch: master | Denis Charmet <typx at dinauz.org> | Sat Feb 18 14:35:46 2012 +0100| [779e24dcad1ba1d5f7ed069a9f0d1b5c3624aada] | committer: Jean-Baptiste Kempf

Fix seek in mka

Fix #6078

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 7098f40219523ba072997c9e86f3b2c626caddda)

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

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

 modules/demux/mkv/matroska_segment.cpp |   50 +++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index c0a0d03..c6e6993 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -690,6 +690,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
     mtime_t     i_pts = 0;
     spoint *p_first = NULL;
     spoint *p_last = NULL;
+    int i_cat;
 
     if( i_global_position >= 0 )
     {
@@ -772,33 +773,42 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
     es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
 
     /* now parse until key frame */
-    for( i_track = 0; i_track < tracks.size(); i_track++ )
+    const int es[3] = { VIDEO_ES, AUDIO_ES, SPU_ES };
+    for( int i = 0, i_cat = es[0]; i < 2; i_cat = es[++i] )
     {
-        if( tracks[i_track]->fmt.i_cat == VIDEO_ES )
+        for( i_track = 0; i_track < tracks.size(); i_track++ )
         {
-            spoint * seekpoint = new spoint(i_track, i_seek_time, i_seek_position, i_seek_position);
-            if( unlikely( !seekpoint ) )
+            if( tracks[i_track]->fmt.i_cat == i_cat )
             {
-                for( spoint * sp = p_first; sp; )
+                spoint * seekpoint = new spoint(i_track, i_seek_time, i_seek_position, i_seek_position);
+                if( unlikely( !seekpoint ) )
                 {
-                    spoint * tmp = sp;
-                    sp = sp->p_next;
-                    delete tmp;                    
+                    for( spoint * sp = p_first; sp; )
+                    {
+                        spoint * tmp = sp;
+                        sp = sp->p_next;
+                        delete tmp;                    
+                    }
+                    return;
+                }
+                if( unlikely( !p_first ) )
+                {
+                    p_first = seekpoint;
+                    p_last = seekpoint;
+                }
+                else
+                {
+                    p_last->p_next = seekpoint;
+                    p_last = seekpoint;
                 }
-                return;
-            }
-            if( unlikely( !p_first ) )
-            {
-                p_first = seekpoint;
-                p_last = seekpoint;
-            }
-            else
-            {
-                p_last->p_next = seekpoint;
-                p_last = seekpoint;
             }
         }
+        if( likely( p_first ) )
+            break;
     }
+    /*Neither video nor audio track... no seek further*/
+    if( unlikely( !p_first ) )
+        return; 
 
     while( i_pts < i_date )
     {
@@ -825,7 +835,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
             i_pts = sys.i_chapter_time + block->GlobalTimecode() / (mtime_t) 1000;
         if( i_track < tracks.size() )
         {
-            if( tracks[i_track]->fmt.i_cat == VIDEO_ES && b_key_picture )
+            if( tracks[i_track]->fmt.i_cat == i_cat && b_key_picture )
             {
                 /* get the seekpoint */
                 spoint * sp;



More information about the vlc-commits mailing list