summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-21 15:44:46 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-21 15:44:46 +0100
commitde49deb8b65bad47fda93a04fab2e97b10d48a75 (patch)
tree65a94d8fb4da433db32bae0ec84f78a9a988de2c /src
parenta05f25fc0e70ecd5c51984c9efccd2377ebb8ffe (diff)
Add FrameTime constructor from frames and fps.
Diffstat (limited to 'src')
-rw-r--r--src/frame_time.cc11
-rw-r--r--src/frame_time.h6
2 files changed, 17 insertions, 0 deletions
diff --git a/src/frame_time.cc b/src/frame_time.cc
index 726c552..e9b72b7 100644
--- a/src/frame_time.cc
+++ b/src/frame_time.cc
@@ -61,3 +61,14 @@ FrameTime::timecode () const
{
return String::compose ("%1:%2:%3:%4", _hours, _minutes, _seconds, _frames);
}
+
+FrameTime::FrameTime (int64_t f, int fps)
+{
+ _hours = f / (60 * 60 * fps);
+ f -= _hours * 60 * 60 * fps;
+ _minutes = f / (60 * fps);
+ f -= _minutes * 60 * fps;
+ _seconds = f / fps;
+ f -= _seconds * fps;
+ _frames = int (f);
+}
diff --git a/src/frame_time.h b/src/frame_time.h
index 1a97e63..e721a29 100644
--- a/src/frame_time.h
+++ b/src/frame_time.h
@@ -21,6 +21,7 @@
#define LIBSUB_FRAME_TIME_H
#include <iostream>
+#include <stdint.h>
namespace sub {
@@ -36,6 +37,11 @@ public:
, _seconds (0)
, _frames (0)
{}
+
+ /** @param f Number of frames.
+ * @param fps Frames per second.
+ */
+ FrameTime (int64_t f, int fps);
FrameTime (int h, int m, int s, int f)
: _hours (h)