From f509c806965f4a381eec454e7f55a70fd676f302 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Jul 2015 12:46:53 +0100 Subject: [PATCH] Slightly cleaner implementations of Player::dcp_to_content_video and vice versa. --- src/lib/player.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/player.cc b/src/lib/player.cc index 83131e200..c551c9886 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -521,18 +521,23 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame Player::dcp_to_content_video (shared_ptr piece, DCPTime t) const { + shared_ptr vc = dynamic_pointer_cast (piece->content); + DCPTime s = t - piece->content->position () + piece->content->trim_start (); s = DCPTime (max (DCPTime::Type (0), s.get ())); s = DCPTime (min (piece->content->length_after_trim().get(), s.get())); - /* Convert this to the content frame */ - return s.frames (_film->video_frame_rate()) / piece->frc.factor (); + return ContentTime (s, piece->frc).frames (vc->video_frame_rate ()); } DCPTime Player::content_video_to_dcp (shared_ptr piece, Frame f) const { - DCPTime t = DCPTime::from_frames (f * piece->frc.factor (), _film->video_frame_rate()) - piece->content->trim_start () + piece->content->position (); + shared_ptr vc = dynamic_pointer_cast (piece->content); + + ContentTime const c = ContentTime::from_frames (f, vc->video_frame_rate ()); + DCPTime t = DCPTime (c, piece->frc) - piece->content->trim_start () + piece->content->position (); + if (t < DCPTime ()) { t = DCPTime (); } -- 2.30.2