| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- namespace System.Net.ApiService.Compression.Brotli {
- /// <summary>Contains a collection of huffman trees with the same alphabet size.</summary>
- internal sealed class HuffmanTreeGroup {
- /// <summary>The maximal alphabet size in this group.</summary>
- private int alphabetSize;
- /// <summary>Storage for Huffman lookup tables.</summary>
- internal int[] codes;
- /// <summary>
- /// Offsets of distinct lookup tables in
- /// <see cref="codes"/>
- /// storage.
- /// </summary>
- internal int[] trees;
- /// <summary>Initializes the Huffman tree group.</summary>
- /// <param name="group">POJO to be initialised</param>
- /// <param name="alphabetSize">the maximal alphabet size in this group</param>
- /// <param name="n">number of Huffman codes</param>
- internal static void Init(System.Net.ApiService.Compression.Brotli.HuffmanTreeGroup group, int alphabetSize, int n) {
- group.alphabetSize = alphabetSize;
- group.codes = new int[n * System.Net.ApiService.Compression.Brotli.Huffman.HuffmanMaxTableSize];
- group.trees = new int[n];
- }
- /// <summary>Decodes Huffman trees from input stream and constructs lookup tables.</summary>
- /// <param name="group">target POJO</param>
- /// <param name="br">data source</param>
- internal static void Decode(System.Net.ApiService.Compression.Brotli.HuffmanTreeGroup group, System.Net.ApiService.Compression.Brotli.BitReader br) {
- int next = 0;
- int n = group.trees.Length;
- for (int i = 0; i < n; i++) {
- group.trees[i] = next;
- System.Net.ApiService.Compression.Brotli.Decode.ReadHuffmanCode(group.alphabetSize, group.codes, next, br);
- next += System.Net.ApiService.Compression.Brotli.Huffman.HuffmanMaxTableSize;
- }
- }
- }
- }
|