[Vorbis-dev] Reg. getting codewords from codelengths

Graham Mitchell graham at grahammitchell.com
Mon Aug 8 11:00:03 PDT 2005


> Thanks.. in the below case, if tehre is one more line with codelenght
> "7", what would be the codeword assigned to it.
>
> > ---------------------------
> > Entry len   |    Codeword |
> > ---------------------------
> > 1           |  0
> > 6           |  100000
> > 3           |  101
> > 7           |  1000010
> > 2           |  11
> > 5           |  10001
> > 4           |  1001
> > 7           |  1000011

You mean if there were a third line with length 7?  That can't happen.

If one of the 7s is "1000010" and another is "1000011", then you're done.

These code come from a Huffman tree.  It's a binary tree, and each node either 
has no children (it's a leaf) or it has two children.  Codes come from the 
paths from the root of the tree to the leaves.

If you go left, that's a 0; if you go right, that's a 1.

So, "0" means "Start at the root, go left, then stop".
"101" means "Start at the root, go right, left, right, then stop."
"1000010" is "right, left, left, left, left, right, left, stop", and so
"1000011" is "right, left, left, left, left, right, right, stop".

I've you've already been left from a node and then right from that node, then 
that node has no more exits.

-- 
Graham Mitchell - computer science teacher, Leander High School
"Given the pace of technology, I propose we leave math to the machines and go
play outside."
	-- Calvin


More information about the Vorbis-dev mailing list