Commit 202938b1 authored by Loren Merritt's avatar Loren Merritt Committed by Fiona 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.
parent 0d387291
......@@ -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)
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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 */
......
......@@ -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."
......
......@@ -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 );
......
......@@ -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) )
......
......@@ -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 );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment