diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c index 336d22a182..773f720858 100644 --- a/libavcodec/dirac_vlc.c +++ b/libavcodec/dirac_vlc.c @@ -216,9 +216,14 @@ static void generate_offset_lut(DiracGolombLUT *lut, int off) 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); }