Allow repeat-frame to work with 3D.
[dcpomatic.git] / test / scaling_test.cc
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 /** @file test/scaling_test.cc
22  *  @brief Test scaling and black-padding of images from a still-image source.
23  *  @ingroup specific
24  */
25
26 #include <boost/test/unit_test.hpp>
27 #include "lib/image_content.h"
28 #include "lib/ratio.h"
29 #include "lib/film.h"
30 #include "lib/dcp_content_type.h"
31 #include "lib/video_content.h"
32 #include "test.h"
33
34 using std::string;
35 using boost::shared_ptr;
36
37 static void scaling_test_for (shared_ptr<Film> film, shared_ptr<Content> content, string image, string container)
38 {
39         content->video->set_scale (VideoContentScale (Ratio::from_id (image)));
40         film->set_container (Ratio::from_id (container));
41         film->make_dcp ();
42
43         wait_for_jobs ();
44
45         boost::filesystem::path ref;
46         ref = "test";
47         ref /= "data";
48         ref /= "scaling_test_" + image + "_" + container;
49
50         boost::filesystem::path check;
51         check = "build";
52         check /= "test";
53         check /= "scaling_test";
54         check /= film->dcp_name();
55
56         check_dcp (ref.string(), check.string());
57 }
58
59 BOOST_AUTO_TEST_CASE (scaling_test)
60 {
61         shared_ptr<Film> film = new_test_film ("scaling_test");
62         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
63         film->set_name ("scaling_test");
64         shared_ptr<ImageContent> imc (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
65
66         film->examine_and_add_content (imc);
67
68         wait_for_jobs ();
69
70         imc->video->set_length (1);
71
72         /* F-133: 133 image in a flat container */
73         scaling_test_for (film, imc, "133", "185");
74         /* F: flat image in a flat container */
75         scaling_test_for (film, imc, "185", "185");
76         /* F-S: scope image in a flat container */
77         scaling_test_for (film, imc, "239", "185");
78
79         /* S-133: 133 image in a scope container */
80         scaling_test_for (film, imc, "133", "239");
81         /* S-F: flat image in a scope container */
82         scaling_test_for (film, imc, "185", "239");
83         /* S: scope image in a scope container */
84         scaling_test_for (film, imc, "239", "239");
85 }