Some more decode logging.
[dcpomatic.git] / src / lib / dcp_subtitle_decoder.cc
index 81dfc6598ff345034636ac629905477a4297d39a..daafee3e5acfaf687a6d4b5de76f064dfeede0df 100644 (file)
@@ -28,12 +28,13 @@ using std::cout;
 using boost::shared_ptr;
 using boost::bind;
 
-DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content)
+DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr<const DCPSubtitleContent> content, shared_ptr<Log> log)
 {
        subtitle.reset (
                new SubtitleDecoder (
                        this,
                        content->subtitle,
+                       log,
                        bind (&DCPSubtitleDecoder::image_subtitles_during, this, _1, _2),
                        bind (&DCPSubtitleDecoder::text_subtitles_during, this, _1, _2)
                        )
@@ -79,6 +80,7 @@ DCPSubtitleDecoder::pass (PassReason, bool)
        }
 
        subtitle->give_text (p, s);
+       subtitle->set_position (p.from);
 
        return false;
 }
@@ -98,11 +100,14 @@ DCPSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) c
 
        for (list<dcp::SubtitleString>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
                ContentTimePeriod period = content_time_period (*i);
-               if ((starting && p.contains (period.from)) || (!starting && p.overlaps (period))) {
+               if ((starting && p.contains(period.from)) || (!starting && p.overlap(period))) {
                        d.push_back (period);
                }
        }
 
+       d.sort ();
+       d.unique ();
+
        return d;
 }