]> git.sesse.net Git - x264/commitdiff
Fix log2f detection, include order, some gcc warnings
authorLoren Merritt <pengvado@akuvian.org>
Sat, 30 Jan 2010 20:01:51 +0000 (12:01 -0800)
committerFiona Glaser <fiona@x264.com>
Sat, 30 Jan 2010 20:14:04 +0000 (12:14 -0800)
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.

Makefile
common/common.c
common/common.h
common/cpu.c
common/osdep.h
configure
encoder/encoder.c
encoder/ratecontrol.c
output/flv.c

index cef87250d8beaefeff6cc88592c66a602d303ee8..3ac975d51292f5e072a3f8d440786533594284cb 100644 (file)
--- 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)
index b454e37e31f5f0d753ce9ece49e1764c221903a7..6d1d7f06392b6bd2d8d7abd64d94c1b389e9b531 100644 (file)
@@ -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
index a52e5310c38e32b25067c6c31fed43c7270e51b1..950f48f964aaf0f5286021e28072517342d7b91f 100644 (file)
@@ -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;
index 0f0bd7814b8fe7f3116e4b0970d7d16b38167b26..9b3da24f74d14d784530068f89320615cd1efd0d 100644 (file)
  * 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
index 907bceee396d5390f1cbb346cff67d4cb0edb76c..7f680ed039ad2ba269f28559467d7894c3e60de8 100644 (file)
@@ -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 */
index 2fd2bb8c36e8390d8789542c65aeadb1eb14b732..b254383eca5bc513609bfb737d589a2fdc367518 100755 (executable)
--- 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."
index 8d3bc34406febb87aa70e8b03c182c52305a2e8e..b68899511d5df98367554bc4d3ba72f3b068e061 100644 (file)
@@ -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 );
index fef6c9a1712c1c3c8b2327518043545d719fc9c2..6b2601f8135106521e7eb2ce999142baf34bee99 100644 (file)
@@ -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) )
index d73466b5ddb764cd1dca420b5561ca044e9c05ac..b3e5d16dd6cf1a68c88fe2616793d8893b4509ff 100644 (file)
@@ -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 );
         }
     }