From a0d1dd5d91c81ec9907cbc7b890905c463c18f62 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 28 Jul 2015 17:53:27 +0100 Subject: Replace Time::frames with Time::frames_round and Time::frames_floor. I believe both are necessary; doing floor instead of round caused #648. --- src/lib/player.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/lib/player.cc') diff --git a/src/lib/player.cc b/src/lib/player.cc index e73481107..147f08ae8 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -431,7 +431,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) setup_pieces (); } - Frame const length_frames = length.frames (_film->audio_frame_rate ()); + Frame const length_frames = length.frames_round (_film->audio_frame_rate ()); shared_ptr audio (new AudioBuffers (_film->audio_channels(), length_frames)); audio->make_silent (); @@ -457,7 +457,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) the stuff we get back. */ offset = -request; - request_frames += request.frames (_film->audio_frame_rate ()); + request_frames += request.frames_round (_film->audio_frame_rate ()); if (request_frames < 0) { request_frames = 0; } @@ -509,7 +509,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) audio->accumulate_frames ( all.audio.get(), content_frame - all.frame, - offset.frames (_film->audio_frame_rate()), + offset.frames_round (_film->audio_frame_rate()), min (Frame (all.audio->frames()), request_frames) ); } @@ -524,7 +524,10 @@ 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 (); s = min (piece->content->length_after_trim(), s); - return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start ()).frames (vc->video_frame_rate ()); + /* We're returning a frame index here so we need to floor() the conversion since we want to know the frame + that contains t, I think + */ + return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start ()).frames_floor (vc->video_frame_rate ()); } DCPTime @@ -540,7 +543,8 @@ Player::dcp_to_resampled_audio (shared_ptr piece, DCPTime t) const { DCPTime s = t - piece->content->position (); s = min (piece->content->length_after_trim(), s); - return max (DCPTime (), DCPTime (piece->content->trim_start (), piece->frc) + s).frames (_film->audio_frame_rate ()); + /* See notes in dcp_to_content_video */ + return max (DCPTime (), DCPTime (piece->content->trim_start (), piece->frc) + s).frames_floor (_film->audio_frame_rate ()); } ContentTime -- cgit v1.2.3