From 52b8a0530721abb276c286d95a7827da3529baa4 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 24 Sep 2006 21:35:56 +0000 Subject: [PATCH] workaround: on some systems, alloca() isn't aligned git-svn-id: svn://svn.videolan.org/x264/trunk@566 df754926-b1dd-0310-bc7b-ec298dee348c --- common/common.h | 6 ++++-- common/pixel.c | 4 ++-- encoder/me.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/common.h b/common/common.h index 93dfa8ae..8ee5b975 100644 --- a/common/common.h +++ b/common/common.h @@ -37,9 +37,11 @@ #define X264_VERSION "" // no configure script for msvc #endif -/* alloca */ +/* alloca: force 16byte alignment */ #ifdef _MSC_VER -#define alloca _alloca +#define x264_alloca(x) (void*)(((intptr_t)_alloca((x)+15)+15)&~15) +#else +#define x264_alloca(x) (void*)(((intptr_t) alloca((x)+15)+15)&~15) #endif /* threads */ diff --git a/common/pixel.c b/common/pixel.c index 5ab6f726..6477e974 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -379,8 +379,8 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, { int x, y, z; float ssim = 0.0; - int (*sum0)[4] = alloca(4 * (width/4+3) * sizeof(int)); - int (*sum1)[4] = alloca(4 * (width/4+3) * sizeof(int)); + int (*sum0)[4] = x264_alloca(4 * (width/4+3) * sizeof(int)); + int (*sum1)[4] = x264_alloca(4 * (width/4+3) * sizeof(int)); width >>= 2; height >>= 2; z = 0; diff --git a/encoder/me.c b/encoder/me.c index 035a58bb..b31b32b8 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -467,7 +467,7 @@ me_hex2: int enc_dc[4]; int sad_size = i_pixel <= PIXEL_8x8 ? PIXEL_8x8 : PIXEL_4x4; int delta = x264_pixel_size[sad_size].w; - uint16_t *ads = alloca((max_x-min_x+8) * sizeof(uint16_t)); + uint16_t *ads = x264_alloca((max_x-min_x+8) * sizeof(uint16_t)); h->pixf.sad_x4[sad_size]( zero, m->p_fenc[0], m->p_fenc[0]+delta, m->p_fenc[0]+delta*FENC_STRIDE, m->p_fenc[0]+delta+delta*FENC_STRIDE, -- 2.40.0