[FFmpeg-devel] [PATCH 2/4] lavc: add standalone cached bitstream reader

Anton Khirnov anton at khirnov.net
Thu Jun 30 15:16:01 EEST 2022


Quoting Andreas Rheinhardt (2022-06-23 20:56:00)
> Anton Khirnov:
> > + */
> > +static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned int n)
> > +{
> > +    if (!n)
> > +        return 0;
> 
> This makes this function a get_bitsz equivalent. Why is there no
> get_bits() equivalent for the cases where it is known that n is not
> zero, but where it is impossible for the compiler to know?

I did not write this code, but I suppose because there were many bugs in
the past where get_bits(0) was called and the advantage did not seem
worth the risk.

If you think such a function would be useful, I'd prefer it to be a
non-default variant, e.g. bits_read_nz.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list