#define APPEND_RESIDUE(N, M) \
N |= M >> (N ## _bits); \
- N ## _bits += (M ## _bits)
+ N ## _bits = (N ## _bits + (M ## _bits)) & 0x3F
int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf,
int bytes, uint8_t *_dst, int coeffs)
INIT_RESIDUE(res);
SET_RESIDUE(res, idx, LUT_BITS);
- l->preamble = CONVERT_TO_RESIDUE(res >> (RSIZE_BITS - off), off);
l->preamble_bits = off;
- l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1;
+ if (off) {
+ l->preamble = CONVERT_TO_RESIDUE(res >> (RSIZE_BITS - off), off);
+ l->sign = ((l->preamble >> (RSIZE_BITS - l->preamble_bits)) & 1) ? -1 : +1;
+ } else {
+ l->preamble = 0;
+ l->sign = 1;
+ }
search_for_golomb(l, res << off, LUT_BITS - off);
}