Release Notes

Open Source Used In AsyncOS 8.8 for Cisco Web Security Appliances
76
The JPEG compression library sends its compressed data to a "destination
manager" module. The default destination manager just writes the data to a
memory buffer or to a stdio stream, but you can provide your own manager to
do something else. Similarly, the decompression library calls a "source
manager" to obtain the compressed data; you can provide your own source
manager if you want the data to come from somewhere other than a memory
buffer or a stdio stream.
In both cases, compressed data is processed a bufferload at a time: the
destination or source manager provides a work buffer, and the library invokes
the manager only when the buffer is filled or emptied. (You could define a
one-character buffer to force the manager to be invoked for each byte, but
that would be rather inefficient.) The buffer's size and location are
controlled by the manager, not by the library. For example, the memory
source manager just makes the buffer pointer and length point to the original
data in memory. In this case the buffer-reload procedure will be invoked
only if the decompressor ran off the end of the datastream, which would
indicate an erroneous datastream.
The work buffer is defined as an array of datatype JOCTET, which is generally
"char" or "unsigned char". On a machine where char is not exactly 8 bits
wide, you must define JOCTET as a wider data type and then modify the data
source and destination modules to transcribe the work arrays into 8-bit units
on external storage.
A data destination manager struct contains a pointer and count defining the
next byte to write in the work buffer and the remaining free space:
JOCTET * next_output_byte; /* => next byte to write in buffer */
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
The library increments the pointer and decrements the count until the buffer
is filled. The manager's empty_output_buffer method must reset the pointer
and count. The manager is expected to remember the buffer's starting address
and total size in private fields not visible to the library.
A data destination manager provides three methods:
init_destination (j_compress_ptr cinfo)
Initialize destination. This is called by jpeg_start_compress()
before any data is actually written. It must initialize
next_output_byte and free_in_buffer. free_in_buffer must be
initialized to a positive value.
empty_output_buffer (j_compress_ptr cinfo)
This is called whenever the buffer has filled (free_in_buffer
reaches zero). In typical applications, it should write out the