This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
README
NAME
Algorithm::RangeCoder - Data compression with Range Coder
SYNOPSIS
use Algorithm::RangeCoder;
use constant UCHAR_MAX => 0x100;
my $str = shift or die "usage: $0 <string>";
my @char = unpack('C*', $str);
my @freq;
for (my $i = 0; $i < UCHAR_MAX; $i++) {
$freq[$i] = 0;
}
for my $c (@char) {
$freq[$c]++;
}
my @cum = (0);
for (my $i = 0; $i < UCHAR_MAX; $i++) {
$cum[$i + 1] = $cum[$i] + $freq[$i];
}
my $rc = Algorithm::RangeCoder->new;
$rc->freq = \@freq;
$rc->cumfreq = \@cum;
my $bin = $rc->encode($str);
say "origin: ", $str;
say "decoded: ", $rc->decode( $bin );
DESCRIPTION
Range coder is an algorithm used for entropy coding in compression
algorithms.
SEE ALSO
<http://en.wikipedia.org/wiki/Range_encoding>
AUTHOR
Naoya Ito, <naoya at bloghackers.net<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Naoya Ito
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.8 or, at
your option, any later version of Perl 5 you may have available.








