From f08407bb620638a402ec8f52ba6c3a54383caf86 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 21 Sep 2015 10:42:39 +0100 Subject: [PATCH] Implement Film::reels(). --- src/lib/film.cc | 38 +++++++++++++++++++++++++++++++++++++- test/wscript | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index c0060b040..8cf468150 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1291,7 +1291,43 @@ list Film::reels () const { list p; - p.push_back (DCPTimePeriod (DCPTime (), length ())); + DCPTime const len = length (); + + switch (reel_type ()) { + case REELTYPE_SINGLE: + p.push_back (DCPTimePeriod (DCPTime (), len)); + break; + case REELTYPE_ONE_PER_VIDEO: + { + optional last; + BOOST_FOREACH (shared_ptr c, content ()) { + shared_ptr v = dynamic_pointer_cast (c); + if (v) { + if (last) { + p.push_back (DCPTimePeriod (last.get(), v->position ())); + } + last = v->position (); + } + } + if (last) { + p.push_back (DCPTimePeriod (last.get(), len)); + } + break; + } + case REELTYPE_BY_LENGTH: + { + DCPTime current; + /* Integer-divide reel length by the size of one frame to give the number of frames per reel */ + Frame const reel_in_frames = _reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8); + while (current < len) { + DCPTime end = min (len, current + DCPTime::from_frames (reel_in_frames, video_frame_rate ())); + p.push_back (DCPTimePeriod (current, end)); + current = end; + } + break; + } + } + return p; } diff --git a/test/wscript b/test/wscript index 6ee995e36..89f84e836 100644 --- a/test/wscript +++ b/test/wscript @@ -71,6 +71,7 @@ def build(bld): ratio_test.cc repeat_frame_test.cc recover_test.cc + reels_test.cc resampler_test.cc scaling_test.cc seek_zero_test.cc -- 2.30.2