[FFmpeg-devel] Stack variables alignment check in libavcodec/dsputil.c

Roman Shaposhnick rvs
Tue Jul 31 01:51:19 CEST 2007


On Tue, 2007-07-31 at 01:12 +0200, Michael Niedermayer wrote:
> >  Michael, would you consider a patch with a reasonable performance
> > deviation to be acceptable replacement for trying to make gcc align
> > stack variables?
> no

  And the reasons being pure performance?

> if this bothers you so much, 

  Well, now that stock gcc failed on me on two different distros it
does ;-)

> you can just write wraper functions which
> realign the stack, something like
> avcodec_encode_video(){
>     if(realign_stack(&ret, avcodec_encode_video, bytes used for args on stack))
>         return ret
> }
> realign_stack() would check if the stack is aligned and if so just return 0
> if not it would align the stack, copy the function arguments to the aligned
> stack, call the function ptr, set ret to what the function returned and
> return 1
> yes you have to write realign_stack() in asm

  I know the trick, but I don't think it would solve the issue if you
have an arbitrary order of stack declarations and gcc fails to properly
track the alignment for you.


More information about the ffmpeg-devel mailing list