AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

2001.06.04 14:13 "YCbCr sampling factors, Old JPEG?", by Ross

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/