Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx009.isp.belgacom.be (inmx009.isp.belgacom.be [195.238.3.146])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id j2MKQPk9028702
        for <joris.at.lebbeke@skynet.be>; Tue, 22 Mar 2005 21:26:25 +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 inmx009.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j2MKQ9bs015278
        for <joris.at.lebbeke@skynet.be>; Tue, 22 Mar 2005 21:26:13 +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 C83C417218DF; Tue, 22 Mar 2005 15:25:50 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from scooby.simplesystems.org (scooby.simplesystems.org
	[65.66.246.67])
	by xserve.flids.com (Postfix) with ESMTP id F03C717218CE
	for <tiff@remotesensing.org>; Tue, 22 Mar 2005 15:25:48 -0500 (EST)
Received: from blade.simplesystems.org (blade.simplesystems.org [65.66.246.74])
	by scooby.simplesystems.org (8.12.10+Sun/8.12.10) with ESMTP id
	j2MKPjAi021589; Tue, 22 Mar 2005 14:25:45 -0600 (CST)
Date: Tue, 22 Mar 2005 14:25:45 -0600 (CST)
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
X-X-Sender: bfriesen@blade.simplesystems.org
To: David Gilbert <dgilbert@dclg.ca>
Subject: Re: [Tiff] tif_jpeg.c and 12bit JPEG Files
In-Reply-To: <16960.28021.4204.14634@canoe.dclg.ca>
Message-ID: <Pine.SOC.4.60.0503221407310.8945@blade.simplesystems.org>
References: <931f8ea905032209207728feb5@mail.gmail.com>
	<Pine.SOC.4.60.0503221158080.8945@blade.simplesystems.org>
	<931f8ea905032210105f1486b1@mail.gmail.com>
	<Pine.SOC.4.60.0503221217560.8945@blade.simplesystems.org>
	<16960.28021.4204.14634@canoe.dclg.ca>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: libtiff-Mailinglist <tiff@remotesensing.org>
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: ca3e0bf9ed3ea94f941bedcdbccdc666

On Tue, 22 Mar 2005, David Gilbert wrote:

>>>>>> "Bob" == Bob Friesenhahn <bfriesen@simple.dallas.tx.us> writes:
>
> Bob> The only way that makes sense is for 12 bit samples to be
> Bob> returned the same as for an uncompressed 12 bit TIFF file.
> Bob> Likewise, 12 bit samples should be consumed so that the only
> Bob> thing special the library user needs to do is request JPEG
> Bob> compression, and possibly JPEG RGB mode.
>
> Well... the "issue" is that the jpeg library treats 12 bit samples as
> 12 bit stored in 16 bit integers.  JPEG's transformation uses 16 bit
> ints for the math anyways ... so someone has to do the upsampling.
> Both the classic and the MK1 jpeg expect the user to do this.

This is not really compatible with the way the libtiff interfaces 
work.  Libtiff normally provides the data as a scanline, strip, or 
tile where the bits-per-sample of the data is the same as reported by 
libtiff, and the values occupy the full range of the sample.  As part 
of the "decompress" step, the data should be converted to packed 
12-bit form.  This can easily be done "in-place" if necessary while 
reading since 12-bits is smaller than 16-bits.  A secondary buffer 
would be needed while writing.

In order to make 12-bit JPEG in TIFF available to a broader variety of 
applications, an option could be provided via a virtual tag (similar 
to that used by the LogLuv support) to set libtiff in a mode where 
12-bit JPEG in TIFF pretends to be a 16-bit format.  12-bit JPEG in 
TIFF files would be reported as 16-bits/sample.  In this case the 
samples should be scaled to 16-bits.  The only change necessary for 
applications already supporting 16-bit TIFF is to set the option 
requesting that 12-bit TIFF be supported like 16-bit TIFF.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
