From 42e5f91c3e730d64bf35ff4ea798f75b03aa2bbe Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 24 Nov 2013 21:00:44 +0100 Subject: [PATCH] QT/MP4 reader: ignore obviously wrong sample size entries --- ChangeLog | 3 +++ src/input/r_qtmp4.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8d57400c5..ed7db3807 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2013-11-24 Moritz Bunkus + * mkvmerge: bug fix: improved resilience against MP4 files with + obviously wrong entries in the 'sample size table' (STSZ) atom. + * mkvmerge: bug fix: improved VC1 frame type detection so that it works even for streams without entry points. diff --git a/src/input/r_qtmp4.cpp b/src/input/r_qtmp4.cpp index a5c09e432..a7560ae1e 100644 --- a/src/input/r_qtmp4.cpp +++ b/src/input/r_qtmp4.cpp @@ -950,6 +950,12 @@ qtmp4_reader_c::handle_stsz_atom(qtmp4_demuxer_cptr &new_dmx, qt_sample_t sample; sample.size = m_in->read_uint32_be(); + + // This is a sanity check against damaged samples. I have one of + // those in which one sample was suppposed to be > 2GB big. + if (sample.size >= 100 * 1024 * 1024) + sample.size = 0; + new_dmx->sample_table.push_back(sample); } @@ -1912,6 +1918,7 @@ qtmp4_demuxer_c::build_index() { void qtmp4_demuxer_c::build_index_constant_sample_size_mode() { + mxinfo(boost::format("CONST mode\n")); size_t keyframe_table_idx = 0; size_t keyframe_table_size = keyframe_table.size(); @@ -1949,6 +1956,7 @@ qtmp4_demuxer_c::build_index_constant_sample_size_mode() { void qtmp4_demuxer_c::build_index_chunk_mode() { + mxinfo(boost::format("CHUNK mode\n")); size_t keyframe_table_idx = 0; size_t keyframe_table_size = keyframe_table.size();