From: Alex Izvorski Date: Sat, 26 May 2007 03:13:08 +0000 (+0000) Subject: replace alloca with malloc everywhere. per manpage, use of alloca is discouraged... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a35548661f5f50c22516147b9b164f25d44a69db;p=libx264 replace alloca with malloc everywhere. per manpage, use of alloca is discouraged. this may have a minor effect on the speed of ssim and esa, but that appears too small to measure. git-svn-id: svn://svn.videolan.org/x264/trunk@656 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/common.h b/common/common.h index 88879737..0d6e8310 100644 --- a/common/common.h +++ b/common/common.h @@ -40,13 +40,6 @@ #define X264_VERSION "" // no configure script for msvc #endif -/* alloca: force 16byte alignment */ -#ifdef _MSC_VER -#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 - #ifdef _MSC_VER #define DECLARE_ALIGNED( type, var, n ) __declspec(align(n)) type var #else diff --git a/common/pixel.c b/common/pixel.c index 2625ad54..1ccfb6e8 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -385,8 +385,8 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, { int x, y, z; float ssim = 0.0; - int (*sum0)[4] = x264_alloca(4 * (width/4+3) * sizeof(int)); - int (*sum1)[4] = x264_alloca(4 * (width/4+3) * sizeof(int)); + int (*sum0)[4] = x264_malloc(4 * (width/4+3) * sizeof(int)); + int (*sum1)[4] = x264_malloc(4 * (width/4+3) * sizeof(int)); width >>= 2; height >>= 2; z = 0; @@ -401,6 +401,8 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, for( x = 0; x < width-1; x += 4 ) ssim += pf->ssim_end4( sum0+x, sum1+x, X264_MIN(4,width-x-1) ); } + x264_free(sum0); + x264_free(sum1); return ssim / ((width-1) * (height-1)); } diff --git a/encoder/me.c b/encoder/me.c index ccffe2dc..a901326d 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -460,7 +460,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 = x264_alloca((max_x-min_x+8) * sizeof(uint16_t)); + uint16_t *ads = x264_malloc((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, @@ -495,6 +495,8 @@ me_hex2: for( i=0; i