backport fix for an issue creating tiled 12-bit JPEGs, triggered by a recent

change in libjpeg-turbo.  ok tb naddy
This commit is contained in:
sthen
2026-04-14 21:41:19 +00:00
parent 9128876748
commit dffcc2b298
2 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ DISTNAME= tiff-4.7.1
SHARED_LIBS= tiff 42.2 # 13.0
SHARED_LIBS+= tiffxx 42.0 # 13.0
CATEGORIES= graphics
REVISION= 1
REVISION= 2
SITES= https://download.osgeo.org/libtiff/
EXTRACT_SUFX= .tar.xz
@@ -0,0 +1,26 @@
From 200e5ca51e477ac439ef9514c3c3ac8c9799a5c8 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Mon, 16 Mar 2026 02:06:02 +0100
Subject: [PATCH] JPEG: fix generation of tiled 12-bit JPEG compressed files
with libjpeg-turbo 3.0.3
Fixes https://gitlab.com/libtiff/libtiff/-/work_items/773
Index: libtiff/tif_jpeg.c
--- libtiff/tif_jpeg.c.orig
+++ libtiff/tif_jpeg.c
@@ -2276,7 +2276,13 @@ static int JPEGPreEncode(TIFF *tif, uint16_t s)
/* an existing file */
suppress_huff_table(sp, 0);
suppress_huff_table(sp, 1);
- sp->cinfo.c.optimize_coding = FALSE;
+
+ /* We want to keep optimize_coding = TRUE for 12-bit JPEG */
+ /* See lengthy explanation at
+ * https://gitlab.com/libtiff/libtiff/-/work_items/773#note_3009836854
+ */
+ if (sp->cinfo.c.data_precision == 8)
+ sp->cinfo.c.optimize_coding = FALSE;
}
else
sp->cinfo.c.optimize_coding = TRUE;