summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-12-10 21:02:17 +0000
committerCarl Hetherington <cth@carlh.net>2014-12-10 21:02:17 +0000
commita49e1c2df1568391651344ae368c53f76d504571 (patch)
tree8f69f8f7d5c19306a4a44e8a4b864595f1026d27 /src
parentf2ebc98bfa8e780935d76108b897015128c6271e (diff)
Round times correctly when converting.
Diffstat (limited to 'src')
-rw-r--r--src/time_pair.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/time_pair.cc b/src/time_pair.cc
index 35ba3d0..b625aca 100644
--- a/src/time_pair.cc
+++ b/src/time_pair.cc
@@ -22,6 +22,7 @@
*/
#include "time_pair.h"
+#include <cmath>
using std::ostream;
using namespace sub;
@@ -34,7 +35,7 @@ TimePair::frame (float fps) const
}
MetricTime const m = _metric.get ();
- return FrameTime (m.hours(), m.minutes(), m.seconds(), m.milliseconds() * fps / 1000);
+ return FrameTime (m.hours(), m.minutes(), m.seconds(), rint (m.milliseconds() * fps / 1000));
}
MetricTime
@@ -45,7 +46,7 @@ TimePair::metric (float fps) const
}
FrameTime const f = _frame.get ();
- return MetricTime (f.hours(), f.minutes(), f.seconds(), f.frames() * 1000 / fps);
+ return MetricTime (f.hours(), f.minutes(), f.seconds(), rint (f.frames() * 1000 / fps));
}
void
@@ -54,7 +55,7 @@ TimePair::add (FrameTime t, float fps)
if (_frame) {
_frame.get().add (t, fps);
} else {
- _metric.get().add (MetricTime (t.hours(), t.minutes(), t.seconds(), t.frames() * 1000 / fps));
+ _metric.get().add (MetricTime (t.hours(), t.minutes(), t.seconds(), rint (t.frames() * 1000 / fps)));
}
}