X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Ftime_calculation_test.cc;h=272d3edfefb951b56ad52039e0813c8a5497f711;hb=7bd4ecce60488f7f7cfbdcc16ba7022b979a891d;hp=2be49f629c32398597aa77b92908ef027eee8c5f;hpb=a788f3c1e29a6b8329d54e1518f3b84d68d347d5;p=dcpomatic.git diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index 2be49f629..272d3edfe 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) list notes; shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); - film->set_sequence_video (false); + film->set_sequence (false); film->add_content (content); shared_ptr player (new Player (film, film->playlist ())); @@ -330,6 +330,21 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)), 72); BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 144); BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 396); + + /* Position 0s, no trim, content rate 29.9978733, DCP rate 30 */ + content->set_position (DCPTime::from_seconds (0)); + content->set_trim_start (ContentTime::from_seconds (0)); + content->set_video_frame_rate (29.9978733); + film->set_video_frame_rate (30); + player->setup_pieces (); + BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1); + 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 (3200)), 1); + BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (6400)), 2); + BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (9600)), 3); + BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (12800)), 4); + } /** Test Player::content_video_to_dcp */ @@ -342,7 +357,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) list notes; shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); - film->set_sequence_video (false); + film->set_sequence (false); film->add_content (content); shared_ptr player (new Player (film, film->playlist ())); @@ -519,7 +534,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) list notes; shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); AudioStreamPtr stream = content->audio_streams().front(); - film->set_sequence_video (false); + film->set_sequence (false); film->add_content (content); shared_ptr player (new Player (film, film->playlist ())); @@ -562,7 +577,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1); 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.50)), 0); + BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)), 0); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); @@ -596,8 +611,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000); /* Position 3s, 1.6s trim, content rate 24, DCP rate 25, both audio rates still 48k. - Since the DCP is faster, and resampled audio is at the DCP rate, our 1.6s trim in - content time corresponds to 1.6 * 24 * 48000 / 25 audio samples. + 1s of content is 46080 samples after resampling. */ content->set_position (DCPTime::from_seconds (3)); content->set_trim_start (ContentTime::from_seconds (1.6)); @@ -748,4 +762,15 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)), 72000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000); + + /* Check with a large start trim */ + content->set_position (DCPTime::from_seconds (0)); + content->set_trim_start (ContentTime::from_seconds (54143)); + content->set_video_frame_rate (24); + film->set_video_frame_rate (24); + stream->_frame_rate = 48000; + player->setup_pieces (); + BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1); + piece = player->_pieces.front (); + BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 54143L * 48000); }