[FFmpeg-devel] [PATCH v2] add put_bits_long to avoid undefined behaviour in put_bits

Diego Biurrun diego
Tue Aug 25 21:49:37 CEST 2009


On Tue, Aug 25, 2009 at 09:45:08PM +0200, matthieu castet wrote:
> 
> --- libavcodec/put_bits.h	(r?vision 19681)
> +++ libavcodec/put_bits.h	(copie de travail)
> @@ -259,6 +259,22 @@
>  
> +static inline void put_bits_long(PutBitContext *s, int n, unsigned int value)
> +{
> +    if(n<=31) 

if (n <= 31)

> --- libavcodec/alacenc.c	(r?vision 19681)
> +++ libavcodec/alacenc.c	(copie de travail)
> @@ -123,7 +123,7 @@
>      put_bits(&s->pbctx, 2,  0);                             // FIXME: Wasted bytes field
>      put_bits(&s->pbctx, 1,  is_verbatim);                   // Audio block is verbatim
> -    put_bits(&s->pbctx, 32, s->avctx->frame_size);          // No. of samples in the frame
> +    put_bits_long(&s->pbctx, 32, s->avctx->frame_size);          // No. of samples in the frame

This should remain aligned.


Wait for more comments before sending in new patches.

Diego



More information about the ffmpeg-devel mailing list