lzx_data ** lzxdp
, int wsize_code
, lzx_get_bytes_t get_bytes
, void *get_bytes_arg
, lzx_at_eof_t at_eof
, lzx_put_bytes_t put_bytes
, void *put_bytes_arg
, lzx_mark_frame_t mark_frame
, void *mark_frame_arg)
, int block_size
, int subdivide)
, struct lzx_results *lzxr)
), and lzx_finish(
) functions comprise an compression engine for Microsoft's LZX compression format.
) function takes a
wsize_codeto indicate the log (base 2) of the window size for compression, so 15 is 32K, 16 is 64K, on up to 21 meaning 2MB. It also takes the following callback functions and their associated arguments:
, int n
, void *buf)
) routine calls this function when it needs more uncompressed input to process. The number of bytes requested is
nand the bytes should be placed in the buffer pointed to by
buf. The get_bytes(
) function should return the number of bytes actually provided (which must not be greater than
n), nor 0, except at EOF.
void * get_bytes_arg)
void * put_bytes_arg
, int n
, void * buf)
) callback is called by lzx_compress(
) when compressed bytes need to be output. The number of bytes to be output is
nand the bytes are in the buffer pointed to by
, uint32_t uncomp
, uint32_t comp)
) callback is called whenever
LZX_FRAME_SIZE(0x8000) uncompressed bytes have been processed. The current (as of the last call to put_bytes(
) ) location in the uncompressed and compressed data streams are provided in
comprespectively. This is intended for .CHM (ITSS) and other similar files which require a "reset table" listing the frame locations. This callback is optional; if the
mark_frameargument to lzx_init(
) is NULL, no function will be called at the end of each frame.
function allocates an opaque structure, a pointer to which will be returned in
A pointer to this structure may be passed to the other LZX compression functions.
The function returns negative on error, 0 otherwise
function writes out any unflushed data,
releases all memory held by the compressor (including the
structure) and optionally fills in the
structure, a pointer to which is passed in as
(NULL if results are not required)
) function takes the opaque pointer returned by lzx_init(
block_size, and a flag which says whether or not to subdivide the block. If the
subdivideflag is set, blocks may be subdivided to increase compression ratio based on the entropy of the data at a given point. Otherwise, just one block is created. Returns negative on error, 0 otherwise.
function may be called after any block in order to reset all
compression state except the number of compressed and uncompressed
bytes processed. This forces the one-bit Intel preprocessing header
to be output again, the Lempel-Ziv window to be cleared, and the
Huffman tables to be reset to zero length. It should only be called
on a frame boundary; the results of calling it elsewhere or during a
callback are undefined.
To compress data, simply
repeatedly, handling the various callbacks described above, until your data is exhausted.
The callbacks are intended to return a negative result on error, but this is not yet understood by the compressor.
The compressor is currently unable to output an uncompressed block, so incompressible data may expand more than is necessary (though still not more than is permitted by the CAB standard, 6144 bytes.)
There is no well-defined set of error codes.
There is no way for the callbacks to report an error and abort the compression.
The algorithm for splitting blocks is suboptimal.
LZXFMT.DOC -- Microsoft LZX Data Compression Format (part of Microsoft Cabinet SDK)
Comments in cabextract.c, concerning errors in LZXFMT.DOC (part of
file format documentation