[FFmpeg-devel] [PATCH] get/show_bits() can read up to MIN_CACHE_BITS bits

Måns Rullgård mans
Mon Feb 22 12:43:07 CET 2010


Stefan Gehrer <stefan.gehrer at gmx.de> writes:

> M?ns Rullg?rd wrote:
>> Stefan Gehrer <stefan.gehrer at gmx.de> writes:
>>
>>> Mans Rullgard wrote:
>>>> The limit for get/show_bits_long() to use get/show_bits() directly
>>>> should be MIN_CACHE_BITS, not 17.
>>> I think something like attached should go with it.
>>> Index: libavcodec/get_bits.h
>>> ===================================================================
>>> --- libavcodec/get_bits.h	(revision 21936)
>>> +++ libavcodec/get_bits.h	(working copy)
>>> @@ -356,7 +356,7 @@
>>>  }
>>>   /**
>>> - * reads 1-17 bits.
>>> + * reads between 1 and MIN_CACHE_BITS bits.
>>>   * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
>>>   */
>>>  static inline unsigned int get_bits(GetBitContext *s, int n){
>>> @@ -370,7 +370,7 @@
>>>  }
>>>   /**
>>> - * shows 1-17 bits.
>>> + * shows between 1 and MIN_CACHE_BITS bits.
>>>   * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
>>>   */
>>>  static inline unsigned int show_bits(GetBitContext *s, int n){
>> I disagree.  17 is the maximum number of bits guaranteed to be
>> readable with any choice of implementation.  If you want to improve
>> the documentation, you should explain how MIN_CACHE_BITS is assigned
>> somewhere.  You should also make it clear that a specific reader
>> should be forced only in special cases.
>
> So people that use an alternative bitstream reader should still call
> the functions with n<=17 in order to keep the readers interchangeable.
> Makes sense.
> Since I don't know when it is indicated to use another than the
> default reader, I can't improve the documentation much, so just
> forget the patch.

A few codecs set ALT_BITSTREAM_READER_LE.  The rest should be using
the default.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list