[FFmpeg-devel] skip_put_bits() bugged?

Stefano Sabatini stefano.sabatini-lala
Tue Mar 31 21:49:56 CEST 2009


On date Tuesday 2009-03-31 21:36:27 +0200, Stefano Sabatini encoded:
> On date Tuesday 2009-03-31 20:44:34 +0200, Michael Niedermayer encoded:
> > On Tue, Mar 31, 2009 at 08:15:15PM +0200, Stefano Sabatini wrote:
> [...]
> > > My previous fix adds a check, so it slows down it a little, but I
> > > don't see other alternatives but to change the other functions (such
> > > as put_bits() to make bit_left only take values less than 32.
> > 
> > i dont see any bug that you fix i just see a slowdown you create,
> > if there is a bug id like to see full ffmpeg output from an unmodified ffmpeg
> 
> Uh, looks like you're right.
> 
> Patch attached, regards.
> -- 
> FFmpeg = Friendly Fundamentalist Mean Patchable Ecletic Gadget

> Index: libavcodec/bitstream.h
> ===================================================================
> --- libavcodec/bitstream.h	(revision 18174)
> +++ libavcodec/bitstream.h	(working copy)
> @@ -337,6 +337,7 @@
>  /**
>   * Skips the given number of bits.
>   * Must only be used if the actual values in the bitstream do not matter.
> + * If \p n is 0 the behavior is undefined.
>   */
>  static inline void skip_put_bits(PutBitContext *s, int n){
>  #ifdef ALT_BITSTREAM_WRITER

Another idea may be to define another skip_put_bits() variant
(skip_put_bits2()?) which does the check, it would simplify code which
does for example:

if (a*b+c-d/e*f) skip_put_bits(&pb, a*b+c-d/e*f);

Regards.
-- 
FFmpeg = Fast and Faithless Minimal Puristic Extreme Gymnast



More information about the ffmpeg-devel mailing list