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.
This commit is contained in:
Moritz Bunkus 2011-11-26 21:50:07 +01:00
parent 58e85ca882
commit 00d5c1e19e
2 changed files with 11 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2011-11-26 Moritz Bunkus <moritz@bunkus.org>
* 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 <moritz@bunkus.org>
* all: enhancement: Made all EXEs declare their required access

View File

@ -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));
}