Make sure main picture active area values are even (#2392).
authorCarl Hetherington <cth@carlh.net>
Thu, 15 Dec 2022 23:19:00 +0000 (00:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 16 Dec 2022 09:51:34 +0000 (10:51 +0100)
src/lib/writer.cc
src/wx/verify_dcp_dialog.cc
test/dcp_metadata_test.cc

index 2dd46f0b2324f4516364b319ab2a1561542cba26..2e732c280277fd44938ff75482c7eaad87e8759a 100644 (file)
@@ -676,8 +676,8 @@ Writer::finish (boost::filesystem::path output_dcp)
 
        auto active_area = film()->active_area();
        if (active_area.width > 0 && active_area.height > 0) {
-               /* It's not allowed to have a zero active area width or height */
-               cpl->set_main_picture_active_area (active_area);
+               /* It's not allowed to have a zero active area width or height, and the sizes must be multiples of 2 */
+               cpl->set_main_picture_active_area({ active_area.width & ~1, active_area.height & ~1});
        }
 
        auto sl = film()->subtitle_languages().second;
index bb51baeace6ba87b2508f300a8610c955fb1338f..bd36334cdcc12a56d8ce05ba781e4aa1fa4bef7a 100644 (file)
@@ -380,6 +380,9 @@ VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, shared_ptr<VerifyDCPJob> job
                case dcp::VerificationNote::Code::INVALID_CONTENT_KIND:
                        add(i, _("An invalid <ContentKind> %n has been used."));
                        break;
+               case dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA:
+                       add(i, _("The <MainPictureActiveArea> is either not a multiple of 2, or is bigger than an asset."));
+                       break;
                }
        }
 
index 8d410e13dcecd7bb70d5286e076d2b04c37fc051..dd81a41613711a76b940ed0aa2402c092bc621d1 100644 (file)
@@ -50,3 +50,22 @@ BOOST_AUTO_TEST_CASE (dcp_metadata_test)
        BOOST_CHECK_EQUAL (cpls[0]->issuer(), "this is the issuer");
 }
 
+
+BOOST_AUTO_TEST_CASE(main_picture_active_area_test)
+{
+       auto content = content_factory(TestPaths::private_data() / "bbc405.png");
+       auto film = new_test_film2("main_picture_active_area_test", content);
+       film->set_resolution(Resolution::FOUR_K);
+       film->set_interop(false);
+
+       make_and_verify_dcp(film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA });
+
+       dcp::DCP dcp(film->dir(film->dcp_name()));
+       dcp.read();
+       auto cpls = dcp.cpls();
+       BOOST_REQUIRE_EQUAL(cpls.size(), 1U);
+
+       BOOST_REQUIRE(static_cast<bool>(cpls[0]->main_picture_active_area()));
+       BOOST_REQUIRE(cpls[0]->main_picture_active_area() == dcp::Size(2866, 2160));
+}
+