From 89b2ca022fd8020a713d3a66c0bee93b2b95aac1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 2 Apr 2014 17:03:39 +0100 Subject: [PATCH] Allow round-up to non-integer sample rates. --- src/lib/dcpomatic_time.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index e0d47d9c8..59986e6d8 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -123,12 +123,11 @@ public: * at some sampling rate. * @param r Sampling rate. */ - ContentTime round_up (int r) { - int64_t const n = HZ / r; + ContentTime round_up (float r) { + int64_t const n = rint (HZ / r); int64_t const a = _t + n - 1; return ContentTime (a - (a % n)); } - static ContentTime from_seconds (double s) { return ContentTime (s * HZ); @@ -199,8 +198,8 @@ public: * at some sampling rate. * @param r Sampling rate. */ - DCPTime round_up (int r) { - int64_t const n = HZ / r; + DCPTime round_up (float r) { + int64_t const n = rint (HZ / r); int64_t const a = _t + n - 1; return DCPTime (a - (a % n)); } -- 2.30.2