hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright 2015 Google Inc. All Rights Reserved.
 
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
namespace Org.Brotli.Dec
{
   /// <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(Org.Brotli.Dec.HuffmanTreeGroup group, int alphabetSize, int n)
       {
           group.alphabetSize = alphabetSize;
           group.codes = new int[n * Org.Brotli.Dec.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(Org.Brotli.Dec.HuffmanTreeGroup group, Org.Brotli.Dec.BitReader br)
       {
           int next = 0;
           int n = group.trees.Length;
           for (int i = 0; i < n; i++)
           {
               group.trees[i] = next;
               Org.Brotli.Dec.Decode.ReadHuffmanCode(group.alphabetSize, group.codes, next, br);
               next += Org.Brotli.Dec.Huffman.HuffmanMaxTableSize;
           }
       }
   }
}