diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-09-21 10:42:39 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-12 11:05:26 +0100 |
| commit | f08407bb620638a402ec8f52ba6c3a54383caf86 (patch) | |
| tree | 11df1d33fcb7a4045e28ea0453499f1f89adc842 /src/lib | |
| parent | 1c20cecba6ded6c878ba67c5c2dc4950d65d9cc3 (diff) | |
Implement Film::reels().
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 38 |
1 files changed, 37 insertions, 1 deletions
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<DCPTimePeriod> Film::reels () const { list<DCPTimePeriod> 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<DCPTime> last; + BOOST_FOREACH (shared_ptr<Content> c, content ()) { + shared_ptr<VideoContent> v = dynamic_pointer_cast<VideoContent> (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; } |
