Commit a3554866 authored by Alex Izvorski's avatar Alex Izvorski

replace alloca with malloc everywhere. per manpage, use of alloca is...

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
parent ffa4e76d
......@@ -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
......
......@@ -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));
}
......
......@@ -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<i_mvs; i++ )
COST_MV( mvs[i], my );
}
x264_free(ads);
#endif
}
break;
......
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