AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.05.28 06:26 "[Tiff] Tiff last tile problems", by Adell, Albert
2004.05.28 06:26 "[Tiff] Tiff JPEG compression quality factor", by Adell, Albert
2004.05.28 12:18 "Re: [Tiff] Tiff JPEG compression quality factor", by Frank Warmerdam
2004.05.28 17:32 "Re: [Tiff] Tiff JPEG compression quality factor", by Phillip Crews
2004.06.01 08:27 "RE: [Tiff] Tiff JPEG compression quality factor", by Adell, Albert
2004.06.01 18:04 "RE: [Tiff] Tiff JPEG compression quality factor", by Phillip Crews
2004.06.23 07:15 "[Tiff] Tiff JPEG compression quality factor", by Adell, Albert
2004.06.23 10:31 "[Tiff] Tiff JpegCompression 12-bit", by Adell, Albert
2004.05.28 14:35 "Re: [Tiff] Tiff JPEG compression quality factor", by Bob Friesenhahn
2004.05.28 20:57 "Re: [Tiff] Tiff last tile problems", by Andrey Kiselev
2004.06.01 07:59 "RE: [Tiff] Tiff last tile problems", by Adell, Albert

2004.06.01 18:04 "RE: [Tiff] Tiff JPEG compression quality factor", by Phillip Crews

Albert,

I haven't used the equation directly with JPEG-compressed TIFF files, only with JPEG files directly.

 From looking at tif_jpeg.c and the JPEG code, I *think* what you'll see in

the buffer returned using TIFFTAG_JPEGTABLES is:

SOI (0xff, 0xd8), DQT (0xff, 0xdb), (2 byte length of quant table+3), (table number & precision, 0x00 or 0x10), table data in zig-zag order, each value as a 16-bit word in network byte order if the previous byte & 0x10 is true, or 8-bit bytes if the previous byte & 0x10 is false.

It may be simplest to use libjpeg to parse the tables from the JPEGTABLES return data. This will parse the JPEG markers and return the table in natural (rather than zig-zag) order, something like this:

void *buf;
unsigned short len;
jpeg_decompress_struct cinfo = {0};
jpeg_source_mgr src;

TIFFVGetField(tif, TIFFTAG_JPEGTABLES, &len, &buf); jpeg_create_decompress(&cinfo);

cinfo.src = &src;

/* Set up the libjpeg source manager to read from buffer
    (crib code from TIF_JPEG.c) */

jpeg_read_header(&cinfo, FALSE);

At this point, cinfo.quant_table_ptrs should work for the code I provided.

Don't forget to jpeg_destroy_decompres(&cinfo) when you're done.

I'm sorry I don't have time to provide actual working code today. I hope this helps. ¡Buena suerte!

Kind regards,
Phillip

I've tried to write the code with the formula you provided me, but I can't access to the Q-Tables using the LibTiff Library.

I've read in a JPEG-compressed TIFF file the following tags:

-TIFFTAG_JPEGQTABLES: the library returns code 0 that means that this tag does not exist.

-TIFFTAG_JPEGTABLES: With this tag I succeed on reading some values, but I have no idea what they mean. I've looked for it in Internet and I've found that using this tag, the library returns the following:

        u_short*,void** count & tables

My problem is that I don't how to use the void **, anyway the "u_Short" value returns a value of 289... and does not look very good...

What am I doing wrong?

Which is the right way to get this q-value back using the LibTiff (the q-value that you refered in your mail as q = cinfo.quant_tbl_ptrs[0]->quantval[6])?

Thank a lot,

>From: Phillip Crews [<mailto:pcrews@cerious.com>mailto:pcrews@cerious.com]

Cc: 'tiff@remotesensing.org'

Subject: Re: [Tiff] Tiff JPEG compression quality factor