Fix dec artifacts w/cropped+smoothed prog DC scans
This commit modifies decompress_smooth_data(), adding missing MCU column
offsets to the prev_block_row and next_block_row indices that are used
for block rows other than the first and last. Effectively, this
eliminates unexpected visual artifacts when using jpeg_crop_scanline()
along with interblock smoothing while decompressing the DC scan of a
progressive JPEG image.
Based on:
https://github.com/mo271/libjpeg-turbo/commit/0227d4fb484e6baf1565163211ee64e52e7b96bd
Fixes #456
Closes #457
diff --git a/ChangeLog.md b/ChangeLog.md
index 89c5cfe..7f8eb3c 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -23,6 +23,10 @@
3. The ARM 64-bit (ARMv8) NEON SIMD extensions can now be built using MinGW
toolchains targetting ARM64 (AArch64) Windows binaries.
+4. Fixed unexpected visual artifacts that occurred when using
+`jpeg_crop_scanline()` and interblock smoothing while decompressing only the
+DC scan of a progressive JPEG image.
+
2.0.5
=====
diff --git a/jdcoefct.c b/jdcoefct.c
index 723a9ac..2ba6aa1 100644
--- a/jdcoefct.c
+++ b/jdcoefct.c
@@ -6,7 +6,7 @@
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2010, 2015-2016, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2015, 2020, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -495,11 +495,13 @@
if (first_row && block_row == 0)
prev_block_row = buffer_ptr;
else
- prev_block_row = buffer[block_row - 1];
+ prev_block_row = buffer[block_row - 1] +
+ cinfo->master->first_MCU_col[ci];
if (last_row && block_row == block_rows - 1)
next_block_row = buffer_ptr;
else
- next_block_row = buffer[block_row + 1];
+ next_block_row = buffer[block_row + 1] +
+ cinfo->master->first_MCU_col[ci];
/* We fetch the surrounding DC values using a sliding-register approach.
* Initialize all nine here so as to do the right thing on narrow pics.
*/