diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-06-06 03:45:53 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-06-06 03:45:53 +0000 |
commit | da9b170c6f06184a5114dc66afb8385cd0ffff83 (patch) | |
tree | 5c0001fa589306f13cbc36f69a71a6a617101f31 | |
parent | 940aed50ed1b1920d5363fa63f7e2c5d6e823817 (diff) | |
download | ffmpeg-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
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | libavcodec/mem.c | 18 |
2 files changed, 26 insertions, 1 deletions
@@ -62,6 +62,7 @@ echo " --disable-ffserver disable ffserver build" echo " --disable-ffplay disable ffplay build" echo " --disable-risky disables patent encumbered codecs" echo " --enable-small optimize for size instead of speed" +echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers" echo "" echo "NOTE: The object files are build at the place where configure is launched" exit 1 @@ -178,6 +179,7 @@ amr_nb_fixed="no" sunmlib="no" pthreads="no" gpl="no" +memalignhack="no" # OS specific targetos=`uname -s` @@ -427,6 +429,8 @@ for opt do ;; --enable-gpl) gpl="yes" ;; + --enable-memalign-hack) memalignhack="yes" + ;; esac done @@ -1269,6 +1273,11 @@ else echo "#undef HAVE_MEMALIGN" >> $TMPH fi +if test "$memalignhack" = "yes" ; then + echo "#define MEMALIGN_HACK 1" >> $TMPH +fi + + if test "$netserver" = "yes" ; then echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak 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 } |