[FFmpeg-devel] [PATCH 1/2] avcodec/put_bits: Parametrize bit buffer type

Michael Niedermayer michael at niedermayer.cc
Sat Jul 18 14:34:55 EEST 2020


On Fri, Jul 17, 2020 at 09:41:19PM +0200, Steinar H. Gunderson wrote:
> Preparatory patch for making the bit buffer different size on different
> platforms; make a typedef and make all the hardcoded sizes into expressions
> deriving from this size.
> 
> No functional change; generated assembler is near-identical.
> ---
>  libavcodec/put_bits.h | 95 +++++++++++++++++++++++--------------------
>  1 file changed, 52 insertions(+), 43 deletions(-)
[...]

> @@ -346,8 +352,8 @@ static inline void skip_put_bytes(PutBitContext *s, int n)
>  static inline void skip_put_bits(PutBitContext *s, int n)
>  {
>      s->bit_left -= n;
> -    s->buf_ptr  -= 4 * (s->bit_left >> 5);
> -    s->bit_left &= 31;
> +    s->buf_ptr  -= sizeof(BitBuf) * ((unsigned)s->bit_left / BUF_BITS);
> +    s->bit_left &= (BUF_BITS - 1);
>  }
>  
>  /**
> @@ -357,9 +363,12 @@ static inline void skip_put_bits(PutBitContext *s, int n)
>   */
>  static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
>  {
> -    av_assert0(size <= INT_MAX/8 - 32);
> +    av_assert0(size <= INT_MAX/8 - BUF_BITS);

this from libavcodec/mpegvideo_enc.c 
            set_put_bits_buffer_size(&s->pb, FFMIN(s->thread_context[i]->pb.buf_end - s->pb.buf, INT_MAX/8-32));
needs to be updated too

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200718/bbbe529d/attachment.sig>


More information about the ffmpeg-devel mailing list