Release Notes
Open Source Used In AsyncOS 8.8 for Cisco Web Security Appliances
94
into the decompression object before trying to read the abbreviated image.
If the proper tables are stored in the application program, you can just
allocate the table structs and fill in their contents directly. For example,
to load a fixed quantization table into table slot "n":
if (cinfo.quant_tbl_ptrs[n] == NULL)
cinfo.quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) &cinfo);
quant_ptr = cinfo.quant_tbl_ptrs[n];/* quant_ptr is JQUANT_TBL* */
for (i = 0; i < 64; i++) {
/* Qtable[] is desired quantization table, in natural array order */
quant_ptr->quantval[i] = Qtable[i];
}
Code to load a fixed Huffman table is typically (for AC table "n"):
if (cinfo.ac_huff_tbl_ptrs[n] == NULL)
cinfo.ac_huff_tbl_ptrs[n] = jpeg_alloc_huff_table((j_common_ptr) &cinfo);
huff_ptr = cinfo.ac_huff_tbl_ptrs[n];/* huff_ptr is JHUFF_TBL* */
for (i = 1; i <= 16; i++) {
/* counts[i] is number of Huffman codes of length i bits, i=1..16 */
huff_ptr->bits[i] = counts[i];
}
for (i = 0; i < 256; i++) {
/* symbols[] is the list of Huffman symbols, in code-length order */
huff_ptr->huffval[i] = symbols[i];
}
(Note that trying to set cinfo.quant_tbl_ptrs[n] to point directly at a
constant JQUANT_TBL object is not safe. If the incoming file happened to
contain a quantization table definition, your master table would get
overwritten! Instead allocate a working table copy and copy the master table
into it, as illustrated above. Ditto for Huffman tables, of course.)
You might want to read the tables from a tables-only file, rather than
hard-wiring them into your application. The jpeg_read_header() call is
sufficient to read a tables-only file. You must pass a second parameter of
FALSE to indicate that you do not require an image to be present. Thus, the
typical scenario is
create JPEG decompression object
set source to tables-only file
jpeg_read_header(&cinfo, FALSE);
set source to abbreviated image file
jpeg_read_header(&cinfo, TRUE);
set decompression parameters
jpeg_start_decompress(&cinfo);
read data...
jpeg_finish_decompress(&cinfo);