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 81BD3400164
	for <info@awaresystems.be>; Tue,  3 Nov 2009 00:29:45 +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 C8B858C50
	for <info@awaresystems.be>; Tue,  3 Nov 2009 00:29:44 +0100 (CET)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id A0D3E1D18E0C0;
	Mon,  2 Nov 2009 18:28:24 -0500 (EST)
Received: from toronto2.smartgames.ca (toronto2.smartgames.ca [204.15.192.18])
	by lists.maptools.org (Postfix) with ESMTP id 9A83B1D18E115
	for <tiff@lists.maptools.org>; Mon,  2 Nov 2009 18:02:57 -0500 (EST)
Received: from [10.143.176.101] (unknown [10.143.176.101])
	by toronto2.smartgames.ca (Postfix) with ESMTP id E844B16C5A
	for <tiff@lists.maptools.org>; Mon,  2 Nov 2009 18:03:22 -0500 (EST)
Mime-Version: 1.0 (Apple Message framework v753.1)
In-Reply-To: <4AEF564F.9090305@cybox.com>
References: <4AEF1C2D.9070907@cybox.com>
	<alpine.GSO.2.01.0911021231460.1964@freddy.simplesystems.org>
	<4AEF564F.9090305@cybox.com>
Message-Id: <FE0E6CD1-AAD3-4E35-911B-9B2EA664AC48@telegraphics.com.au>
From: Toby Thain <toby@telegraphics.com.au>
Date: Mon, 2 Nov 2009 18:02:52 -0500
To: Tiff Listserve <tiff@lists.maptools.org>
X-Mailer: Apple Mail (2.753.1)
Subject: Re: [Tiff] Tiffcrop test suite and logluv issues
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


On 2-Nov-09, at 4:59 PM, Richard Nolde wrote:

> ...
> Every pixel shows at least one change for sample 0, a few pixels show
> multiple changes.  Since tiffcp doesn't do anything but copy  
> scanlines,
> unlike tiffcrop which loads the image into memory so that it can be
> manipulated, it is hard to figure out why the data would change  
> unless,
> as I suspect, the following code from tif_luv.c doesn't take into
> consideration the fact that the original data is bigendian and I am
> compiling on a little endian host (having just gone through this with
> Toby's patch suggestion.)  In fact, running tiffcp or tiffcrop with  
> the
> -B switch to generate big endian TIFF produces quite a different  
> result
> for both off_luv24.tif and off_luv32.tif.
>
> LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
> {
>          LogLuvState* sp = DecoderState(tif);
>          int cc, i, npixels;
>          unsigned char* bp;
>          uint32* tp;
>
>          assert(s == 0);
>          assert(sp != NULL);
>
>          npixels = occ / sp->pixel_size;
>
>          if (sp->user_datafmt == SGILOGDATAFMT_RAW)
>                  tp = (uint32 *)op;
>          else {
>                  assert(sp->tbuflen >= npixels);
>                  tp = (uint32 *) sp->tbuf;
>          }
>                                          /* copy to array of uint32 */
>          bp = (unsigned char*) tif->tif_rawcp;
>          cc = tif->tif_rawcc;
>          for (i = 0; i < npixels && cc > 0; i++) {
>                  tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];

^^ This is a portable way of decoding a 3-byte BigEndian value. It  
will work on any host.

--Toby

>                  bp += 3;
>                  cc -= 3;
>          }
>
> Richard Nolde
>
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/

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