Huffman coding

From ioquake3 wiki
Revision as of 18:41, 15 December 2007 by TimeDoctor (talk | contribs) (1 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ioquake3 compresses all of its messages using Huffman coding to save bandwidth. The MSG_WriteBits() function uses Huff_putBit() and Huff_offsetTransmit() to compress data as a message is composed. These functions use a static coding tree that is seeded by MSG_initHuffman(). The contents of the tree is defined in msg_hData, which is presumably tuned to compress typical message data as efficiently as possible.

The NET_OutOfBandData() function uses Huff_Compress() to compress an entire message at once. This function uses adaptive Huffman coding, where every message starts with an empty coding tree.