Release Notes

Open Source Used In AsyncOS 8.8 for Cisco Web Security Appliances
97
When reading, two methods of handling special markers are available:
1. You can ask the library to save the contents of COM and/or APPn markers
into memory, and then examine them at your leisure afterwards.
2. You can supply your own routine to process COM and/or APPn markers
on-the-fly as they are read.
The first method is simpler to use, especially if you are using a suspending
data source; writing a marker processor that copes with input suspension is
not easy (consider what happens if the marker is longer than your available
input buffer). However, the second method conserves memory since the marker
data need not be kept around after it's been processed.
For either method, you'd normally set up marker handling after creating a
decompression object and before calling jpeg_read_header(), because the
markers of interest will typically be near the head of the file and so will
be scanned by jpeg_read_header. Once you've established a marker handling
method, it will be used for the life of that decompression object
(potentially many datastreams), unless you change it. Marker handling is
determined separately for COM markers and for each APPn marker code.
To save the contents of special markers in memory, call
jpeg_save_markers(cinfo, marker_code, length_limit)
where marker_code is the marker type to save, JPEG_COM or JPEG_APP0+n.
(To arrange to save all the special marker types, you need to call this
routine 17 times, for COM and APP0-APP15.) If the incoming marker is longer
than length_limit data bytes, only length_limit bytes will be saved; this
parameter allows you to avoid chewing up memory when you only need to see the
first few bytes of a potentially large marker. If you want to save all the
data, set length_limit to 0xFFFF; that is enough since marker lengths are only
16 bits. As a special case, setting length_limit to 0 prevents that marker
type from being saved at all. (That is the default behavior, in fact.)
After jpeg_read_header() completes, you can examine the special markers by
following the cinfo->marker_list pointer chain. All the special markers in
the file appear in this list, in order of their occurrence in the file (but
omitting any markers of types you didn't ask for). Both the original data
length and the saved data length are recorded for each list entry; the latter
will not exceed length_limit for the particular marker type. Note that these
lengths exclude the marker length word, whereas the stored representation
within the JPEG file includes it. (Hence the maximum data length is really
only 65533.)
It is possible that additional special markers appear in the file beyond the
SOS marker at which jpeg_read_header stops; if so, the marker list will be
extended during reading of the rest of the file. This is not expected to be
common, however. If you are short on memory you may want to reset the length
limit to zero for all marker types after finishing jpeg_read_header, to