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 60D9B400F7E
	for <info@awaresystems.be>; Wed, 15 Jun 2011 17:15:13 +0200 (CEST)
Received: by mx-i.b-one.net (Postfix, from userid 106)
	id 5B1589070F2; Wed, 15 Jun 2011 17:14:41 +0200 (CEST)
X-Virus-Scanned: by one.com
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 6F3FC9070E7 for
 <info@awaresystems.be>; Wed, 15 Jun 2011 17:14:40 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id 3010186F06; Wed, 15 Jun 2011
 10:13:33 -0500 (EST)
Received: from cwb.pacific.net.hk (cwb.pacific.net.hk [202.14.67.92]) by
 lists.maptools.org (Postfix) with ESMTP id 6734486DFE for
 <tiff@lists.maptools.org>; Wed, 15 Jun 2011 10:01:07 -0500 (EST)
Received: from i7.coppice.org (183.219.17.210.static.pacific.net.hk
 [210.17.219.183] (may be forged)) by cwb.pacific.net.hk with ESMTP id
 p5FF14CY016766 for <tiff@lists.maptools.org>; Wed, 15 Jun 2011 23:01:05 +0800
Message-ID: <4DF8C90D.9000801@coppice.org>
Date: Wed, 15 Jun 2011 23:00:29 +0800
From: Steve Underwood <steveu@coppice.org>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17)
 Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.10
MIME-Version: 1.0
To: tiff@lists.maptools.org
References: <4DF7409B.4060102@thiele-hydraulik.de>
 <4DF75DF1.70108@coppice.org> <4DF76621.9090504@thiele-hydraulik.de>
