Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-i.b-one.net (mx-i.one.com [91.198.169.56])
	by mail9.b-one.net (Postfix) with ESMTP id B1E7840024C
	for <info@awaresystems.be>; Fri, 11 Dec 2009 20:18:37 +0100 (CET)
X-Virus-Scanned: by one.com
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=6 tests=[none]
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144])
	by mx-i.b-one.net (Postfix) with ESMTP id 10880ECD
	for <info@awaresystems.be>; Fri, 11 Dec 2009 20:18:37 +0100 (CET)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 7E51F1D22E03F;
	Fri, 11 Dec 2009 14:17:34 -0500 (EST)
Received: from isadora.cybox.com (isadora.cybox.com [206.168.112.10])
	by lists.maptools.org (Postfix) with ESMTP id E223A1D203D6C
	for <tiff@lists.maptools.org>; Fri, 11 Dec 2009 13:49:55 -0500 (EST)
Received: from boreas.wriverody.net (vc7-1-52.dsl.netrack.net [199.45.160.84]
	(may be forged)) (authenticated)
	by isadora.cybox.com (msa 8.13.8/8.13.6) with ESMTP id nBBInnZt016663
	for <tiff@lists.maptools.org>; Fri, 11 Dec 2009 11:49:49 -0700
Message-ID: <4B229448.7010108@cybox.com>
Date: Fri, 11 Dec 2009 11:49:44 -0700
From: Richard Nolde <richard.nolde@cybox.com>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US;
	rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11
	Thunderbird/3.0b4
MIME-Version: 1.0
To: tiff@lists.maptools.org
References: <mailman.3.1260550802.30590.tiff@lists.maptools.org>
In-Reply-To: <mailman.3.1260550802.30590.tiff@lists.maptools.org>
Subject: [Tiff] JPEG compression in 3.9.2
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Something definitely changed in the 3.9.X JPEG code.  I found that some 
of the old libtiffpic sample images cause segfaults for tiffcp, and I 
had to do some workarounds to make tiffcrop handle them at all.  Since 
OJEPG compression is now deprecated for writing images, I try to convert 
them to new JPEG compression on the fly but this is not working uniformly.
Zackthecat and Smalliz come out at half the height they should and the 
colors are way off.  The values are probably the subsampled data rather 
than the upsampled data and/or the Cb and Cr only. Quad-jpeg comes out 
OK in my working copy but looks more like a grayscale luminance map in 
the distributed copy. I'm also getting strange results, ie, several 
stripes of color but no image for ycbcr-cat.tif.

tiffcp can no longer handle zackthecat.tif at all and smallliz aborts 
with a complaint about OJPEG not supported for writing (which is why I 
try to convert to new JPEG on the fly in tiffcrop).

I use TIFFReadEncodedStrip/Tile to avoid issues with compression 
algorithms that do not allow random seeks and I found that the 
calculated strip sizes are smaller than you would get by computing 
length * width * spp *bps/8 so I override that when I allocate buffers 
and ask for more data on the read.  For the problem images, it only 
brings back the number of bytes that it calculated, which suggests it is 
bringing back the down sampled data without up sampling it for YCbCr.

I fiddled with the JPEG_COLORMODE pseudo-tag at various points when 
writing out the data, not at load time, but it didn't solve the problem 
for these images.

Richard Nolde
TIffcrop author

Date: Fri, 11 Dec 2009 14:15:39 -0200
> From: "Antonio Scuri"<scuri@tecgraf.puc-rio.br>
> Subject: Re: [Tiff] YCbCr
> To: "'Steve Mills'"<smills@multi-ad.com>,	"'tiff list'"
>
>    As Joris pointed out, you actually get Y Cb and Cr planes. So the first
> component, that looks red, is infact Y, and indeed has the correct size. But
> the Cb and Cr planes are downsampled. At least this is what I got here.
>
>    I use libtiff 3.8.2. I have to comment the code at "tiff_jpeg.c" that does
> "downsampled_output = TRUE" and add "tif->tif_flags |= TIFF_UPSAMPLED;" so I
> got all YCbCr planes at normal resolution.
>
>    When I upgraded to libtiff 3.9.2 my code stop working. Now almost all the
> samples I have with YCbCr and JPEG compression fail to read. This includes
> the known quad-jpeg, smallliz and zackthecat.
>
>    It is the same for libjpeg6 or libjpeg7.
>
>    I have to investigate the changes between 3.8 and 3.9 to see if I'm not
> missing anything.
>
>    BTW, I do use TIFFReadScanline and TIFFReadTile to read the image data.
> I'm not using the high level functions.
>
> Best,
> scuri
>    

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
