2 Copyright (C) 2013-2021 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/>.
22 /** @file test/threed_test.cc
23 * @brief Create some 3D DCPs (without comparing the results to anything).
24 * @ingroup completedcp
28 #include "lib/config.h"
29 #include "lib/content_factory.h"
30 #include "lib/cross.h"
31 #include "lib/dcp_content_type.h"
32 #include "lib/ffmpeg_content.h"
35 #include "lib/job_manager.h"
36 #include "lib/ratio.h"
37 #include "lib/video_content.h"
39 #include <boost/test/unit_test.hpp>
44 using std::make_shared;
45 using std::shared_ptr;
48 /** Basic sanity check of THREE_D_LEFT_RIGHT */
49 BOOST_AUTO_TEST_CASE (threed_test1)
51 auto film = new_test_film ("threed_test1");
52 film->set_name ("test_film1");
53 auto c = make_shared<FFmpegContent>("test/data/test.mp4");
54 film->examine_and_add_content (c);
55 BOOST_REQUIRE (!wait_for_jobs());
57 c->video->set_frame_type (VideoFrameType::THREE_D_LEFT_RIGHT);
59 film->set_container (Ratio::from_id ("185"));
60 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
61 film->set_three_d (true);
62 make_and_verify_dcp (film);
66 /** Basic sanity check of THREE_D_ALTERNATE; at the moment this is just to make sure
67 * that such a transcode completes without error.
69 BOOST_AUTO_TEST_CASE (threed_test2)
71 auto film = new_test_film ("threed_test2");
72 film->set_name ("test_film2");
73 auto c = make_shared<FFmpegContent>("test/data/test.mp4");
74 film->examine_and_add_content (c);
75 BOOST_REQUIRE (!wait_for_jobs());
77 c->video->set_frame_type (VideoFrameType::THREE_D_ALTERNATE);
79 film->set_container (Ratio::from_id ("185"));
80 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
81 film->set_three_d (true);
82 make_and_verify_dcp (film);
86 /** Basic sanity check of THREE_D_LEFT and THREE_D_RIGHT; at the moment this is just to make sure
87 * that such a transcode completes without error.
89 BOOST_AUTO_TEST_CASE (threed_test3)
91 shared_ptr<Film> film = new_test_film2 ("threed_test3");
92 auto L = make_shared<FFmpegContent>("test/data/test.mp4");
93 film->examine_and_add_content (L);
94 auto R = make_shared<FFmpegContent>("test/data/test.mp4");
95 film->examine_and_add_content (R);
96 BOOST_REQUIRE (!wait_for_jobs());
98 L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
99 R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
101 film->set_three_d (true);
102 make_and_verify_dcp (film);
106 BOOST_AUTO_TEST_CASE (threed_test4)
108 auto film = new_test_film2 ("threed_test4");
109 auto L = make_shared<FFmpegContent>(TestPaths::private_data() / "LEFT_TEST_DCP3D4K.mov");
110 film->examine_and_add_content (L);
111 auto R = make_shared<FFmpegContent>(TestPaths::private_data() / "RIGHT_TEST_DCP3D4K.mov");
112 film->examine_and_add_content (R);
113 BOOST_REQUIRE (!wait_for_jobs());
115 L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
116 R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
117 /* There doesn't seem much point in encoding the whole input, especially as we're only
118 * checking for errors during the encode and not the result. Also decoding these files
119 * (4K HQ Prores) is very slow.
121 L->set_trim_end (dcpomatic::ContentTime::from_seconds(22));
122 R->set_trim_end (dcpomatic::ContentTime::from_seconds(22));
124 film->set_three_d (true);
125 make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D});
129 BOOST_AUTO_TEST_CASE (threed_test5)
131 auto film = new_test_film2 ("threed_test5");
132 auto L = make_shared<FFmpegContent>(TestPaths::private_data() / "boon_telly.mkv");
133 film->examine_and_add_content (L);
134 auto R = make_shared<FFmpegContent>(TestPaths::private_data() / "boon_telly.mkv");
135 film->examine_and_add_content (R);
136 BOOST_REQUIRE (!wait_for_jobs());
138 L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
139 R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
140 /* There doesn't seem much point in encoding the whole input, especially as we're only
141 * checking for errors during the encode and not the result.
143 L->set_trim_end (dcpomatic::ContentTime::from_seconds(3 * 60 + 20));
144 R->set_trim_end (dcpomatic::ContentTime::from_seconds(3 * 60 + 20));
146 film->set_three_d (true);
147 make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K});
151 BOOST_AUTO_TEST_CASE (threed_test6)
153 auto film = new_test_film2 ("threed_test6");
154 auto L = make_shared<FFmpegContent>("test/data/3dL.mp4");
155 film->examine_and_add_content (L);
156 auto R = make_shared<FFmpegContent>("test/data/3dR.mp4");
157 film->examine_and_add_content (R);
158 BOOST_REQUIRE (!wait_for_jobs());
160 L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
161 R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
163 film->set_three_d (true);
164 make_and_verify_dcp (film);
165 check_dcp ("test/data/threed_test6", film->dir(film->dcp_name()));
169 /** Check 2D content set as being 3D; this should give an informative error */
170 BOOST_AUTO_TEST_CASE (threed_test7)
172 using boost::filesystem::path;
174 auto film = new_test_film2 ("threed_test7");
175 path const content_path = "test/data/flat_red.png";
176 auto c = content_factory(content_path).front();
177 film->examine_and_add_content (c);
178 BOOST_REQUIRE (!wait_for_jobs());
180 c->video->set_frame_type (VideoFrameType::THREE_D);
181 c->video->set_length (24);
183 film->set_three_d (true);
185 film->write_metadata ();
187 auto jm = JobManager::instance ();
188 while (jm->work_to_do ()) {
189 while (signal_manager->ui_idle()) {}
190 dcpomatic_sleep_seconds (1);
193 while (signal_manager->ui_idle ()) {}
195 BOOST_REQUIRE (jm->errors());
196 shared_ptr<Job> failed;
197 for (auto i: jm->_jobs) {
198 if (i->finished_in_error()) {
199 BOOST_REQUIRE (!failed);
203 BOOST_REQUIRE (failed);
204 BOOST_CHECK_EQUAL (failed->error_summary(), String::compose("The content file %1 is set as 3D but does not appear to contain 3D images. Please set it to 2D. You can still make a 3D DCP from this content by ticking the 3D option in the DCP video tab.", content_path.string()));
206 while (signal_manager->ui_idle ()) {}