[Vorbis-dev] Reg. getting codewords from codelengths

Sebastian Gesemann sgeseman at upb.de
Mon Aug 8 10:17:27 PDT 2005


Shashank Khanvilkar wrote:
> Hi,
> I am a bit confused on how code-words are derived from the codeword
> lengths. I will appreciate if someone can point me in the correct
> direction.
> 
> I will take the example of an actual codebook that i found in a valid
> vorbis encoded file as shown below.
> 
> [SK] +------Codebook [0] --------
> [SK] Codebook Dimensions = 1
> [SK] Codebook Entries = 8
> [SK] Unordered
> [SK] 1, 6, 3, 7, 2, 5, 4, 7,
> [SK] NO Mapping
> [SK] +------Codebook [1] --------
> 
> What are the correspnding codewords? I have written below a few, but I
> think they might be wrong.
> 
> ---------------------------
> Entry len   |    Codeword |
> ---------------------------
> 1           |  0
> 6           |  100000
> 3           |  000
> 7           |  10000000
> 2           |
> 5           |
> 4           |
> 7           |
> 
> Shank

The following assignment should be correct:

---------------------------
Entry len   |    Codeword |
---------------------------
1           |  0
6           |  100000
3           |  101
7           |  1000010
2           |  11
5           |  10001
4           |  1001
7           |  1000011

The code is always the smallest (if interpreted as integer in binary)
possible with that length so that there're no conflicts with the already
generated ones above (ie codes have to be prefix-free).


Sebi


More information about the Vorbis-dev mailing list