Bug 17: Botched Bitwise Arithmetic Decoder
- This is a state-of-the-art entropy decoder. It consumes a sequence of bytes from the encoder.
- Each bit is decoded using the same probability that the encoder used: How likely is this bit to be 1?
- 0 <= probability1 <= 65535 (0 denotes a probability near 0 and 65535 denotes a probability near 1)
- For each bit, this code splits a numeric range (from lo to hi, inclusive) according to probability1.
- The bytes received from the encoder indicate which side of that split to select.
- The selected side becomes the new numeric range: lo or hi is updated, just like in the encoder.
- Both sides of the split always contain at least one number. If lo becomes equal to hi, that is ok.
- Side selection also yields an output bit. This code returns true to indicate a 1-bit.
- When the most-significant byte of lo matches the most-significant byte of hi, both bytes are discarded.
- As lo/hi bytes are discarded, additional bytes from the encoder are consumed.
Fix The Tiny Bug In This Go Code: