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

Art Clarke aclarke
Thu Jun 26 20:07:20 CEST 2008


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.

- Art
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixstaticleaks_patch2.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080626/18ac8a75/attachment.txt>



More information about the ffmpeg-devel mailing list