From c8ff422a42eac30517a7acde57ab84e55449f4e4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 26 Jun 2015 22:02:00 +0100 Subject: 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. --- src/lib/subrip_decoder.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/lib/subrip_decoder.cc') 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 d; for (vector::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()) + ); +} -- cgit v1.2.3