selectHuffmanTables
private fn
HuffmanTableSelection selectHuffmanTables(const(ushort)[] symbols,
const(uint)[] mtfFreqs,
int alphaSize) pureSelect Huffman tables for MTF-encoded symbols using iterative optimization.
Implements the bzip2 multi-table Huffman scheme:
- Determine number of tables based on symbol count.
- Create initial table assignment by partitioning the frequency range.
- Iteratively optimize: divide symbols into groups of BZ_G_SIZE,
select the table with minimum encoding cost per group, regenerate codes from accumulated frequencies.
- MTF-encode the selector sequence.