summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-11-25 00:11:55 +0100
committerCarl Hetherington <cth@carlh.net>2020-11-25 00:11:55 +0100
commitaccdec63a79b43c6349597b15243dc41e521521d (patch)
tree88dadb3eebc45c4980e9f4498bb9a065f0b562e4 /test
parent82faf2d5817af3ca8d303a8e1b62f23bb461dcaf (diff)
Fix corrupted image when over-cropping black filler frames.v2.14.45
FFmpegDecoder can emit small black frames (128x128 pixels) when it wants to fill in a gap. Image::crop_scale_window would do the wrong thing if we then applied a crop of greater than 128 in either direction; though cropped_size is correctly clamped, the crop value itself was not and is used to calculate the input data pointers. This would result in random frames, usually at the end of DCPs, often made up of blurry colour washes.
Diffstat (limited to 'test')
m---------test/data0
-rw-r--r--test/image_test.cc14
2 files changed, 14 insertions, 0 deletions
diff --git a/test/data b/test/data
-Subproject 3b2a8c56dff15050a9eca576214399ef4a5abc0
+Subproject 33736dcba84fee688b431c00daa2cc17a9dabab
diff --git a/test/image_test.cc b/test/image_test.cc
index 9fe793d70..2f66cf41d 100644
--- a/test/image_test.cc
+++ b/test/image_test.cc
@@ -393,3 +393,17 @@ BOOST_AUTO_TEST_CASE (fade_test)
fade_test_format_red (AV_PIX_FMT_RGB48LE, 0.5, "rgb48le_50");
fade_test_format_red (AV_PIX_FMT_RGB48LE, 1, "rgb48le_100");
}
+
+/** Make sure the image isn't corrupted if it is cropped too much. This can happen when a
+ * filler 128x128 black frame is emitted from the FFmpegDecoder and the overall crop in either direction
+ * is greater than 128 pixels.
+ */
+BOOST_AUTO_TEST_CASE (over_crop_test)
+{
+ shared_ptr<Image> image (new Image (AV_PIX_FMT_RGB24, dcp::Size(128, 128), true));
+ image->make_black ();
+ shared_ptr<Image> scaled = image->crop_scale_window (Crop(0, 0, 128, 128), dcp::Size(1323, 565), dcp::Size(1349, 565), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, true, true);
+ string const filename = "over_crop_test.png";
+ write_image (scaled, "build/test/" + filename, "RGB");
+ check_image ("test/data/" + filename, "build/test/" + filename);
+}