summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-09-30 11:58:29 +0200
committerCarl Hetherington <cth@carlh.net>2023-09-30 11:58:29 +0200
commitdec7ad14997421accfe0ff9f382f9ffcb4e61ec2 (patch)
treed7e79759946335823c6e2034fa5f9bff18b55ebb
parent4fd32ca36487a1130a58769daee9fae22057ffcb (diff)
Add --twod option to create CLI and stop 2D from being forced over
a template if --threed is not specified (#2620/GH#22).
-rw-r--r--src/lib/create_cli.cc13
-rw-r--r--src/lib/create_cli.h1
-rw-r--r--test/create_cli_test.cc39
m---------test/data0
4 files changed, 52 insertions, 1 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc
index 95654286b..495ccddc4 100644
--- a/src/lib/create_cli.cc
+++ b/src/lib/create_cli.cc
@@ -56,6 +56,7 @@ string CreateCLI::_help =
" --twok make a 2K DCP instead of choosing a resolution based on the content\n"
" --fourk make a 4K DCP instead of choosing a resolution based on the content\n"
" -o, --output <dir> output directory\n"
+ " --twod make a 2D DCP\n"
" --threed make a 3D DCP\n"
" --j2k-bandwidth <Mbit/s> J2K bandwidth in Mbit/s\n"
" --left-eye next piece of content is for the left eye\n"
@@ -156,6 +157,8 @@ CreateCLI::CreateCLI (int argc, char* argv[])
_encrypt = claimed = true;
} else if (a == "--no-use-isdcf-name") {
_no_use_isdcf_name = claimed = true;
+ } else if (a == "--twod") {
+ _twod = claimed = true;
} else if (a == "--threed") {
_threed = claimed = true;
} else if (a == "--left-eye") {
@@ -290,6 +293,10 @@ CreateCLI::CreateCLI (int argc, char* argv[])
_standard = dcp::Standard::INTEROP;
}
+ if (_twod && _threed) {
+ error = String::compose("%1: specify one of --twod or --threed, not both", argv[0]);
+ }
+
if (content.empty()) {
error = String::compose("%1: no content specified", argv[0]);
return;
@@ -324,7 +331,11 @@ CreateCLI::make_film() const
film->set_interop(_standard == dcp::Standard::INTEROP);
film->set_use_isdcf_name(!_no_use_isdcf_name);
film->set_encrypted(_encrypt);
- film->set_three_d(_threed);
+ if (_twod) {
+ film->set_three_d(false);
+ } else if (_threed) {
+ film->set_three_d(true);
+ }
if (_twok) {
film->set_resolution(Resolution::TWO_K);
}
diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h
index 1133d21c5..dfc922b07 100644
--- a/src/lib/create_cli.h
+++ b/src/lib/create_cli.h
@@ -64,6 +64,7 @@ private:
std::string _name;
Ratio const* _container_ratio = nullptr;
bool _encrypt = false;
+ bool _twod = false;
bool _threed = false;
DCPContentType const* _dcp_content_type = nullptr;
dcp::Standard _standard = dcp::Standard::SMPTE;
diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc
index 253f3cadd..8da07d5d5 100644
--- a/test/create_cli_test.cc
+++ b/test/create_cli_test.cc
@@ -18,7 +18,10 @@
*/
+
+#include "lib/config.h"
#include "lib/create_cli.h"
+#include "lib/film.h"
#include "lib/ratio.h"
#include "lib/dcp_content_type.h"
#include "test.h"
@@ -27,8 +30,10 @@
#include <boost/algorithm/string/predicate.hpp>
#include <iostream>
+
using std::string;
+
static CreateCLI
run (string cmd)
{
@@ -106,6 +111,15 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
cc = run ("dcpomatic2_create x --standard SMPTEX");
BOOST_CHECK (cc.error);
+ cc = run("dcpomatic2_create x --twod");
+ BOOST_CHECK(cc._twod);
+
+ cc = run("dcpomatic2_create x --threed");
+ BOOST_CHECK(cc._threed);
+
+ cc = run("dcpomatic2_create x --twod --threed");
+ BOOST_CHECK(cc.error);
+
cc = run ("dcpomatic2_create x --config foo/bar");
BOOST_CHECK (!cc.error);
BOOST_REQUIRE (cc.config_dir);
@@ -195,3 +209,28 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
BOOST_CHECK(!cc.still_length);
BOOST_CHECK(cc.error);
}
+
+
+BOOST_AUTO_TEST_CASE(create_cli_template_test)
+{
+ ConfigRestorer cr;
+
+ Config::override_path = "test/data";
+
+ auto cc = run("dcpomatic2_create test/data/flat_red.png --template 2d");
+ auto film = cc.make_film();
+ BOOST_CHECK(!film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 2d --threed");
+ film = cc.make_film();
+ BOOST_CHECK(film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 3d");
+ film = cc.make_film();
+ BOOST_CHECK(film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 3d --twod");
+ film = cc.make_film();
+ BOOST_CHECK(!film->three_d());
+}
+
diff --git a/test/data b/test/data
-Subproject b6d209730b870fec225a375c9b19350cd7f6724
+Subproject ab92d786fe2069ef94d79c53945939265e18d7b