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
This commit is contained in:
Michael Niedermayer 2004-06-06 03:45:53 +00:00
parent 940aed50ed
commit da9b170c6f
2 changed files with 26 additions and 1 deletions

9
configure vendored
View File

@ -62,6 +62,7 @@ echo " --disable-ffserver disable ffserver build"
echo " --disable-ffplay disable ffplay build" echo " --disable-ffplay disable ffplay build"
echo " --disable-risky disables patent encumbered codecs" echo " --disable-risky disables patent encumbered codecs"
echo " --enable-small optimize for size instead of speed" echo " --enable-small optimize for size instead of speed"
echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
echo "" echo ""
echo "NOTE: The object files are build at the place where configure is launched" echo "NOTE: The object files are build at the place where configure is launched"
exit 1 exit 1
@ -178,6 +179,7 @@ amr_nb_fixed="no"
sunmlib="no" sunmlib="no"
pthreads="no" pthreads="no"
gpl="no" gpl="no"
memalignhack="no"
# OS specific # OS specific
targetos=`uname -s` targetos=`uname -s`
@ -427,6 +429,8 @@ for opt do
;; ;;
--enable-gpl) gpl="yes" --enable-gpl) gpl="yes"
;; ;;
--enable-memalign-hack) memalignhack="yes"
;;
esac esac
done done
@ -1269,6 +1273,11 @@ else
echo "#undef HAVE_MEMALIGN" >> $TMPH echo "#undef HAVE_MEMALIGN" >> $TMPH
fi fi
if test "$memalignhack" = "yes" ; then
echo "#define MEMALIGN_HACK 1" >> $TMPH
fi
if test "$netserver" = "yes" ; then if test "$netserver" = "yes" ; then
echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak

View File

@ -46,7 +46,13 @@ void *av_malloc(unsigned int size)
{ {
void *ptr; 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); ptr = memalign(16,size);
/* Why 64? /* Why 64?
Indeed, we should align it: Indeed, we should align it:
@ -87,7 +93,13 @@ void *av_malloc(unsigned int size)
*/ */
void *av_realloc(void *ptr, 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); return realloc(ptr, size);
#endif
} }
/* NOTE: ptr = NULL is explicetly allowed */ /* 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 */ /* XXX: this test should not be needed on most libcs */
if (ptr) if (ptr)
#ifdef MEMALIGN_HACK
free(ptr - ((char*)ptr)[-1]);
#else
free(ptr); free(ptr);
#endif
} }