Return-Path: owner-tiff@olympiakos.com
Return-Path: <owner-tiff@olympiakos.com>
Received: from localhost (localhost [127.0.0.1])
	by at1895.spb.edu (8.12.0.Beta7/8.12.0.Beta7) with ESMTP id f558OnR1002192
	for <dron@localhost>; Tue, 5 Jun 2001 12:29:31 +0400
Received: from eudoramail.com [209.185.123.45]
	by localhost with POP3 (fetchmail-5.8.1)
	for dron@localhost (single-drop); Tue, 05 Jun 2001 12:29:31 +0400 (MSD)
Received: from gate7.olympiakos.com ([207.176.88.85]) by shared1-mail.whowhere.com; Mon Jun  4 08:06:19 2001
Received: from localhost (daemon@localhost)
	by gate7.olympiakos.com (8.9.3/8.9.3) with SMTP id KAA01228;
	Mon, 4 Jun 2001 10:50:07 -0400
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Mon, 4 Jun 2001 10:48:19 -0400
Received: (from majordom@localhost)
	by gate7.olympiakos.com (8.9.3/8.9.3) id KAA01139
	for tiff-outgoing; Mon, 4 Jun 2001 10:48:18 -0400
X-Authentication-Warning: gate7.olympiakos.com: majordom set sender to owner-tiff@olympiakos.com using -f
Received: from waco2.calpha.com (root@waco2.calpha.com [208.232.233.3])
	by gate7.olympiakos.com (8.9.3/8.9.3) with ESMTP id KAA01136
	for <tiff@olympiakos.com>; Mon, 4 Jun 2001 10:48:14 -0400
Received: from calpha.com (63-80-24-049.calpha.com [63.80.24.49])
	by waco2.calpha.com (8.10.1/8.10.1) with ESMTP id f54Em3A18503
	for <tiff@olympiakos.com>; Mon, 4 Jun 2001 09:48:03 -0500
Message-ID: <3B1B977C.3477F2D4@calpha.com>
Date: Mon, 04 Jun 2001 10:13:16 -0400
From: Ross <apex@apexinternetsoftware.com>
Organization: Apex Internet Software
X-Mailer: Mozilla 4.08 [en] (Win98; U)
MIME-Version: 1.0
To: tiff@olympiakos.com
Subject: YCbCr sampling factors, Old JPEG?
Content-Type: text/plain; charset=iso-8859-1
Sender: owner-tiff@olympiakos.com
X-MIME-Autoconverted: from 8bit to quoted-printable by gate7.olympiakos.com id KAA01228
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by at1895.spb.edu id f558OnR1002192
Status: RO
Content-Length: 7278
Lines: 181

Hi,

I have some questions about the PDF DCTDecoder, with regards to TIFF
data.

I have some data, where I want a JPEG marker to have it pass the
information to the decoder, where what would work would be the content
of the Adobe JPEG Application marker.  This is as the PDF DCTDecode
filter has no parameters that it is expecting it from the JPEG data.

I look to the Technical Note #5116, about DCT in PS2, and it tells me
about the APPn application marker that it is APP14 or APPE.

Basically, the DCTDecode filter is expecting 4:2:2 YCbCr data, and it
needs to be notified that that data is in 4:1:4.  So, I want to set the
VSamples and HSamples parameters of the PostScript DCTDecoder.

Here is what the document says:

"Adobe uses the JPEG X’FFEE marker (or APPE marker) to record
informa-tion
at the time of compression such as whether or not the sample values
were blended and which color transform was performed upon the data. The
format of the marker is as follows.
• Two-byte length field (specifies 14 byte marker length)
• The text ‘Adobe’ as a five-character ASCII big-endian string
• Two-byte DCTEncode/DCTDecode version number
(presently X’65)
• Two-byte flags0 0x8000 bit: Encoder used Blend=1 downsampling
• Two-byte flags1
• One-byte color transform code"

The color transform code, it is 3.  The flags0 is 0x8000 for the Blend
or 0x0000 for the Chop
down- or subsampling.  What I need to know is the format of flags1.  As
is noted:

"1 bits in flags1 pass informa-tion
essential for decoding. DCTDecode could reject a compressed image,
if there are 1 bits in flags1 or color transform codes that it cannot
interpret."

It says:

"Any application trying to mimic should arrange to cooperate
with Adobe."

I think it would be mutually beneficial if the "essential" information
was present.  The reason it is required is because the PDF DCTDecode, it
would be good if it supports the PostScript DCTDecode parameters.  Then,
it wouldn't be necessary for any modifications to the JPEG data stream.

I will see if it supports the PostScript DCTDecode parameters, and have
yet to add the remaining code to see that.

I tried changes to the count of MCUs in the Define Restart Interval that
is added.  Checking this MCU number, the interleaved description might
enable a truer count.

