Christophe Gisquet: > This would have also helped a bitstream reader with a cache > of 32 bits. > --- > libavcodec/bitstream_template.h | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/bitstream_template.h b/libavcodec/bitstream_template.h > index 3f90fc6a07..c27e8108b2 100644 > --- a/libavcodec/bitstream_template.h > +++ b/libavcodec/bitstream_template.h > @@ -423,8 +423,18 @@ static inline const uint8_t *BS_FUNC(align)(BSCTX *bc) > */ > static inline int BS_FUNC(read_xbits)(BSCTX *bc, unsigned int n) > { > - int32_t cache = BS_FUNC(peek)(bc, 32); > - int sign = ~cache >> 31; > + int32_t cache; > + int sign; > + > + if (n > bc->bits_valid) > + BS_FUNC(priv_refill_32)(bc); > + > +#if defined(BITSTREAM_READER_LE) > + cache = bc->bits & 0xFFFFFFFF; > +#else > + cache = bc->bits >> 32; > +#endif > + sign = ~cache >> 31; > BS_FUNC(skip_remaining)(bc, n); > > return ((((uint32_t)(sign ^ cache)) >> (32 - n)) ^ sign) - sign;
Great, this function has the same issue at the end of input as read_vlc. - Andreas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".