Fix incorrect fades when trim is being used.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Jan 2016 22:14:22 +0000 (22:14 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 13 Jan 2016 22:14:22 +0000 (22:14 +0000)
ChangeLog
src/lib/video_content.cc

index a256181add4351058a98796b80c0ffb6c378baf8..0175c969e631713713bbee5e404b810353d86bbc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-13  Carl Hetherington  <cth@carlh.net>
+
+       * Fix incorrect fades when trim is being used.
+
 2016-01-11  Carl Hetherington  <cth@carlh.net>
 
        * Updated nl_NL translation from Rob van Nieuwkerk.
index 7321fc7c584bbf8c9dfa42b39f81dfce76b1d752..d104004f23c451ad00ed34c07c298d6e58a64c3e 100644 (file)
@@ -490,16 +490,18 @@ VideoContent::set_video_frame_rate (double r)
        signal_changed (VideoContentProperty::VIDEO_FRAME_RATE);
 }
 
+/** @param f Frame index within the whole (untrimmed) content */
 optional<double>
 VideoContent::fade (Frame f) const
 {
        DCPOMATIC_ASSERT (f >= 0);
 
-       if (f < fade_in()) {
-               return double (f) / fade_in();
+       Frame const ts = trim_start().frames_round(video_frame_rate());
+       if ((f - ts) < fade_in()) {
+               return double (f - ts) / fade_in();
        }
 
-       Frame fade_out_start = video_length() - fade_out();
+       Frame fade_out_start = video_length() - trim_end().frames_round(video_frame_rate()) - fade_out();
        if (f >= fade_out_start) {
                return 1 - double (f - fade_out_start) / fade_out();
        }