#ifndef DCPOMATIC_TIME_H
#define DCPOMATIC_TIME_H
+#include "frame_rate_change.h"
+#include "safe_stringstream.h"
+#include "dcpomatic_assert.h"
+#include <stdint.h>
#include <cmath>
#include <ostream>
#include <sstream>
#include <iomanip>
-#include <stdint.h>
-#include "frame_rate_change.h"
class dcpomatic_round_up_test;
template <typename T>
int64_t frames (T r) const {
- return rint (_t * r / HZ);
+ return rint (double (_t) * r / HZ);
}
+ /** @param r Frames per second */
template <typename T>
void split (T r, int& h, int& m, int& s, int& f) const
{
int f;
split (r, h, m, s, f);
- std::ostringstream o;
+ SafeStringStream o;
o.width (2);
o.fill ('0');
o << std::setw(2) << std::setfill('0') << h << ":"
}
protected:
- friend class dcptime_round_up_test;
+ friend struct dcptime_round_up_test;
Type _t;
static const int HZ = 96000;
template <class T>
static ContentTime from_frames (int64_t f, T r) {
- assert (r > 0);
+ DCPOMATIC_ASSERT (r > 0);
return ContentTime (f * HZ / r);
}
{
public:
ContentTimePeriod () {}
+
ContentTimePeriod (ContentTime f, ContentTime t)
: from (f)
, to (t)
}
bool overlaps (ContentTimePeriod const & o) const;
+ bool contains (ContentTime const & o) const;
};
class DCPTime : public Time
template <class T>
static DCPTime from_frames (int64_t f, T r) {
- assert (r > 0);
+ DCPOMATIC_ASSERT (r > 0);
return DCPTime (f * HZ / r);
}