[FFmpeg-devel] [libav-devel] [PATCH] Fixed size unit given to init_get_bits()

Laurent Aimar fenrir at elivagar.org
Sat Sep 10 01:00:46 CEST 2011


Hi,

On Fri, Sep 09, 2011 at 03:46:26PM -0700, Ronald S. Bultje wrote:
> On Fri, Sep 9, 2011 at 3:20 PM, Laurent Aimar <fenrir at elivagar.org> wrote:
> >  I reviewed all calls to init_get_bits() and fixed every instance where
> > the unit used was bytes instead of bits except for libavcodec/xan.c
> > where it is called with a size of 0...
> [..]
> > --- a/libavcodec/avs.c
> > +++ b/libavcodec/avs.c
> > @@ -117,7 +117,7 @@ avs_decode_frame(AVCodecContext * avctx,
> >      table = buf + (256 * vect_w * vect_h);
> >      if (sub_type != AVS_I_FRAME) {
> >          int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
> > -        init_get_bits(&change_map, table, map_size);
> > +        init_get_bits(&change_map, table, map_size * 8);
> 
> I'm not sure I understand this code.
 If you look at the loop just below, you have:

    for (y=0; y<198; y+=vect_h) {
        for (x=0; x<318; x+=vect_w) {
            if (sub_type == AVS_I_FRAME || get_bits1(&change_map)) {
                ...
	}
    }

ie at most 198 * 318/vect_w bits are read which explain the formula used for
map_size. (In this instance, the size given to init_get_bits() is pretty
useless as it is unrelated to the real accessible size, but that's another
issue IMHO)

Regards,

-- 
fenrir



More information about the ffmpeg-devel mailing list