Compress::PPMd - PPMd compression
use Compress::PPMd; my $encoder=Compress::PPMd::Encoder->new(); my $encoded=$encoder->encode($text); my $encoded2=$encoder->encode($text2); my $decoder=Compress::PPMd::Decoder->new(); my $decoded=$encoder->decode($encoded); my $decoded2=$encoder->decode($encoded2);
This package is a Perl wrapper around Dmitry Shkarin PPMd compression library.
PPMd produces the best compression ratios for textual data.
Compress::PPMd is compossed of two classes to compress and decompress data respectively:
Compress::PPMd::Encoder->new($MaxOrder, $MemSizeMB, $MRMethod, $Solid)
creates a new encoder object. The parameters are:
max order for the PPM modelling ranging from 2 to 16, higher values produce better compression ratios but are slower.
Default value is 8.
max memory in MB the compressor is able to use, bigger values improve compression.
Default value is 4MB.
method of model restoration at memory insufficiency, possible values are:
restart model from scratch (fast).
cut off model (default, slow).
freeze model (faster but dangerous).
Default value is
when true, chunks are compressed with data from previous chunks and so they are dependant and have to be decompressed in the same sequence.
Default value is true.
compresses a chunk of data.
reset causes the encoder to clean its memory.
encode method for Compress::Zlib interface compatibility.
do nothing method for Compress::Zlib interface compatibility.
Compress::PPMd::Decoder->new($MaxOrder, $MemSizeMB, $MRMethod, $Solid)
the decoder has to be initialized with the same parameters that were used to create the encoder or the decompressed data will be corrupted.
decodes a chunk of data generated by the encoder. Partial decodes are not possible, only full chunks *exactly* as generated by the encoder are accepted.
has the same function that the equivalent encoder method and has to be used symmetrically, that is, for every time
$encoder->reset is called
$decoder->reset also has to be called.
decode method for Compress::Zlib interface compatibility.
MRMethod constants when used with
This is a very early release, expect bugs.
Only tested on Linux and NetBSD, support for Win32 planned.
PPMd library doesn't work on 64bits architectures.
I will probably change the interface later.
PPMd library doen't checks for data validity when decompressing, this can cause crashes and introduce security holes in your code, so ...
DON'T USE THIS LIBRARY ON NETWORK APPLICATIONS
... unless you can trust both client and server programs.
Bug reports, patches and any feedback are appreciated.
Original PPMd I1 code at ftp://ftp.elf.stuba.sk/pub/pc/pack/ppmdi1.rar.
If you can read Russian, Dmitry Shkarin web pages at http://compression.graphicon.ru/ds/ may be of interest to you.
For general information about data compression visit http://DataCompression.info/.
Salvador Fandiño <firstname.lastname@example.org>
Copyright 2003 by Salvador Fandiño
Based on code released to the public domain by Dmitry Shkarin.