libtiff: Merge branch 'tiff2pdf_539' into 'master'

From a6db4dba26de662afb8fbbdbb9b2cb2992b67116 Mon Sep 17 00:00:00 2001
From: Lee Howard <[EMAIL REDACTED]>
Date: Thu, 23 May 2024 17:30:43 +0000
Subject: [PATCH] tiff2pdf: fix issue with JPEG restart-interval marker when
 converting from JPEG-compressed files

Fixes #539

however, there certainly remain many JPEG-compressed TIFFs which tiff2pdf will fumble without disabling data passthrough (using the -n option) - I supect that it has to do with the JPEG tables being removed from the JPEG and placed into the TIFF headers - as tiff2pdf would need to put these back into the JPEG instead of just passing the data through to the PDF
---
 tools/tiff2pdf.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index c0545600..a068b5f0 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -2272,7 +2272,6 @@ void t2p_read_tiff_size(T2P *t2p, TIFF *input)
                 k += 2; /* add space for restart marker */
             }
             k = checkAdd64(k, 2, t2p); /* use EOI of last strip */
-            k = checkAdd64(k, 6, t2p); /* for DRI marker of first strip */
             t2p_set_tiff_datasize(t2p, k);
             return;
         }
@@ -3954,7 +3953,6 @@ int t2p_process_jpeg_strip(unsigned char *strip, tsize_t *striplength,
     while (i < *striplength)
     {
         tsize_t datalen;
-        uint16_t ri;
         uint16_t v_samp;
         uint16_t h_samp;
         int j;
@@ -4017,25 +4015,10 @@ int t2p_process_jpeg_strip(unsigned char *strip, tsize_t *striplength,
                     }
                     v_samp *= 8;
                     h_samp *= 8;
-                    ri = (((((uint16_t)(buffer[*bufferoffset + 5]) << 8) |
-                            (uint16_t)(buffer[*bufferoffset + 6])) +
-                           v_samp - 1) /
-                          v_samp);
-                    ri *= (((((uint16_t)(buffer[*bufferoffset + 7]) << 8) |
-                             (uint16_t)(buffer[*bufferoffset + 8])) +
-                            h_samp - 1) /
-                           h_samp);
                     buffer[*bufferoffset + 5] =
                         (unsigned char)((height >> 8) & 0xff);
                     buffer[*bufferoffset + 6] = (unsigned char)(height & 0xff);
                     *bufferoffset += datalen + 2;
-                    /* insert a DRI marker */
-                    buffer[(*bufferoffset)++] = 0xff;
-                    buffer[(*bufferoffset)++] = 0xdd;
-                    buffer[(*bufferoffset)++] = 0x00;
-                    buffer[(*bufferoffset)++] = 0x04;
-                    buffer[(*bufferoffset)++] = (ri >> 8) & 0xff;
-                    buffer[(*bufferoffset)++] = ri & 0xff;
                 }
                 break;
             case 0xc4: /* DHT */