Data::BitStream::Code::GammaGolomb - A Role implementing Gamma-Golomb codes
version 0.03
A role written for Data::BitStream that provides get and set methods for Gamma-Golomb codes. The role applies to a stream object.
Gamma-Golomb codes are basically Golomb codes using the Elias Gamma code for the quotient instead of a Unary code. This makes them suitable for occasional large outliers that would otherwise use thousands or millions of bits to encode.
In particular, the GammaGolomb(3) code is interesting for some distributions.
Insert one or more values as Gamma-Golomb codes with parameter m. Returns 1.
Decode one or more Gamma-Golomb codes from the stream. If count is omitted, one value will be read. If count is negative, values will be read until the end of the stream is reached. In scalar context it returns the last code read; in array context it returns an array of all codes read.
The parameter m must be an integer greater than or equal to 1.
m
The quotient of value / m is encoded using an Elias Gamma code, followed by the remainder in truncated binary form.
value / m
Note: if m == 1 then the result will be coded purely using gamma coding.
m == 1
Note: if m is a power of 2 (m = 2^k for some non-negative integer k), then the result is equal to the simpler ExpGolomb(k) code, where the operations devolve into a shift and mask.
m = 2^k
k
ExpGolomb(k)
These methods are required for the role.
Dana Jacobsen <dana@acm.org>
Copyright 2011 by Dana Jacobsen <dana@acm.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::BitStream, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::BitStream
CPAN shell
perl -MCPAN -e shell install Data::BitStream
For more information on module installation, please visit the detailed CPAN module installation guide.