ONE STAGE OF A CHAIN — WHAT ARRIVES, WHAT LEAVES, WHAT BREAKS DOWNSTREAM
Where This Sits In The Encoding Pipeline
A video encoder is not one algorithm but eight stages in a fixed order, and the order is not arbitrary: each stage exists because the one before it made its job possible. This tool models one of them. The chain below links to the other seven.
Entropy Coding Playground — packs the quantized symbols into as few bits as their statistics permit
- What arrives
- A stream of quantized integers, heavily skewed toward zero.
- What leaves
- The finished bitstream. Nothing is discarded here.
- What the next stage assumes
- Nothing downstream — this is the last coding stage. What it assumes is upstream: that the symbol distribution has already been made lopsided for it.
- What goes wrong here
- No entropy coder can beat the Shannon entropy of what it is handed, so its ceiling is set entirely by the earlier stages. Run it on unquantized coefficients and there is little redundancy to find, which is the reason the lossy step comes first rather than last.
Problem solved in full
-
The room left for a cleverer algorithm than Huffman on 16 symbols 6 steps
16 symbols, Laplacian distribution, entropy 3.010 bits. Huffman achieves 3.012. Work out how much room is left for a cleverer algorithm.
-
Entropy is the average surprise, in bits, of one symbol drawn from this distribution. It is a property of the probabilities alone and knows nothing about any code.
-
The naive alternative gives every symbol the same number of bits, and 16 symbols need 4. This is the baseline the saving is measured against.
-
Huffman gives short codes to common symbols and long ones to rare ones, and the average is the probability-weighted length.
-
The saving compares the two code lengths, not the code with the entropy — which is why it is a claim about this alternative rather than about the limit.
-
Now compare against the limit. Shannon's source coding theorem says no prefix code can go below H, and Huffman is guaranteed to land under H + 1.
-
Express the remaining gap as a fraction and the optimisation question answers itself.
Answer
0.002 bits per symbol, or 0.07%. Shannon's theorem brackets any prefix code between H and H + 1, and Huffman is proven optimal among them, so no prefix code will ever beat 3.012 on this text. The 24.7% saving over fixed-length coding is real, and the remaining 0.07% is the whole of what better engineering could ever add. Compression gains after this point by changing the model rather than the code: if neighbouring symbols correlate, the entropy of the conditional distribution is lower than 3.010, and that is a different number entirely.
-
References (1)
- Insight block 2 — entropy as average surprise, and the limit Huffman cannot beat: C. E. Shannon, "A Mathematical Theory of Communication." Bell System Technical Journal 27(3), 379–423, 1948.