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

Michael Niedermayer michaelni
Sun Jun 29 14:06:19 CEST 2008


On Thu, Jun 26, 2008 at 02:07:20PM -0400, Art Clarke wrote:
> On Wed, Jun 25, 2008 at 9:25 AM, Michael Niedermayer <michaelni at gmx.at>
> wrote:
> 
> > On Wed, Jun 25, 2008 at 09:14:11AM -0400, Art Clarke wrote:
> > [...]
> > > Agree with both of you, but Michael does point the way to a more elegant
> > > solution I think.
> > >
> > > Attempt #2.
> > >
> > > - Art
> >
> > > Index: libavcodec/h264.c
> > > ===================================================================
> > > --- libavcodec/h264.c (revision 13962)
> > > +++ libavcodec/h264.c (working copy)
> > > @@ -48,14 +48,32 @@
> > >   */
> > >  #define DELAYED_PIC_REF 4
> > >
> > > +// Overallocate each table to the largest table; this wastes
> > > +// a few bytes on the stack at startup, but leads to simpler
> > > +// code
> > >  static VLC coeff_token_vlc[4];
> > > +static VLC_TYPE coeff_token_vlc_tables[4][520][2];
> > > +static const int coeff_token_vlc_tables_size[4] = { 520, 332, 280, 256
> > };
> >
> > coeff_token_vlc_tables[520+332+280+256][2];
> > would avoid the overalloc
> 
> 
> Hi Michael et al,
> 
> Don't know if you saw this, but:
> - The varying static array is now a fully packed array (no wasted space).
> - We compute offsets dynamically while initializing it based on the
> ..._tables_size array.
> - We do one assert at the end of initialization to catch any "stupid
> programmer bugs" like when I mistyped an offset in prior change.
> 
> This passes 100% of Vlideshow tests on h264-encoded video files.  All
> resulting audio and video sounds and looks correct.
> This passes 100% of ffmpeg regression tests (make fulltest) when run on
> Fedora 7 static builds (which is the only way regression tests pass at all
> for me).
> There are no new log messages showing up.
> 
> Let me know if this works.  I have one more patch (for mpegaudiodec.c) that
> depends on this if accepted.

Iam fine with the patch in principle but not the do/while(). I do not like
do-whiled macros.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- 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/20080629/c08c67c8/attachment.pgp>



More information about the ffmpeg-devel mailing list