From: Steve Lhomme Date: Sun, 4 Sep 2005 18:12:57 +0000 (+0000) Subject: * mkv.cpp: fix chapter sorting by timecode, apply the right PTS/DTS timecodes from... X-Git-Tag: 0.8.4~576 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3a0a0ec7cb538a264f86f72732ee491c5ca9b657;p=vlc * mkv.cpp: fix chapter sorting by timecode, apply the right PTS/DTS timecodes from the container --- diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index 966c00de55..935729ffa1 100644 --- a/modules/demux/mkv.cpp +++ b/modules/demux/mkv.cpp @@ -953,9 +953,9 @@ public: std::vector codecs; - bool operator<( const chapter_item_c & item ) const + static bool CompareTimecode( const chapter_item_c * & itemA, const chapter_item_c * & itemB ) { - return ( i_user_start_time < item.i_user_start_time || (i_user_start_time == item.i_user_start_time && i_user_end_time < item.i_user_end_time) ); + return ( itemA->i_user_start_time < itemB->i_user_start_time || (itemA->i_user_start_time == itemB->i_user_start_time && itemA->i_user_end_time < itemB->i_user_end_time) ); } bool Enter( bool b_do_subchapters ); @@ -1880,21 +1880,23 @@ static void BlockDecode( demux_t *p_demux, KaxBlock *block, mtime_t i_pts, } return; } - // TODO implement correct timestamping when B frames are used -#if 0 + // correct timestamping when B frames are used if( tk->fmt.i_cat != VIDEO_ES ) { p_block->i_dts = p_block->i_pts = i_pts; } else { - p_block->i_pts = i_pts; + if( !strcmp( tk->psz_codec, "V_MS/VFW/FOURCC" ) ) + { + p_block->i_pts = 0; + } + else + { + p_block->i_pts = i_pts; + } p_block->i_dts = p_sys->i_pts; } -#else - p_block->i_pts = i_pts; - p_block->i_dts = p_sys->i_last_dts; -#endif #if 0 msg_Dbg( p_demux, "block i_dts: "I64Fd" / i_pts: "I64Fd, p_block->i_dts, p_block->i_pts); @@ -1903,10 +1905,6 @@ msg_Dbg( p_demux, "block i_dts: "I64Fd" / i_pts: "I64Fd, p_block->i_dts, p_block { p_block->i_length = i_duration * 1000; } - if( !strcmp( tk->psz_codec, "V_MS/VFW/FOURCC" ) ) - { - p_block->i_pts = 0; - } es_out_Send( p_demux->out, tk->p_es, p_block ); @@ -4801,7 +4799,8 @@ int64_t chapter_item_c::RefreshChapters( bool b_ordered, int64_t i_prev_user_tim } else { - std::sort( sub_chapters.begin(), sub_chapters.end() ); + if ( sub_chapters.begin() != sub_chapters.end() ) + std::sort( sub_chapters.begin(), sub_chapters.end(), chapter_item_c::CompareTimecode ); i_user_start_time = i_start_time; if ( i_end_time != -1 ) i_user_end_time = i_end_time;