From e43dababfc7aaf1429d3552e91b24e4e51979111 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 25 Nov 2020 00:11:55 +0100 Subject: Fix corrupted image when over-cropping black filler frames. 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. --- test/data | 2 +- test/image_test.cc | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/data b/test/data index f47d073d6..b5863343b 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit f47d073d6610bdb3ae0ad9d842c4d66a6e9a16d2 +Subproject commit b5863343b9157102144f70aa4269ec03922692fe diff --git a/test/image_test.cc b/test/image_test.cc index bf7effe09..9c1c7457e 100644 --- a/test/image_test.cc +++ b/test/image_test.cc @@ -479,3 +479,20 @@ BOOST_AUTO_TEST_CASE (make_black_test) ++N; } } + + +/** 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 (new Image (AV_PIX_FMT_RGB24, dcp::Size(128, 128), true)); + image->make_black (); + shared_ptr scaled = image->crop_scale_window ( + Crop(0, 0, 128, 128), dcp::Size(1323, 565), dcp::Size(1349, 565), dcp::YUV_TO_RGB_REC709, VIDEO_RANGE_FULL, AV_PIX_FMT_RGB24, VIDEO_RANGE_FULL, true, true + ); + string const filename = "over_crop_test.png"; + write_image (scaled, "build/test/" + filename); + check_image ("test/data/" + filename, "build/test/" + filename); +} -- cgit v1.2.3