Fix errors when a custom size is given which is larger than the container (#2404).
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Jan 2023 14:29:51 +0000 (15:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Jan 2023 19:29:10 +0000 (20:29 +0100)
src/lib/video_content.cc
test/scaling_test.cc

index c10a94f43f372a4ca184ab4edddcf8577367de58..9b39ff01b8f56d9f84e7176a27b227a482c6786b 100644 (file)
@@ -650,7 +650,10 @@ VideoContent::scaled_size (dcp::Size film_container)
        }
 
        if (_custom_size) {
-               return *_custom_size;
+               if (_custom_size->width <= film_container.width && _custom_size->height <= film_container.height) {
+                       return *_custom_size;
+               }
+               return fit_ratio_within(_custom_size->ratio(), film_container);
        }
 
        auto size = size_after_crop ();
index 9a3424506c0c5dae589cc406e9c1733884c0ad8d..11b8ae1b744587c50cbe4842e73600c45308d51f 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 
+#include "lib/content_factory.h"
 #include "lib/dcp_content_type.h"
 #include "lib/film.h"
 #include "lib/image_content.h"
@@ -93,3 +94,21 @@ BOOST_AUTO_TEST_CASE (scaling_test)
        /* S: scope image in a scope container */
        scaling_test_for (film, imc, 2.38695, "239", "239");
 }
+
+
+BOOST_AUTO_TEST_CASE(assertion_failure_when_scaling)
+{
+       auto content = content_factory("test/data/flat_red.png");
+       auto film = new_test_film2("assertion_failure_when_scaling", content);
+
+       content[0]->video->set_custom_size(dcp::Size{3996, 2180});
+       film->set_resolution(Resolution::FOUR_K);
+
+       make_and_verify_dcp (
+               film,
+               {
+                       dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE,
+                       dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
+               });
+}
+