2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file test/ffmpeg_decoder_sequential_test.cc
22 * @brief Check that the FFmpeg decoder and Player produce sequential frames without gaps or dropped frames;
23 * Also that the decoder picks up frame rates correctly.
27 #include "lib/ffmpeg_content.h"
28 #include "lib/ffmpeg_decoder.h"
29 #include "lib/content_video.h"
30 #include "lib/video_decoder.h"
32 #include "lib/player_video.h"
33 #include "lib/player.h"
35 #include <boost/filesystem.hpp>
36 #include <boost/test/unit_test.hpp>
42 using std::shared_ptr;
43 using boost::optional;
45 #if BOOST_VERSION >= 106100
46 using namespace boost::placeholders;
48 using namespace dcpomatic;
54 check (shared_ptr<PlayerVideo>, DCPTime time)
56 BOOST_REQUIRE (time == next);
61 ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int video_length)
63 boost::filesystem::path path = TestPaths::private_data() / file;
64 BOOST_REQUIRE (boost::filesystem::exists (path));
66 shared_ptr<Film> film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string());
67 shared_ptr<FFmpegContent> content (new FFmpegContent(path));
68 film->examine_and_add_content (content);
69 BOOST_REQUIRE (!wait_for_jobs());
70 film->write_metadata ();
71 shared_ptr<Player> player (new Player(film));
73 BOOST_REQUIRE (content->video_frame_rate());
74 BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
76 player->Video.connect (bind (&check, _1, _2));
79 frame = DCPTime::from_frames (1, film->video_frame_rate ());
80 while (!player->pass()) {}
81 BOOST_REQUIRE (next == DCPTime::from_frames (video_length, film->video_frame_rate()));
84 BOOST_AUTO_TEST_CASE (ffmpeg_decoder_sequential_test)
86 ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6912);
87 ffmpeg_decoder_sequential_test_one ("Sintel_Trailer1.480p.DivX_Plus_HD.mkv", 24, 1253);
88 ffmpeg_decoder_sequential_test_one ("prophet_long_clip.mkv", 23.976, 2879);