diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-22 00:09:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-09-02 22:40:13 +0200 |
| commit | 33b0928b20618da5bc295711bfdf3d638863afa5 (patch) | |
| tree | 24af21c6a7b863d914991ae837c36b6b9b50bcce /test/reels_test.cc | |
| parent | 6784eb8de2451afd2dedc15c05eac043011b5afb (diff) | |
Untested conversion to num/den DCPTime.arbitrary-hz
Summary of required changes:
Replace ::from_frames with a constructor that takes num/den.
Provide and use member to_debug_string() instead of to_string().
Provide and use member to_serializable_string() and string constructor instead of fmt::to_string on .get() and number constructor.
Provide and use content_time() member instead of ContentTime constructor from DCPTime.
Use frames_round(96000) instead of get() when comparing times to see if they are "close enough".
Provide and use DCPTime(x, FrameRateChange) constructor when converting from ContentTime.
Use .seconds() when calculating proportions or sometimes when dividing by HZ.
Provide and use operator bool().
Pass explicit 96000 denominator in a lot of places.
Add member max() and use it instead of static max()
Change BOOST_CHECK_EQUAL to BOOST_CHECK
Provide operator/ and use it instead of .get() / 2.
Diffstat (limited to 'test/reels_test.cc')
| -rw-r--r-- | test/reels_test.cc | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/test/reels_test.cc b/test/reels_test.cc index fcb1aee44..423f55bab 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -70,21 +70,21 @@ BOOST_AUTO_TEST_CASE (reels_test1) auto A = make_shared<FFmpegContent>("test/data/test.mp4"); auto B = make_shared<FFmpegContent>("test/data/test.mp4"); auto film = new_test_film("reels_test1", { A, B }); - BOOST_CHECK_EQUAL (A->full_length(film).get(), 288000); + BOOST_CHECK(A->full_length(film) == DCPTime(288000, 96000)); film->set_reel_type (ReelType::SINGLE); auto r = film->reels (); - BOOST_CHECK_EQUAL (r.size(), 1U); - BOOST_CHECK_EQUAL (r.front().from.get(), 0); - BOOST_CHECK_EQUAL (r.front().to.get(), 288000 * 2); + BOOST_CHECK_EQUAL(r.size(), 1U); + BOOST_CHECK(r.front().from == DCPTime()); + BOOST_CHECK(r.front().to == DCPTime(288000 * 2, 96000)); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); r = film->reels (); - BOOST_CHECK_EQUAL (r.size(), 2U); - BOOST_CHECK_EQUAL (r.front().from.get(), 0); - BOOST_CHECK_EQUAL (r.front().to.get(), 288000); - BOOST_CHECK_EQUAL (r.back().from.get(), 288000); - BOOST_CHECK_EQUAL (r.back().to.get(), 288000 * 2); + BOOST_CHECK_EQUAL(r.size(), 2U); + BOOST_CHECK(r.front().from == DCPTime()); + BOOST_CHECK(r.front().to == DCPTime(288000, 96000)); + BOOST_CHECK(r.back().from == DCPTime(288000, 96000)); + BOOST_CHECK(r.back().to == DCPTime(288000 * 2, 96000)); film->set_video_bit_rate(VideoEncoding::JPEG2000, 100000000); film->set_reel_type (ReelType::BY_LENGTH); @@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE (reels_test1) r = film->reels (); BOOST_CHECK_EQUAL (r.size(), 3U); auto i = r.begin (); - BOOST_CHECK_EQUAL (i->from.get(), 0); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(60, 24).get()); + BOOST_CHECK(i->from == DCPTime()); + BOOST_CHECK(i->to == DCPTime(60, 24)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_frames(60, 24).get()); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(120, 24).get()); + BOOST_CHECK(i->from == DCPTime(60, 24)); + BOOST_CHECK(i->to == DCPTime(120, 24)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_frames(120, 24).get()); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(144, 24).get()); + BOOST_CHECK(i->from == DCPTime(120, 24)); + BOOST_CHECK(i->to == DCPTime(144, 24)); } @@ -135,14 +135,14 @@ BOOST_AUTO_TEST_CASE (reels_test2) auto reels = film2->reels (); BOOST_CHECK_EQUAL(reels.size(), 3U); auto i = reels.begin(); - BOOST_CHECK_EQUAL (i->from.get(), 0); - BOOST_CHECK_EQUAL (i->to.get(), 96000); + BOOST_CHECK(i->from == DCPTime()); + BOOST_CHECK(i->to == DCPTime(96000, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2); + BOOST_CHECK(i->from == DCPTime(96000, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 2, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3); + BOOST_CHECK(i->from == DCPTime(96000 * 2, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 3, 96000)); c->set_reference_video (true); c->set_reference_audio (true); @@ -164,17 +164,17 @@ BOOST_AUTO_TEST_CASE (reels_test3) auto reels = film->reels(); BOOST_REQUIRE_EQUAL (reels.size(), 4U); auto i = reels.begin (); - BOOST_CHECK_EQUAL (i->from.get(), 0); - BOOST_CHECK_EQUAL (i->to.get(), 96000); + BOOST_CHECK(i->from == DCPTime()); + BOOST_CHECK(i->to == DCPTime(96000, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2); + BOOST_CHECK(i->from == DCPTime(96000, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 2, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3); + BOOST_CHECK(i->from == DCPTime(96000 * 2, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 3, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000 * 3); - BOOST_CHECK_EQUAL (i->to.get(), sub->full_length(film).ceil(film->video_frame_rate()).get()); + BOOST_CHECK(i->from == DCPTime(96000 * 3, 96000)); + BOOST_CHECK(i->to == sub->full_length(film).ceil(film->video_frame_rate())); } @@ -205,17 +205,17 @@ BOOST_AUTO_TEST_CASE (reels_test4) auto reels = film->reels(); BOOST_REQUIRE_EQUAL (reels.size(), 4U); auto i = reels.begin (); - BOOST_CHECK_EQUAL (i->from.get(), 0); - BOOST_CHECK_EQUAL (i->to.get(), 96000); + BOOST_CHECK(i->from == DCPTime()); + BOOST_CHECK(i->to == DCPTime(96000, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2); + BOOST_CHECK(i->from == DCPTime(96000, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 2, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3); + BOOST_CHECK(i->from == DCPTime(96000 * 2, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 3, 96000)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), 96000 * 3); - BOOST_CHECK_EQUAL (i->to.get(), 96000 * 4); + BOOST_CHECK(i->from == DCPTime(96000 * 3, 96000)); + BOOST_CHECK(i->to == DCPTime(96000 * 4, 96000)); make_and_verify_dcp ( film, @@ -237,16 +237,16 @@ BOOST_AUTO_TEST_CASE (reels_test5) film->set_sequence (false); /* Set to 2123 but it will be rounded up to the next frame (4000) */ - dcp->set_position(film, DCPTime(2123)); + dcp->set_position(film, DCPTime(2123, 96000)); { auto p = dcp->reels (film); BOOST_REQUIRE_EQUAL (p.size(), 4U); auto i = p.begin(); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 0), DCPTime(4000 + 96000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 96000), DCPTime(4000 + 192000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 192000), DCPTime(4000 + 288000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 288000), DCPTime(4000 + 384000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 0, 96000), DCPTime(4000 + 96000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 96000, 96000), DCPTime(4000 + 192000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 192000, 96000), DCPTime(4000 + 288000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 288000, 96000), DCPTime(4000 + 384000, 96000))); } { @@ -254,10 +254,10 @@ BOOST_AUTO_TEST_CASE (reels_test5) auto p = dcp->reels (film); BOOST_REQUIRE_EQUAL (p.size(), 4U); auto i = p.begin(); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 0), DCPTime(4000 + 48000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 48000), DCPTime(4000 + 144000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 144000), DCPTime(4000 + 240000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 240000), DCPTime(4000 + 336000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 0, 96000), DCPTime(4000 + 48000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 48000, 96000), DCPTime(4000 + 144000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 144000, 96000), DCPTime(4000 + 240000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 240000, 96000), DCPTime(4000 + 336000, 96000))); } { @@ -265,10 +265,10 @@ BOOST_AUTO_TEST_CASE (reels_test5) auto p = dcp->reels (film); BOOST_REQUIRE_EQUAL (p.size(), 4U); auto i = p.begin(); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 0), DCPTime(4000 + 48000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 48000), DCPTime(4000 + 144000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 144000), DCPTime(4000 + 240000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 240000), DCPTime(4000 + 288000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 0, 96000), DCPTime(4000 + 48000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 48000, 96000), DCPTime(4000 + 144000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 144000, 96000), DCPTime(4000 + 240000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 240000, 96000), DCPTime(4000 + 288000, 96000))); } { @@ -276,9 +276,9 @@ BOOST_AUTO_TEST_CASE (reels_test5) auto p = dcp->reels (film); BOOST_REQUIRE_EQUAL (p.size(), 3U); auto i = p.begin(); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 0), DCPTime(4000 + 48000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 48000), DCPTime(4000 + 144000))); - BOOST_CHECK (*i++ == DCPTimePeriod (DCPTime(4000 + 144000), DCPTime(4000 + 192000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 0, 96000), DCPTime(4000 + 48000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 48000, 96000), DCPTime(4000 + 144000, 96000))); + BOOST_CHECK(*i++ == DCPTimePeriod(DCPTime(4000 + 144000, 96000), DCPTime(4000 + 192000, 96000))); } } @@ -319,8 +319,8 @@ BOOST_AUTO_TEST_CASE (reels_test7) film->set_reel_type (ReelType::BY_VIDEO_CONTENT); BOOST_REQUIRE_EQUAL (film->reels().size(), 2U); - BOOST_CHECK (film->reels().front() == DCPTimePeriod(DCPTime(0), DCPTime::from_frames(2 * 24, 24))); - BOOST_CHECK (film->reels().back() == DCPTimePeriod(DCPTime::from_frames(2 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24))); + BOOST_CHECK(film->reels().front() == DCPTimePeriod(DCPTime(0), DCPTime(2 * 24, 24))); + BOOST_CHECK(film->reels().back() == DCPTimePeriod(DCPTime(2 * 24, 24), DCPTime(3 * 24 + 1, 24))); make_and_verify_dcp (film); } @@ -412,15 +412,15 @@ BOOST_AUTO_TEST_CASE (reels_test11) A->set_position (film, DCPTime::from_seconds(1)); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); make_and_verify_dcp (film); - BOOST_CHECK_EQUAL (A->position().get(), DCPTime::from_seconds(1).get()); - BOOST_CHECK_EQUAL (A->end(film).get(), DCPTime::from_seconds(1 + 10).get()); + BOOST_CHECK(A->position() == DCPTime::from_seconds(1)); + BOOST_CHECK(A->end(film) == DCPTime::from_seconds(1 + 10)); auto r = film->reels (); - BOOST_CHECK_EQUAL (r.size(), 2U); - BOOST_CHECK_EQUAL (r.front().from.get(), 0); - BOOST_CHECK_EQUAL (r.front().to.get(), DCPTime::from_seconds(1).get()); - BOOST_CHECK_EQUAL (r.back().from.get(), DCPTime::from_seconds(1).get()); - BOOST_CHECK_EQUAL (r.back().to.get(), DCPTime::from_seconds(1 + 10).get()); + BOOST_CHECK_EQUAL(r.size(), 2U); + BOOST_CHECK(r.front().from == DCPTime()); + BOOST_CHECK(r.front().to == DCPTime::from_seconds(1)); + BOOST_CHECK(r.back().from == DCPTime::from_seconds(1)); + BOOST_CHECK(r.back().to == DCPTime::from_seconds(1 + 10)); } @@ -448,17 +448,17 @@ BOOST_AUTO_TEST_CASE (reels_test12) BOOST_REQUIRE_EQUAL (r.size(), 4U); auto i = r.begin (); - BOOST_CHECK_EQUAL (i->from.get(), 0); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(1).get()); + BOOST_CHECK(i->from == DCPTime()); + BOOST_CHECK(i->to == DCPTime::from_seconds(1)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_seconds(1).get()); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(11).get()); + BOOST_CHECK(i->from == DCPTime::from_seconds(1)); + BOOST_CHECK(i->to == DCPTime::from_seconds(11)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_seconds(11).get()); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(14).get()); + BOOST_CHECK(i->from == DCPTime::from_seconds(11)); + BOOST_CHECK(i->to == DCPTime::from_seconds(14)); ++i; - BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_seconds(14).get()); - BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(19).get()); + BOOST_CHECK(i->from == DCPTime::from_seconds(14)); + BOOST_CHECK(i->to == DCPTime::from_seconds(19)); } @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE (reels_should_not_be_short1) A->video->set_length (23); B->video->set_length (23); - B->set_position (film, DCPTime::from_frames(23, 24)); + B->set_position(film, DCPTime(23, 24)); make_and_verify_dcp (film); @@ -564,10 +564,10 @@ BOOST_AUTO_TEST_CASE (reels_should_not_be_short4) A->video->set_length (240); B->video->set_length (23); - B->set_position (film, DCPTime::from_frames(240, 24)); + B->set_position(film, DCPTime(240, 24)); BOOST_CHECK_EQUAL (film->reels().size(), 1U); - BOOST_CHECK (film->reels().front() == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime(), dcpomatic::DCPTime::from_frames(263, 24))); + BOOST_CHECK(film->reels().front() == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime(), dcpomatic::DCPTime(263, 24))); film->write_metadata (); make_dcp (film, TranscodeJob::ChangedBehaviour::IGNORE); @@ -617,9 +617,9 @@ BOOST_AUTO_TEST_CASE (repeated_dcp_into_reels) film2->set_sequence(false); for (int i = 0; i < 4; ++i) { - original_dcp[i]->set_position(film2, DCPTime::from_frames(total_frames * i / 4, frame_rate)); - original_dcp[i]->set_trim_start(film2, ContentTime::from_frames(total_frames * i / 4, frame_rate)); - original_dcp[i]->set_trim_end (ContentTime::from_frames(total_frames * (4 - i - 1) / 4, frame_rate)); + original_dcp[i]->set_position(film2, DCPTime(total_frames * i / 4, frame_rate)); + original_dcp[i]->set_trim_start(film2, ContentTime(total_frames * i / 4, frame_rate)); + original_dcp[i]->set_trim_end(ContentTime(total_frames * (4 - i - 1) / 4, frame_rate)); original_dcp[i]->set_reference_video(true); original_dcp[i]->set_reference_audio(true); } @@ -672,8 +672,8 @@ BOOST_AUTO_TEST_CASE(reel_assets_same_length_with_atmos) auto const reels = film->reels(); BOOST_CHECK_EQUAL(reels.size(), 2U); - BOOST_CHECK(reels[0] == dcpomatic::DCPTimePeriod({}, dcpomatic::DCPTime::from_frames(240, 24))); - BOOST_CHECK(reels[1] == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime::from_frames(240, 24), dcpomatic::DCPTime::from_frames(480, 24))); + BOOST_CHECK(reels[0] == dcpomatic::DCPTimePeriod({}, dcpomatic::DCPTime(240, 24))); + BOOST_CHECK(reels[1] == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime(240, 24), dcpomatic::DCPTime(480, 24))); make_and_verify_dcp(film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); } |
