summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-09-28 12:13:38 +0100
committerCarl Hetherington <cth@carlh.net>2015-09-28 12:13:38 +0100
commitdb8af2f03cc3c93b6a42b2e5ace53c169eddf5fd (patch)
tree179d7ca79145a1dcc467a79ef181657b0ddd515e
parent57a68aced4450e2f7e0259ffa1ddb171834cc8c9 (diff)
Round down when rebasing times.
-rw-r--r--src/dcp_time.cc2
-rw-r--r--test/dcp_time_test.cc5
-rw-r--r--test/write_subtitle_test.cc2
3 files changed, 6 insertions, 3 deletions
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 19ab2de1..3db449fb 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -291,5 +291,5 @@ Time::as_seconds () const
Time
Time::rebase (int tcr_) const
{
- return Time (h, m, s, rint (float (e) * tcr_ / tcr), tcr_);
+ return Time (h, m, s, floor (float (e) * tcr_ / tcr), tcr_);
}
diff --git a/test/dcp_time_test.cc b/test/dcp_time_test.cc
index 926dd024..196efe17 100644
--- a/test/dcp_time_test.cc
+++ b/test/dcp_time_test.cc
@@ -93,5 +93,8 @@ BOOST_AUTO_TEST_CASE (dcp_time)
a = dcp::Time (1, 58, 56, 2, 25);
BOOST_CHECK_EQUAL (a.rebase (250), dcp::Time (1, 58, 56, 20, 250));
b = dcp::Time (9, 12, 41, 17, 99);
- BOOST_CHECK_EQUAL (b.rebase (250), dcp::Time (9, 12, 41, 43, 250));
+ BOOST_CHECK_EQUAL (b.rebase (250), dcp::Time (9, 12, 41, 42, 250));
+ /* We must round down in rebase() */
+ a = dcp::Time (0, 2, 57, 999, 1000);
+ BOOST_CHECK_EQUAL (a.rebase (250), dcp::Time (0, 2, 57, 249, 250));
}
diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc
index faf5cee2..8b50b0e3 100644
--- a/test/write_subtitle_test.cc
+++ b/test/write_subtitle_test.cc
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
" </Subtitle>\n"
" </Font>\n"
" <Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
- " <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">\n"
+ " <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:218\" TimeOut=\"06:12:15:218\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">\n"
" <Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>\n"
" </Subtitle>\n"
" </Font>\n"