VLC readers

From MultimediaWiki
Jump to navigation Jump to search

Here will be a collection of different approaches used by diverse codecs to read variable-length codes from bitstream:


Fraps

Huffman tree has its nodes pointing to the root and thus operating like state machine:

 get bit
 move to the one of node children depending of bit read
 output current node value
 if node value was '-1' then stay at the current position, else move further
 repeat until all needed values are decoded

Intel Music Coder

This reader has special reordering table to sort symbols in ascending codeword lengths:

 for(i = 0; i < symbols; i++){
   sym = reorder[i];
   if(show_bits(code_length[sym]) == code[sym]){
     return sym;
   }
 }