summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-11-19 22:07:39 +0100
committerCarl Hetherington <cth@carlh.net>2020-11-19 22:08:21 +0100
commit2456409a8db781d9ef505fc9e5f9290276ce6807 (patch)
tree0acbe46b1818bba175339819d12363ba23bfcfa2
parent0ba91c0ce63953a8bbdbc9b43a8879b3e6d4ed29 (diff)
Hack to fix image luminance when cropping subsampled images (#1872).v2.14.44
Without this the luminance varies slightly as you crop by odd and even amounts (for YUV420 images).
-rw-r--r--src/lib/image.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 1a5b11ecb..97aeccd76 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -183,6 +183,14 @@ Image::crop_scale_window (
/* Size of the image after any crop */
dcp::Size const cropped_size = rounded_crop.apply (size());
+ /* Hack: if we're not doing quite the crop that we were asked for, and we carry on scaling
+ * to the inter_size we were asked for, there is a small but noticeable wobble in the image
+ * luminance (#1872). This hack means we will jump in steps of the subsampling distance
+ * in both crop and scale.
+ */
+ inter_size.width = round_width_for_subsampling(inter_size.width, in_desc);
+ inter_size.height = round_width_for_subsampling(inter_size.height, in_desc);
+
/* Scale context for a scale from cropped_size to inter_size */
struct SwsContext* scale_context = sws_getContext (
cropped_size.width, cropped_size.height, pixel_format(),