X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Ftime_calculation_test.cc;h=4ab5d0942923e55733cabc5045dfc7fcd7fcf949;hb=fa85cc6352a2f25bdd1d4421c9490f9fca266e04;hp=d0cf63bb28eda8d2b2aff819d8b700e7c4e4f997;hpb=dd9be86db6cde0afa5da0d1d1ac43b42e05dca26;p=dcpomatic.git diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index d0cf63bb2..4ab5d0942 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2016 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/time_calculation_test.cc * @brief Test calculation of timings when frame rates change. * @ingroup feature */ + #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/video_content.h" @@ -31,11 +33,13 @@ #include "test.h" #include -using std::string; + using std::list; -using std::shared_ptr; +using std::make_shared; +using std::string; using namespace dcpomatic; + static string const xml = "" "FFmpeg" "0" @@ -125,15 +129,16 @@ static string const xml = "" "0" ""; + BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) { - shared_ptr film = new_test_film ("ffmpeg_time_calculation_test"); + auto film = new_test_film ("ffmpeg_time_calculation_test"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); /* 25fps content, 25fps DCP */ film->set_video_frame_rate (25); @@ -177,20 +182,21 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) } + /** Test Player::dcp_to_content_video */ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) { - shared_ptr film = new_test_film ("player_time_calculation_test1"); + auto film = new_test_film ("player_time_calculation_test1"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film, Image::Alignment::COMPACT); /* Position 0, no trim, content rate = DCP rate */ content->set_position (film, DCPTime()); @@ -199,7 +205,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) film->set_video_frame_rate (24); player->setup_pieces (); BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - shared_ptr piece = player->_pieces.front (); + auto piece = player->_pieces.front(); BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0); BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (0.5)), 12); BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.0)), 72); @@ -386,17 +392,17 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) /** Test Player::content_video_to_dcp */ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) { - shared_ptr film = new_test_film ("player_time_calculation_test2"); + auto film = new_test_film ("player_time_calculation_test2"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film, Image::Alignment::COMPACT); /* Position 0, no trim, content rate = DCP rate */ content->set_position (film, DCPTime()); @@ -405,7 +411,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) film->set_video_frame_rate (24); player->setup_pieces (); BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - shared_ptr piece = player->_pieces.front (); + auto piece = player->_pieces.front (); BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0).get(), 0); BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12).get(), DCPTime::from_seconds(0.5).get()); BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72).get(), DCPTime::from_seconds(3.0).get()); @@ -562,18 +568,18 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) /** Test Player::dcp_to_content_audio */ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) { - shared_ptr film = new_test_film ("player_time_calculation_test3"); + auto film = new_test_film ("player_time_calculation_test3"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); - AudioStreamPtr stream = content->audio->streams().front(); + auto content = make_shared(doc, film->state_version(), notes); + auto stream = content->audio->streams().front(); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film, Image::Alignment::COMPACT); /* Position 0, no trim, video/audio content rate = video/audio DCP rate */ content->set_position (film, DCPTime()); @@ -583,7 +589,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) stream->_frame_rate = 48000; player->setup_pieces (); BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - shared_ptr piece = player->_pieces.front (); + auto piece = player->_pieces.front (); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000);