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:
$MaxOrder
max order for the PPM modelling ranging from 2 to 16, higher values produce better compression ratios but are slower.
Default value is 8.
$MemSizeMB
max memory in MB the compressor is able to use, bigger values improve compression.
Default value is 4MB.
$MRMethod
method of model restoration at memory insufficiency, possible values are:
MRM_RESTART=1
restart model from scratch (fast).
MRM_CUTOFF=2
cut off model (default, slow).
MRM_FREEZE=3
freeze model (faster but dangerous).
Default value is MRM_CUTOFF.
MRM_CUTOFF
$Solid
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.
$encoder->encode($data)
compresses a chunk of data.
$encoder->reset()
in solid mode reset causes the encoder to clean its memory.
solid
reset
$encoder->deflate($data)
wrapper around encode method for Compress::Zlib interface compatibility.
encode
$encoder->flush($mode)
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.
$decoder->decode($encoded_data)
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.
$decoder->reset()
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.
$encoder->reset
$decoder->reset
$encoder->inflate($data)
wrapper around decode method for Compress::Zlib interface compatibility.
decode
MRMethod constants when used with :mrm:
:mrm
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.
Compress::ZLib.
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 <sfandino@yahoo.com>
Copyright 2003 by Salvador Fandiño
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Based on code released to the public domain by Dmitry Shkarin.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Fandiño'. Assuming CP1252
To install Compress::PPMd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Compress::PPMd
CPAN shell
perl -MCPAN -e shell install Compress::PPMd
For more information on module installation, please visit the detailed CPAN module installation guide.