Commit 3e7b136c authored by Loren Merritt's avatar Loren Merritt

workaround gcc's inability to align variables on the stack.

this crash was introduced in r642, but only because previous versions didn't use sse2 on the stack.


git-svn-id: svn://svn.videolan.org/x264/trunk@646 df754926-b1dd-0310-bc7b-ec298dee348c
parent 84676d2e
......@@ -30,4 +30,18 @@ int x264_cpu_num_processors( void );
/* probably MMX(EXT) centric but .... */
void x264_cpu_restore( uint32_t cpu );
/* kluge:
* gcc can't give variables any greater alignment than the stack frame has.
* We need 16 byte alignment for SSE2, so here we make sure that the stack is
* aligned to 16 bytes.
* gcc 4.2 introduced __attribute__((force_align_arg_pointer)) to fix this
* problem, but I don't want to require such a new version.
* This applies only to x86_32, since other architectures that need alignment
* also have ABIs that ensure aligned stack. */
#ifdef ARCH_X86
void x264_stack_align( void (*func)(x264_t*), x264_t *arg );
#else
#define x264_stack_align(func,arg) func(arg)
#endif
#endif
......@@ -101,3 +101,19 @@ cglobal x264_emms
emms
ret
;-----------------------------------------------------------------------------
; void x264_stack_align( void (*func)(void*), void *arg );
;-----------------------------------------------------------------------------
cglobal x264_stack_align
push ebp
mov ebp, esp
sub esp, 4
and esp, ~15
mov ecx, [ebp+8]
mov edx, [ebp+12]
mov [esp], edx
call ecx
mov esp, ebp
pop ebp
ret
......@@ -1023,7 +1023,7 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )
x264_macroblock_slice_init( h );
}
static int x264_slice_write( x264_t *h )
static void x264_slice_write( x264_t *h )
{
int i_skip;
int mb_xy;
......@@ -1183,8 +1183,6 @@ static int x264_slice_write( x264_t *h )
- h->stat.frame.i_itex_bits
- h->stat.frame.i_ptex_bits
- h->stat.frame.i_hdr_bits;
return 0;
}
static void x264_thread_sync_context( x264_t *dst, x264_t *src )
......@@ -1223,7 +1221,7 @@ static int x264_slices_write( x264_t *h )
x264_visualize_init( h );
#endif
x264_slice_write( h );
x264_stack_align( x264_slice_write, h );
i_frame_size = h->out.nal[h->out.i_nal-1].i_payload;
x264_fdec_filter_row( h, h->sps->i_mb_height );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment