0
votes

If Huffman code is a prefix code why JPEG's DC and AC coefficients are encoded as pairs of [length][bits]? Why we need length prefix at all?

And why we encode lengths of values and not values themselves (correct me if I'm wrong)?

1

1 Answers

0
votes

Because you've got long runs of zero entries. You'd need a bit zero to encode the zeroes. Then you'd get runs of zeros, which is undesireable for electrical engineering reasons - it can cause a sender and receiver to go out of synchronisation if you send longs tuns of the same bit, and runs are also used for signal synchronisation in MPEG.