selectHuffmanTables

private fnHuffmanTableSelection selectHuffmanTables(const(ushort)[] symbols, const(uint)[] mtfFreqs, int alphaSize) pure

Select Huffman tables for MTF-encoded symbols using iterative optimization.

Implements the bzip2 multi-table Huffman scheme:

  1. Determine number of tables based on symbol count.
  2. Create initial table assignment by partitioning the frequency range.
  3. Iteratively optimize: divide symbols into groups of BZ_G_SIZE,

select the table with minimum encoding cost per group, regenerate codes from accumulated frequencies.

  1. MTF-encode the selector sequence.