aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/mem.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-10 03:15:42 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-10 03:15:42 +0200
commit08675bb39928fff0a31ecc068e290704a358739d (patch)
tree4efac96df8c389a361d730509b185b71b9d8046b /libavutil/mem.c
parent53789a27f8a2ca06563d9555013e20b191b2a705 (diff)
downloadffmpeg-08675bb39928fff0a31ecc068e290704a358739d.tar.gz
mem: Choose alignment at compile time depending on AVX enabledness.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/mem.c')
-rw-r--r--libavutil/mem.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 42beb503a1..873d8feb76 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -57,6 +57,8 @@ void free(void *ptr);
#endif /* MALLOC_PREFIX */
+#define ALIGN (HAVE_AVX ? 32 : 16)
+
/* You can redefine av_malloc and av_free in your project to use your
memory allocator. You do not need to suppress this file because the
linker will do it automatically. */
@@ -73,17 +75,17 @@ void *av_malloc(size_t size)
return NULL;
#if CONFIG_MEMALIGN_HACK
- ptr = malloc(size+32);
+ ptr = malloc(size+ALIGN);
if(!ptr)
return ptr;
- diff= ((-(long)ptr - 1)&31) + 1;
+ diff= ((-(long)ptr - 1)&(ALIGN-1)) + 1;
ptr = (char*)ptr + diff;
((char*)ptr)[-1]= diff;
#elif HAVE_POSIX_MEMALIGN
- if (posix_memalign(&ptr,32,size))
+ if (posix_memalign(&ptr,ALIGN,size))
ptr = NULL;
#elif HAVE_MEMALIGN
- ptr = memalign(32,size);
+ ptr = memalign(ALIGN,size);
/* Why 64?
Indeed, we should align it:
on 4 for 386