summaryrefslogtreecommitdiff
path: root/src/lib/subrip_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-26 22:02:00 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-26 22:02:00 +0100
commitc8ff422a42eac30517a7acde57ab84e55449f4e4 (patch)
tree6715a334126cca5558fb6158f0e9082cdb0afb5b /src/lib/subrip_decoder.cc
parentaddd3f846ed924710d7a416eedcda87653b75968 (diff)
Fix missing subtitles in some cases.
We were passing subtitles back from decoders to SubtitleDecoder using dcp::SubtitleStrings and relying on their storage of time to know when the subtitles were. These times are quantised (by the use of dcp::SubtitleString) and then compared with unquantised times (kept as ContentTime) in the main checking loop in SubtitleDecoder::get(). Fix this by storing periods as ContentTimePeriod as well as in the dcp::SubtitleStrings.
Diffstat (limited to 'src/lib/subrip_decoder.cc')
-rw-r--r--src/lib/subrip_decoder.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc
index c2bd4f3e0..6542c1a8e 100644
--- a/src/lib/subrip_decoder.cc
+++ b/src/lib/subrip_decoder.cc
@@ -82,7 +82,8 @@ SubRipDecoder::pass ()
}
}
- text_subtitle (out);
+ text_subtitle (content_time_period (_subtitles[_next]), out);
+
++_next;
return false;
}
@@ -101,12 +102,7 @@ SubRipDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const
list<ContentTimePeriod> d;
for (vector<sub::Subtitle>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
-
- ContentTimePeriod t (
- ContentTime::from_seconds (i->from.all_as_seconds()),
- ContentTime::from_seconds (i->to.all_as_seconds())
- );
-
+ ContentTimePeriod t = content_time_period (*i);
if ((starting && p.contains (t.from)) || (!starting && p.overlaps (t))) {
d.push_back (t);
}
@@ -114,3 +110,12 @@ SubRipDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const
return d;
}
+
+ContentTimePeriod
+SubRipDecoder::content_time_period (sub::Subtitle s) const
+{
+ return ContentTimePeriod (
+ ContentTime::from_seconds (s.from.all_as_seconds()),
+ ContentTime::from_seconds (s.to.all_as_seconds())
+ );
+}