summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-15 09:55:48 +0100
committerCarl Hetherington <cth@carlh.net>2015-10-15 09:55:48 +0100
commitf6b789850b0cd50971707084632c4ec08e145d0f (patch)
treeead0b094e55cd36e3d8fd488d885a7abfb3e10ea
parent1f181883996536ac4b3ea1672160bea4625d75d3 (diff)
Force specification of timecode rate when creating a Time from seconds.
-rw-r--r--src/dcp_time.cc8
-rw-r--r--src/dcp_time.h2
-rw-r--r--test/dcp_time_test.cc3
3 files changed, 8 insertions, 5 deletions
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 3db449fb..4e7ab6f2 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -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
diff --git a/src/dcp_time.h b/src/dcp_time.h
index 270177dd..44e3cf02 100644
--- a/src/dcp_time.h
+++ b/src/dcp_time.h
@@ -62,7 +62,7 @@ public:
, tcr (tcr_)
{}
- Time (double seconds);
+ Time (double seconds, int tcr);
Time (std::string time, int tcr);
diff --git a/test/dcp_time_test.cc b/test/dcp_time_test.cc
index 196efe17..61b38ec4 100644
--- a/test/dcp_time_test.cc
+++ b/test/dcp_time_test.cc
@@ -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));