Force specification of timecode rate when creating a Time from seconds.
authorCarl Hetherington <cth@carlh.net>
Thu, 15 Oct 2015 08:55:48 +0000 (09:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 15 Oct 2015 08:55:48 +0000 (09:55 +0100)
src/dcp_time.cc
src/dcp_time.h
test/dcp_time_test.cc

index 3db449fb058a8a56f6c4800e72b79db3af72d671..4e7ab6f2fa0cac106c840dbebc45ed093e1a34b2 100644 (file)
@@ -38,14 +38,14 @@ Time::Time (int frame, int frames_per_second, int tcr_)
        set (double (frame) / frames_per_second, tcr_);
 }
 
-/** Construct a Time with a timecode rate of 24 and using the supplied
- *  number of seconds.
+/** Construct a Time from a number of seconds and a timecode rate.
  *
  *  @param seconds A number of seconds.
+ *  @param tcr_ Timecode rate.
  */
-Time::Time (double seconds)
+Time::Time (double seconds, int tcr_)
 {
-       set (seconds, 24);
+       set (seconds, tcr_);
 }
 
 /** Construct a Time with specified timecode rate and using the supplied
index 270177dd653edb65ad94f63222391ce216575afa..44e3cf0234bd7ccc37dab548ed81215052cebb5e 100644 (file)
@@ -62,7 +62,7 @@ public:
                , tcr (tcr_)
        {}
 
-       Time (double seconds);
+       Time (double seconds, int tcr);
 
        Time (std::string time, int tcr);
 
index 196efe172c9bf10ff19111dfa0a0c83bf26cb4e2..61b38ec4981e51e89b24dfd1b0ce2abbf1a3dc72 100644 (file)
@@ -89,6 +89,9 @@ BOOST_AUTO_TEST_CASE (dcp_time)
        r = a + b;
        BOOST_CHECK_EQUAL (r, dcp::Time (0, 0, 0, 240, 1152));
 
+       /* Check rounding on conversion from seconds */
+       BOOST_CHECK_EQUAL (dcp::Time (80.990, 1000), dcp::Time (0, 1, 20, 990, 1000));
+
        /* Check rebase() */
        a = dcp::Time (1, 58, 56, 2, 25);
        BOOST_CHECK_EQUAL (a.rebase (250), dcp::Time (1, 58, 56, 20, 250));