Cleanup variable name: k -> reel
[dcpomatic.git] / src / lib / player.cc
index a1ddd07ba2cbf87b085585867f8dc561adbfe732..2669b350fb694e7085bd468eb5904f21fb047bb8 100644 (file)
@@ -582,9 +582,9 @@ Player::get_reel_assets ()
                int64_t offset_from_start = 0;
                /* position i the asset from the end */
                int64_t offset_from_end = 0;
-               for (auto k: decoder->reels()) {
+               for (auto reel: decoder->reels()) {
                        /* Assume that main picture duration is the length of the reel */
-                       offset_from_end += k->main_picture()->actual_duration();
+                       offset_from_end += reel->main_picture()->actual_duration();
                }
 
                for (auto reel: decoder->reels()) {
@@ -596,7 +596,7 @@ Player::get_reel_assets ()
                        Frame const reel_trim_start = min(reel_duration, max(int64_t(0), trim_start - offset_from_start));
                        Frame const reel_trim_end =   min(reel_duration, max(int64_t(0), reel_duration - (offset_from_end - trim_end)));
 
-                       auto const from = content->position() + DCPTime::from_frames (offset_from_start, _film->video_frame_rate());
+                       auto const from = max(DCPTime(), content->position() + DCPTime::from_frames(offset_from_start, ffr) - DCPTime::from_frames(trim_start, cfr));
                        if (dcp->reference_video()) {
                                maybe_add_asset (reel_assets, reel->main_picture(), reel_trim_start, reel_trim_end, from, ffr);
                        }
@@ -610,8 +610,8 @@ Player::get_reel_assets ()
                        }
 
                        if (dcp->reference_text(TextType::CLOSED_CAPTION)) {
-                               for (auto l: reel->closed_captions()) {
-                                       maybe_add_asset (reel_assets, l, reel_trim_start, reel_trim_end, from, ffr);
+                               for (auto caption: reel->closed_captions()) {
+                                       maybe_add_asset (reel_assets, caption, reel_trim_start, reel_trim_end, from, ffr);
                                }
                        }