From 00d5c1e19eb6efc1744f7a2c55bee75521715819 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 26 Nov 2011 21:50:07 +0100 Subject: [PATCH] Fix timecode handling for MPEG TS with unexpected packet structure If there was no start packet or a start packet without a timecode between two calls for processing the packet then the track's stored timecode was converted from 90Hz base to ns base more than once resulting in huge timecodes in the output file. --- ChangeLog | 6 ++++++ src/input/r_mpeg_ts.cpp | 12 +++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51e8c5235..1911156f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-11-26 Moritz Bunkus + + * mkvmerge: bug fix: Fixed bogus huge timecodes sometimes + occurring for AVC/h.264 video tracks read from MPEG transport + streams. + 2011-11-24 Moritz Bunkus * all: enhancement: Made all EXEs declare their required access diff --git a/src/input/r_mpeg_ts.cpp b/src/input/r_mpeg_ts.cpp index 1dd683674..f59cde36d 100644 --- a/src/input/r_mpeg_ts.cpp +++ b/src/input/r_mpeg_ts.cpp @@ -52,18 +52,16 @@ int mpeg_ts_reader_c::potential_packet_sizes[] = { 188, 192, 204, 0 }; void mpeg_ts_track_c::send_to_packetizer() { - if (timecode < reader.m_global_timecode_offset) - timecode = 0; - else - timecode = (uint64_t)(timecode - reader.m_global_timecode_offset) * 100000ll / 9; + int64_t timecode_to_use = (timecode < reader.m_global_timecode_offset) ? 0 : (timecode - reader.m_global_timecode_offset) * 100000ll / 9; if ((type == ES_AUDIO_TYPE) && reader.m_dont_use_audio_pts) - timecode = -1; + timecode_to_use = -1; - mxverb(3, boost::format("mpeg_ts: PTS in nanoseconds: %1%\n") % timecode); + mxverb(3, boost::format("mpeg_ts: PTS in nanoseconds: %1%\n") % timecode_to_use); if (ptzr != -1) { - int64_t timecode_to_use = m_apply_dts_timecode_fix && (m_previous_timecode == timecode) ? -1 : timecode; + if (m_apply_dts_timecode_fix && (m_previous_timecode == timecode)) + timecode_to_use = -1; reader.m_reader_packetizers[ptzr]->process(new packet_t(clone_memory(pes_payload->get_buffer(), pes_payload->get_size()), timecode_to_use)); }