namespace System.Net.ApiService.Compression.Brotli {
/// Contains a collection of huffman trees with the same alphabet size.
internal sealed class HuffmanTreeGroup {
/// The maximal alphabet size in this group.
private int alphabetSize;
/// Storage for Huffman lookup tables.
internal int[] codes;
///
/// Offsets of distinct lookup tables in
///
/// storage.
///
internal int[] trees;
/// Initializes the Huffman tree group.
/// POJO to be initialised
/// the maximal alphabet size in this group
/// number of Huffman codes
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];
}
/// Decodes Huffman trees from input stream and constructs lookup tables.
/// target POJO
/// data source
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;
}
}
}
}