]> granicus.if.org Git - libx264/commitdiff
+ No need to emulate memalign on OS X
authorEric Petit <titer@videolan.org>
Wed, 27 Oct 2004 19:06:47 +0000 (19:06 +0000)
committerEric Petit <titer@videolan.org>
Wed, 27 Oct 2004 19:06:47 +0000 (19:06 +0000)
 + 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

Makefile
core/common.c

index 4a8fe5f08b1314ec3a6c131962cbc99859a8e7d4..82c05a8870c983b845c49a24fe289fa3d3eedc90 100644 (file)
--- 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
index ea33e0693ab6c3905265fdb35f939a734f9edded..cbb1ea4937603939caedfebbc8eaba72dc7abcf8 100644 (file)
@@ -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 ) );