[Ffmpeg-devel] DECLARE_ALIGNED_16 not honoured correctly in MinGW
Fri Oct 27 16:49:30 CEST 2006
Steve Lhomme skrev:
> We are encountering a crash when calling DrFFMPEG from DrDivX on
> Windows. The crash occurs when decoding WMA content. After some
> investigation it appears that this declaration in wmadec.c doesn't
> produce what it's supposed to do:
> DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
> When the DLL (could be libavcodec) is called from MSVC code 'output'
> is not aligned to 16 bits (0x01F36D28 in this case for example). And
> it crashes the SSE code used later. But it works fine when everything
> is built with MinGW. It appears that gcc assumes the stack is already
> aligned a certain way when it does the alignment of this variable in
> the stack. And this is not true when the stack is given by MSVC code.
> Now I understand there's no support for MSVC here, but on the other
> hand libavcodec is a library, no matter how it's being called. Plus
> the bug is not in MSVC (who has the right to do whatever they want
> with the stack) but in gcc.
> So my question is: does anybody know a way to make gcc behave
> correctly in such case ?
> The other possibility I see to avoid the crash in my case is to add a
> test in ff_imdct_calc_sse() and vector_fmul_add_add_sse() to use the C
> code if one of the parameter passed is not aligned as it should. (I
> could make the patch if the solution is OK)
I'm just confirming this. There has been several reported instances of
this on irc. Both with mingw and with gcc on BeOS. And I would reject
the proposed imdct hack and use an aligned malloc instead (assuming that
atleast mallocs can be aligned properly), that should work just as well
if I remember the code correctly.
More information about the ffmpeg-devel