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 /src/lib | |
| parent | ea491ba4ea7d5c4c575ae8b3d0415d78bbf32af6 (diff) | |
Disallow referencing DCPs of different frame rates to the project.
Fix reel calculations of DCPContent under trim.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_content.cc | 29 | ||||
| -rw-r--r-- | src/lib/dcp_content.h | 2 |
2 files changed, 26 insertions, 5 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); |
