Improve implementation of ContentTime/DCPTime.
[dcpomatic.git] / src / lib / dcpomatic_time.cc
index ae4dea44f5c0752f6b387365713f772336e8d867..4541ced7dc504db73621e9db29e23bbe4b2750d5 100644 (file)
 
 using std::ostream;
 
-ContentTime::ContentTime (DCPTime d, FrameRateChange f)
-       : Time (rint (d.get() * f.speed_up))
+template <>
+Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
+       : _t (rint (d.get() * f.speed_up))
 {
 
 }
 
-DCPTime min (DCPTime a, DCPTime b)
+template <>
+Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f)
+       : _t (rint (d.get() / f.speed_up))
+{
+
+}
+
+DCPTime
+min (DCPTime a, DCPTime b)
 {
        if (a < b) {
                return a;
@@ -53,5 +62,11 @@ operator<< (ostream& s, DCPTime t)
 bool
 ContentTimePeriod::overlaps (ContentTimePeriod const & other) const
 {
-       return (from < other.to && to > other.from);
+       return (from < other.to && to >= other.from);
+}
+
+bool
+ContentTimePeriod::contains (ContentTime const & other) const
+{
+       return (from <= other && other < to);
 }