This data, it is stored in TIFFs.  These are TIFFs that in the
standardly defined TIFF 6.0 way "Old JPEG" optionally do not include the
JPEG RSTm markers, which are basically the markers for each strip or
tile.  More exactly, based upon the the number of Minimum Coded Units
(MCUs) in each block of raw data from the TIFF file, the restart markers
are that many MCUs apart in the JPEG data.  That kind of software, it
must be able to calculate from the width, height, tiling, component
sampling factors, JPEG procedure, planar configuration, etc., of the
image from the TIFF tags for width, height, tiling, etc.:

TIFFTAG_IMAGEWIDTH:  1275
TIFFTAG_IMAGELENGTH:  1754
TIFFTAG_FILLORDER:  1
TIFFTAG_COMPRESSION:  6
TIFFTAG_RESOLUTIONUNIT:  2
TIFFTAG_ROWSPERSTRIP:  8
TIFFTAG_SAMPLESPERPIXEL:  3
TIFFTAG_BITSPERSAMPLE:  8
TIFFTAG_XRESOLUTION:  150
TIFFTAG_YRESOLUTION:  150
TIFFTAG_SUBFILETYPE:  0
TIFFTAG_OSUBFILETYPE:  0
TIFFTAG_SOFTWARE:  Oi/GFS, writer v00.06.00P, (c) Wang Labs, Inc. 1990,
1991
TIFFTAG_ORIENTATION:  1
TIFFTAG_PHOTOMETRIC:  6
TIFFTAG_PLANARCONFIG:  1
TIFFTAG_JPEGPROC:  1
TIFFTAG_JPEGIFOFFSET:  760
TIFFTAG_JPEGIFBYTECOUNT:  601
TIFFTAG_YCBCRSUBSAMPLING:  4, 1

These are image tags from one of these images.  Here the only way this
is different from the other TIFF/JPEG images that convert correctly is
that those are using 4:2:2 Y:4/Cb:4/Cr chrominance downsampling, where
these images' tags are defining 4:1:4.  That is where the values for the
YCbCr subsampling TIFF tag are 2, 2 (default) and 4, 1, respectively,
where the two values of the tag only describe the sampling factors for
the two chrominance components, C_blue and C_red.


These would be the values for the default Adobe PostScript HSamples and
VSamples:

/HSamples [4 2 2]
/VSamples [4 2 2]

These would be the ones for the Wang 4:1:4 sampling, I think:

/HSamples [4 1 1]
/VSamples [4 4 4]

One thing to note is that the some of the other sampling variations are
supported by the Adobe decoder, without the existence of data stream
marker compensation.

Then, I have here some other JPEG images, maybe they are supposed to be
JTIF?

What is the story of JTIF?

Another thing I have noticed is that some of the images have the
centered downsampled component placement, some from these other vendors
use the cosited placement, where that is about the application of the
less weighted components:

TIFFTAG_YCBCRSUBSAMPLING:  1, 1
TIFFTAG_YCBCRPOSITIONING:  2

Adobe describes a functional resampler, so to get the relevant component
sampling factor information would be good.  Basically, I think it a
matter of the vertical and horizontal sampling factors, where there are
different orders in which the components may be interleaved.

So, is there a more complete specification of the Adobe JPEG marker,
APP14?  That is to say, is there a specification for flags1?  Are more
flags used?  Does Adobe's JPEG software understand the EXP marker
(Expand Reference Components)?  Most specifically, would the DCTDecoder
be able to convert the data if this tag were present in the JPEG data?

Also, I wonder if the various resampling factors of the interleaved
components in the raw JPEG data stream describe different reasons to
consider the MCUs as anything other than 8x8 blocks.  The specification,
it describes the order of the interleaved components, that was a way to
determine what actual value of restart interval was implied, which
allows some of the data stored in "Old JPEG" TIFFs to be reconstructed
to image data readable by regular JPEG readers.

The Wang images the convert by adding the RSTm markers before each strip
or tile are having these values for YCbCrSubsampling:  2, 1.  That would
make them 4:2:4 images.

The description of the TIFF handling of this is from the TIFF 6.0
specification, June 3, 1992.  In section 21, it is describing class Y
for applications that use YCbCr colorspace, where it defines the
photometric tag of 6 for the YCbCr colorspace.

Would calculating a different restart interval make a difference?  I
tried multiples and fractions of the determined value. Does the Adobe
APP14 marker have use to define resampling factors and methods?

I hope someone will correct me if I'm wrong, or have some of this
information.  I could be misguided as to how some aspect of these things
really does function, I am still trying to figure it out.  For example,
I have no idea if the appropriate Adobe APP14 marker in the JPEG data
would allow the Adobe PDF DCTDecode to interpret the incoming samples,
or if there is some much simpler way.  Also, I wonder why the sampling
factors are set as they are in this image, and wh yit would be any
different from other images with varying sampling factors.  So, I
learned some information from the various Adobe documents, the libjpg
documentation, and some of the ITU documents.

Thanks,

Ross

--
contact Ross
company Apex Internet Software
email info@apexinternetsoftware.com
website http://www.apexinternetsoftware.com/


