diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-27 11:12:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-05-27 11:12:30 +0100 |
| commit | f24ecc55366073d1c267806914e293602f90e3ce (patch) | |
| tree | 65843283f9be1d29413adb8a4ebb59d7f10f4dc2 /test/time_calculation_test.cc | |
| parent | 0a20f4b0ee59f06732648f981fe4d3e387b5705a (diff) | |
Use BOOST_REQUIRE to stop a hail of errors.
Diffstat (limited to 'test/time_calculation_test.cc')
| -rw-r--r-- | test/time_calculation_test.cc | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc new file mode 100644 index 000000000..51d2939de --- /dev/null +++ b/test/time_calculation_test.cc @@ -0,0 +1,141 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + This program 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, + 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. + +*/ + +#include "lib/film.h" +#include "lib/ffmpeg_content.h" +#include "test.h" +#include <boost/test/unit_test.hpp> + +using std::string; +using std::list; +using boost::shared_ptr; + +BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) +{ + shared_ptr<Film> film = new_test_film ("ffmpeg_time_calculation_test"); + + string const xml = "<Content>" + "<Type>FFmpeg</Type>" + "<Path>/home/c.hetherington/DCP/clapperboard.mp4</Path>" + "<Digest>2760e03c7251480f7f02c01a907792673784335</Digest>" + "<Position>0</Position>" + "<TrimStart>0</TrimStart>" + "<TrimEnd>0</TrimEnd>" + "<VideoLength>1353600</VideoLength>" + "<VideoWidth>1280</VideoWidth>" + "<VideoHeight>720</VideoHeight>" + "<VideoFrameRate>25</VideoFrameRate>" + "<VideoFrameType>0</VideoFrameType>" + "<LeftCrop>0</LeftCrop>" + "<RightCrop>0</RightCrop>" + "<TopCrop>0</TopCrop>" + "<BottomCrop>0</BottomCrop>" + "<Scale>" + "<Ratio>178</Ratio>" + "</Scale>" + "<ColourConversion>" + "<InputTransferFunction>" + "<Type>ModifiedGamma</Type>" + "<Power>2.222222222222222</Power>" + "<Threshold>0.081</Threshold>" + "<A>0.099</A>" + "<B>4.5</B>" + "</InputTransferFunction>" + "<RedX>0.64</RedX>" + "<RedY>0.33</RedY>" + "<GreenX>0.3</GreenX>" + "<GreenY>0.6</GreenY>" + "<BlueX>0.15</BlueX>" + "<BlueY>0.06</BlueY>" + "<WhiteX>0.3127</WhiteX>" + "<WhiteY>0.329</WhiteY>" + "<OutputGamma>2.6</OutputGamma>" + "</ColourConversion>" + "<FadeIn>0</FadeIn>" + "<FadeOut>0</FadeOut>" + "<AudioGain>0</AudioGain>" + "<AudioDelay>0</AudioDelay>" + "<UseSubtitles>0</UseSubtitles>" + "<SubtitleXOffset>0</SubtitleXOffset>" + "<SubtitleYOffset>0</SubtitleYOffset>" + "<SubtitleXScale>1</SubtitleXScale>" + "<SubtitleYScale>1</SubtitleYScale>" + "<SubtitleLanguage></SubtitleLanguage>" + "<AudioStream>" + "<Selected>1</Selected>" + "<Name>und; 2 channels</Name>" + "<Id>2</Id>" + "<FrameRate>44100</FrameRate>" + "<Channels>2</Channels>" + "<FirstAudio>0</FirstAudio>" + "<Mapping>" + "<ContentChannels>2</ContentChannels>" + "<Gain Content=\"0\" DCP=\"0\">1</Gain>" + "<Gain Content=\"0\" DCP=\"1\">0</Gain>" + "<Gain Content=\"0\" DCP=\"2\">0</Gain>" + "<Gain Content=\"0\" DCP=\"3\">0</Gain>" + "<Gain Content=\"0\" DCP=\"4\">0</Gain>" + "<Gain Content=\"0\" DCP=\"5\">0</Gain>" + "<Gain Content=\"0\" DCP=\"6\">0</Gain>" + "<Gain Content=\"0\" DCP=\"7\">0</Gain>" + "<Gain Content=\"0\" DCP=\"8\">0</Gain>" + "<Gain Content=\"0\" DCP=\"9\">0</Gain>" + "<Gain Content=\"0\" DCP=\"10\">0</Gain>" + "<Gain Content=\"0\" DCP=\"11\">0</Gain>" + "<Gain Content=\"1\" DCP=\"0\">0</Gain>" + "<Gain Content=\"1\" DCP=\"1\">1</Gain>" + "<Gain Content=\"1\" DCP=\"2\">0</Gain>" + "<Gain Content=\"1\" DCP=\"3\">0</Gain>" + "<Gain Content=\"1\" DCP=\"4\">0</Gain>" + "<Gain Content=\"1\" DCP=\"5\">0</Gain>" + "<Gain Content=\"1\" DCP=\"6\">0</Gain>" + "<Gain Content=\"1\" DCP=\"7\">0</Gain>" + "<Gain Content=\"1\" DCP=\"8\">0</Gain>" + "<Gain Content=\"1\" DCP=\"9\">0</Gain>" + "<Gain Content=\"1\" DCP=\"10\">0</Gain>" + "<Gain Content=\"1\" DCP=\"11\">0</Gain>" + "</Mapping>" + "</AudioStream>" + "<FirstVideo>0</FirstVideo>" + "</Content>"; + + shared_ptr<cxml::Document> doc (new cxml::Document); + doc->read_string (xml); + + list<string> notes; + shared_ptr<FFmpegContent> content (new FFmpegContent (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)); +} + +/* XXX much more stuff to test */ |
