[FFmpeg-devel] [Patch] Fix for static leaks in h264.c
Michael Niedermayer
michaelni
Wed Jul 30 21:29:24 CEST 2008
On Tue, Jul 29, 2008 at 03:13:20PM -0700, Art Clarke wrote:
> 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?
The macro is an additional layer the reader has to understand and its
not reducing the number of lines of code.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080730/6472bb27/attachment.pgp>
More information about the ffmpeg-devel
mailing list