tjTrans: Allow 8x8 crop alignmnt w/odd 4:4:4 JPEGs

Fixes #549
This commit is contained in:
DRC
2021-09-02 12:48:50 -05:00
parent 5d2430f4da
commit 173900b1ca
2 changed files with 8 additions and 3 deletions

View File

@@ -11,6 +11,11 @@ automatically place the `.rodata` section in an executable segment, which
prevented libjpeg-turbo from working properly with other linkers and also
represented a potential security risk.
2. Fixed an issue whereby the `tjTransform()` function incorrectly computed the
MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus
unduly rejected some cropping regions, even though those regions aligned with
8x8 MCU block boundaries.
2.1.1
=====

View File

@@ -1966,12 +1966,12 @@ DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
THROW("tjTransform(): Transform is not perfect");
if (xinfo[i].crop) {
if ((t[i].r.x % xinfo[i].iMCU_sample_width) != 0 ||
(t[i].r.y % xinfo[i].iMCU_sample_height) != 0) {
if ((t[i].r.x % tjMCUWidth[jpegSubsamp]) != 0 ||
(t[i].r.y % tjMCUHeight[jpegSubsamp]) != 0) {
snprintf(this->errStr, JMSG_LENGTH_MAX,
"To crop this JPEG image, x must be a multiple of %d\n"
"and y must be a multiple of %d.\n",
xinfo[i].iMCU_sample_width, xinfo[i].iMCU_sample_height);
tjMCUWidth[jpegSubsamp], tjMCUHeight[jpegSubsamp]);
this->isInstanceError = TRUE;
retval = -1; goto bailout;
}