diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-12 23:34:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-12 23:34:31 +0100 |
| commit | 41d32a43f761fd2d79dacf9a84374a6d17916d36 (patch) | |
| tree | bf106bf5a6df144af38a93adc70adddf8ce2897b /src/lib/subrip_decoder.cc | |
| parent | 141f9a795381fa3bbd3f2bcbd19975dfd8a8c35e (diff) | |
Fix subrip subtitles a little.
Diffstat (limited to 'src/lib/subrip_decoder.cc')
| -rw-r--r-- | src/lib/subrip_decoder.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index e832c2d84..3d971fd4b 100644 --- a/src/lib/subrip_decoder.cc +++ b/src/lib/subrip_decoder.cc @@ -22,6 +22,7 @@ #include "subrip_content.h" using std::list; +using std::vector; using boost::shared_ptr; SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> content) @@ -39,7 +40,7 @@ SubRipDecoder::seek (ContentTime time, bool accurate) _next = 0; list<SubRipSubtitlePiece>::const_iterator i = _subtitles[_next].pieces.begin(); - while (i != _subtitles[_next].pieces.end() && _subtitles[_next].from < time) { + while (i != _subtitles[_next].pieces.end() && _subtitles[_next].period.from < time) { ++i; } @@ -60,8 +61,8 @@ SubRipDecoder::pass () i->italic, dcp::Color (255, 255, 255), 72, - dcp::Time (rint (_subtitles[_next].from.seconds() * 250)), - dcp::Time (rint (_subtitles[_next].to.seconds() * 250)), + dcp::Time (rint (_subtitles[_next].period.from.seconds() * 250)), + dcp::Time (rint (_subtitles[_next].period.to.seconds() * 250)), 0.9, dcp::BOTTOM, i->text, @@ -77,3 +78,17 @@ SubRipDecoder::pass () _next++; return false; } + +bool +SubRipDecoder::has_subtitle_during (ContentTimePeriod p) const +{ + /* XXX: inefficient */ + + for (vector<SubRipSubtitle>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { + if (p.overlaps (i->period)) { + return true; + } + } + + return false; +} |
