Add comment.
[dcpomatic.git] / src / lib / dcpomatic_time.h
index 496f54d8efdb7fbf57a65a0fef0fc2ddc7505a9e..ac16830eeaf0f43257e24e22ad7b4cdf12900ff8 100644 (file)
@@ -132,7 +132,11 @@ public:
 
        template <typename T>
        int64_t frames_round (T r) const {
-               return llrint (_t * r / HZ);
+               /* We must cast to double here otherwise if T is integer
+                  the calculation will round down before we get the chance
+                  to llrint().
+               */
+               return llrint (_t * double(r) / HZ);
        }
 
        template <typename T>
@@ -142,7 +146,11 @@ public:
 
        template <typename T>
        int64_t frames_ceil (T r) const {
-               return ceil (_t * r / HZ);
+               /* We must cast to double here otherwise if T is integer
+                  the calculation will round down before we get the chance
+                  to ceil().
+               */
+               return ceil (_t * double(r) / HZ);
        }
 
        /** @param r Frames per second */
@@ -239,7 +247,9 @@ public:
                , to (t)
        {}
 
+       /** start time of sampling interval that the period is from */
        T from;
+       /** start time of next sampling interval after the period */
        T to;
 
        T duration () const {
@@ -258,7 +268,7 @@ public:
                return (from <= other && other < to);
        }
 
-       bool operator== (TimePeriod<T> const & other) {
+       bool operator== (TimePeriod<T> const & other) const {
                return from == other.from && to == other.to;
        }
 };