Use cxml::ConstNodePtr.
[dcpomatic.git] / src / lib / dcpomatic_time.h
index b19a94ad78d5b817f117cd5b9080c0bf71860208..109dc9b7fe1c34b9850409a2bb4787298a58d492 100644 (file)
@@ -123,12 +123,11 @@ public:
         *  at some sampling rate.
         *  @param r Sampling rate.
         */
-       ContentTime round_up (int r) {
-               int64_t const n = HZ / r;
+       ContentTime round_up (float r) {
+               int64_t const n = rint (HZ / r);
                int64_t const a = _t + n - 1;
                return ContentTime (a - (a % n));
        }
-       
 
        static ContentTime from_seconds (double s) {
                return ContentTime (s * HZ);
@@ -136,8 +135,13 @@ public:
 
        template <class T>
        static ContentTime from_frames (int64_t f, T r) {
+               assert (r > 0);
                return ContentTime (f * HZ / r);
        }
+
+       static ContentTime max () {
+               return ContentTime (INT64_MAX);
+       }
 };
 
 std::ostream& operator<< (std::ostream& s, ContentTime t);
@@ -182,6 +186,10 @@ public:
                return *this;
        }
 
+       DCPTime operator- () const {
+               return DCPTime (-_t);
+       }
+
        DCPTime operator- (DCPTime const & o) const {
                return DCPTime (_t - o._t);
        }
@@ -195,8 +203,8 @@ public:
         *  at some sampling rate.
         *  @param r Sampling rate.
         */
-       DCPTime round_up (int r) {
-               int64_t const n = HZ / r;
+       DCPTime round_up (float r) {
+               int64_t const n = rint (HZ / r);
                int64_t const a = _t + n - 1;
                return DCPTime (a - (a % n));
        }
@@ -211,6 +219,7 @@ public:
 
        template <class T>
        static DCPTime from_frames (int64_t f, T r) {
+               assert (r > 0);
                return DCPTime (f * HZ / r);
        }