X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fvideo_content.cc;h=d173b4607abb7e698568ca7b6564d01c961309e2;hp=1d1d010a95662193bc52ab84e5dacb2b8746fb10;hb=0303a96b66eaf85060ce02d85cc36067f34b1051;hpb=32294829b99fcbfa67e2b6b13b7a60d7244ff0ac diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 1d1d010a9..d173b4607 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -417,27 +417,29 @@ VideoContent::size_after_crop () const } -/** @param f Frame index within the whole (untrimmed) content. +/** @param time Time within the whole (untrimmed) content. * @return Fade factor (between 0 and 1) or unset if there is no fade. */ optional -VideoContent::fade (shared_ptr film, Frame f) const +VideoContent::fade(shared_ptr film, ContentTime time) const { - DCPOMATIC_ASSERT (f >= 0); + DCPOMATIC_ASSERT(time.get() >= 0); double const vfr = _parent->active_video_frame_rate(film); - auto const ts = _parent->trim_start().frames_round(vfr); - if ((f - ts) < fade_in()) { - return double (f - ts) / fade_in(); + auto const ts = _parent->trim_start(); + auto const fade_in_time = ContentTime::from_frames(fade_in(), vfr); + if ((time - ts) < fade_in_time) { + return double(ContentTime(time - ts).get()) / fade_in_time.get(); } - auto fade_out_start = length() - _parent->trim_end().frames_round(vfr) - fade_out(); - if (f >= fade_out_start) { - return 1 - double (f - fade_out_start) / fade_out(); + auto const fade_out_time = ContentTime::from_frames(fade_out(), vfr); + auto fade_out_start = ContentTime::from_frames(length(), vfr) - _parent->trim_end() - fade_out_time; + if (time >= fade_out_start) { + return 1 - double(ContentTime(time - fade_out_start).get()) / fade_out_time.get(); } - return optional (); + return {}; } string