Merge 2.0.
[dcpomatic.git] / src / lib / subrip_decoder.cc
index 3d971fd4b4fe8516ec43d5b7111b9f095b6176be..2ae285b5ede17586143aa56728f37e2877a773b3 100644 (file)
@@ -52,6 +52,8 @@ SubRipDecoder::pass ()
        if (_next >= _subtitles.size ()) {
                return true;
        }
+
+       /* XXX: we are ignoring positioning specified in the file */
        
        list<dcp::SubtitleString> out;
        for (list<SubRipSubtitlePiece>::const_iterator i = _subtitles[_next].pieces.begin(); i != _subtitles[_next].pieces.end(); ++i) {
@@ -60,10 +62,11 @@ SubRipDecoder::pass ()
                                "Arial",
                                i->italic,
                                dcp::Color (255, 255, 255),
-                               72,
+                               /* .srt files don't specify size, so this is an arbitrary value */
+                               48,
                                dcp::Time (rint (_subtitles[_next].period.from.seconds() * 250)),
                                dcp::Time (rint (_subtitles[_next].period.to.seconds() * 250)),
-                               0.9,
+                               0.2,
                                dcp::BOTTOM,
                                i->text,
                                dcp::NONE,
@@ -75,20 +78,22 @@ SubRipDecoder::pass ()
        }
 
        text_subtitle (out);
-       _next++;
+       ++_next;
        return false;
 }
 
-bool
-SubRipDecoder::has_subtitle_during (ContentTimePeriod p) const
+list<ContentTimePeriod>
+SubRipDecoder::subtitles_during (ContentTimePeriod p, bool starting) const
 {
        /* XXX: inefficient */
 
+       list<ContentTimePeriod> d;
+
        for (vector<SubRipSubtitle>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
-               if (p.overlaps (i->period)) {
-                       return true;
+               if ((starting && p.contains (i->period.from)) || (!starting && p.overlaps (i->period))) {
+                       d.push_back (i->period);
                }
        }
 
-       return false;
+       return d;
 }