EBook::Tools::LZSS(3pm)

NAME
EBook::Tools::LZSS - Lempel-Ziv-Storer-Szymanski compression and decompression

SYNOPSIS
 use EBook::Tools::LZSS;
 my $lzss = EBook::Tools::LZSS->new(lengthbits => 3,
                                    offsetbits => 14,
                                    windowinit => 'the man');
 my $textref = $lzss->uncompress(\$data);

CONSTRUCTOR AND INITIALIZATION

  "new(%args)"
Instantiates a new EBook::Tools::LZSS object.

Arguments

All arguments are optional, but must be identical between compression and decompression for the result to be valid.

•   "lengthbits"

    The number of bits used to encode the length of a LZSS reference. If not specified defaults to 4 bits.

    The eBookwise .IMP format typically compresses with 3 length bits.

    Note that the actual length of the LZSS reference in bytes is greater than the value stored in the length bits. The actual number of bytes returned is the decoded length bits value plus "maxuncoded" plus 1,

•   "offsetbits"

    The number of bits used to encode the offset to a LZSS reference. This also determines the size of the sliding window of reference data. If not specified, it defaults to 12 bits (4096-byte window).

    The eBookwise .IMP format typically compresses with 14 offset bits (16384-byte window).

•   "windowinit"

    A string used to initalize the sliding window. If specified, this string MUST be the same length as the window size, or the subroutine will croak. If not specified, the window will be initialized with spaces.

•   "windowstart"

    The first byte position in the window that will be overwritten by decoded text. If not specified, defaults to 0.

•   "maxuncoded"

    The maximum number of uncoded bytes (?). This currently isn't used for that purpose, but determines the actual length of a LZSS reference.

•   "screwybits"

    If set to true and the number of offset bits is greater than 8, then the offset bits will be read first in a chunk of 8 for the least significant bits, and then the remaining bits will be read and use as the most significant bits. This seems to be necessary for compatibility with Michael Dipperstein's LZSS C compression library but does not hold true for IMP e-book LZSS decompression.

•   "verbose"

    If set to true, compression and uncompression will provide additional status feedback on STDOUT.

METHODS

  "uncompress(\$dataref)"
Takes a reference to a compressed data string, uncompresses the data string and returns a reference to the uncompressed string.

BUGS AND LIMITATIONS

•   Compression not yet implemented.

•   The LZSS algorithm isn't documented in the POD.

•   Once compression is implemented and the algorithm is documented, this module is a good candidate for being forked off into its own project. Relying on it to keep its current name may be unwise.

AUTHOR
Zed Pobre <zed@debian.org>

The design of this module was based on the C LZSS library by Michael Dipperstein, version 0.5.2, at http://michael.dipperstein.com/lzss/

LICENSE AND COPYRIGHT
Copyright 2008 Zed Pobre

Licensed to the public under the terms of the GNU GPL, version 2.