- // ... boring stuff here
- RansEncPut(enc.rans, enc.rans_offset, k, 1, prob_bits - 1);
+ // Put the coefficient as a 1/(2^12) symbol _before_
+ // the 255 coefficient, since the decoder will read the
+ // 255 coefficient first.
+ RansEncPut(enc.rans, enc.rans_offset, k, 1, prob_bits);