Handle IDX VobSub files with negative "delay" fields

This commit is contained in:
Moritz Bunkus 2011-05-23 20:49:57 +02:00
parent e718b02245
commit c15ddd9238
4 changed files with 34 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-05-23 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: enhancement: Added support for VobSub IDX files with
negative "delay" fields.
2011-05-11 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: bug fix: The 'doc type read version' EBML header field

View File

@ -204,6 +204,7 @@ vobsub_reader_c::parse_headers() {
}
}
track = new vobsub_track_c(language);
delay = 0;
last_timestamp = 0;
sort_required = false;
continue;
@ -216,10 +217,16 @@ vobsub_reader_c::parse_headers() {
line.erase(0, 6);
strip(line);
int factor = 1;
if (!line.empty() && (line[0] == '-')) {
factor = -1;
line.erase(0, 1);
}
int64_t timestamp;
if (!parse_timecode(line, timestamp, true))
mxerror_fn(m_ti.m_fname, boost::format(Y("line %1%: The 'delay' timestamp could not be parsed.\n")) % line_no);
delay = timestamp;
delay += timestamp * factor;
}
if ((7 == version) && starts_with_case(line, "timestamp:")) {
@ -262,6 +269,13 @@ vobsub_reader_c::parse_headers() {
entry.position = filepos;
entry.timestamp = timestamp * factor + delay;
if ( (0 > delay)
&& (0 != last_timestamp)
&& (entry.timestamp < last_timestamp)) {
delay += last_timestamp - entry.timestamp;
entry.timestamp = last_timestamp;
}
if (0 > entry.timestamp) {
mxwarn_fn(m_ti.m_fname,
boost::format(Y("Line %1%: The line seems to be a subtitle entry but the timecode was negative even after adding the track "

View File

@ -140,3 +140,4 @@ T_290seven_bytes_aac_codec_data:d8680e35f0f6b595dce0fcb8af3b6e9e:passed:20110415
T_291waveformatextensible:wav-avi:passed:20110415-124159:0.057127293
T_292avi_aac_706d_privsize_huge:7b34a92c34461e869834e7db0c63ab97:passed:20110422-152313:0.042857788
T_293aac_adif_misdetected_as_video:3:passed:20110426-091956:0.02536219
T_294vobsub_negative_delay:6e1c59551b7ad05fa570bed2ffc926fe:passed:20110523-204847:1.41224474

View File

@ -0,0 +1,13 @@
#!/usr/bin/ruby -w
class T_294vobsub_negative_delay < Test
def description
"mkvmerge / VobSub with negative \"delay\" fields"
end
def run
merge "data/vobsub/House.S07E22.idx"
hash_tmp
end
end