From 5a2aaaa015d092beb787eae50731d2f7fc6cbb7f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 Jul 2015 21:48:40 +0100 Subject: [PATCH] Round up in Time::as_editable_units. --- src/dcp_time.cc | 6 +++--- test/write_subtitle_test.cc | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 8101bed1..5e2e3121 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -263,13 +263,13 @@ Time::as_string () const } /** @param tcr_ Timecode rate with which the return value should be counted. - * @return the total number of editable units that this time consists of at the specified timecode rate. - * For example, as_editable_units (24) returns the total time in frames at 24fps. + * @return the total number of editable units that this time consists of at the specified timecode rate, rounded up + * to the nearest editable unit. For example, as_editable_units (24) returns the total time in frames at 24fps. */ int64_t Time::as_editable_units (int tcr_) const { - return (int64_t(e) * float (tcr_ / tcr)) + int64_t(s) * tcr_ + int64_t(m) * 60 * tcr_ + int64_t(h) * 60 * 60 * tcr_; + return ceil (int64_t(e) * double (tcr_) / tcr) + int64_t(s) * tcr_ + int64_t(m) * 60 * tcr_ + int64_t(h) * 60 * 60 * tcr_; } /** @return the total number of seconds that this time consists of */ diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc index d2402262..faf5cee2 100644 --- a/test/write_subtitle_test.cc +++ b/test/write_subtitle_test.cc @@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test) " \n" " \n" " \n" - " \n" + " \n" " What's going on\n" " \n" " \n" @@ -99,4 +99,3 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test) list () ); } - -- 2.30.2