Archive for the ‘Game Video’ Category

Another codec in FFmpeg

Wednesday, March 22nd, 2006

Yesterday I’ve added implementation of Smacker demuxer and decoder, so you can enjoy you favourite pieces of video from various games.

I cannot credit the person who did the actual reverse engineering as he prefers to stay anonymous. Anyway, thank you very much!

The most interesting things in Smacker are Huffman trees. Smacker has trees by principle “every byte must have a tree”. Video operates with 16-bits values from Huffman trees, every of this trees stores values as two codes from Huffman trees. So you must construct two smaller Huffman trees before decoding large one. And packed audio data has also 1,2 or 4 Huffman trees depending if we have 8-bit or 16-bit data and stereo or not.

And now spotted inefficiencies in Smacker:

  • Smacker stores header information for 7 audio streams (!) yet I’ve never seen Smacker with two audio streams. Was that intended for internationalization?
  • Due to weird Huffman tree decoding procedure one bit is constantly wasted on stream. That means global Huffman trees for video lack 12 bits of waste (two support Huffman trees, one large Huffman tree, repeat four times) and audio chunks waste 1-4 bits depending on size. Not a big deal though.

And the final thought – the main difference between Smacker and M$ Video 1 is the packing scheme, block structure is almost identical. Anyone volunteering to write convertor from one format to another?