[x264-devel] commit: Fix log2f detection, include order, some gcc warnings ( Loren Merritt )

git version control git at videolan.org
Sat Jan 30 21:19:53 CET 2010


x264 | branch: master | Loren Merritt <pengvado at akuvian.org> | Sat Jan 30 12:01:51 2010 -0800| [3f3343abfba8a2377a66b6a7f7a8c564ade86bc6] | committer: Jason Garrett-Glaser 

Fix log2f detection, include order, some gcc warnings
r1413 caused crashes on any system with malloc.h.
Also switch to std=c99 or std=gnu99 if supported by the compiler.
Fix visualize support.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=3f3343abfba8a2377a66b6a7f7a8c564ade86bc6
---

 Makefile              |    6 +++---
 common/common.c       |   10 +++++-----
 common/common.h       |    2 +-
 common/cpu.c          |    8 ++++----
 common/osdep.h        |    2 ++
 configure             |   22 +++++++++++++++-------
 encoder/encoder.c     |    8 ++++----
 encoder/ratecontrol.c |    2 +-
 output/flv.c          |    2 +-
 9 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile
index cef8725..3ac975d 100644
--- a/Makefile
+++ b/Makefile
@@ -138,8 +138,8 @@ checkasm: tools/checkasm.o libx264.a
 	-@ $(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;)
+	@rm -f .depend
+	@$(foreach SRC, $(SRCS) $(SRCCLI) $(SRCSO), $(CC) $(CFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;)
 
 config.mak:
 	./configure
@@ -186,7 +186,7 @@ clean:
 	- sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
 
 distclean: clean
-	rm -f config.mak config.h x264.pc
+	rm -f config.mak config.h config.log x264.pc
 	rm -rf test/
 
 install: x264$(EXE) $(SONAME)
diff --git a/common/common.c b/common/common.c
index b454e37..6d1d7f0 100644
--- a/common/common.c
+++ b/common/common.c
@@ -21,6 +21,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#include "common.h"
+#include "cpu.h"
+
 #include <stdarg.h>
 #include <ctype.h>
 
@@ -28,9 +31,6 @@
 #include <malloc.h>
 #endif
 
-#include "common.h"
-#include "cpu.h"
-
 static void x264_log_default( void *, int, const char *, va_list );
 
 /****************************************************************************
@@ -263,7 +263,7 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
         if( b_error )
         {
             char *buf = strdup(value);
-            char *tok, UNUSED *saveptr, *init;
+            char *tok, UNUSED *saveptr=NULL, *init;
             b_error = 0;
             p->cpu = 0;
             for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL )
@@ -474,7 +474,7 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
     }
     OPT("log")
         p->i_log_level = atoi(value);
-#ifdef VISUALIZE
+#ifdef HAVE_VISUALIZE
     OPT("visualize")
         p->b_visualize = atobool(value);
 #endif
diff --git a/common/common.h b/common/common.h
index a52e531..950f48f 100644
--- a/common/common.h
+++ b/common/common.h
@@ -739,7 +739,7 @@ struct x264_t
     x264_quant_function_t quantf;
     x264_deblock_function_t loopf;
 
-#if VISUALIZE
+#ifdef HAVE_VISUALIZE
     struct visualize_t *visualize;
 #endif
     x264_lookahead_t *lookahead;
diff --git a/common/cpu.c b/common/cpu.c
index 2715652..9f2d5a6 100644
--- a/common/cpu.c
+++ b/common/cpu.c
@@ -22,8 +22,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define _GNU_SOURCE // for sched_getaffinity
+#include "common.h"
+#include "cpu.h"
+
 #if defined(HAVE_PTHREAD) && defined(SYS_LINUX)
-#define _GNU_SOURCE
 #include <sched.h>
 #endif
 #ifdef SYS_BEOS
@@ -39,9 +42,6 @@
 #include <machine/cpu.h>
 #endif
 
-#include "common.h"
-#include "cpu.h"
-
 const x264_cpu_name_t x264_cpu_names[] = {
     {"Altivec", X264_CPU_ALTIVEC},
 //  {"MMX",     X264_CPU_MMX}, // we don't support asm on mmx1 cpus anymore
diff --git a/common/osdep.h b/common/osdep.h
index 907bcee..7f680ed 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -165,6 +165,8 @@ static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(vo
 
 #define WORD_SIZE sizeof(void*)
 
+#define asm __asm__
+
 #if !defined(_WIN64) && !defined(__LP64__)
 #if defined(__INTEL_COMPILER)
 #define BROKEN_STACK_ALIGNMENT /* define it if stack is not mod16 */
diff --git a/configure b/configure
index 2fd2bb8..b254383 100755
--- a/configure
+++ b/configure
@@ -45,15 +45,17 @@ log_msg() {
 
 cc_check() {
     if [ -z "$3" ]; then
-        if [ -z "$1" ]; then
+        if [ -z "$1$2" ]; then
             log_check "whether $CC works"
+        elif [ -z "$1" ]; then
+            log_check "for $2"
         else
             log_check "for $1"
         fi
     elif [ -z "$1" ]; then
         log_check "whether $CC supports $3"
     else
-        log_check "for $3 on $1";
+        log_check "for $3 in $1";
     fi
     rm -f conftest.c
     [ -n "$1" ] && echo "#include <$1>" > conftest.c
@@ -212,7 +214,7 @@ for opt do
             ;;
         --enable-visualize)
             LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
-            define VISUALIZE
+            define HAVE_VISUALIZE
             vis="yes"
             ;;
         --host=*)
@@ -392,6 +394,12 @@ log_msg ""
 
 cc_check || die "No working C compiler found."
 
+if cc_check '' -std=gnu99 ; then
+    CFLAGS="$CFLAGS -std=gnu99"
+elif cc_check '' -std=c99 ; then
+    CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
+fi
+
 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" \) ] ; then
     pic="yes"
 fi
@@ -404,7 +412,7 @@ if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
         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"
@@ -419,9 +427,9 @@ if [ $asm = yes -a $ARCH = ARM ] ; then
     # set flags so neon is built by default
     echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
 
-    if  cc_check '' '' 'asm("rev ip, ip");' ; then      define HAVE_ARMV6   && ASFLAGS="$ASFLAGS -DHAVE_ARMV6"
-        cc_check '' '' 'asm("movt r0, #0");'         && define HAVE_ARMV6T2 && ASFLAGS="$ASFLAGS -DHAVE_ARMV6T2"
-        cc_check '' '' 'asm("vadd.i16 q0, q0, q0");' && define HAVE_NEON    && ASFLAGS="$ASFLAGS -DHAVE_NEON"
+    if  cc_check '' '' '__asm__("rev ip, ip");' ; then      define HAVE_ARMV6   && ASFLAGS="$ASFLAGS -DHAVE_ARMV6"
+        cc_check '' '' '__asm__("movt r0, #0");'         && define HAVE_ARMV6T2 && ASFLAGS="$ASFLAGS -DHAVE_ARMV6T2"
+        cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON    && ASFLAGS="$ASFLAGS -DHAVE_NEON"
         ASFLAGS="$ASFLAGS -c"
     else
         echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 0a16a6b..d873cd0 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -33,7 +33,7 @@
 #include "macroblock.h"
 #include "me.h"
 
-#if VISUALIZE
+#ifdef HAVE_VISUALIZE
 #include "common/visualize.h"
 #endif
 
@@ -1787,7 +1787,7 @@ static int x264_slice_write( x264_t *h )
         else
             h->mb.b_reencode_mb = 0;
 
-#if VISUALIZE
+#ifdef HAVE_VISUALIZE
         if( h->param.b_visualize )
             x264_visualize_mb( h );
 #endif
@@ -1929,7 +1929,7 @@ static void *x264_slices_write( x264_t *h )
         x264_cpu_mask_misalign_sse();
 #endif
 
-#if VISUALIZE
+#ifdef HAVE_VISUALIZE
     if( h->param.b_visualize )
         if( x264_visualize_init( h ) )
             return (void *)-1;
@@ -1956,7 +1956,7 @@ static void *x264_slices_write( x264_t *h )
         h->sh.i_first_mb = h->sh.i_last_mb + 1;
     }
 