In-Reply-To: <4DF76621.9090504@thiele-hydraulik.de>
Subject: Re: [Tiff] bug in G4 encoder.
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 06/14/2011 09:46 PM, Erik Thiele wrote:
> Am 14.06.2011 15:11, schrieb Steve Underwood:
>> On 06/14/2011 07:06 PM, Erik Thiele wrote:
>>> Hello,
>>>
>>> there is a bug in the G4 encoder. attached to this email you find a file
>>> "gimpcrop.g3.tiff". it is a correct TIFF file encoded with G3. you can
>>> open it with the usual viewers.
>>>
>>> now do this:
>>>
>>> bughunt$ tiffcp -c g4 gimpcrop.g3.tiff out.tiff
>>>
>>> the file gets converted from G3 to G4. the following command shows that
>>> the output file is corrupted.
>>>
>>> bughunt$ tiffcp out.tiff lala.tiff
>>> Fax4Decode: out.tiff: Bad code word at line 17 of strip 9 (x 0).
>>> Fax4Decode: Warning, out.tiff: Premature EOL at line 17 of strip 9 (got
>>> 0, expected 4519).
>>> Fax4Decode: Warning, out.tiff: Line length mismatch at line 44 of strip
>>> 9 (got 4520, expected 4519).
>>> Fax4Decode: Warning, out.tiff: Line length mismatch at line 53 of strip
>>> 9 (got 4574, expected 4519).
>>> Fax4Decode: Warning, out.tiff: Premature EOL at line 63 of strip 9 (got
>>> 72, expected 4519).
>>> bughunt$
>>>
>>> you can open lala.tiff in a viewer and get error messages. usually the
>>> viewer anyway views the image, but it contains a horizontal black line,
>>> which should not be there. in addition it contains more pixel errors.
>>>
>>> in case you cannot reproduce the problem, i attached lala.tiff to this
>>> email.
>>>
>>> tiffcp sais:
>>> LIBTIFF, Version 3.9.4
>>> my debian version of the libtiff4 package is 3.9.4-5+squeeze2
>>>
>>>
>>> I have recently reported this bug on the debian bug tracking system and
>>> am hereby forwarding it to you.
>>>
>>> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630042
>>>
>>>
>>>
>>> cu&   thanks
>>> Erik
>>>
>> Its a rather odd looking image, but libtiff 3.9.5 converts the odd
>> looking G3 image into a matching G4 image.
>>
>> Steve
>>
> i downloaded 3.9.4 (as this is the supposed buggy version that my debian
> uses) and 3.9.5 (as you suggest it is not buggy). i unpacked both and
> then did:
>
> cd tiff-3.9.5
> ./configure --prefix=/home/global/erik/localinst/tiff-3.9.5
> make install
>
> cd tiff-3.9.4
> ./configure --prefix=/home/global/erik/localinst/tiff-3.9.4
> make install
>
> then i first checked that there is no linker problems by calling ldd:
>
> bughunt$ ldd ~/localinst/tiff-3.9.4/bin/tiffcp
> 	linux-gate.so.1 =>   (0xb7723000)
> 	libtiff.so.3 =>  /home/global/erik/localinst/tiff-3.9.4/lib/libtiff.so.3
> (0xb76c6000)
> 	libjpeg.so.62 =>  /usr/lib/libjpeg.so.62 (0xb768f000)
> 	libz.so.1 =>  /usr/lib/libz.so.1 (0xb767a000)
> 	libm.so.6 =>  /lib/i686/cmov/libm.so.6 (0xb7654000)
> 	libc.so.6 =>  /lib/i686/cmov/libc.so.6 (0xb750e000)
> 	/lib/ld-linux.so.2 (0xb7724000)
>
> bughunt$ ldd ~/localinst/tiff-3.9.5/bin/tiffcp
> 	linux-gate.so.1 =>   (0xb778e000)
> 	libtiff.so.3 =>  /home/global/erik/localinst/tiff-3.9.5/lib/libtiff.so.3
> (0xb7732000)
> 	libjpeg.so.62 =>  /usr/lib/libjpeg.so.62 (0xb76fb000)
> 	libz.so.1 =>  /usr/lib/libz.so.1 (0xb76e6000)
> 	libm.so.6 =>  /lib/i686/cmov/libm.so.6 (0xb76c0000)
> 	libc.so.6 =>  /lib/i686/cmov/libc.so.6 (0xb757a000)
> 	/lib/ld-linux.so.2 (0xb778f000)
>
> now i called tiffcp to produce output pictures:
>
>
> bughunt$ ~/localinst/tiff-3.9.4/bin/tiffcp -c g4 gimpcrop.g3.tiff
> lala.3.9.4.tiff
>
> bughunt$ ~/localinst/tiff-3.9.5/bin/tiffcp -c g4 gimpcrop.g3.tiff
> lala.3.9.5.tiff
>
> i compared output pictures to see they are same:
>
> bughunt$ md5sum lala.3.9.4.tiff lala.3.9.5.tiff
> e9e0c41b94a32bfd620be39c3c2894c7  lala.3.9.4.tiff
> e9e0c41b94a32bfd620be39c3c2894c7  lala.3.9.5.tiff
>
> i verified that the outputs are buggy:
>
> bughunt$ display lala.3.9.5.tiff
> display: lala.3.9.5.tiff: Bad code word at line 17 of strip 9 (x 0).
> `Fax4Decode' @ warning/tiff.c/TIFFErrors/493.
> display: lala.3.9.5.tiff: Premature EOL at line 17 of strip 9 (got 0,
> expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703.
> display: lala.3.9.5.tiff: Line length mismatch at line 44 of strip 9
> (got 4520, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703.
> display: lala.3.9.5.tiff: Line length mismatch at line 53 of strip 9
> (got 4574, expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703.
> display: lala.3.9.5.tiff: Premature EOL at line 63 of strip 9 (got 72,
> expected 4519). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/703.
>
> the pictures look as corrupted as described in first email.
>
> what kind of additional problem do we have here?
>
> bughunt$ gcc --version
> gcc (Debian 4.4.5-8) 4.4.5
>
> how can we debug?
I actually used the libtiff 3.9.5 in Fedora 14 when I got good results. 
Perhaps it has been patched in some way. There was breakage of the G4 
codec a while ago, when a fix to stop a potential buffer overflow 
screwed up some images. Is this the same issue resurfacing?

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