JpegHuffmanTable

Ecng.Drawing

Canonical JPEG Huffman codes with an eight-bit lookup and compact tables for longer prefixes.

Constructores

JpegHuffmanTable
public JpegHuffmanTable(ReadOnlySpan<byte> counts, ReadOnlySpan<byte> symbols)
jpegHuffmanTable = JpegHuffmanTable(counts, symbols)
counts
How many codes there are of each length from 1 to 16.
symbols
The symbols, in order of their codes.

Métodos

Optimize
public static byte[] Optimize(ReadOnlySpan<int> frequencies, Span<byte> counts)
result = JpegHuffmanTable.Optimize(frequencies, counts)

Works out the table that makes a scan shortest: the more often a symbol occurs, the shorter its code (section K.2 of the standard). No code is longer than sixteen bits, and none is all ones.

frequencies
How many times each of the 256 symbols occurs; at least one of them does.
counts
Receives how many codes there are of each length from 1 to 16.

Devuelve: The symbols that occur, in order of their codes.