| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2004.06.23 07:15 "Tiff JPEG compression quality factor", by Albert AdellHi Philip,
I have modified the method JPEGSetupDecode in tiff_jpeg.c file, in order
to calculate the Q-factor.
I have acceded to the JPEG struct at this function and I am able to apply
the Q-factor computation.
JPEGSetupDecode(TIFF* tif)
{
...
/* Read JPEGTables if it is present */
if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) {
TIFFjpeg_tables_src(sp, tif);
if(TIFFjpeg_read_header(sp,FALSE) !=
JPEG_HEADER_TABLES_ONLY) {
TIFFError("JPEGSetupDecode", "Bogus JPEGTables
field");
return (0);
}
//$$$ QualityFactor begin
q = sp->cinfo.d.quant_tbl_ptrs[0]->quantval[6];
if (q > 51)
q = (50 * 51 + q / 2) / q;
else
q = (5126 - 50 * q) / 51;
sp->jpegquality=q;
//$$$ QualityFactor end
}
...
}
This method is automaticaly called when reading a tile or a strip but I
suppose that is more interesting if it could be calculated before. I put
the JPEGSetupCode explicit call after an Open call and it seems that
works!
Thanks for the qFactor computation its a nice aproximation.
Thanks a lot,
Albert Adell
________________________________________________________________________
Albert Adell Fernández Desenvolupament Fotogrametria Digital
Institut Cartografic de Catalunya Passeig Santa Madrona 45-51
E-08004 Barcelona www http://www.icc.es
_________________________________________________________________________
|
|||||||