summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-10-24 15:42:32 +0100
committerCarl Hetherington <cth@carlh.net>2013-10-24 15:42:32 +0100
commit91f94491733d790d41e39b3604d67d3c3561bf01 (patch)
treeb6794553d060157882b7c6a867ca72aaed0baba0 /src
parentef26e37fce728cba6fb50e9e6743a012b1bbbf64 (diff)
Add Time constructor from ticks; fix Time::to_ticks().
Diffstat (limited to 'src')
-rw-r--r--src/dcp_time.cc15
-rw-r--r--src/dcp_time.h2
2 files changed, 16 insertions, 1 deletions
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 7d3111d2..ccedd8ce 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -42,6 +42,19 @@ Time::Time (int frame, int frames_per_second)
set (double (frame) / frames_per_second);
}
+Time::Time (int64_t ticks)
+{
+ h = ticks / (60 * 60 * 25);
+ ticks -= int64_t (h) * 60 * 60 * 25;
+ m = ticks / (60 * 25);
+ ticks -= int64_t (m) * 60 * 25;
+ s = ticks / 25;
+ ticks -= int64_t (s) * 25;
+ t = ticks;
+
+ std::cout << "Hello: " << h << " " << m << " " << s << " " << t << "\n";
+}
+
void
Time::set (double ss)
{
@@ -235,6 +248,6 @@ Time::to_string () const
int64_t
Time::to_ticks () const
{
- return t + s * 25 + m * 60 * 25 + h * 60 * 60 * 25;
+ return int64_t(t) + int64_t(s) * 25 + int64_t(m) * 60 * 25 + int64_t(h) * 60 * 60 * 25;
}
diff --git a/src/dcp_time.h b/src/dcp_time.h
index 10e495f9..92cee9a0 100644
--- a/src/dcp_time.h
+++ b/src/dcp_time.h
@@ -39,6 +39,8 @@ class Time
public:
Time () : h (0), m (0), s (0), t (0) {}
+ Time (int64_t ticks);
+
/** Construct a Time from a frame index (starting from 0)
* and a frames per second count.
*/