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

matthieu castet castet.matthieu
Mon Sep 14 21:28:50 CEST 2009


Michael Niedermayer wrote:
> On Sun, Sep 13, 2009 at 03:17:01PM +0200, matthieu castet wrote:
>> Hi,
>>
>>  
>> +static inline void put_bits_long(PutBitContext *s, int n, unsigned int value)
>> +{
>> +    if(n <= 31) {
>> +        put_bits(s, n, value);
>> +    } else {
>> +#ifdef ALT_BITSTREAM_READER_LE
>> +        put_bits(s, 16, value & 0xffff);
>> +        put_bits(s, 16, value >> 16);
>> +#else
>> +        put_bits(s, 16, value >> 16);
>> +        put_bits(s, 16, value & 0xffff);
>> +#endif
>> +    }
>> +
>> +}
>> +
> 
> i dont think this should be static inline or where is it speed critical?
> 
Why not but :
- the equivalent "get_bits_long" is static inline.
- most of time it is called with const n/value arguments and the function will be optimised
- should we create a put_bits.c for putting only this function ?


Matthieu



More information about the ffmpeg-devel mailing list