NAME
Data::BitStream::Code::ExponentialGolomb - A Role implementing Exponential-Golomb codes
VERSION
version 0.08
DESCRIPTION
A role written for Data::BitStream that provides get and set methods for Exponential-Golomb codes. The role applies to a stream object.
Exponential-Golomb codes are Rice codes using an Elias Gamma code instead of a Unary code for the upper bits. Rice codes in turn are Golomb codes where the parameter m is a power of two. Hence:
Rice(k) ~ Golomb(2^k)
ExponentialGolomb(k) ~ GammaGolomb(2^k)
METHODS
Provided Object Methods
- put_expgolomb($k, $value)
- put_expgolomb($k, @values)
-
Insert one or more values as Exponential-Golomb codes with parameter k. Returns 1.
- get_expgolomb($k)
- get_expgolomb($k, $count)
-
Decode one or more Exponential-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.
Parameters
The parameter k
must be an integer greater than or equal to 0.
The quotient value >> k
is encoded using an Elias Gamma code, followed by the lowest k
bits.
Note: if k == 0
then the result will be coded purely using gamma coding.
Note: this is a special case of a GammaGolomb(m)
code where m = 2^k
.
Required Methods
- put_rice
- put_gamma
- get_rice
- get_gamma
-
These methods are required for the role.
SEE ALSO
- Data::BitStream::Code::Golomb
- Data::BitStream::Code::Rice
- Data::BitStream::Code::GammaGolomb
- http://en.wikipedia.org/wiki/Exponential-Golomb_coding
AUTHORS
Dana Jacobsen <dana@acm.org>
COPYRIGHT
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.