Merge master.
[dcpomatic.git] / src / lib / dcpomatic_time.h
index 59986e6d892994787301325b7a4fc15316d89911..2a871889a529be2ec7e7f6bcc7c0c15c2f2cf5c8 100644 (file)
@@ -135,6 +135,7 @@ public:
 
        template <class T>
        static ContentTime from_frames (int64_t f, T r) {
+               assert (r > 0);
                return ContentTime (f * HZ / r);
        }
 
@@ -145,6 +146,23 @@ public:
 
 std::ostream& operator<< (std::ostream& s, ContentTime t);
 
+class ContentTimePeriod
+{
+public:
+       ContentTimePeriod () {}
+       ContentTimePeriod (ContentTime f, ContentTime t)
+               : from (f)
+               , to (t)
+       {}
+
+       ContentTime from;
+       ContentTime to;
+
+       ContentTimePeriod operator+ (ContentTime const & o) const {
+               return ContentTimePeriod (from + o, to + o);
+       }
+};
+
 class DCPTime : public Time
 {
 public:
@@ -185,6 +203,10 @@ public:
                return *this;
        }
 
+       DCPTime operator- () const {
+               return DCPTime (-_t);
+       }
+
        DCPTime operator- (DCPTime const & o) const {
                return DCPTime (_t - o._t);
        }
@@ -214,6 +236,7 @@ public:
 
        template <class T>
        static DCPTime from_frames (int64_t f, T r) {
+               assert (r > 0);
                return DCPTime (f * HZ / r);
        }