[FFmpeg-devel] MPADecodeContext on stack

Michael Niedermayer michaelni
Thu Jan 22 12:16:07 CET 2009


On Thu, Jan 22, 2009 at 11:48:23AM +0100, Benjamin Larsson wrote:
> M?ns Rullg?rd wrote:
> > Michael Niedermayer <michaelni at gmx.at> writes:
> >
> >   
> >> On Mon, Jan 19, 2009 at 05:56:54PM +0100, Andreas ?man wrote:
> >>     
> >>> Hi
> >>>
> >>> MPADecodeContext is allocated on the stack at two places:
> >>>
> >>> libavformat/mp3.c
> >>> libavcodec/mpegaudio_parser.c
> >>>
> >>> sizeof(MPADecodeContext) = ~23k
> >>>
> >>>       
> >>> This is, by far, the biggest stack consumer in ffmpeg.
> >>>       
> >> i do not belive this entirely
> >>     
> >
> > You believe correctly.  Here's a list of stack offenders on ARM:
> >
> > 6553600 encode_frame                   nellymoserenc.c:339
> >   
> Found the culprit.
> 
> #*define* OPT_SIZE ((1<<15) + 3000)
> 
> **
> *static* *void* *get_exponent_dynamic*(NellyMoserEncodeContext *s, *float* *cand, *int* *idx_table)
> {
>     *int* i, j, band, best_idx;
>     *float* power_candidate, best_val;
> 
>     *float* opt[NELLY_BANDS][OPT_SIZE];
>     *int* path[NELLY_BANDS][OPT_SIZE];
> 
> 3290656 * 2 = 6581312
> 
> 
> Should I move the tables to the context ?

only 2*OPT_SIZE elements of opt are needed for opt
path fits in uint8_t

except that, allocating it via malloc once during init when
AVCodecContext.trellis is set seems reasonable

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20090122/0c83dca0/attachment.pgp>



More information about the ffmpeg-devel mailing list