From: Sigmund Augdal Helberg Date: Mon, 6 Sep 2004 19:01:34 +0000 (+0000) Subject: some timecode and chapter-related fixes from Mosu(thanks a lot). X-Git-Tag: 0.8.0~461 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=381fcdb7866f29786566f5dbf7cfbf112c9868b4;p=vlc some timecode and chapter-related fixes from Mosu(thanks a lot). --- diff --git a/TODO b/TODO index 2c74f185ee..8f3ccb59f8 100644 --- a/TODO +++ b/TODO @@ -496,12 +496,10 @@ Status: Todo Task Difficulty: Medium Platform: any -Urgency: Critical +Urgency: Normal Description: Update matroska demux - Support non-default timescale Support default track flag General bugfixes - Chapters etc Status: Todo Task diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index c2c3f68dea..8c259740f2 100644 --- a/modules/demux/mkv.cpp +++ b/modules/demux/mkv.cpp @@ -793,14 +793,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) if( p_sys->title && p_sys->title->i_seekpoint > 0 ) { int i_skp = (int)va_arg( args, int ); - int64_t i_start = (int64_t)p_sys->title->seekpoint[i_skp]->i_time_offset; - if( p_sys->f_duration > 0.0 ) - { - double f_pos = (double)i_start / (double)(1000.0 * p_sys->f_duration ); - Seek( p_demux, -1, (int)(100 * f_pos+0.5)); - return VLC_SUCCESS; - } + Seek( p_demux, (int64_t)p_sys->title->seekpoint[i_skp]->i_time_offset, -1); + return VLC_SUCCESS; } return VLC_EGENERIC; @@ -839,7 +834,7 @@ static int BlockGet( demux_t *p_demux, KaxBlock **pp_block, int64_t *pi_ref1, in #define idx p_sys->index[p_sys->i_index - 1] if( p_sys->i_index > 0 && idx.i_time == -1 ) { - idx.i_time = (*pp_block)->GlobalTimecode() * (mtime_t) 1000 / p_sys->i_timescale; + idx.i_time = (*pp_block)->GlobalTimecode() / (mtime_t)1000; idx.b_key = *pi_ref1 == -1 ? VLC_TRUE : VLC_FALSE; } #undef idx @@ -1138,7 +1133,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, int i_percent) return; } - p_sys->i_pts = block->GlobalTimecode() * (mtime_t) 1000 / p_sys->i_timescale + 1; + p_sys->i_pts = block->GlobalTimecode() / (mtime_t) 1000 + 1; for( i_track = 0; i_track < p_sys->i_track; i_track++ ) { @@ -1193,7 +1188,7 @@ static int Demux( demux_t *p_demux) return 0; } - p_sys->i_pts = block->GlobalTimecode() * (mtime_t) 1000 / p_sys->i_timescale + 1; + p_sys->i_pts = block->GlobalTimecode() / (mtime_t) 1000 + 1; if( p_sys->i_pts > 0 ) { @@ -1432,7 +1427,7 @@ static void LoadCues( demux_t *p_demux ) idx.i_track = -1; idx.i_block_number= -1; idx.i_position = -1; - idx.i_time = -1; + idx.i_time = 0; idx.b_key = VLC_TRUE; ep->Down(); @@ -1444,7 +1439,7 @@ static void LoadCues( demux_t *p_demux ) ctime.ReadData( p_sys->es->I_O() ); - idx.i_time = uint64( ctime ) * (mtime_t)1000000000 / p_sys->i_timescale; + idx.i_time = uint64( ctime ) * p_sys->i_timescale / (mtime_t)1000; } else if( MKV_IS_ID( el, KaxCueTrackPositions ) ) { @@ -2184,6 +2179,8 @@ static void ParseInfo( demux_t *p_demux, EbmlElement *info ) msg_Dbg( p_demux, "| | + Unknown (%s)", typeid(*l).name() ); } } + + p_sys->f_duration = p_sys->f_duration * p_sys->i_timescale / 1000000.0; } @@ -2265,16 +2262,10 @@ static void ParseChapterAtom( demux_t *p_demux, int i_level, EbmlMaster *ca ) ParseChapterAtom( p_demux, i_level+1, static_cast(l) ); } } - if( sk->i_time_offset > 0 ) - { - p_sys->title->i_seekpoint++; - p_sys->title->seekpoint = (seekpoint_t**)realloc( p_sys->title->seekpoint, p_sys->title->i_seekpoint * sizeof( seekpoint_t* ) ); - p_sys->title->seekpoint[p_sys->title->i_seekpoint-1] = sk; - } - else - { - vlc_seekpoint_Delete( sk ); - } + // A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value. + p_sys->title->i_seekpoint++; + p_sys->title->seekpoint = (seekpoint_t**)realloc( p_sys->title->seekpoint, p_sys->title->i_seekpoint * sizeof( seekpoint_t* ) ); + p_sys->title->seekpoint[p_sys->title->i_seekpoint-1] = sk; } /*****************************************************************************