summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-03 12:38:30 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-03 12:38:30 +0000
commita2e3a20a441e604550f0036ca198d5d2122e16a7 (patch)
treec0da2b4ace57020b9973f20108e8bbf11ed4e444 /src/lib/util.cc
parentc93389b617d2b1a4f5b36025e3097a9f03a7c9cf (diff)
Fix rounding of timecodes in at least some cases (#323).
Reported-by: Gérald Maruccia
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 25fbc130b..f604cd10a 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -1016,3 +1016,13 @@ entities_to_text (string e)
boost::algorithm::replace_all (e, "%2F", "/");
return e;
}
+
+int64_t
+divide_with_round (int64_t a, int64_t b)
+{
+ if (a % b >= (b / 2)) {
+ return (a + b - 1) / b;
+ } else {
+ return a / b;
+ }
+}