diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-01-18 01:27:35 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-01-18 01:27:35 +0000 |
| commit | 0bb3c873e28552293e7132c93cdeeef65845596d (patch) | |
| tree | 4921e244946c1e1c1aaa5689a91415cfbff1b686 | |
| parent | 35e5de23b21a1fc9788fadd9ecd8beae9cfc18e3 (diff) | |
Remove a cast from float to double which seemingly causes
slight errors in Time::ceil(). Possibly related to #1174.
| -rw-r--r-- | src/lib/dcpomatic_time.h | 8 | ||||
| -rw-r--r-- | test/dcpomatic_time_test.cc | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 5f00807bd..204af3c1e 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -117,12 +117,12 @@ public: * at some sampling rate. * @param r Sampling rate. */ - Time<S, O> ceil (float r) const { - return Time<S, O> (llrint (HZ * frames_ceil(r) / double(r))); + Time<S, O> ceil (double r) const { + return Time<S, O> (llrint (HZ * frames_ceil(r) / r)); } - Time<S, O> floor (float r) const { - return Time<S, O> (llrint (HZ * frames_floor(r) / double(r))); + Time<S, O> floor (double r) const { + return Time<S, O> (llrint (HZ * frames_floor(r) / r)); } double seconds () const { diff --git a/test/dcpomatic_time_test.cc b/test/dcpomatic_time_test.cc index 94d515035..1637738ad 100644 --- a/test/dcpomatic_time_test.cc +++ b/test/dcpomatic_time_test.cc @@ -316,6 +316,9 @@ BOOST_AUTO_TEST_CASE (dcpomatic_time_ceil_test) /* Check that rounding up to non-integer frame rates works */ BOOST_CHECK_EQUAL (DCPTime(45312).ceil(29.976).get(), 48038); + + /* Check another tricky case that used to fail */ + BOOST_CHECK_EQUAL (DCPTime(212256039).ceil(23.976).get(), 212256256); } /* Straightforward test of DCPTime::floor */ |