-#if VISUALIZE
+#ifdef HAVE_VISUALIZE
     if( h->param.b_visualize )
     {
         x264_visualize_show( h );
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 5304616..63b3be6 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -818,7 +818,7 @@ fail:
 static int parse_zone( x264_t *h, x264_zone_t *z, char *p )
 {
     int len = 0;
-    char *tok, UNUSED *saveptr;
+    char *tok, UNUSED *saveptr=NULL;
     z->param = NULL;
     z->f_bitrate_factor = 1;
     if( 3 <= sscanf(p, "%u,%u,q=%u%n", &z->i_start, &z->i_end, &z->i_qp, &len) )
diff --git a/output/flv.c b/output/flv.c
index d73466b..b3e5d16 100644
--- a/output/flv.c
+++ b/output/flv.c
@@ -229,7 +229,7 @@ static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_
         if( prev_cts == cts )
         {
             double fps = ((double)p_flv->i_timebase_den / p_flv->i_timebase_num) / (p_picture->i_pts - p_flv->i_prev_pts);
-            fprintf( stderr, "flv [warning]: duplicate CTS %"PRId64" is generated by rounding\n"
+            fprintf( stderr, "flv [warning]: duplicate CTS %"PRId64" generated by rounding\n"
                              "               current internal composition framerate: %.6f fps\n", cts, fps );
         }
     }



More information about the x264-devel mailing list