Express trims using ContentTime so that they do not change
[dcpomatic.git] / src / lib / playlist.cc
index e2135a60ed6a9479450f0991430aab819fc16ec6..4e46fdbdffb885778b99e373cd5d38a679c81e73 100644 (file)
@@ -303,13 +303,16 @@ Playlist::video_end () const
 FrameRateChange
 Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const
 {
-       for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+       for (ContentList::const_reverse_iterator i = _content.rbegin(); i != _content.rend(); ++i) {
                shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
                if (!vc) {
                        continue;
                }
 
-               if (vc->position() >= t && t < vc->end()) {
+               if (vc->position() <= t) {
+                       /* This is the first piece of content (going backwards...) that starts before t,
+                          so it's the active one.
+                       */
                        return FrameRateChange (vc->video_frame_rate(), dcp_video_frame_rate);
                }
        }