Fix failure of DCPDecoder::text_subtitles_during to account for reels.
authorCarl Hetherington <cth@carlh.net>
Mon, 10 Oct 2016 22:55:59 +0000 (23:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 10 Oct 2016 22:55:59 +0000 (23:55 +0100)
ChangeLog
src/lib/dcp_decoder.cc

index a9f56492cddf393c17d433bd9823aa6c3a12c626..3fc747632be36e56736736d6a4298eb0bd6246ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-10-10  Carl Hetherington  <cth@carlh.net>
+
+       * Fix incorrect import of multi-reel DCPs with subtitles.
+
 2016-10-09  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.9.31 released.
index 156fba1017760629a2308db044d7f2f401b304b8..5d73a9bbfa32066832f41748bdc3de2beb423370 100644 (file)
@@ -251,27 +251,32 @@ DCPDecoder::text_subtitles_during (ContentTimePeriod period, bool starting) cons
        list<ContentTimePeriod> ctp;
        double const vfr = _dcp_content->active_video_frame_rate ();
 
+       int offset = 0;
+
        BOOST_FOREACH (shared_ptr<dcp::Reel> r, _reels) {
                if (!r->main_subtitle ()) {
+                       offset += r->main_picture()->duration();
                        continue;
                }
 
                int64_t const entry_point = r->main_subtitle()->entry_point ();
 
                list<dcp::SubtitleString> subs = r->main_subtitle()->asset()->subtitles_during (
-                       dcp::Time (period.from.seconds(), 1000) - dcp::Time (entry_point, vfr, vfr),
-                       dcp::Time (period.to.seconds(), 1000) - dcp::Time (entry_point, vfr, vfr),
+                       dcp::Time (period.from.seconds(), 1000) - dcp::Time (offset - entry_point, vfr, vfr),
+                       dcp::Time (period.to.seconds(), 1000) - dcp::Time (offset - entry_point, vfr, vfr),
                        starting
                        );
 
                BOOST_FOREACH (dcp::SubtitleString const & s, subs) {
                        ctp.push_back (
                                ContentTimePeriod (
-                                       ContentTime::from_seconds (s.in().as_seconds ()),
-                                       ContentTime::from_seconds (s.out().as_seconds ())
+                                       ContentTime::from_seconds (s.in().as_seconds ()) + ContentTime::from_frames (offset - entry_point, vfr),
+                                       ContentTime::from_seconds (s.out().as_seconds ()) + ContentTime::from_frames (offset - entry_point, vfr)
                                        )
                                );
                }
+
+               offset += r->main_subtitle()->duration();
        }
 
        return ctp;