MPEG TS: ignore timestamp outliers of at least five minutes

Fixes #998.
This commit is contained in:
Moritz Bunkus 2014-03-05 20:39:12 +01:00
parent cca3f1696c
commit aad9455d00
5 changed files with 30 additions and 5 deletions

View File

@ -1,5 +1,9 @@
2014-03-05 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: MPEG TS: timestamp outliers are ignored if
they differ at least five minutes from the last valid
timestamp. Fixes #998.
* mkvmerge: enhancements: trailing zero bytes will be removed from
AVC/h.264 NALUs. Implements #997.

View File

@ -312,6 +312,21 @@ mpeg_ts_track_c::detect_timecode_wrap(timecode_c &timecode) {
return true;
}
void
mpeg_ts_track_c::adjust_timecode_for_wrap(timecode_c &timecode) {
static auto const s_wrap_limit = timecode_c::mpeg(1ll << 30);
static auto const s_bad_limit = timecode_c::m(5);
if (!timecode.valid())
return;
if (timecode < s_wrap_limit)
timecode += m_timecode_wrap_add;
if ((timecode - m_previous_valid_timecode).abs() >= s_bad_limit)
timecode = timecode_c{};
}
void
mpeg_ts_track_c::handle_timecode_wrap(timecode_c &pts,
timecode_c &dts) {
@ -336,11 +351,10 @@ mpeg_ts_track_c::handle_timecode_wrap(timecode_c &pts,
% pid % pts % dts % m_previous_valid_timecode % reader.m_global_timecode_offset % m_timecode_wrap_add);
}
if (pts.valid() && (pts < s_wrap_limit))
pts += m_timecode_wrap_add;
adjust_timecode_for_wrap(pts);
adjust_timecode_for_wrap(dts);
if (dts.valid() && (dts < s_wrap_limit))
dts += m_timecode_wrap_add;
// mxinfo(boost::format("pid %5% PTS before %1% now %2% wrapped %3% reset prevvalid %4% diff %6%\n") % before % pts % m_timecodes_wrapped % m_previous_valid_timecode % pid % (pts - m_previous_valid_timecode));
}
// ------------------------------------------------------------

View File

@ -353,6 +353,7 @@ public:
void handle_timecode_wrap(timecode_c &pts, timecode_c &dts);
bool detect_timecode_wrap(timecode_c &timecode);
void adjust_timecode_for_wrap(timecode_c &timecode);
};
typedef std::shared_ptr<mpeg_ts_track_c> mpeg_ts_track_ptr;

View File

@ -242,7 +242,7 @@ T_393aac_audiospecificconfig_0channels:0bf60d7f32b9a05462ca9585bebf8b86:passed:2
T_394flv_negative_cts_offset:3509ad61f8f886de8f27e420139cc89c:passed:20130414-115331:0.123013461
T_395remove_bitstream_ar_info:ea1df2cd599c8311730bce76c78d21d9-cc48db1bfac51a06a9b8ffd684481a92-66852921e2a157b3b62800368d133c4d-a1d5882c43fd871622ddbb755f14252c:passed:20130427-171243:0.334408574
T_396X_pcm_mono_16bit:49b80add61d8a11514d747c9616f7e80:passed:20130624-200214:0.055106028
T_397mpeg_ts_broken_pes_track_detection:e002775d9f85ad5dbc03d050da9bb373:passed:20130624-220549:1.12831027
T_397mpeg_ts_broken_pes_track_detection:2666da444bef9f02389b3c49846d33d3:passed:20130624-220549:1.12831027
T_398flv1_no_pixel_dimensions:44cdf14a8ffdfe91e5a0a7639b1b5834:passed:20130624-225648:0.103188723
T_399h264_append_and_default_duration:54f0d87ba4189fcd53b951e963c5b5b5:passed:20130627-195946:5.558958754
T_400opus_experimental:46a9a8e73f0d7423f0143597885688c2:passed:20130703-213929:0.055921025
@ -270,3 +270,4 @@ T_421svq3_from_mov:4947c2a51a12097cf2b3d002eff2e9df:passed:20140112-124559:0.195
T_422ac3_rederive_track_parameters_from_bitstream:7cf40379f451c604c8b6fce1f66b52b3:passed:20140215-162358:0.231506136
T_423deprecated_iso639_codes:9e7d8ab790007cf4f26ea31bb5de148f-good-6dd4fb24b0c76fb411a108102145eb71-good-2f580ffb94651b8782075a35b69258f3-good-4425838d0144c380ddbf59815cf83455-good:passed:20140222-185414:0.243526271
T_424avc_recover_point_sei_before_second_field:b66042e704ced1b55a5283d4b09876de:passed:20140304-190254:1.581374408
T_425mpeg_ts_timestamp_outlier:d9c6a4a1c7e815fed80a038128899586:passed:20140305-203603:2.509694471

View File

@ -0,0 +1,5 @@
#!/usr/bin/ruby -w
# T_425mpeg_ts_timestamp_outlier
describe "mkvmerge / MPEG TS ignore timestamp outliers"
test_merge "data/ts/pts_outlier.ts"