Commit 0a6b059e authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

MKV: fix mixup between VLC timestamps and Matroska timestamps

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent bf6f6714
...@@ -331,9 +331,9 @@ struct demux_sys_t ...@@ -331,9 +331,9 @@ struct demux_sys_t
public: public:
demux_sys_t( demux_t & demux ) demux_sys_t( demux_t & demux )
:demuxer(demux) :demuxer(demux)
,i_pts(0) ,i_pts(VLC_TS_INVALID)
,i_pcr(0) ,i_pcr(VLC_TS_INVALID)
,i_start_pts(0) ,i_start_pts(VLC_TS_0)
,i_chapter_time(0) ,i_chapter_time(0)
,meta(NULL) ,meta(NULL)
,i_current_title(0) ,i_current_title(0)
......
...@@ -942,9 +942,9 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -942,9 +942,9 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
ep = new EbmlParser( &es, segment, &sys.demuxer, ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) ); var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
sys.i_start_pts = 0; sys.i_start_pts = VLC_TS_0;
sys.i_pts = 0; sys.i_pts = VLC_TS_INVALID;
sys.i_pcr = 0; sys.i_pcr = VLC_TS_0;
return; return;
} }
...@@ -972,7 +972,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -972,7 +972,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) ); var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
sys.i_start_pts = i_date; sys.i_start_pts = i_date + VLC_TS_0;
/* now parse until key frame */ /* now parse until key frame */
const int es_types[3] = { VIDEO_ES, AUDIO_ES, SPU_ES }; const int es_types[3] = { VIDEO_ES, AUDIO_ES, SPU_ES };
...@@ -1024,7 +1024,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -1024,7 +1024,7 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
/*Neither video nor audio track... no seek further*/ /*Neither video nor audio track... no seek further*/
if( unlikely( !p_first ) ) if( unlikely( !p_first ) )
{ {
es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, i_date ); es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, i_date + VLC_TS_0 );
es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date ); es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
return; return;
} }
...@@ -1101,8 +1101,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -1101,8 +1101,8 @@ 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_pcr = sys.i_pts = p_min->i_date; sys.i_pcr = sys.i_pts = p_min->i_date + VLC_TS_0;
es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, VLC_TS_0 + sys.i_pcr ); es_out_Control( sys.demuxer.out, ES_OUT_SET_PCR, sys.i_pcr );
es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date ); es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
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 );
...@@ -1338,7 +1338,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) ...@@ -1338,7 +1338,7 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
} }
es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_start_time ); es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_start_time );
sys.i_start_pts = i_start_time; sys.i_start_pts = i_start_time + VLC_TS_0;
// reset the stream reading to the first cluster of the segment used // reset the stream reading to the first cluster of the segment used
es.I_O().setFilePointer( i_start_pos ); es.I_O().setFilePointer( i_start_pos );
......
...@@ -757,7 +757,7 @@ static int Demux( demux_t *p_demux) ...@@ -757,7 +757,7 @@ static int Demux( demux_t *p_demux)
{ {
/* TODO handle successive chapters with the same user_start_time/user_end_time /* TODO handle successive chapters with the same user_start_time/user_end_time
*/ */
p_sys->i_pts = p_chap->i_virtual_stop_time; p_sys->i_pts = p_chap->i_virtual_stop_time + VLC_TS_0;
p_sys->i_pts++; // trick to avoid staying on segments with no duration and no content p_sys->i_pts++; // trick to avoid staying on segments with no duration and no content
i_return = 1; i_return = 1;
...@@ -773,9 +773,10 @@ static int Demux( demux_t *p_demux) ...@@ -773,9 +773,10 @@ static int Demux( demux_t *p_demux)
} }
if( simpleblock != NULL ) if( simpleblock != NULL )
p_sys->i_pts = p_sys->i_chapter_time + ( (mtime_t)simpleblock->GlobalTimecode() / INT64_C(1000) ); p_sys->i_pts = (mtime_t)simpleblock->GlobalTimecode() / INT64_C(1000);
else else
p_sys->i_pts = p_sys->i_chapter_time + ( (mtime_t)block->GlobalTimecode() / INT64_C(1000) ); p_sys->i_pts = (mtime_t)block->GlobalTimecode() / INT64_C(1000);
p_sys->i_pts += p_sys->i_chapter_time + VLC_TS_0;
mtime_t i_pcr = VLC_TS_INVALID; mtime_t i_pcr = VLC_TS_INVALID;
for( size_t i = 0; i < p_segment->tracks.size(); i++) for( size_t i = 0; i < p_segment->tracks.size(); i++)
......
...@@ -399,12 +399,13 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time ) ...@@ -399,12 +399,13 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time )
bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux ) bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
{ {
demux_sys_t & sys = *demux.p_sys; demux_sys_t & sys = *demux.p_sys;
virtual_chapter_c *p_cur_chapter; virtual_chapter_c *p_cur_chapter = NULL;
virtual_edition_c * p_cur_edition = editions[ i_current_edition ]; virtual_edition_c * p_cur_edition = editions[ i_current_edition ];
bool b_has_seeked = false; bool b_has_seeked = false;
p_cur_chapter = p_cur_edition->getChapterbyTimecode( sys.i_pts ); if ( sys.i_pts != VLC_TS_INVALID )
p_cur_chapter = p_cur_edition->getChapterbyTimecode( sys.i_pts - VLC_TS_0 );
/* we have moved to a new chapter */ /* we have moved to a new chapter */
if ( p_cur_chapter != NULL && p_current_chapter != p_cur_chapter ) if ( p_cur_chapter != NULL && p_current_chapter != p_cur_chapter )
...@@ -426,7 +427,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux ) ...@@ -426,7 +427,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
return true; return true;
} }
} }
sys.i_start_pts = p_cur_chapter->i_virtual_start_time;; sys.i_start_pts = p_cur_chapter->i_virtual_start_time + VLC_TS_0;
} }
p_current_chapter = p_cur_chapter; p_current_chapter = p_cur_chapter;
......
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