[x264-devel] [Question] Technical reason why x264 sets a mstack-alignment value on compile time?

Henrik Gramner henrik at gramner.com
Sat Nov 12 22:03:35 UTC 2022


On Sat, Nov 12, 2022 at 8:05 PM Nomis101 <Nomis101 at web.de> wrote:
> And here comes my questions. I was wondering, about the technical reason why x264 does set
> mstack-alignment? And if it would be safe to disable it in case x264 is compiled with ThinLTO (for
> HandBrake)?

The purpose is to avoid having to realign the stack in every function
that uses aligned stack buffers by realigning the stack only once (on
API entrypoints) and then maintaining that alignment.

It's safe to remove it as long as you also remove the corresponding
entry from ASFLAGS. Doing so will result in the system default being
used, and stack realignment will be performed when needed.

Note that the last time I checked using LTO had a negative impact on
performance in x264, so unless it has improved recently it's not
really recommended.


More information about the x264-devel mailing list