Struct StreamCompressionModel
A type that uses Huffman encoding to encode values in a lossless manner.
Namespace: Unity.Collections
Assembly: solution.dll
Syntax
public struct StreamCompressionModel
Remarks
This type puts values into a manageable number of power-of-two-sized buckets. It codes the bucket index with Huffman, and uses several raw bits that correspond to the size of the bucket to code the position in the bucket.
For example, if you want to send a 32-bit integer over the network, it's impractical to create a Huffman tree that encompasses every value the integer can take because it requires a tree with 2^32 leaves. This type manages that situation.
The buckets are small, around 0, and become progressively larger as the data moves away from zero. Because most data is deltas against predictions, most values are small and most of the redundancy is in the error's size and not in the values of that size we end up hitting.
The context is as a sub-model that has its own statistics and uses its own Huffman tree. When using the context to read and write a specific value, the context must always be the same. The benefit of using multiple contexts is that it allows you to separate the statistics of things that have different expected distributions, which leads to more precise statistics, which again yields better compression. More contexts does, however, result in a marginal cost of a slightly larger model.
Properties
Name | Description |
---|---|
Default | A shared singleton instance of StreamCompressionModel, this instance is initialized using hardcoded bucket parameters and model. |
Methods
Name | Description |
---|---|
CalculateBucket(uint) | Calculates the bucket index into the encodeTable where the specified value should be written. |