From: Carl Hetherington Date: Wed, 21 Sep 2016 13:39:42 +0000 (+0100) Subject: Disallow referencing DCPs of different frame rates to the project. X-Git-Tag: v2.9.25~1 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=2169abd0f6d569492122ad699253ab7c792f4969 Disallow referencing DCPs of different frame rates to the project. Fix reel calculations of DCPContent under trim. --- diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 8b823c619..c180240c8 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -362,11 +362,23 @@ DCPContent::reels () const return p; } - DCPTime from = position (); - BOOST_FOREACH (shared_ptr i, decoder->reels()) { - DCPTime const to = from + DCPTime::from_frames (i->main_picture()->duration(), film()->video_frame_rate()); - p.push_back (DCPTimePeriod (from, to)); - from = to; + /* This content's frame rate must be the same as the output DCP rate, so we can + convert `directly' from ContentTime to DCPTime. + */ + + /* The starting point of this content on the timeline */ + DCPTime pos = position() - DCPTime (trim_start().get()); + + BOOST_FOREACH (shared_ptr i, decoder->reels ()) { + /* This reel runs from `pos' to `to' */ + DCPTime const to = pos + DCPTime::from_frames (i->main_picture()->duration(), film()->video_frame_rate()); + if (to > position()) { + p.push_back (DCPTimePeriod (max(position(), pos), min(end(), to))); + if (to > end()) { + break; + } + } + pos = to; } return p; @@ -396,7 +408,14 @@ DCPContent::can_reference (function (shared_ptrvideo_frame_rate())) { + why_not.push_back (_("The film has a different frame rate to this DCP.")); + return false; + } + list const fr = film()->reels (); + /* fr must contain reels(). It can also contain other reels, but it must at least contain reels(). */ diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 11096037c..f97045484 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -120,6 +120,8 @@ public: } private: + friend class reels_test5; + void add_properties (std::list& p) const; void read_directory (boost::filesystem::path); diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index a1457ac6d..177799208 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -252,8 +252,11 @@ void VideoPanel::film_changed (Film::Property property) { switch (property) { - case Film::CONTAINER: case Film::VIDEO_FRAME_RATE: + setup_description (); + setup_sensitivity (); + break; + case Film::CONTAINER: case Film::RESOLUTION: setup_description (); break; diff --git a/test/reels_test.cc b/test/reels_test.cc index 9718898e2..51cb1f200 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -221,3 +221,55 @@ BOOST_AUTO_TEST_CASE (reels_test4) check_dcp ("test/data/reels_test4", film->dir (film->dcp_name())); } + +BOOST_AUTO_TEST_CASE (reels_test5) +{ + shared_ptr film = new_test_film ("reels_test4"); + shared_ptr dcp (new DCPContent (film, "test/data/reels_test4")); + film->examine_and_add_content (dcp); + wait_for_jobs (); + + dcp->set_position(DCPTime(123)); + + { + list p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list::const_iterator i = p.begin(); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 0), DCPTime(123 + 96000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 96000), DCPTime(123 + 192000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 192000), DCPTime(123 + 288000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 288000), DCPTime(123 + 384000))); + } + + { + dcp->set_trim_start (ContentTime::from_seconds (0.5)); + list p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list::const_iterator i = p.begin(); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 0), DCPTime(123 + 48000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 48000), DCPTime(123 + 144000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 144000), DCPTime(123 + 240000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 240000), DCPTime(123 + 336000))); + } + + { + dcp->set_trim_end (ContentTime::from_seconds (0.5)); + list p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list::const_iterator i = p.begin(); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 0), DCPTime(123 + 48000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 48000), DCPTime(123 + 144000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 144000), DCPTime(123 + 240000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 240000), DCPTime(123 + 288000))); + } + + { + dcp->set_trim_start (ContentTime::from_seconds (1.5)); + list p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 3); + list::const_iterator i = p.begin(); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 0), DCPTime(123 + 48000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 48000), DCPTime(123 + 144000))); + BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(123 + 144000), DCPTime(123 + 192000))); + } +}