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;
}
}
+ /* 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().
*/
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)));
+ }
+}