From: Eric Petit Date: Wed, 27 Oct 2004 19:06:47 +0000 (+0000) Subject: + No need to emulate memalign on OS X X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=851989ac7c839ee2bf42c74a6fd90b5eb78f0a69;p=libx264 + No need to emulate memalign on OS X + Fixed Makefile for OS X (Original patch by Peter Handel) git-svn-id: svn://svn.videolan.org/x264/trunk@55 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/Makefile b/Makefile index 4a8fe5f0..82c05a88 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,29 @@ # Makefile: tuned for i386/MMX system only -# For ppc append -# SRCS: core/ppc/mc.c core/ppc/pixel.c -# Defines: HAVE_PPC -# CFLAGS: -faltivec + # For FreeBSD, remove -DHAVE_MALLOC_H and add -DSYS_FREEBSD -# -PFLAGS=-DARCH_X86 -DHAVE_MMXEXT -DHAVE_SSE2 -CC=gcc -CFLAGS=-g -Wall -I. -DDEBUG -O4 -funroll-loops -D__X264__ -DHAVE_MALLOC_H $(PFLAGS) -SRCS= core/mc.c core/predict.c core/pixel.c core/macroblock.c \ - core/frame.c core/dct.c core/cpu.c core/cabac.c \ - core/common.c core/mdate.c core/csp.c \ - encoder/analyse.c encoder/me.c encoder/ratecontrol.c \ - encoder/set.c encoder/macroblock.c encoder/cabac.c encoder/cavlc.c \ - encoder/encoder.c encoder/eval.c \ - core/i386/mc-c.c core/i386/dct-c.c core/i386/predict.c \ - x264.c +# Uncomment this for Mac OS X +#SYS_MACOSX=1 + +SRCS_COMMON= core/mc.c core/predict.c core/pixel.c core/macroblock.c \ + core/frame.c core/dct.c core/cpu.c core/cabac.c \ + core/common.c core/mdate.c core/csp.c \ + encoder/analyse.c encoder/me.c encoder/ratecontrol.c \ + encoder/set.c encoder/macroblock.c encoder/cabac.c \ + encoder/cavlc.c encoder/encoder.c encoder/eval.c x264.c + +ifdef SYS_MACOSX +PFLAGS=-DARCH_PPC -DSYS_MACOSX -faltivec +SRCS= $(SRCS_COMMON) core/ppc/mc.c core/ppc/pixel.c +else +PFLAGS=-DARCH_X86 -DHAVE_MMXEXT -DHAVE_SSE2 -DHAVE_MALLOC_H +SRCS= $(SRCS_COMMON) core/i386/mc-c.c core/i386/dct-c.c core/i386/predict.c +ASMSRC= core/i386/dct.asm core/i386/cpu.asm core/i386/pixel.asm core/i386/mc.asm +OBJASM= $(ASMSRC:%.asm=%.o) +endif + +CC=gcc +CFLAGS=-g -Wall -I. -DDEBUG -O4 -funroll-loops -D__X264__ $(PFLAGS) AS= nasm # for linux @@ -24,9 +31,6 @@ ASFLAGS=-f elf $(PFLAGS) # for cygwin #ASFLAGS=-f gnuwin32 -DPREFIX -ASMSRC= core/i386/dct.asm core/i386/cpu.asm core/i386/pixel.asm core/i386/mc.asm -OBJASM= $(ASMSRC:%.asm=%.o) - OBJS = $(SRCS:%.c=%.o) DEP = depend @@ -34,6 +38,7 @@ default: $(DEP) x264 libx264.a: $(OBJS) $(OBJASM) ar rc libx264.a $(OBJS) $(OBJASM) + ranlib libx264.a x264: libx264.a x264.o $(CC) $(CFLAGS) -o x264 x264.o libx264.a -lm diff --git a/core/common.c b/core/common.c index ea33e069..cbb1ea49 100644 --- a/core/common.c +++ b/core/common.c @@ -303,7 +303,10 @@ int x264_nal_decode( x264_nal_t *nal, void *p_data, int i_data ) ****************************************************************************/ void *x264_malloc( int i_size ) { -#ifdef HAVE_MALLOC_H +#ifdef SYS_MACOSX + /* Mac OS X always returns 16 bytes aligned memory */ + return malloc( i_size ); +#elif defined( HAVE_MALLOC_H ) return memalign( 16, i_size ); #else uint8_t * buf; @@ -325,7 +328,7 @@ void x264_free( void *p ) { if( p ) { -#ifdef HAVE_MALLOC_H +#if defined( HAVE_MALLOC_H ) || defined( SYS_MACOSX ) free( p ); #else free( *( ( ( void **) p ) - 1 ) );