Blame SOURCES/libtiff-scanlinesize.patch

7c98bb
Partial fix for issues filed upstream at
7c98bb
http://bugzilla.maptools.org/show_bug.cgi?id=2140
7c98bb
This stops the tiffcmp core dump noted in bug #460322, but isn't enough
7c98bb
to make tiffcmp return the right answer (it emits a bunch of error
7c98bb
messages instead).
7c98bb
7c98bb
7c98bb
diff -Naur tiff-3.9.2.orig/libtiff/tif_jpeg.c tiff-3.9.2/libtiff/tif_jpeg.c
7c98bb
--- tiff-3.9.2.orig/libtiff/tif_jpeg.c	2009-08-30 12:21:46.000000000 -0400
7c98bb
+++ tiff-3.9.2/libtiff/tif_jpeg.c	2010-01-05 22:40:40.000000000 -0500
7c98bb
@@ -988,8 +988,15 @@
7c98bb
 	tsize_t nrows;
7c98bb
 	(void) s;
7c98bb
 
7c98bb
-	/* data is expected to be read in multiples of a scanline */
7c98bb
-	if ( (nrows = sp->cinfo.d.image_height) ) {
7c98bb
+    nrows = cc / sp->bytesperline;
7c98bb
+    if (cc % sp->bytesperline)
7c98bb
+		TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read");
7c98bb
+
7c98bb
+    if( nrows > (int) sp->cinfo.d.image_height )
7c98bb
+        nrows = sp->cinfo.d.image_height;
7c98bb
+
7c98bb
+    /* data is expected to be read in multiples of a scanline */
7c98bb
+    if (nrows) {
7c98bb
 		/* Cb,Cr both have sampling factors 1, so this is correct */
7c98bb
 		JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;            
7c98bb
 		int samples_per_clump = sp->samplesperclump;
7c98bb
@@ -1087,8 +1094,7 @@
7c98bb
 			 * TODO: resolve this */
7c98bb
 			buf += sp->bytesperline;
7c98bb
 			cc -= sp->bytesperline;
7c98bb
-			nrows -= sp->v_sampling;
7c98bb
-		} while (nrows > 0);
7c98bb
+		} while (--nrows > 0);
7c98bb
 
7c98bb
 #ifdef JPEG_LIB_MK1
7c98bb
 		_TIFFfree(tmpbuf);
7c98bb
diff -Naur tiff-3.9.2.orig/libtiff/tif_strip.c tiff-3.9.2/libtiff/tif_strip.c
7c98bb
--- tiff-3.9.2.orig/libtiff/tif_strip.c	2006-03-25 13:04:35.000000000 -0500
7c98bb
+++ tiff-3.9.2/libtiff/tif_strip.c	2010-01-05 21:39:20.000000000 -0500
7c98bb
@@ -238,23 +238,19 @@
7c98bb
 				     ycbcrsubsampling + 0,
7c98bb
 				     ycbcrsubsampling + 1);
7c98bb
 
7c98bb
-			if (ycbcrsubsampling[0] == 0) {
7c98bb
+			if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) {
7c98bb
 				TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
7c98bb
 					     "Invalid YCbCr subsampling");
7c98bb
 				return 0;
7c98bb
 			}
7c98bb
 
7c98bb
-			scanline = TIFFroundup(td->td_imagewidth,
7c98bb
+			/* number of sample clumps per line */
7c98bb
+			scanline = TIFFhowmany(td->td_imagewidth,
7c98bb
 					       ycbcrsubsampling[0]);
7c98bb
-			scanline = TIFFhowmany8(multiply(tif, scanline,
7c98bb
-							 td->td_bitspersample,
7c98bb
-							 "TIFFScanlineSize"));
7c98bb
-			return ((tsize_t)
7c98bb
-				summarize(tif, scanline,
7c98bb
-					  multiply(tif, 2,
7c98bb
-						scanline / ycbcrsubsampling[0],
7c98bb
-						"TIFFVStripSize"),
7c98bb
-					  "TIFFVStripSize"));
7c98bb
+			/* number of samples per line */
7c98bb
+			scanline = multiply(tif, scanline,
7c98bb
+					    ycbcrsubsampling[0]*ycbcrsubsampling[1] + 2,
7c98bb
+					    "TIFFScanlineSize");
7c98bb
 		} else {
7c98bb
 			scanline = multiply(tif, td->td_imagewidth,
7c98bb
 					    td->td_samplesperpixel,