public
Description: Range Coder for Perl
Homepage:
Clone URL: git://github.com/naoya/perl-algorithm-rangecoder.git
name age message
file Changes Loading commit data...
file MANIFEST
file Makefile.PL
file README
directory examples/
directory inc/
directory lib/
directory t/
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.