[FFmpeg-devel] [Patch] Fix for static leaks in h264.c

Art Clarke aclarke
Wed Jul 30 00:13:20 CEST 2008


On Tue, Jul 29, 2008 at 1:57 PM, Michael Niedermayer <michaelni at gmx.at>wrote:

> [...]
> > -        init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
> > +        INIT_VLC_STATIC_WITH_TABLE(&run7_vlc, RUN7_VLC_BITS, 16,
> >                   &run_len [6][0], 1, 1,
> > -                 &run_bits[6][0], 1, 1, 1);
> > +                 &run_bits[6][0], 1, 1,
> > +                 run7_vlc_table,
> > +                 run7_vlc_table_size);
> >      }
> >  }
> >
> > Index: libavcodec/bitstream.h
> > ===================================================================
> > --- libavcodec/bitstream.h    (revision 14466)
> > +++ libavcodec/bitstream.h    (working copy)
> > @@ -769,7 +769,12 @@
> >  #define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\
> >  {\
> >      static VLC_TYPE table[static_size][2];\
> > -    (vlc)->table= table;\
> > +    INIT_VLC_STATIC_WITH_TABLE(vlc, bits, a,b,c,d,e,f,g, table,
> static_size);\
> > +}
> > +
>
> > +#define INIT_VLC_STATIC_WITH_TABLE(vlc, bits, a,b,c,d,e,f,g,
> static_table, static_size)\
> > +{\
> > +    (vlc)->table= static_table;\
> >      (vlc)->table_allocated= static_size;\
> >      init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\
> >  }
>
> Is this macro really needed?
>
> INIT_VLC_STATIC_WITH_TABLE(&run7_vlc, RUN7_VLC_BITS, 16,
>         &run_len [6][0], 1, 1,
>         &run_bits[6][0], 1, 1,
>         run7_vlc_table,
>         run7_vlc_table_size);
>
> vs.
>
> run7_vlc->table          = run7_vlc_table;
> run7_vlc->table_allocated= run7_vlc_table_size;
>
> init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
>         &run_len [6][0], 1, 1,
>         &run_bits[6][0], 1, 1, INIT_VLC_USE_NEW_STATIC);
>
>
> [...]


I think the macro is a good idea, mostly because there are a bunch of other
similar changes I'll be submitting in other files (e.g. the mpeg decoder has
a similar leak).  Without the macro, I'll be constantly referencing
"->table" and "->table_allocated" over and over.  I'd rather have it happen
once in the header file.

Not sure how much this is a democratic process (since you're the maintainer)
but my vote is put in the macro so my future submissions have fewer lines
changed.  Your thoughts?

- Art




More information about the ffmpeg-devel mailing list