On Wed, Sep 28, 2011 at 05:57:50PM -0700, Alex Converse wrote:
> show_bits() is undefined when the number of bits is less than or equal to
> zero.
> ---
>  libavcodec/proresdec.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
> index 759c10b..25c7f8d 100644
> --- a/libavcodec/proresdec.c
> +++ b/libavcodec/proresdec.c
> @@ -403,6 +403,10 @@ static uint8_t run_to_cb_index[16] =
>  
>  static uint8_t lev_to_cb_index[10] = { 0, 6, 3, 5, 0, 1, 1, 1, 1, 2 };
>  
> +static inline unsigned show_bits0(GetBitContext *s, int n)
> +{
> +    return n <= 0 ? 0 : show_bits(s, n);
> +}
>  
>  /**
>   * Decode AC coefficients for all blocks in a slice.
> @@ -427,13 +431,13 @@ static inline void decode_ac_coeffs(GetBitContext *gb, 
> DCTELEM *out,
>          lev_cb_index = lev_to_cb_index[FFMIN(level, 9)];
>  
>          bits_left = get_bits_left(gb);
> -        if (bits_left <= 8 && !show_bits(gb, bits_left))
> +        if (bits_left <= 8 && !show_bits0(gb, bits_left))
>              return;
>  
>          run = decode_vlc_codeword(gb, ac_codebook[run_cb_index]);
>  
>          bits_left = get_bits_left(gb);
> -        if (bits_left <= 8 && !show_bits(gb, bits_left))
> +        if (bits_left <= 8 && !show_bits0(gb, bits_left))
>              return;
>  
>          level = decode_vlc_codeword(gb, ac_codebook[lev_cb_index]) + 1;
> -- 

I think in this situation

 if (bits_left <= 0 || (bits_left <= 8 && !show_bits(gb, bits_left)))

should be enough.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to