aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mem.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-06-06 03:45:53 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-06-06 03:45:53 +0000
commitda9b170c6f06184a5114dc66afb8385cd0ffff83 (patch)
tree5c0001fa589306f13cbc36f69a71a6a617101f31 /libavcodec/mem.c
parent940aed50ed1b1920d5363fa63f7e2c5d6e823817 (diff)
downloadffmpeg-da9b170c6f06184a5114dc66afb8385cd0ffff83.tar.gz
optional and disabled by default memalign hack for SSE/SSE2 on that alternative OS
Originally committed as revision 3199 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mem.c')
-rw-r--r--libavcodec/mem.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libavcodec/mem.c b/libavcodec/mem.c
index c5ca166d33..35c8305033 100644
--- a/libavcodec/mem.c
+++ b/libavcodec/mem.c
@@ -46,7 +46,13 @@ void *av_malloc(unsigned int size)
{
void *ptr;
-#if defined (HAVE_MEMALIGN)
+#ifdef MEMALIGN_HACK
+ int diff;
+ ptr = malloc(size+16+1);
+ diff= ((-(int)ptr - 1)&15) + 1;
+ ptr += diff;
+ ((char*)ptr)[-1]= diff;
+#elif defined (HAVE_MEMALIGN)
ptr = memalign(16,size);
/* Why 64?
Indeed, we should align it:
@@ -87,7 +93,13 @@ void *av_malloc(unsigned int size)
*/
void *av_realloc(void *ptr, unsigned int size)
{
+#ifdef MEMALIGN_HACK
+ //FIXME this isnt aligned correctly though it probably isnt needed
+ int diff= ptr ? ((char*)ptr)[-1] : 0;
+ return realloc(ptr - diff, size + diff) + diff;
+#else
return realloc(ptr, size);
+#endif
}
/* NOTE: ptr = NULL is explicetly allowed */
@@ -95,6 +107,10 @@ void av_free(void *ptr)
{
/* XXX: this test should not be needed on most libcs */
if (ptr)
+#ifdef MEMALIGN_HACK
+ free(ptr - ((char*)ptr)[-1]);
+#else
free(ptr);
+#endif
}