[vlc-devel] [PATCH] Avoid late picture drop when using many threads

Denis Charmet typx at dinauz.org
Thu Feb 16 22:42:14 CET 2012


---
 modules/demux/mkv/demux.hpp            |    2 ++
 modules/demux/mkv/matroska_segment.cpp |    8 ++++++--
 modules/demux/mkv/mkv.cpp              |    7 +++++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index 0f18ffe..9ab470c 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -332,6 +332,7 @@ public:
     demux_sys_t( demux_t & demux )
         :demuxer(demux)
         ,i_pts(0)
+        ,i_pcr(0)
         ,i_start_pts(0)
         ,i_chapter_time(0)
         ,meta(NULL)
@@ -351,6 +352,7 @@ public:
     demux_t                 & demuxer;
 
     mtime_t                 i_pts;
+    mtime_t                 i_pcr;
     mtime_t                 i_start_pts;
     mtime_t                 i_chapter_time;
 
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 4a69a84..90b3088 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -725,11 +725,12 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
         }
     }
 
-#ifdef WIN32
+#ifndef WIN32
     /* Don't try complex seek if we seek to 0 */
     if( i_date == 0 )
     {
         es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, 0 );
+        es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, VLC_TS_0 );
         es.I_O().setFilePointer( i_start_pos );
 
         delete ep;
@@ -737,6 +738,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
         cluster = NULL;
         sys.i_start_pts = 0;
         sys.i_pts = 0;
+        sys.i_pcr = 0;
         return;       
     }
 #endif
@@ -849,9 +851,11 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
         if( p_last->i_date < p_min->i_date )
             p_min = p_last;
 
-    sys.i_pts = p_min->i_date;
+    sys.i_pcr = sys.i_pts = p_min->i_date;
+    es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, VLC_TS_0 + sys.i_pcr );
     cluster = (KaxCluster *) ep->UnGet( p_min->i_seek_pos, p_min->i_cluster_pos );
 
+
     /* hack use BlockGet to get the cluster then goto the wanted block */
     if ( !cluster )
     {
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index eedeba1..7be24c8 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -714,8 +714,11 @@ static int Demux( demux_t *p_demux)
             p_sys->i_pts = p_sys->i_chapter_time + ( block->GlobalTimecode() / (mtime_t) 1000 );
 
         /* The blocks are in coding order so we can safely consider that only references are in chronological order */
-        if( simpleblock == NULL || b_key_picture )
-            es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pts );
+        if( p_sys->i_pts > p_sys->i_pcr + 300000 )
+        {
+            es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pcr );
+            p_sys->i_pcr = p_sys->i_pts;
+        }
 
         if( p_sys->i_pts >= p_sys->i_start_pts  )
         {
-- 
1.7.8.3




More information about the vlc-devel mailing list