4th parameter of time is ticks (1 tick = 4ms) not milliseconds
authorCarl Hetherington <cth@carlh.net>
Mon, 13 Aug 2012 15:24:37 +0000 (16:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 13 Aug 2012 15:24:37 +0000 (16:24 +0100)
src/dcp_time.cc
src/dcp_time.h
test/tests.cc

index 6af653adeabc43be623e9aab56a1745b9c10eb01..5b4241c4f42978d63a67579e7ac8ec618412428c 100644 (file)
@@ -27,7 +27,7 @@ using namespace libdcp;
 Time::Time (int frame, int frames_per_second)
 {
        float sec_float = float (frame) / frames_per_second;
-       ms = int (sec_float * 1000) % 1000;
+       t = (int (sec_float * 1000) % 1000) / 4;
        s = floor (sec_float);
 
        if (s > 60) {
@@ -44,7 +44,7 @@ Time::Time (int frame, int frames_per_second)
 bool
 libdcp::operator== (Time const & a, Time const & b)
 {
-       return (a.h == b.h && a.m == b.m && a.s == b.s && a.ms == b.ms);
+       return (a.h == b.h && a.m == b.m && a.s == b.s && a.t == b.t);
 }
 
 bool
@@ -62,8 +62,8 @@ libdcp::operator<= (Time const & a, Time const & b)
                return a.s <= b.s;
        }
 
-       if (a.ms != b.ms) {
-               return a.ms <= b.ms;
+       if (a.t != b.t) {
+               return a.t <= b.t;
        }
 
        return true;
@@ -72,6 +72,6 @@ libdcp::operator<= (Time const & a, Time const & b)
 ostream &
 libdcp::operator<< (ostream& s, Time const & t)
 {
-       s << t.h << ":" << t.m << ":" << t.s << "." << t.ms;
+       s << t.h << ":" << t.m << ":" << t.s << "." << t.t;
        return s;
 }
index 22dcec0fd73004650787aecc254a476040c6c40e..a611cd89db9b3545de727b2dee32caa7f7941c48 100644 (file)
@@ -25,19 +25,19 @@ namespace libdcp {
 class Time
 {
 public:
-       Time () : h (0), m (0), s (0), ms (0) {}
+       Time () : h (0), m (0), s (0), t (0) {}
        Time (int frame, int frames_per_second);
-       Time (int h_, int m_, int s_, int ms_)
+       Time (int h_, int m_, int s_, int t_)
                : h (h_)
                , m (m_)
                , s (s_)
-               , ms (ms_)
+               , t (t_)
        {}
 
        int h;
        int m;
        int s;
-       int ms;
+       int t;
 };
 
 extern bool operator== (Time const & a, Time const & b);
index ccbf8787895dabb86299d586eee912abc7245cc3..a7ad67f6f0c9140ae310855ab62b87a04aaffe1b 100644 (file)
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE (dcp_time)
 {
        libdcp::Time t (977143, 24);
 
-       BOOST_CHECK_EQUAL (t.ms, 292);
+       BOOST_CHECK_EQUAL (t.t, 73);
        BOOST_CHECK_EQUAL (t.s, 34);
        BOOST_CHECK_EQUAL (t.m, 18);
        BOOST_CHECK_EQUAL (t.h, 11);