libtiff: Merge branch 'fix_564' into 'master'

From 8f8916c1d36d47c94926a6a5cf04b8c8e04c2e3d Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Thu, 15 Aug 2024 23:22:38 +0200
Subject: [PATCH] TIFFScanlineSize64(): revert merge request #564

https://gitlab.com/libtiff/libtiff/-/merge_requests/564 broke decoding of: "tools/tiffcp -c none in.tif out.tif"
with [in.tif](/uploads/0475a88cf6e66652b030a0a3a0c47313/in.tif)
leading to shift each line of the target image by one extra pixel at each line.
Unfortunately, this cancels what https://gitlab.com/libtiff/libtiff/-/merge_requests/564 tried to fix. I'll let @caolanm propose an alternative fix in a follow-up merge request
---
 libtiff/tif_strip.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
index 088dd4bd..7ae7ce41 100644
--- a/libtiff/tif_strip.c
+++ b/libtiff/tif_strip.c
@@ -296,6 +296,10 @@ uint64_t TIFFScanlineSize64(TIFF *tif)
             uint64_t scanline_samples;
             uint32_t scanline_width = td->td_imagewidth;
 
+#if 0
+            // Tries to fix https://gitlab.com/libtiff/libtiff/-/merge_requests/564
+            // but causes regression when decoding legit files with tiffcp -c none
+            // Cf https://gitlab.com/libtiff/libtiff/-/merge_requests/644
             if (td->td_photometric == PHOTOMETRIC_YCBCR)
             {
                 uint16_t subsampling_hor;
@@ -306,6 +310,7 @@ uint64_t TIFFScanlineSize64(TIFF *tif)
                     scanline_width =
                         TIFFroundup_32(scanline_width, subsampling_hor);
             }
+#endif
 
             scanline_samples = _TIFFMultiply64(tif, scanline_width,
                                                td->td_samplesperpixel, module);