Named after Robert Rice, Rice coding is a specialised form of Golomb coding. It's used to encode strings of numbers with a variable bit length for each number. If most of the numbers are small, fairly good compression can be achieved. Rice coding is generally used to encode entropy in an audio/video codec.
Rice coding depends on a parameter k and works the same as Golomb coding with a parameter m where m = 2k. To encode a number, x:
Decoding works the same way, just backwards. You can see my implementation here:
The encoder calculates the output length of a Rice coding using all values of k between 0 and 7, then encodes the input data using the k value that will create the shortest compressed file.
In general, a lower value of k will make smaller numbers cheaper and bigger numbers more expensive to store, while a bigger value of k will make big numbers relatively cheap to store, while increasing the storage overhead on all smaller values and making them more expensive to store. For example:
|
http://www.firstpr.com.au/audiocomp/lossless/
Valid XHTML 1.1
copyright © 2004 Emil Mikulic
$Date: 2006/04/22 07:06:40 $