X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fput_bits.h;h=3ba9549948ee09858a38b078cd6690d8e1ec94dc;hb=aa5e49e46d3aa22cc805c85a982afac1405aede5;hp=ddd97906b2f91323d7fbaa1bd5900fc583587c43;hpb=88d80cb97528d52dac3178cf5393d6095eca6200;p=ffmpeg diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index ddd97906b2f..3ba9549948e 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -364,13 +364,13 @@ static inline void skip_put_bytes(PutBitContext *s, int n) /** * Skip the given number of bits. * Must only be used if the actual values in the bitstream do not matter. - * If n is 0 the behavior is undefined. + * If n is < 0 the behavior is undefined. */ static inline void skip_put_bits(PutBitContext *s, int n) { - s->bit_left -= n; - s->buf_ptr -= sizeof(BitBuf) * ((unsigned)s->bit_left / BUF_BITS); - s->bit_left &= (BUF_BITS - 1); + unsigned bits = BUF_BITS - s->bit_left + n; + s->buf_ptr += sizeof(BitBuf) * (bits / BUF_BITS); + s->bit_left = BUF_BITS - (bits & (BUF_BITS - 1)); } /**