#include <iomanip>
#include <cstdio>
+struct dcpomatic_time_ceil_test;
+struct dcpomatic_time_floor_test;
+
+namespace dcpomatic {
+
/** A time in seconds, expressed as a number scaled up by Time::HZ. We want two different
- * versions of this class, ContentTime and DCPTime, and we want it to be impossible to
+ * versions of this class, dcpomatic::ContentTime and dcpomatic::DCPTime, and we want it to be impossible to
* convert implicitly between the two. Hence there's this template hack. I'm not
* sure if it's the best way to do it.
*
return *this;
}
+ Time<S, O> operator/ (int o) const {
+ return Time<S, O> (_t / o);
+ }
+
/** Round up to the nearest sampling interval
* at some sampling rate.
* @param r Sampling rate.
*/
- Time<S, O> ceil (float r) const {
- return Time<S, O> (llrint (HZ * frames_ceil(r) / double(r)));
+ Time<S, O> ceil (double r) const {
+ return Time<S, O> (llrint (HZ * frames_ceil(r) / r));
+ }
+
+ Time<S, O> floor (double r) const {
+ return Time<S, O> (llrint (HZ * frames_floor(r) / r));
}
- Time<S, O> floor (float r) const {
- return Time<S, O> (llrint (HZ * frames_floor(r) / double(r)));
+ Time<S, O> round (double r) const {
+ return Time<S, O> (llrint (HZ * frames_round(r) / r));
}
double seconds () const {
return Time<S, O> (INT64_MAX);
}
+ static const int HZ = 96000;
+
private:
- friend struct dcpomatic_time_ceil_test;
- friend struct dcpomatic_time_floor_test;
+ friend struct ::dcpomatic_time_ceil_test;
+ friend struct ::dcpomatic_time_floor_test;
Type _t;
- static const int HZ = 96000;
};
class ContentTimeDifferentiator {};
std::string to_string (DCPTime t);
std::string to_string (DCPTimePeriod p);
+}
+
#endif