diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-09-21 14:39:42 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-09-21 14:39:42 +0100 |
| commit | 2169abd0f6d569492122ad699253ab7c792f4969 (patch) | |
| tree | 0596a808dada6fdfb9ff9e50ab7054a509455867 | |
| parent | ea491ba4ea7d5c4c575ae8b3d0415d78bbf32af6 (diff) | |
Disallow referencing DCPs of different frame rates to the project.
Fix reel calculations of DCPContent under trim.
| -rw-r--r-- | src/lib/dcp_content.cc | 29 | ||||
| -rw-r--r-- | src/lib/dcp_content.h | 2 | ||||
| -rw-r--r-- | src/wx/video_panel.cc | 5 | ||||
| -rw-r--r-- | test/reels_test.cc | 52 |
4 files changed, 82 insertions, 6 deletions
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<dcp::Reel> 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<dcp::Reel> 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_ptr<ContentPart> (shared_ptr<const Co } } + /* And the same frame rate */ + if (!video_frame_rate() || (lrint(video_frame_rate().get()) != film()->video_frame_rate())) { + why_not.push_back (_("The film has a different frame rate to this DCP.")); + return false; + } + list<DCPTimePeriod> 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<UserProperty>& 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> film = new_test_film ("reels_test4"); + shared_ptr<DCPContent> dcp (new DCPContent (film, "test/data/reels_test4")); + film->examine_and_add_content (dcp); + wait_for_jobs (); + + dcp->set_position(DCPTime(123)); + + { + list<DCPTimePeriod> p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list<DCPTimePeriod>::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<DCPTimePeriod> p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list<DCPTimePeriod>::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<DCPTimePeriod> p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 4); + list<DCPTimePeriod>::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<DCPTimePeriod> p = dcp->reels (); + BOOST_REQUIRE_EQUAL (p.size(), 3); + list<DCPTimePeriod>::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))); + } +} |
