X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=test%2Ftime_calculation_test.cc;h=bf21e5476d47e807c756e07ef4adc53f77eb4ab0;hp=f11f0dc28f5213d1dbedc248e8bd31fc6472f421;hb=5a5324ed3a381a86dfe0a6e3932c1d58fdcd596f;hpb=52dc5e2f2d0e5be8e9ba75b5978a1de58b11cb25 diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index f11f0dc28..bf21e5476 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -1,31 +1,36 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ #include "lib/film.h" #include "lib/ffmpeg_content.h" +#include "lib/video_content.h" #include "lib/player.h" +#include "lib/audio_content.h" #include "test.h" #include +#include using std::string; using std::list; using boost::shared_ptr; +using boost::make_shared; static string const xml = "" "FFmpeg" @@ -40,7 +45,7 @@ static string const xml = "" "1280" "720" "25" - "0" + "2d" "0" "0" "0" @@ -81,6 +86,7 @@ static string const xml = "" "und; 2 channels" "2" "44100" + "44100" "2" "0" "" @@ -119,27 +125,52 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) { shared_ptr film = new_test_film ("ffmpeg_time_calculation_test"); - shared_ptr doc (new cxml::Document); + shared_ptr doc = make_shared (); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); + shared_ptr content = boost::make_shared (film, doc, film->state_version(), notes); + + /* 25fps content, 25fps DCP */ + film->set_video_frame_rate (25); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0)); + /* 25fps content, 24fps DCP; length should be increased */ + film->set_video_frame_rate (24); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 24.0)); + /* 25fps content, 30fps DCP; length should be decreased */ + film->set_video_frame_rate (30); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 30.0)); + /* 25fps content, 50fps DCP; length should be the same */ + film->set_video_frame_rate (50); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0)); + /* 25fps content, 60fps DCP; length should be decreased */ + film->set_video_frame_rate (60); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() * (50.0 / 60) / 25.0)); + /* Make the content audio-only */ + content->video.reset (); + + /* 24fps content, 24fps DCP */ + film->set_video_frame_rate (24); + content->set_video_frame_rate (24); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1)); /* 25fps content, 25fps DCP */ film->set_video_frame_rate (25); - BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0)); + content->set_video_frame_rate (25); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1)); /* 25fps content, 24fps DCP; length should be increased */ film->set_video_frame_rate (24); - BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 24.0)); + BOOST_CHECK_SMALL (abs (content->full_length().get() - DCPTime::from_seconds(25.0 / 24).get()), 2); /* 25fps content, 30fps DCP; length should be decreased */ film->set_video_frame_rate (30); - BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 30.0)); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (25.0 / 30)); /* 25fps content, 50fps DCP; length should be the same */ film->set_video_frame_rate (50); - BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0)); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1)); /* 25fps content, 60fps DCP; length should be decreased */ film->set_video_frame_rate (60); - BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() * (50.0 / 60) / 25.0)); + BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (50.0 / 60)); + } /** Test Player::dcp_to_content_video */ @@ -147,15 +178,15 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) { shared_ptr film = new_test_film ("player_time_calculation_test1"); - shared_ptr doc (new cxml::Document); + shared_ptr doc = make_shared (); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); - film->set_sequence_video (false); + shared_ptr content = boost::make_shared (film, doc, film->state_version(), notes); + film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player (film, film->playlist ())); + shared_ptr player = make_shared (film, film->playlist ()); /* Position 0, no trim, content rate = DCP rate */ content->set_position (DCPTime ()); @@ -352,15 +383,15 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) { shared_ptr film = new_test_film ("player_time_calculation_test2"); - shared_ptr doc (new cxml::Document); + shared_ptr doc = make_shared (); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); - film->set_sequence_video (false); + shared_ptr content = boost::make_shared (film, doc, film->state_version(), notes); + film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player (film, film->playlist ())); + shared_ptr player = make_shared (film, film->playlist ()); /* Position 0, no trim, content rate = DCP rate */ content->set_position (DCPTime ()); @@ -528,16 +559,16 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) { shared_ptr film = new_test_film ("player_time_calculation_test3"); - shared_ptr doc (new cxml::Document); + shared_ptr doc = make_shared (); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent (film, doc, film->state_version(), notes)); - AudioStreamPtr stream = content->audio_streams().front(); - film->set_sequence_video (false); + shared_ptr content = boost::make_shared (film, doc, film->state_version(), notes); + AudioStreamPtr stream = content->audio->streams().front(); + film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player (film, film->playlist ())); + shared_ptr player = make_shared (film, film->playlist ()); /* Position 0, no trim, video/audio content rate = video/audio DCP rate */ content->set_position (DCPTime ());