diff -uNrp c/Makefile b/Makefile --- c/Makefile 2010-01-14 16:09:54 +0200 +++ b/Makefile 2010-01-20 22:46:44 +0200 @@ -98,11 +98,11 @@ OBJASM = $(ASMSRC:%.asm=%.o) endif ifneq ($(HAVE_GETOPT_LONG),1) -SRCS += extras/getopt.c +SRCCLI += extras/getopt.c endif ifneq ($(SONAME),) -ifeq ($(SYS),MINGW) +ifeq ($(SYS),WINDOWS) SRCSO += x264dll.c endif endif @@ -116,30 +116,30 @@ DEP = depend default: $(DEP) x264$(EXE) -libx264.a: .depend $(OBJS) $(OBJASM) - $(AR) rc libx264.a $(OBJS) $(OBJASM) - $(RANLIB) libx264.a +$(LIBX264): .depend $(OBJS) $(OBJASM) + $(AR)$@ $(OBJS) $(OBJASM) + $(if $(RANLIB), $(RANLIB) $@) $(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO) - $(CC) -shared -o $@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS) + $(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS) -x264$(EXE): $(OBJCLI) libx264.a - $(CC) -o $@ $+ $(LDFLAGS) $(LDFLAGSCLI) +x264$(EXE): $(OBJCLI) $(LIBX264) + $(LD)$@ $+ $(LDFLAGS) $(LDFLAGSCLI) -checkasm: tools/checkasm.o libx264.a - $(CC) -o $@ $+ $(LDFLAGS) +checkasm: tools/checkasm.o $(LIBX264) + $(LD)$@ $+ $(LDFLAGS) %.o: %.asm $(AS) $(ASFLAGS) -o $@ $< - -@ $(STRIP) -x $@ # delete local/anonymous symbols, so they don't show up in oprofile + -@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile %.o: %.S $(AS) $(ASFLAGS) -o $@ $< - -@ $(STRIP) -x $@ # delete local/anonymous symbols, so they don't show up in oprofile + -@ $(if $($STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile .depend: config.mak rm -f .depend - $(foreach SRC, $(SRCS) $(SRCCLI) $(SRCSO), $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;) + $(foreach SRC, $(SRCS) $(SRCCLI) $(SRCSO), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:%.c=%.o) $(DEPMM) 1>> .depend;) config.mak: ./configure @@ -168,21 +168,17 @@ fprofiled: else fprofiled: $(MAKE) clean - mv config.mak config.mak2 - sed -e 's/CFLAGS.*/& -fprofile-generate/; s/LDFLAGS.*/& -fprofile-generate/' config.mak2 > config.mak - $(MAKE) x264$(EXE) + @$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)" $(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;)) rm -f $(SRC2:%.c=%.o) - sed -e 's/CFLAGS.*/& -fprofile-use/; s/LDFLAGS.*/& -fprofile-use/' config.mak2 > config.mak - $(MAKE) - rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) - mv config.mak2 config.mak + @$(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)" + rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn *.dpi* endif clean: - rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a x264 x264.exe .depend TAGS + rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o - rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) + rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn *.dpi* - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak distclean: clean @@ -193,11 +189,11 @@ install: x264$(EXE) $(SONAME) install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir) install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig install -m 644 x264.h $(DESTDIR)$(includedir) - install -m 644 libx264.a $(DESTDIR)$(libdir) + install -m 644 $(LIBX264) $(DESTDIR)$(libdir) install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig install x264$(EXE) $(DESTDIR)$(bindir) - $(RANLIB) $(DESTDIR)$(libdir)/libx264.a -ifeq ($(SYS),MINGW) + $(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264)) +ifeq ($(SYS),WINDOWS) $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir)) else $(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)) diff -uNrp c/common/common.h b/common/common.h --- c/common/common.h 2010-01-14 16:09:54 +0200 +++ b/common/common.h 2010-01-20 22:47:04 +0200 @@ -78,6 +78,7 @@ do {\ #include #include #include +#include /* Unions for type-punning. * Mn: load or store n bits, aligned, native-endian diff -uNrp c/common/mc.c b/common/mc.c --- c/common/mc.c 2009-11-09 20:43:25 +0200 +++ b/common/mc.c 2010-01-20 22:47:39 +0200 @@ -429,7 +429,7 @@ static void frame_init_lowres_core( uint } } -#if defined(__GNUC__) && (defined(ARCH_X86) || defined(ARCH_X86_64)) +#ifdef HAVE_X86_INLINE_ASM // gcc isn't smart enough to use the "idiv" instruction static ALWAYS_INLINE int32_t div_64_32(int64_t x, int32_t y) { int32_t quotient, remainder; diff -uNrp c/common/mdate.c b/common/mdate.c --- c/common/mdate.c 2009-10-26 11:18:13 +0200 +++ b/common/mdate.c 2010-01-20 22:48:32 +0200 @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#ifndef __MINGW32__ -#include -#else +#ifdef SYS_WINDOWS #include #include +#else +#include #endif #include @@ -31,14 +31,14 @@ int64_t x264_mdate( void ) { -#ifndef __MINGW32__ - struct timeval tv_date; - gettimeofday( &tv_date, NULL ); - return( (int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec ); -#else +#ifdef SYS_WINDOWS struct _timeb tb; _ftime(&tb); return ((int64_t)tb.time * (1000) + (int64_t)tb.millitm) * (1000); +#else + struct timeval tv_date; + gettimeofday( &tv_date, NULL ); + return( (int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec ); #endif } diff -uNrp c/common/osdep.h b/common/osdep.h --- c/common/osdep.h 2010-01-14 16:09:54 +0200 +++ b/common/osdep.h 2010-01-20 22:50:58 +0200 @@ -39,6 +39,25 @@ #include // _O_BINARY #endif +#ifdef __ICL +#define asm __asm__ +#define inline __inline +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define snprintf _snprintf +#define strtok_r strtok_s +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifdef __INTEL_COMPILER +#include +#endif + +#undef HAVE_X86_INLINE_ASM +#if (defined(__GNUC__) || defined(__INTEL_COMPILER)) && (defined(ARCH_X86) || defined(ARCH_X86_64)) +#define HAVE_X86_INLINE_ASM +#endif + #if (defined(SYS_OPENBSD) && !defined(isfinite)) || defined(SYS_SunOS) #define isfinite finite #endif @@ -49,7 +68,11 @@ #endif #endif +#ifdef __ICL +#define DECLARE_ALIGNED( var, n ) __declspec(align(n)) var +#else #define DECLARE_ALIGNED( var, n ) var __attribute__((aligned(n))) +#endif #define ALIGNED_16( var ) DECLARE_ALIGNED( var, 16 ) #define ALIGNED_8( var ) DECLARE_ALIGNED( var, 8 ) #define ALIGNED_4( var ) DECLARE_ALIGNED( var, 4 ) @@ -85,9 +108,14 @@ #define MAY_ALIAS __attribute__((may_alias)) #define x264_constant_p(x) __builtin_constant_p(x) #else -#define UNUSED +#ifdef __ICL +#define ALWAYS_INLINE __forceinline +#define NOINLINE __declspec(noinline) +#else #define ALWAYS_INLINE inline #define NOINLINE +#endif +#define UNUSED #define MAY_ALIAS #define x264_constant_p(x) 0 #endif @@ -159,7 +187,7 @@ static inline int x264_pthread_create( x #define WORD_SIZE sizeof(void*) #if !defined(_WIN64) && !defined(__LP64__) -#if defined(__INTEL_COMPILER) +#ifdef __ICL #define BROKEN_STACK_ALIGNMENT /* define it if stack is not mod16 */ #endif #endif @@ -170,7 +198,7 @@ static inline int x264_pthread_create( x #define endian_fix32(x) (x) #define endian_fix16(x) (x) #else -#if defined(__GNUC__) && defined(HAVE_MMX) +#ifdef HAVE_X86_INLINE_ASM static ALWAYS_INLINE uint32_t endian_fix32( uint32_t x ) { asm("bswap %0":"+r"(x)); @@ -188,7 +216,7 @@ static ALWAYS_INLINE uint32_t endian_fix return (x<<24) + ((x<<8)&0xff0000) + ((x>>8)&0xff00) + (x>>24); } #endif -#if defined(__GNUC__) && defined(ARCH_X86_64) +#if defined(HAVE_X86_INLINE_ASM) && defined(ARCH_X86_64) static ALWAYS_INLINE uint64_t endian_fix64( uint64_t x ) { asm("bswap %0":"+r"(x)); @@ -227,7 +255,7 @@ static int ALWAYS_INLINE x264_clz( uint3 #endif #ifdef USE_REAL_PTHREAD -#ifdef SYS_MINGW +#ifdef SYS_WINDOWS #define x264_lower_thread_priority(p)\ {\ x264_pthread_t handle = pthread_self();\ diff -uNrp c/common/x86/predict-c.c b/common/x86/predict-c.c --- c/common/x86/predict-c.c 2009-11-13 13:50:53 +0200 +++ b/common/x86/predict-c.c 2010-01-20 22:53:06 +0200 @@ -110,26 +110,26 @@ PREDICT_16x16_P( mmxext ) #endif PREDICT_16x16_P( sse2 ) -#ifdef __GNUC__ +#ifdef HAVE_X86_INLINE_ASM static void predict_16x16_p_ssse3( uint8_t *src ) { int a, b, c, i00; int H, V; asm ( - "movq %1, %%mm1 \n" - "movq 8+%1, %%mm0 \n" - "palignr $7, -8+%1, %%mm1 \n" - "pmaddubsw %2, %%mm0 \n" - "pmaddubsw %3, %%mm1 \n" + "movq %2, %%mm0 \n" + "palignr $7, %3, %%mm1 \n" + "pmaddubsw %4, %%mm0 \n" + "pmaddubsw %5, %%mm1 \n" "paddw %%mm1, %%mm0 \n" "pshufw $14, %%mm0, %%mm1 \n" "paddw %%mm1, %%mm0 \n" "pshufw $1, %%mm0, %%mm1 \n" "paddw %%mm1, %%mm0 \n" "movd %%mm0, %0 \n" - "movsx %w0, %0 \n" + "movswl %w0, %0 \n" :"=r"(H) - :"m"(src[-FDEC_STRIDE]), "m"(*pb_12345678), "m"(*pb_m87654321) + :"m"(src[-FDEC_STRIDE]), "m"(src[8-FDEC_STRIDE]), "m"(src[-8-FDEC_STRIDE]), + "m"(*pb_12345678), "m"(*pb_m87654321) ); V = 8 * ( src[15*FDEC_STRIDE-1] - src[-1*FDEC_STRIDE-1] ) + 7 * ( src[14*FDEC_STRIDE-1] - src[ 0*FDEC_STRIDE-1] ) @@ -170,7 +170,7 @@ PREDICT_8x8_P( mmxext ) #endif PREDICT_8x8_P( sse2 ) -#ifdef __GNUC__ +#ifdef HAVE_X86_INLINE_ASM static void predict_8x8c_p_ssse3( uint8_t *src ) { int a, b, c, i00; @@ -183,7 +183,7 @@ static void predict_8x8c_p_ssse3( uint8_ "pshufw $1, %%mm0, %%mm1 \n" "paddw %%mm1, %%mm0 \n" "movd %%mm0, %0 \n" - "movsx %w0, %0 \n" + "movswl %w0, %0 \n" :"=r"(H) :"m"(src[-FDEC_STRIDE]), "m"(*pb_m32101234) ); @@ -394,7 +394,7 @@ void x264_predict_16x16_init_mmx( int cp if( !(cpu&X264_CPU_SSSE3) ) return; pf[I_PRED_16x16_H] = predict_16x16_h_ssse3; -#ifdef __GNUC__ +#ifdef HAVE_X86_INLINE_ASM pf[I_PRED_16x16_P] = predict_16x16_p_ssse3; #endif } @@ -421,7 +421,7 @@ void x264_predict_8x8c_init_mmx( int cpu if( !(cpu&X264_CPU_SSSE3) ) return; pf[I_PRED_CHROMA_H] = predict_8x8c_h_ssse3; -#ifdef __GNUC__ +#ifdef HAVE_X86_INLINE_ASM pf[I_PRED_CHROMA_P] = predict_8x8c_p_ssse3; #endif } diff -uNrp c/common/x86/util.h b/common/x86/util.h --- c/common/x86/util.h 2009-11-13 13:50:53 +0200 +++ b/common/x86/util.h 2010-01-20 22:53:24 +0200 @@ -24,7 +24,7 @@ #ifndef X264_X86_UTIL_H #define X264_X86_UTIL_H -#ifdef __GNUC__ +#ifdef HAVE_X86_INLINE_ASM #define x264_median_mv x264_median_mv_mmxext static inline void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) { diff -uNrp c/configure b/configure --- c/configure 2010-01-14 16:09:54 +0200 +++ b/configure 2010-01-20 23:00:59 +0200 @@ -23,15 +23,52 @@ echo " --extra-cflags=ECFLAGS add ECF echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS" echo " --host=HOST build programs to run on HOST" echo " --cross-prefix=PREFIX use PREFIX for compilation tools" +echo " --intel use intel's compiler for compilation" echo "" exit 1 fi +intel_cflags() { + for arg in $*; do + [ $arg = -ffast-math ] && arg= + [[ "$arg" = -falign-loops* ]] && arg= + if [ $SYS = WINDOWS ]; then + [ "$arg" = -Wall ] && arg=-W0 + [ "$arg" = -g ] && arg=-Z7 + [ "$arg" = -fomit-frame-pointer ] && arg= + [ "$arg" = -s ] && arg= + else + [ "$arg" = -Wall ] && arg=-w0 + fi + [ $SYS = MACOSX -a \( "$arg" = -mia32 -o "$arg" = -msse -o "$arg" = -msse2 \) ] && arg= + [ -n "$arg" ] && echo -n "$arg " + done + [ $SYS != WINDOWS -a $ARCH = X86 ] && echo -n "-falign-stack=assume-16-byte " +} + +icl_ldflags() { + for arg in $*; do + arg=${arg/LIBPATH/libpath} + [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib + [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L} + [ $arg = -s ] && arg= + + arg=${arg/pthreadGC/pthreadVC} + [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib + [ -n "$arg" ] && echo -n "$arg " + done +} + + cc_check() { rm -f conftest.c [ -n "$1" ] && echo "#include <$1>" > conftest.c echo "int main () { $3 return 0; }" >> conftest.c - $CC conftest.c $CFLAGS $LDFLAGS $LDFLAGSCLI $2 -o conftest 2>$DEVNULL + if [ $SYS = WINDOWS -a $compiler = INTEL ]; then + $CC -Feconftest conftest.c $CFLAGS $2 -link $(icl_ldflags $LDFLAGS $LDFLAGSCLI $2) 1>$DEVNULL 2>&1 + else + $CC conftest.c $CFLAGS $LDFLAGS $LDFLAGSCLI $2 -o conftest 2>$DEVNULL + fi } as_check() { @@ -44,7 +81,7 @@ die() { exit 1 } -rm -f config.h config.mak x264.pc conftest* +rm -f config.h config.mak x264.pc x264.def conftest* prefix='/usr/local' exec_prefix='${prefix}' @@ -64,6 +101,7 @@ gprof="no" pic="no" vis="no" shared="no" +compiler="GNU" CFLAGS="$CFLAGS -Wall -I." LDFLAGS="$LDFLAGS" @@ -164,6 +202,9 @@ for opt do --cross-prefix=*) cross_prefix="${opt#--cross-prefix=}" ;; + --intel) + compiler="INTEL" + ;; *) echo "Unknown option $opt, ignored" ;; @@ -172,8 +213,6 @@ done CC="${CC-${cross_prefix}gcc}" AR="${AR-${cross_prefix}ar}" -RANLIB="${RANLIB-${cross_prefix}ranlib}" -STRIP="${STRIP-${cross_prefix}strip}" if [ "x$host" = x ]; then host=`./config.guess` @@ -187,6 +226,20 @@ host="${host#*-}" host_vendor="${host%%-*}" host_os="${host#*-}" +if [ $compiler = INTEL ]; then + if [[ $host_os = cygwin* || $host_os = mingw* ]]; then + ARCHPRE="-arch:" + CC=icl + CFLAGS="$CFLAGS -Qstd=c99 -nologo -DHAVE_STRING_H -Iextras" + QPRE="-Q" + else + AR="xiar" + ARCHPRE="-m" + [[ "$CC" != icc* ]] && CC=icc + QPRE="-" + fi +fi + case $host_os in beos*) SYS="BEOS" @@ -224,16 +277,16 @@ case $host_os in LDFLAGS="$LDFLAGS -lm" ;; cygwin*) - SYS="MINGW" + SYS="WINDOWS" EXE=".exe" DEVNULL="NUL" - if cc_check "" -mno-cygwin; then + if [ $compiler = GNU ] && cc_check "" -mno-cygwin; then CFLAGS="$CFLAGS -mno-cygwin" LDFLAGS="$LDFLAGS -mno-cygwin" fi ;; mingw*) - SYS="MINGW" + SYS="WINDOWS" EXE=".exe" DEVNULL="NUL" ;; @@ -253,15 +306,25 @@ case $host_cpu in ARCH="X86" AS="yasm" ASFLAGS="$ASFLAGS -O2" - if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then - CFLAGS="$CFLAGS -march=i686" - fi - if [[ "$asm" == yes && "$CFLAGS" != *-mfpmath* ]]; then - CFLAGS="$CFLAGS -mfpmath=sse -msse" + if [ $compiler = GNU ]; then + if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then + CFLAGS="$CFLAGS -march=i686" + fi + if [[ "$asm" == yes && "$CFLAGS" != *-mfpmath* ]]; then + CFLAGS="$CFLAGS -mfpmath=sse -msse" + fi + else + if ! echo $CFLAGS | grep -Eiq "(${ARCHPRE}ia32|${ARCHPRE}sse |${ARCHPRE}sse2|${ARCHPRE}sse3|${ARCHPRE}ssse3|${ARCHPRE}sse4.1)" && [[ "$CFLAGS" != *${QPRE}x* ]]; then + if [ $asm = yes ]; then + CFLAGS="$CFLAGS ${ARCHPRE}sse" + else + CFLAGS="$CFLAGS ${ARCHPRE}ia32" + fi + fi fi if [ "$SYS" = MACOSX ]; then ASFLAGS="$ASFLAGS -f macho -DPREFIX" - elif [ "$SYS" = MINGW ]; then + elif [ "$SYS" = WINDOWS ]; then ASFLAGS="$ASFLAGS -f win32 -DPREFIX" else ASFLAGS="$ASFLAGS -f elf" @@ -276,8 +339,9 @@ case $host_cpu in CFLAGS="$CFLAGS -arch x86_64" LDFLAGS="$LDFLAGS -arch x86_64" fi - elif [ "$SYS" = MINGW ]; then - ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX" + elif [ "$SYS" = WINDOWS ]; then + ASFLAGS="$ASFLAGS -f win32 -m amd64" + [ $compiler = GNU ] && ASFLAGS="$ASFLAGS -DPREFIX" else ASFLAGS="$ASFLAGS -f elf -m amd64" fi @@ -327,6 +391,7 @@ cc_check || die "No working C compiler f if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" \) ] ; then pic="yes" fi +[ $SYS = WINDOWS ] && pic=no if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then if ! as_check "lzcnt eax, eax" ; then @@ -336,7 +401,7 @@ if [ $asm = yes -a \( $ARCH = X86 -o $AR echo "If you really want to compile without asm, configure with --disable-asm." exit 1 fi - if ! cc_check '' '' 'asm("pabsw %xmm0, %xmm0");' ; then + if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1` echo "Found $VER" echo "Minimum version is binutils-2.17" @@ -367,12 +432,14 @@ fi CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS" -echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c -$CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed" -if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then - CFLAGS="$CFLAGS -DWORDS_BIGENDIAN" -elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then - die "endian test failed" +if [ $compiler = GNU ]; then + echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c + $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed" + if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then + CFLAGS="$CFLAGS -DWORDS_BIGENDIAN" + elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then + die "endian test failed" + fi fi # autodetect options that weren't forced nor disabled @@ -384,7 +451,7 @@ if test "$pthread" = "auto" ; then BEOS) pthread="yes" ;; - MINGW) + WINDOWS) if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then pthread="yes" libpthread="-lpthread" @@ -457,7 +524,7 @@ if [ "$ffms_input" = "auto" ] ; then fi MP4_LDFLAGS="-lgpac_static" -if [ $SYS = MINGW ]; then +if [ $SYS = WINDOWS ]; then MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm" fi if [ "$mp4_output" = "auto" ] ; then @@ -471,11 +538,11 @@ fi if [ "$avs_input" = "auto" ] ; then avs_input=no - if [ $SYS = MINGW ] && cc_check avisynth_c.h ; then + if [ $SYS = WINDOWS ] && cc_check avisynth_c.h ; then avs_input="yes" echo "#define AVS_INPUT" >> config.h echo "#define HAVE_AVISYNTH_C_H" >> config.h - elif [ $SYS = MINGW ] && cc_check extras/avisynth_c.h ; then + elif [ $SYS = WINDOWS ] && cc_check extras/avisynth_c.h ; then avs_input="yes" echo "#define AVS_INPUT" >> config.h fi @@ -498,12 +565,15 @@ if [ "$debug" = "yes" ]; then elif [ $ARCH = ARM ]; then # arm-gcc-4.2 produces incorrect output with -ffast-math # and it doesn't save any speed anyway on 4.4, so disable it - CFLAGS="-O4 -fno-fast-math $CFLAGS" + CFLAGS="-O3 -fno-fast-math $CFLAGS" else - CFLAGS="-O4 -ffast-math $CFLAGS" + CFLAGS="-O3 -ffast-math $CFLAGS" fi -if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then +if cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then + echo "#define fseek _fseeki64" >> config.h + echo "#define ftell _ftelli64" >> config.h +elif cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then echo "#define fseek fseeko" >> config.h echo "#define ftell ftello" >> config.h elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then @@ -513,6 +583,45 @@ fi rm -f conftest* +if [ $compiler = INTEL -a $SYS = WINDOWS ]; then + AR="xilib -nologo -out:" + DEPMM=-QMM + DEPMT=-QMT + HAVE_GETOPT_LONG=0 + LD="xilink -out:" + LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)" + LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)" + LIBX264=libx264.lib + RANLIB= + STRIP= + if [ $debug = yes ]; then + LDFLAGS="-debug $LDFLAGS" + CFLAGS="-D_DEBUG $CFLAGS" + else + CFLAGS="-DNDEBUG $CFLAGS" + fi +else + AR="$AR rc " + DEPMM="-MM -g0" + DEPMT="-MT" + LD="$CC -o " + LIBX264=libx264.a + RANLIB="${RANLIB-${cross_prefix}ranlib}" + STRIP="${STRIP-${cross_prefix}strip}" +fi +if [ $compiler = INTEL ]; then + CFLAGS="$(intel_cflags $CFLAGS)" + PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir." + PROF_GEN_LD= + PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir." + PROF_USE_LD= +else + PROF_GEN_CC="-fprofile-generate" + PROF_GEN_LD="-fprofile-generate" + PROF_USE_CC="-fprofile-use" + PROF_USE_LD="-fprofile-use" +fi + # generate config files cat > config.mak << EOF @@ -525,37 +634,60 @@ ARCH=$ARCH SYS=$SYS CC=$CC CFLAGS=$CFLAGS +DEPMM=$DEPMM +DEPMT=$DEPMT +LD=$LD LDFLAGS=$LDFLAGS LDFLAGSCLI=$LDFLAGSCLI +LIBX264=$LIBX264 AR=$AR -RANLIB=$RANLIB -STRIP=$STRIP AS=$AS ASFLAGS=$ASFLAGS EXE=$EXE VIS=$vis HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG DEVNULL=$DEVNULL +PROF_GEN_CC=$PROF_GEN_CC +PROF_GEN_LD=$PROF_GEN_LD +PROF_USE_CC=$PROF_USE_CC +PROF_USE_LD=$PROF_USE_LD EOF +[ -n "$RANLIB" ] && echo "RANLIB=$RANLIB" >> config.mak +[ -n "$STRIP" ] && echo "STRIP=$STRIP" >> config.mak + +if [ $SYS = WINDOWS -a $compiler = INTEL ]; then + echo '%.o: %.c' >> config.mak + echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak +fi + + if [ "$shared" = "yes" ]; then API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ') - if [ "$SYS" = "MINGW" ]; then + if [ "$SYS" = "WINDOWS" ]; then echo "SONAME=libx264-$API.dll" >> config.mak - echo 'IMPLIBNAME=libx264.dll.a' >> config.mak - echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak + if [ $compiler = GNU ]; then + echo 'IMPLIBNAME=libx264.dll.a' >> config.mak + echo 'SOFLAGS=-shared -Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak + else + echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak + echo 'SOFLAGS=-dll -def:x264.def -implib:$(IMPLIBNAME)' >> config.mak + echo "LIBRARY" > x264.def + echo "EXPORTS" >> x264.def + grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(]" x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/open/open_$API/" >> x264.def + fi elif [ "$SYS" = "MACOSX" ]; then echo "SOSUFFIX=dylib" >> config.mak echo "SONAME=libx264.$API.dylib" >> config.mak - echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak + echo 'SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak elif [ "$SYS" = "SunOS" ]; then echo "SOSUFFIX=so" >> config.mak echo "SONAME=libx264.so.$API" >> config.mak - echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak + echo 'SOFLAGS=-shared -Wl,-h,$(SONAME)' >> config.mak else echo "SOSUFFIX=so" >> config.mak echo "SONAME=libx264.so.$API" >> config.mak - echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak + echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak fi echo 'default: $(SONAME)' >> config.mak fi diff -uNrp c/encoder/analyse.c b/encoder/analyse.c --- c/encoder/analyse.c 2010-01-14 16:09:54 +0200 +++ b/encoder/analyse.c 2010-01-20 23:01:25 +0200 @@ -23,8 +23,9 @@ *****************************************************************************/ #define _ISOC99_SOURCE -#include +#ifndef __ICL #include +#endif #include "common/common.h" #include "common/cpu.h" diff -uNrp c/encoder/encoder.c b/encoder/encoder.c --- c/encoder/encoder.c 2010-01-14 16:09:54 +0200 +++ b/encoder/encoder.c 2010-01-20 23:01:38 +0200 @@ -22,8 +22,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#include - #include "common/common.h" #include "common/cpu.h" diff -uNrp c/encoder/ratecontrol.c b/encoder/ratecontrol.c --- c/encoder/ratecontrol.c 2010-01-14 16:09:54 +0200 +++ b/encoder/ratecontrol.c 2010-01-20 23:01:46 +0200 @@ -26,7 +26,6 @@ #define _ISOC99_SOURCE #undef NDEBUG // always check asserts, the speed effect is far too small to disable them -#include #include "common/common.h" #include "common/cpu.h" diff -uNrp c/encoder/set.c b/encoder/set.c --- c/encoder/set.c 2010-01-14 16:09:54 +0200 +++ b/encoder/set.c 2010-01-20 23:01:56 +0200 @@ -21,8 +21,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#include - #include "common/common.h" #include "set.h" diff -uNrp c/encoder/slicetype.c b/encoder/slicetype.c --- c/encoder/slicetype.c 2010-01-14 16:09:54 +0200 +++ b/encoder/slicetype.c 2010-01-20 23:02:09 +0200 @@ -22,8 +22,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#include - #include "common/common.h" #include "common/cpu.h" #include "macroblock.h" diff -uNrp c/extras/inttypes.h b/extras/inttypes.h --- c/extras/inttypes.h 1970-01-01 02:00:00 +0200 +++ b/extras/inttypes.h 2010-01-20 23:02:53 +0200 @@ -0,0 +1,265 @@ +// ISO C9x compliant inttypes.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_INTTYPES_H_ // [ +#define _MSC_INTTYPES_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "stdint.h" + +// 7.8 Format conversion of integer types + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +// 7.8.1 Macros for format specifiers + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 + +// The fprintf macros for signed integers are: +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIdLEAST16 "hd" +#define PRIiLEAST16 "hi" +#define PRIdFAST16 "hd" +#define PRIiFAST16 "hi" + +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIdLEAST32 "I32d" +#define PRIiLEAST32 "I32i" +#define PRIdFAST32 "I32d" +#define PRIiFAST32 "I32i" + +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIdLEAST64 "I64d" +#define PRIiLEAST64 "I64i" +#define PRIdFAST64 "I64d" +#define PRIiFAST64 "I64i" + +#define PRIdMAX "I64d" +#define PRIiMAX "I64i" + +#define PRIdPTR "Id" +#define PRIiPTR "Ii" + +// The fprintf macros for unsigned integers are: +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" +#define PRIoLEAST16 "ho" +#define PRIuLEAST16 "hu" +#define PRIxLEAST16 "hx" +#define PRIXLEAST16 "hX" +#define PRIoFAST16 "ho" +#define PRIuFAST16 "hu" +#define PRIxFAST16 "hx" +#define PRIXFAST16 "hX" + +#define PRIo32 "I32o" +#define PRIu32 "I32u" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRIoLEAST32 "I32o" +#define PRIuLEAST32 "I32u" +#define PRIxLEAST32 "I32x" +#define PRIXLEAST32 "I32X" +#define PRIoFAST32 "I32o" +#define PRIuFAST32 "I32u" +#define PRIxFAST32 "I32x" +#define PRIXFAST32 "I32X" + +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#define PRIoLEAST64 "I64o" +#define PRIuLEAST64 "I64u" +#define PRIxLEAST64 "I64x" +#define PRIXLEAST64 "I64X" +#define PRIoFAST64 "I64o" +#define PRIuFAST64 "I64u" +#define PRIxFAST64 "I64x" +#define PRIXFAST64 "I64X" + +#define PRIoMAX "I64o" +#define PRIuMAX "I64u" +#define PRIxMAX "I64x" +#define PRIXMAX "I64X" + +#define PRIoPTR "Io" +#define PRIuPTR "Iu" +#define PRIxPTR "Ix" +#define PRIXPTR "IX" + +// The fscanf macros for signed integers are: +#define SCNd16 "hd" +#define SCNi16 "hi" +#define SCNdLEAST16 "hd" +#define SCNiLEAST16 "hi" +#define SCNdFAST16 "hd" +#define SCNiFAST16 "hi" + +#define SCNd32 "ld" +#define SCNi32 "li" +#define SCNdLEAST32 "ld" +#define SCNiLEAST32 "li" +#define SCNdFAST32 "ld" +#define SCNiFAST32 "li" + +#define SCNd64 "I64d" +#define SCNi64 "I64i" +#define SCNdLEAST64 "I64d" +#define SCNiLEAST64 "I64i" +#define SCNdFAST64 "I64d" +#define SCNiFAST64 "I64i" + +#define SCNdMAX "I64d" +#define SCNiMAX "I64i" + +#ifdef _WIN64 // [ +# define SCNdPTR "I64d" +# define SCNiPTR "I64i" +#else // _WIN64 ][ +# define SCNdPTR "ld" +# define SCNiPTR "li" +#endif // _WIN64 ] + +// The fscanf macros for unsigned integers are: +#define SCNo16 "ho" +#define SCNu16 "hu" +#define SCNx16 "hx" +#define SCNX16 "hX" +#define SCNoLEAST16 "ho" +#define SCNuLEAST16 "hu" +#define SCNxLEAST16 "hx" +#define SCNXLEAST16 "hX" +#define SCNoFAST16 "ho" +#define SCNuFAST16 "hu" +#define SCNxFAST16 "hx" +#define SCNXFAST16 "hX" + +#define SCNo32 "lo" +#define SCNu32 "lu" +#define SCNx32 "lx" +#define SCNX32 "lX" +#define SCNoLEAST32 "lo" +#define SCNuLEAST32 "lu" +#define SCNxLEAST32 "lx" +#define SCNXLEAST32 "lX" +#define SCNoFAST32 "lo" +#define SCNuFAST32 "lu" +#define SCNxFAST32 "lx" +#define SCNXFAST32 "lX" + +#define SCNo64 "I64o" +#define SCNu64 "I64u" +#define SCNx64 "I64x" +#define SCNX64 "I64X" +#define SCNoLEAST64 "I64o" +#define SCNuLEAST64 "I64u" +#define SCNxLEAST64 "I64x" +#define SCNXLEAST64 "I64X" +#define SCNoFAST64 "I64o" +#define SCNuFAST64 "I64u" +#define SCNxFAST64 "I64x" +#define SCNXFAST64 "I64X" + +#define SCNoMAX "I64o" +#define SCNuMAX "I64u" +#define SCNxMAX "I64x" +#define SCNXMAX "I64X" + +#ifdef _WIN64 // [ +# define SCNoPTR "I64o" +# define SCNuPTR "I64u" +# define SCNxPTR "I64x" +# define SCNXPTR "I64X" +#else // _WIN64 ][ +# define SCNoPTR "lo" +# define SCNuPTR "lu" +# define SCNxPTR "lx" +# define SCNXPTR "lX" +#endif // _WIN64 ] + +#endif // __STDC_FORMAT_MACROS ] + +// 7.8.2 Functions for greatest-width integer types + +// 7.8.2.1 The imaxabs function +#define imaxabs _abs64 + +// 7.8.2.2 The imaxdiv function + +// This is modified version of div() function from Microsoft's div.c found +// in %MSVC.NET%\crt\src\div.c +#ifdef STATIC_IMAXDIV // [ +static +#else // STATIC_IMAXDIV ][ +_inline +#endif // STATIC_IMAXDIV ] +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + + result.quot = numer / denom; + result.rem = numer % denom; + + if (numer < 0 && result.rem > 0) { + // did division wrong; must fix up + ++result.quot; + result.rem -= denom; + } + + return result; +} + +// 7.8.2.3 The strtoimax and strtoumax functions +#define strtoimax _strtoi64 +#define strtoumax _strtoui64 + +// 7.8.2.4 The wcstoimax and wcstoumax functions +#define wcstoimax _wcstoi64 +#define wcstoumax _wcstoui64 + + +#endif // _MSC_INTTYPES_H_ ] diff -uNrp c/tools/checkasm.c b/tools/checkasm.c --- c/tools/checkasm.c 2009-11-23 16:39:30 +0200 +++ b/tools/checkasm.c 2010-01-20 23:03:17 +0200 @@ -23,9 +23,6 @@ *****************************************************************************/ #include -#include -#include -#include #include "common/common.h" #include "common/cpu.h" diff -uNrp c/x264.c b/x264.c --- c/x264.c 2010-01-20 22:42:42 +0200 +++ b/x264.c 2010-01-20 23:04:08 +0200 @@ -23,16 +23,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#include -#include - #include #define _GNU_SOURCE #include #include "common/common.h" #include "common/cpu.h" -#include "x264.h" #include "muxers.h" #ifdef _WIN32 @@ -1038,10 +1034,12 @@ static int Parse( int argc, char **argv, printf( "x264 0.%d.X\n", X264_BUILD ); #endif printf( "built by Komisar on " __DATE__ ", " ); -#ifdef __GNUC__ +#ifdef __INTEL_COMPILER + printf( "intel: %d (%d)\n", __INTEL_COMPILER, __INTEL_COMPILER_BUILD_DATE ); +#elif defined(__GNUC__) printf( "gcc: " __VERSION__ "\n" ); #else - printf( "using a non-gcc compiler\n" ); + printf( "using an unknown compiler\n" ); #endif exit(0); case OPT_FRAMES: