Commit ef8bdea5 authored by Denis Charmet's avatar Denis Charmet Committed by Jean-Baptiste Kempf

MKV: Avoid late picture drop when using many threads

Close #5953
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit fdd1eae579d1847952bcbd5bb2c60b8f46c9204c)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent d153e838
...@@ -332,6 +332,7 @@ public: ...@@ -332,6 +332,7 @@ public:
demux_sys_t( demux_t & demux ) demux_sys_t( demux_t & demux )
:demuxer(demux) :demuxer(demux)
,i_pts(0) ,i_pts(0)
,i_pcr(0)
,i_start_pts(0) ,i_start_pts(0)
,i_chapter_time(0) ,i_chapter_time(0)
,meta(NULL) ,meta(NULL)
...@@ -351,6 +352,7 @@ public: ...@@ -351,6 +352,7 @@ public:
demux_t & demuxer; demux_t & demuxer;
mtime_t i_pts; mtime_t i_pts;
mtime_t i_pcr;
mtime_t i_start_pts; mtime_t i_start_pts;
mtime_t i_chapter_time; mtime_t i_chapter_time;
......
...@@ -725,11 +725,12 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -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 */ /* Don't try complex seek if we seek to 0 */
if( i_date == 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_NEXT_DISPLAY_TIME, 0 );
es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, VLC_TS_0 );
es.I_O().setFilePointer( i_start_pos ); es.I_O().setFilePointer( i_start_pos );
delete ep; delete ep;
...@@ -737,6 +738,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -737,6 +738,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
cluster = NULL; cluster = NULL;
sys.i_start_pts = 0; sys.i_start_pts = 0;
sys.i_pts = 0; sys.i_pts = 0;
sys.i_pcr = 0;
return; return;
} }
#endif #endif
...@@ -849,9 +851,11 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -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 ) if( p_last->i_date < p_min->i_date )
p_min = p_last; 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 ); 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 */ /* hack use BlockGet to get the cluster then goto the wanted block */
if ( !cluster ) if ( !cluster )
{ {
......
...@@ -714,8 +714,11 @@ static int Demux( demux_t *p_demux) ...@@ -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 ); 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 */ /* The blocks are in coding order so we can safely consider that only references are in chronological order */
if( simpleblock == NULL || b_key_picture ) 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_pts ); {
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 ) if( p_sys->i_pts >= p_sys->i_start_pts )
{ {
......
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