On Thu, Jun 9, 2016 at 11:12 AM, Diego Biurrun <di...@biurrun.de> wrote: > From: Luca Barbato <lu_z...@gentoo.org> > > --- > libavcodec/dvdec.c | 122 > ++++++++++++++++++++++++++++++----------------------- > 1 file changed, 69 insertions(+), 53 deletions(-) > > diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c > index 463d108..3ccd672 100644 > --- a/libavcodec/dvdec.c > +++ b/libavcodec/dvdec.c > @@ -40,9 +40,9 @@ > #include "libavutil/pixdesc.h" > > #include "avcodec.h" > +#include "bitstream.h" > #include "dv.h" > #include "dvdata.h" > -#include "get_bits.h" > #include "idctdsp.h" > #include "internal.h" > #include "put_bits.h" > @@ -79,52 +79,63 @@ static av_cold int dvvideo_decode_init(AVCodecContext > *avctx) > return ff_dvvideo_init(avctx); > } > > +// unwind the cache so a fill32 can fill it back > +static void bitstream_unwind(BitstreamContext *bc) > +{ > + int unwind = 4; > + int unwind_bits = unwind * 8; > + > + if (bc->bits_left < unwind_bits) > + return; > + > + bc->bits >>= unwind_bits; > + bc->bits <<= unwind_bits; > + bc->bits_left -= unwind_bits; > + bc->ptr -= unwind; > +} > + > +// unget up to 32 bits > +static void bitstream_unget(BitstreamContext *bc, uint64_t value, int size) > +{ > + int cache_size = sizeof(bc->bits) * 8; > + > + if (bc->bits_left + size > cache_size) > + bitstream_unwind(bc); > + > + bc->bits = (bc->bits >> size) | (value << (cache_size - size)); > + > + bc->bits_left += size; > +}
maybe these two functions could be dv_ prefixed to avoid clashing with the main bitstream API? -- Vittorio _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel