Simple Algorithm
Note below that this is the Rice-Golomb encoding, where the remainder code uses simple truncated binary encoding, also named "Rice coding" (other varying-length binary encodings, like arithmetic or Huffman encodings, are possible for the remainder codes, if the statistic distribution of remainder codes is not flat, and notably when not all possible remainders after the division are used). In this algorithm, if the M parameter is a power of 2, it becomes equivalent to the simpler Rice encoding.
- Fix the parameter M to an integer value.
- For N, the number to be encoded, find
- quotient = q = int
- remainder = r = N modulo M
- Generate Codeword
- The Code format :
, where - Quotient Code (in unary coding)
- Write a q-length string of 1 bits
- Write a 0 bit
- Remainder Code (in truncated binary encoding)
- If M is power of 2, code remainder as binary format. So bits are needed. (Rice code)
- If M is not a power of 2, set
- If code r as plain binary using b-1 bits.
- If code the number in plain binary representation using b bits.
- The Code format :
Read more about this topic: Golomb Coding
Famous quotes containing the word simple:
“Cannot a plain man live and think no harm,
But that his simple truth must be abused
With silken, sly, insinuating Jacks?”
—William Shakespeare (15641616)
Related Phrases
Related Words