Return-Path: <tiff-bounces@remotesensing.org>
Received: from inav016.isp.belgacom.be (inav016.isp.belgacom.be [195.238.2.248])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id iACIxNvN013387
        for <joris.at.lebbeke@skynet.be>; Fri, 12 Nov 2004 19:59:23 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from inas014.isp.belgacom.be (localhost [127.0.0.1])
        by inav016.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id iACIxFNQ006570
        for <joris.at.lebbeke@skynet.be>; Fri, 12 Nov 2004 19:59:15 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from inmx010.isp.belgacom.be (inmx010.isp.belgacom.be [195.238.2.73])
        by inas014.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id iACIx48u019893
        for <joris.at.lebbeke@skynet.be>; Fri, 12 Nov 2004 19:59:06 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx010.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id iACIwnio020080
        for <joris.at.lebbeke@skynet.be>; Fri, 12 Nov 2004 19:58:53 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id 8DA9146E1D9; Fri, 12 Nov 2004 13:55:58 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from mailfe01.swip.net (mailfe01.swip.net [212.247.154.1])
	by xserve.flids.com (Postfix) with ESMTP
	id 4F20C44BADF; Fri,  5 Nov 2004 12:36:10 -0500 (EST)
X-T2-Posting-ID: cwZnxQPHzUwgEs7d4isMLA==
Received: from [193.217.200.153] (HELO curly.tele2.no)
	by mailfe01.swip.net (CommuniGate Pro SMTP 4.2.5)
	with ESMTP id 208110682; Fri, 05 Nov 2004 18:35:41 +0100
Received: (from root@localhost)
	by curly.tele2.no (8.12.5/8.12.3) id iA5HeKQI001301;
	Fri, 5 Nov 2004 18:40:20 +0100 (CET) (envelope-from hselasky@c2i.net)
Date: Fri, 5 Nov 2004 18:40:18 +0100
From: Hans Petter Selasky <hselasky@c2i.net>
To: tiff@remotesensing.org, dinoex@FreeBSD.org, dron@remotesensing.org,
        warmerdam@pobox.com
Message-ID: <20041105184018.A292@curly.tele2.no>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR"
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
X-Mailman-Approved-At: Fri, 12 Nov 2004 13:54:41 -0500
Cc: 
Subject: [Tiff] bug in YCbCr support, tiff 3.6.1
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 0192c20ecab80ae6374711c9b3c609c0


--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

BUG: some tables were initialized with wrong value; tiff 3.5.5 initialized the table right;
BUG: missing check for division by zero

see attached patch

please CC me, hence I'm not subscribed to this list

Yours
-HPS


--T4sUOijqQbZv57TR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="libtiff.patch.diff"

*** libtiff/tif_color.c.ref	Fri Nov  5 18:01:44 2004
--- libtiff/tif_color.c	Fri Nov  5 18:26:46 2004
***************
*** 170,176 ****
  #define	SHIFT			16
  #define	FIX(x)			((int32)((x) * (1L<<SHIFT) + 0.5))
  #define	ONE_HALF		((int32)(1<<(SHIFT-1)))
! #define	Code2V(c, RB, RW, CR)	((((c)-(int32)(RB))*(float)(CR))/(float)((RW)-(RB)))
  #define	CLAMP(f,min,max)	((f)<(min)?(min):(f)>(max)?(max):(f))
  
  void
--- 170,176 ----
  #define	SHIFT			16
  #define	FIX(x)			((int32)((x) * (1L<<SHIFT) + 0.5))
  #define	ONE_HALF		((int32)(1<<(SHIFT-1)))
! #define	Code2V(c, RB, RW, CR)	((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)) ? ((RW)-(RB)) : 1))
  #define	CLAMP(f,min,max)	((f)<(min)?(min):(f)>(max)?(max):(f))
  
  void
***************
*** 243,252 ****
         * constructing tables indexed by the raw pixel data.
         */
        for (i = 0, x = -128; i < 256; i++, x++) {
! 	    int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F,
! 			    refBlackWhite[5] - 128.0F, 127);
! 	    int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F,
! 			    refBlackWhite[3] - 128.0F, 127);
  
  	    ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
  	    ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
--- 243,252 ----
         * constructing tables indexed by the raw pixel data.
         */
        for (i = 0, x = -128; i < 256; i++, x++) {
! 	    int32 Cr = ((int32)Code2V(x, refBlackWhite[4] - 128.0F,
! 			    refBlackWhite[5] - 128.0F, 255)) - 128;
! 	    int32 Cb = ((int32)Code2V(x, refBlackWhite[2] - 128.0F,
! 			    refBlackWhite[3] - 128.0F, 255)) - 128;
  
  	    ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
  	    ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);

--T4sUOijqQbZv57TR
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff

--T4sUOijqQbZv57TR--
