From f9bc2de28f637fa199424f544c94aeabc551eeb4 Mon Sep 17 00:00:00 2001 From: Steven Walters Date: Fri, 4 Jun 2010 13:44:55 -0700 Subject: [PATCH] Preprocessing cosmetics Unify input/output defines to HAVE_* format. Define values as 1 to simplify conditionals. --- Makefile | 8 ++-- common/bitstream.h | 2 +- common/cabac.h | 2 +- common/common.c | 10 ++-- common/common.h | 4 +- common/cpu.c | 40 ++++++++-------- common/cpu.h | 4 +- common/dct.c | 26 +++++------ common/deblock.c | 16 +++---- common/display-x11.c | 2 +- common/macroblock.h | 8 ++-- common/mc.c | 14 +++--- common/osdep.h | 36 +++++++-------- common/pixel.c | 30 ++++++------ common/ppc/ppccommon.h | 2 +- common/predict.c | 26 +++++------ common/quant.c | 16 +++---- common/x86/mc-c.c | 10 ++-- common/x86/predict-c.c | 12 ++--- configure | 102 ++++++++++++++++++++--------------------- encoder/encoder.c | 20 ++++---- encoder/lookahead.c | 4 +- encoder/me.c | 2 +- input/avs.c | 2 +- output/mp4.c | 2 +- tools/checkasm.c | 24 +++++----- x264.c | 34 +++++++------- x264dll.c | 2 +- 28 files changed, 230 insertions(+), 230 deletions(-) diff --git a/Makefile b/Makefile index 519e1812..8074ce5f 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ SRCSO = CONFIG := $(shell cat config.h) # Optional muxer module sources -ifneq ($(findstring AVS_INPUT, $(CONFIG)),) +ifneq ($(findstring HAVE_AVS, $(CONFIG)),) SRCCLI += input/avs.c endif @@ -31,15 +31,15 @@ ifneq ($(findstring HAVE_PTHREAD, $(CONFIG)),) SRCCLI += input/thread.c endif -ifneq ($(findstring LAVF_INPUT, $(CONFIG)),) +ifneq ($(findstring HAVE_LAVF, $(CONFIG)),) SRCCLI += input/lavf.c endif -ifneq ($(findstring FFMS_INPUT, $(CONFIG)),) +ifneq ($(findstring HAVE_FFMS, $(CONFIG)),) SRCCLI += input/ffms.c endif -ifneq ($(findstring MP4_OUTPUT, $(CONFIG)),) +ifneq ($(findstring HAVE_GPAC, $(CONFIG)),) SRCCLI += output/mp4.c endif diff --git a/common/bitstream.h b/common/bitstream.h index 73dc6910..1bc074a8 100644 --- a/common/bitstream.h +++ b/common/bitstream.h @@ -121,7 +121,7 @@ static inline void bs_write( bs_t *s, int i_count, uint32_t i_bits ) s->i_left -= i_count; if( s->i_left <= 32 ) { -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN M32( s->p ) = s->cur_bits >> (32 - s->i_left); #else M32( s->p ) = endian_fix( s->cur_bits << s->i_left ); diff --git a/common/cabac.h b/common/cabac.h index cec4e51a..19030796 100644 --- a/common/cabac.h +++ b/common/cabac.h @@ -62,7 +62,7 @@ void x264_cabac_encode_terminal_asm( x264_cabac_t *cb ); void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val ); void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb ); -#ifdef HAVE_MMX +#if HAVE_MMX #define x264_cabac_encode_decision x264_cabac_encode_decision_asm #define x264_cabac_encode_bypass x264_cabac_encode_bypass_asm #define x264_cabac_encode_terminal x264_cabac_encode_terminal_asm diff --git a/common/common.c b/common/common.c index 1ba420cb..2c52e403 100644 --- a/common/common.c +++ b/common/common.c @@ -26,7 +26,7 @@ #include #include -#ifdef HAVE_MALLOC_H +#if HAVE_MALLOC_H #include #endif @@ -780,7 +780,7 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) } OPT("log") p->i_log_level = atoi(value); -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE OPT("visualize") p->b_visualize = atobool(value); #endif @@ -1040,10 +1040,10 @@ void x264_picture_clean( x264_picture_t *pic ) void *x264_malloc( int i_size ) { uint8_t *align_buf = NULL; -#ifdef SYS_MACOSX +#if SYS_MACOSX /* Mac OS X always returns 16 bytes aligned memory */ align_buf = malloc( i_size ); -#elif defined( HAVE_MALLOC_H ) +#elif HAVE_MALLOC_H align_buf = memalign( 16, i_size ); #else uint8_t *buf = malloc( i_size + 15 + sizeof(void **) + sizeof(int) ); @@ -1067,7 +1067,7 @@ void x264_free( void *p ) { if( p ) { -#if defined( HAVE_MALLOC_H ) || defined( SYS_MACOSX ) +#if HAVE_MALLOC_H || SYS_MACOSX free( p ); #else free( *( ( ( void **) p ) - 1 ) ); diff --git a/common/common.h b/common/common.h index 0fc0e67b..08d30660 100644 --- a/common/common.h +++ b/common/common.h @@ -809,7 +809,7 @@ struct x264_t x264_deblock_function_t loopf; x264_bitstream_function_t bsf; -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE struct visualize_t *visualize; #endif x264_lookahead_t *lookahead; @@ -819,7 +819,7 @@ struct x264_t #include "macroblock.h" #include "rectangle.h" -#ifdef HAVE_MMX +#if HAVE_MMX #include "x86/util.h" #endif diff --git a/common/cpu.c b/common/cpu.c index 87e21c33..d873b0c2 100644 --- a/common/cpu.c +++ b/common/cpu.c @@ -26,17 +26,17 @@ #include "common.h" #include "cpu.h" -#if defined(HAVE_PTHREAD) && defined(SYS_LINUX) +#if HAVE_PTHREAD && SYS_LINUX #include #endif -#ifdef SYS_BEOS +#if SYS_BEOS #include #endif -#if defined(SYS_MACOSX) || defined(SYS_FREEBSD) +#if SYS_MACOSX || SYS_FREEBSD #include #include #endif -#ifdef SYS_OPENBSD +#if SYS_OPENBSD #include #include #include @@ -69,7 +69,7 @@ const x264_cpu_name_t x264_cpu_names[] = { {"", 0}, }; -#if (defined(ARCH_PPC) && defined(SYS_LINUX)) || (defined(ARCH_ARM) && !defined(HAVE_NEON)) +#if (ARCH_PPC && SYS_LINUX) || (ARCH_ARM && !HAVE_NEON) #include #include static sigjmp_buf jmpbuf; @@ -88,7 +88,7 @@ static void sigill_handler( int sig ) } #endif -#ifdef HAVE_MMX +#if HAVE_MMX int x264_cpu_cpuid_test( void ); uint32_t x264_cpu_cpuid( uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx ); @@ -100,7 +100,7 @@ uint32_t x264_cpu_detect( void ) int max_extended_cap; int cache; -#ifndef ARCH_X86_64 +#if !ARCH_X86_64 if( !x264_cpu_cpuid_test() ) return 0; #endif @@ -225,22 +225,22 @@ uint32_t x264_cpu_detect( void ) x264_log( NULL, X264_LOG_WARNING, "unable to determine cacheline size\n" ); } -#ifdef BROKEN_STACK_ALIGNMENT +#if BROKEN_STACK_ALIGNMENT cpu |= X264_CPU_STACK_MOD4; #endif return cpu; } -#elif defined( ARCH_PPC ) +#elif ARCH_PPC -#if defined(SYS_MACOSX) || defined(SYS_OPENBSD) +#if SYS_MACOSX || SYS_OPENBSD #include uint32_t x264_cpu_detect( void ) { /* Thank you VLC */ uint32_t cpu = 0; -#ifdef SYS_OPENBSD +#if SYS_OPENBSD int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC }; #else int selectors[2] = { CTL_HW, HW_VECTORUNIT }; @@ -255,7 +255,7 @@ uint32_t x264_cpu_detect( void ) return cpu; } -#elif defined( SYS_LINUX ) +#elif SYS_LINUX uint32_t x264_cpu_detect( void ) { @@ -281,7 +281,7 @@ uint32_t x264_cpu_detect( void ) } #endif -#elif defined( ARCH_ARM ) +#elif ARCH_ARM void x264_cpu_neon_test(); int x264_cpu_fast_neon_mrc_test(); @@ -289,11 +289,11 @@ int x264_cpu_fast_neon_mrc_test(); uint32_t x264_cpu_detect( void ) { int flags = 0; -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 flags |= X264_CPU_ARMV6; // don't do this hack if compiled with -mfpu=neon -#ifndef HAVE_NEON +#if !HAVE_NEON static void (* oldsig)( int ); oldsig = signal( SIGILL, sigill_handler ); if( sigsetjmp( jmpbuf, 1 ) ) @@ -334,13 +334,13 @@ uint32_t x264_cpu_detect( void ) int x264_cpu_num_processors( void ) { -#if !defined(HAVE_PTHREAD) +#if !HAVE_PTHREAD return 1; #elif defined(_WIN32) return pthread_num_processors_np(); -#elif defined(SYS_LINUX) +#elif SYS_LINUX unsigned int bit; int np; cpu_set_t p_aff; @@ -350,15 +350,15 @@ int x264_cpu_num_processors( void ) np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1; return np; -#elif defined(SYS_BEOS) +#elif SYS_BEOS system_info info; get_system_info( &info ); return info.cpu_count; -#elif defined(SYS_MACOSX) || defined(SYS_FREEBSD) || defined(SYS_OPENBSD) +#elif SYS_MACOSX || SYS_FREEBSD || SYS_OPENBSD int numberOfCPUs; size_t length = sizeof( numberOfCPUs ); -#ifdef SYS_OPENBSD +#if SYS_OPENBSD int mib[2] = { CTL_HW, HW_NCPU }; if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) ) #else diff --git a/common/cpu.h b/common/cpu.h index 3b61f051..96e69121 100644 --- a/common/cpu.h +++ b/common/cpu.h @@ -25,7 +25,7 @@ uint32_t x264_cpu_detect( void ); int x264_cpu_num_processors( void ); void x264_cpu_emms( void ); void x264_cpu_sfence( void ); -#ifdef HAVE_MMX +#if HAVE_MMX #define x264_emms() x264_cpu_emms() #else #define x264_emms() @@ -41,7 +41,7 @@ void x264_cpu_mask_misalign_sse( void ); * problem, but I don't want to require such a new version. * This applies only to x86_32, since other architectures that need alignment * either have ABIs that ensure aligned stack, or don't support it at all. */ -#if defined(ARCH_X86) && defined(HAVE_MMX) +#if ARCH_X86 && HAVE_MMX int x264_stack_align( void (*func)(), ... ); #define x264_stack_align(func,...) x264_stack_align((void (*)())func, __VA_ARGS__) #else diff --git a/common/dct.c b/common/dct.c index dc402b85..60dbd551 100644 --- a/common/dct.c +++ b/common/dct.c @@ -22,13 +22,13 @@ *****************************************************************************/ #include "common.h" -#ifdef HAVE_MMX +#if HAVE_MMX # include "x86/dct.h" #endif -#ifdef ARCH_PPC +#if ARCH_PPC # include "ppc/dct.h" #endif -#ifdef ARCH_ARM +#if ARCH_ARM # include "arm/dct.h" #endif @@ -418,7 +418,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf ) dctf->dct4x4dc = dct4x4dc; dctf->idct4x4dc = idct4x4dc; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMX ) { dctf->sub4x4_dct = x264_sub4x4_dct_mmx; @@ -429,7 +429,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf ) dctf->idct4x4dc = x264_idct4x4dc_mmx; dctf->sub8x8_dct_dc = x264_sub8x8_dct_dc_mmxext; -#ifndef ARCH_X86_64 +#if !ARCH_X86_64 dctf->sub8x8_dct = x264_sub8x8_dct_mmx; dctf->sub16x16_dct = x264_sub16x16_dct_mmx; dctf->add8x8_idct = x264_add8x8_idct_mmx; @@ -473,7 +473,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf ) #endif //HAVE_MMX -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) { dctf->sub4x4_dct = x264_sub4x4_dct_altivec; @@ -492,7 +492,7 @@ void x264_dct_init( int cpu, x264_dct_function_t *dctf ) } #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 if( cpu&X264_CPU_NEON ) { dctf->sub4x4_dct = x264_sub4x4_dct_neon; @@ -709,7 +709,7 @@ void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf, int b_interlaced ) pf->sub_8x8 = zigzag_sub_8x8_field; pf->sub_4x4 = zigzag_sub_4x4_field; pf->sub_4x4ac = zigzag_sub_4x4ac_field; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMXEXT ) { pf->scan_4x4 = x264_zigzag_scan_4x4_field_mmxext; @@ -722,7 +722,7 @@ void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf, int b_interlaced ) } #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) pf->scan_4x4 = x264_zigzag_scan_4x4_field_altivec; #endif @@ -734,7 +734,7 @@ void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf, int b_interlaced ) pf->sub_8x8 = zigzag_sub_8x8_frame; pf->sub_4x4 = zigzag_sub_4x4_frame; pf->sub_4x4ac = zigzag_sub_4x4ac_frame; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMX ) pf->scan_4x4 = x264_zigzag_scan_4x4_frame_mmx; if( cpu&X264_CPU_MMXEXT ) @@ -751,18 +751,18 @@ void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf, int b_interlaced ) } #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) pf->scan_4x4 = x264_zigzag_scan_4x4_frame_altivec; #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 if( cpu&X264_CPU_NEON ) pf->scan_4x4 = x264_zigzag_scan_4x4_frame_neon; #endif } pf->interleave_8x8_cavlc = zigzag_interleave_8x8_cavlc; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMX ) pf->interleave_8x8_cavlc = x264_zigzag_interleave_8x8_cavlc_mmx; if( cpu&X264_CPU_SHUFFLE_IS_FAST ) diff --git a/common/deblock.c b/common/deblock.c index 784710e0..97c86910 100644 --- a/common/deblock.c +++ b/common/deblock.c @@ -385,7 +385,7 @@ void x264_frame_deblock_row( x264_t *h, int mb_y ) } } -#ifdef HAVE_MMX +#if HAVE_MMX void x264_deblock_v_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_h_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_v_chroma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta ); @@ -404,7 +404,7 @@ void x264_deblock_strength_sse2 ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X void x264_deblock_strength_ssse3 ( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE], int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][4][4], int mvy_limit, int bframe ); -#ifdef ARCH_X86 +#if ARCH_X86 void x264_deblock_h_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_v8_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_h_luma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta ); @@ -423,12 +423,12 @@ static void x264_deblock_v_luma_intra_mmxext( uint8_t *pix, int stride, int alph #endif #endif -#ifdef ARCH_PPC +#if ARCH_PPC void x264_deblock_v_luma_altivec( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_h_luma_altivec( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); #endif // ARCH_PPC -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 void x264_deblock_v_luma_neon( uint8_t *, int, int, int, int8_t * ); void x264_deblock_h_luma_neon( uint8_t *, int, int, int, int8_t * ); void x264_deblock_v_chroma_neon( uint8_t *, int, int, int, int8_t * ); @@ -447,14 +447,14 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf ) pf->deblock_chroma_intra[0] = deblock_h_chroma_intra_c; pf->deblock_strength = deblock_strength_c; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMXEXT ) { pf->deblock_chroma[1] = x264_deblock_v_chroma_mmxext; pf->deblock_chroma[0] = x264_deblock_h_chroma_mmxext; pf->deblock_chroma_intra[1] = x264_deblock_v_chroma_intra_mmxext; pf->deblock_chroma_intra[0] = x264_deblock_h_chroma_intra_mmxext; -#ifdef ARCH_X86 +#if ARCH_X86 pf->deblock_luma[1] = x264_deblock_v_luma_mmxext; pf->deblock_luma[0] = x264_deblock_h_luma_mmxext; pf->deblock_luma_intra[1] = x264_deblock_v_luma_intra_mmxext; @@ -477,7 +477,7 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf ) } #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) { pf->deblock_luma[1] = x264_deblock_v_luma_altivec; @@ -485,7 +485,7 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf ) } #endif // HAVE_ALTIVEC -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 if( cpu&X264_CPU_NEON ) { pf->deblock_luma[1] = x264_deblock_v_luma_neon; diff --git a/common/display-x11.c b/common/display-x11.c index bbdde882..1fc75f47 100644 --- a/common/display-x11.c +++ b/common/display-x11.c @@ -153,7 +153,7 @@ void disp_gray( int num, char *data, int width, int height, int stride, const un int dpy_depth = DefaultDepth( disp_display, screen ); XImage *ximage = XCreateImage( disp_display, visual, dpy_depth, ZPixmap, 0, &dummy, width, height, 8, 0 ); disp_chkerror( !ximage, "no ximage" ); -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN ximage->byte_order = MSBFirst; ximage->bitmap_bit_order = MSBFirst; #else diff --git a/common/macroblock.h b/common/macroblock.h index 8a617682..b2723da2 100644 --- a/common/macroblock.h +++ b/common/macroblock.h @@ -310,7 +310,7 @@ void x264_mb_mc_8x8( x264_t *h, int i8 ); static ALWAYS_INLINE uint32_t pack16to32( int a, int b ) { -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN return b + (a<<16); #else return a + (b<<16); @@ -318,7 +318,7 @@ static ALWAYS_INLINE uint32_t pack16to32( int a, int b ) } static ALWAYS_INLINE uint32_t pack8to16( int a, int b ) { -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN return b + (a<<8); #else return a + (b<<8); @@ -326,7 +326,7 @@ static ALWAYS_INLINE uint32_t pack8to16( int a, int b ) } static ALWAYS_INLINE uint32_t pack8to32( int a, int b, int c, int d ) { -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN return d + (c<<8) + (b<<16) + (a<<24); #else return a + (b<<8) + (c<<16) + (d<<24); @@ -334,7 +334,7 @@ static ALWAYS_INLINE uint32_t pack8to32( int a, int b, int c, int d ) } static ALWAYS_INLINE uint32_t pack16to32_mask( int a, int b ) { -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN return (b&0xFFFF) + (a<<16); #else return (a&0xFFFF) + (b<<16); diff --git a/common/mc.c b/common/mc.c index daff9e04..9776becf 100644 --- a/common/mc.c +++ b/common/mc.c @@ -23,13 +23,13 @@ #include "common.h" -#ifdef HAVE_MMX +#if HAVE_MMX #include "x86/mc.h" #endif -#ifdef ARCH_PPC +#if ARCH_PPC #include "ppc/mc.h" #endif -#ifdef ARCH_ARM +#if ARCH_ARM #include "arm/mc.h" #endif @@ -404,7 +404,7 @@ static void frame_init_lowres_core( pixel *src0, pixel *dst0, pixel *dsth, pixel } } -#if defined(__GNUC__) && (defined(ARCH_X86) || defined(ARCH_X86_64)) +#if defined(__GNUC__) && (ARCH_X86 || ARCH_X86_64) // gcc isn't smart enough to use the "idiv" instruction static ALWAYS_INLINE int32_t div_64_32(int64_t x, int32_t y) { @@ -474,14 +474,14 @@ void x264_mc_init( int cpu, x264_mc_functions_t *pf ) pf->mbtree_propagate_cost = mbtree_propagate_cost; -#ifdef HAVE_MMX +#if HAVE_MMX x264_mc_init_mmx( cpu, pf ); #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) x264_mc_altivec_init( pf ); #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 x264_mc_init_arm( cpu, pf ); #endif } diff --git a/common/osdep.h b/common/osdep.h index 4f49d308..b1b357c0 100644 --- a/common/osdep.h +++ b/common/osdep.h @@ -31,13 +31,13 @@ #include "config.h" -#ifdef HAVE_STDINT_H +#if HAVE_STDINT_H #include #else #include #endif -#ifndef HAVE_LOG2F +#if !HAVE_LOG2F #define log2f(x) (logf(x)/0.693147180559945f) #define log2(x) (log(x)/0.693147180559945) #endif @@ -47,7 +47,7 @@ #include // _O_BINARY #endif -#if (defined(SYS_OPENBSD) && !defined(isfinite)) || defined(SYS_SunOS) +#if (SYS_OPENBSD && !defined(isfinite)) || SYS_SunOS #define isfinite finite #endif #ifdef _WIN32 @@ -68,7 +68,7 @@ // - armcc can't either, but is nice enough to actually tell you so // - Apple gcc only maintains 4 byte alignment // - llvm can align the stack, but only in svn and (unrelated) it exposes bugs in all released GNU binutils... -#if defined(ARCH_ARM) && defined(SYS_MACOSX) +#if ARCH_ARM && SYS_MACOSX #define ALIGNED_ARRAY_8( type, name, sub1, ... )\ uint8_t name##_u [sizeof(type sub1 __VA_ARGS__) + 7]; \ type (*name) __VA_ARGS__ = (void*)((intptr_t)(name##_u+7) & ~7) @@ -77,7 +77,7 @@ ALIGNED_8( type name sub1 __VA_ARGS__ ) #endif -#ifdef ARCH_ARM +#if ARCH_ARM #define ALIGNED_ARRAY_16( type, name, sub1, ... )\ uint8_t name##_u [sizeof(type sub1 __VA_ARGS__) + 15];\ type (*name) __VA_ARGS__ = (void*)((intptr_t)(name##_u+15) & ~15) @@ -103,7 +103,7 @@ #endif /* threads */ -#if defined(SYS_BEOS) +#if SYS_BEOS #include #define x264_pthread_t thread_id static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(void *), void *d ) @@ -121,9 +121,9 @@ static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(vo #endif #define HAVE_PTHREAD 1 -#elif defined(HAVE_PTHREAD) +#elif HAVE_PTHREAD #include -#define USE_REAL_PTHREAD +#define USE_REAL_PTHREAD 1 #else #define x264_pthread_t int @@ -131,7 +131,7 @@ static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(vo #define x264_pthread_join(t,s) #endif //SYS_* -#ifdef USE_REAL_PTHREAD +#if USE_REAL_PTHREAD #define x264_pthread_t pthread_t #define x264_pthread_create pthread_create #define x264_pthread_join pthread_join @@ -172,23 +172,23 @@ static inline int x264_pthread_create( x264_pthread_t *t, void *a, void *(*f)(vo #if !defined(_WIN64) && !defined(__LP64__) #if defined(__INTEL_COMPILER) -#define BROKEN_STACK_ALIGNMENT /* define it if stack is not mod16 */ +#define BROKEN_STACK_ALIGNMENT 1 /* define it if stack is not mod16 */ #endif #endif -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN #define endian_fix(x) (x) #define endian_fix64(x) (x) #define endian_fix32(x) (x) #define endian_fix16(x) (x) #else -#if defined(__GNUC__) && defined(HAVE_MMX) +#if defined(__GNUC__) && HAVE_MMX static ALWAYS_INLINE uint32_t endian_fix32( uint32_t x ) { asm("bswap %0":"+r"(x)); return x; } -#elif defined(__GNUC__) && defined(HAVE_ARMV6) +#elif defined(__GNUC__) && HAVE_ARMV6 static ALWAYS_INLINE uint32_t endian_fix32( uint32_t x ) { asm("rev %0, %0":"+r"(x)); @@ -200,7 +200,7 @@ static ALWAYS_INLINE uint32_t endian_fix32( uint32_t x ) return (x<<24) + ((x<<8)&0xff0000) + ((x>>8)&0xff00) + (x>>24); } #endif -#if defined(__GNUC__) && defined(ARCH_X86_64) +#if defined(__GNUC__) && ARCH_X86_64 static ALWAYS_INLINE uint64_t endian_fix64( uint64_t x ) { asm("bswap %0":"+r"(x)); @@ -251,7 +251,7 @@ static int ALWAYS_INLINE x264_ctz( uint32_t x ) } #endif -#if defined(__GNUC__) && defined(HAVE_MMX) +#if defined(__GNUC__) && HAVE_MMX /* Don't use __builtin_prefetch; even as recent as 4.3.4, GCC seems incapable of * using complex address modes properly unless we use inline asm. */ static ALWAYS_INLINE void x264_prefetch( void *p ) @@ -261,14 +261,14 @@ static ALWAYS_INLINE void x264_prefetch( void *p ) /* We require that prefetch not fault on invalid reads, so we only enable it on * known architectures. */ #elif defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 1) &&\ - (defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_ARM) || defined(ARCH_PPC)) + (ARCH_X86 || ARCH_X86_64 || ARCH_ARM || ARCH_PPC) #define x264_prefetch(x) __builtin_prefetch(x) #else #define x264_prefetch(x) #endif -#ifdef USE_REAL_PTHREAD -#ifdef SYS_MINGW +#if USE_REAL_PTHREAD +#if SYS_MINGW #define x264_lower_thread_priority(p)\ {\ x264_pthread_t handle = pthread_self();\ diff --git a/common/pixel.c b/common/pixel.c index 19540092..580686e4 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -23,16 +23,16 @@ #include "common.h" -#ifdef HAVE_MMX +#if HAVE_MMX # include "x86/pixel.h" #endif -#ifdef ARCH_PPC +#if ARCH_PPC # include "ppc/pixel.h" #endif -#ifdef ARCH_ARM +#if ARCH_ARM # include "arm/pixel.h" #endif -#ifdef ARCH_UltraSparc +#if ARCH_UltraSparc # include "sparc/pixel.h" #endif @@ -406,7 +406,7 @@ SAD_X( 8x4 ) SAD_X( 4x8 ) SAD_X( 4x4 ) -#ifdef ARCH_UltraSparc +#if ARCH_UltraSparc SAD_X( 16x16_vis ) SAD_X( 16x8_vis ) SAD_X( 8x16_vis ) @@ -444,14 +444,14 @@ SATD_X_DECL6( cpu )\ SATD_X( 4x4, cpu ) SATD_X_DECL7() -#ifdef HAVE_MMX +#if HAVE_MMX SATD_X_DECL7( _mmxext ) SATD_X_DECL6( _sse2 ) SATD_X_DECL7( _ssse3 ) SATD_X_DECL7( _sse4 ) #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 SATD_X_DECL7( _neon ) #endif @@ -678,7 +678,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) pixf->intra_sad_x3_16x16 = x264_intra_sad_x3_16x16; pixf->intra_satd_x3_16x16 = x264_intra_satd_x3_16x16; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMX ) { INIT7( ssd, _mmx ); @@ -697,7 +697,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) INIT_ADS( _mmxext ); pixf->var[PIXEL_16x16] = x264_pixel_var_16x16_mmxext; pixf->var[PIXEL_8x8] = x264_pixel_var_8x8_mmxext; -#ifdef ARCH_X86 +#if ARCH_X86 pixf->sa8d[PIXEL_16x16] = x264_pixel_sa8d_16x16_mmxext; pixf->sa8d[PIXEL_8x8] = x264_pixel_sa8d_8x8_mmxext; pixf->intra_sa8d_x3_8x8 = x264_intra_sa8d_x3_8x8_mmxext; @@ -746,7 +746,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) pixf->ssim_end4 = x264_pixel_ssim_end4_sse2; pixf->sa8d[PIXEL_16x16] = x264_pixel_sa8d_16x16_sse2; pixf->sa8d[PIXEL_8x8] = x264_pixel_sa8d_8x8_sse2; -#ifdef ARCH_X86_64 +#if ARCH_X86_64 pixf->intra_sa8d_x3_8x8 = x264_intra_sa8d_x3_8x8_sse2; #endif pixf->var2_8x8 = x264_pixel_var2_8x8_sse2; @@ -770,7 +770,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) if( cpu&X264_CPU_CACHELINE_64 ) { INIT2( ssd, _sse2); /* faster for width 16 on p4 */ -#ifdef ARCH_X86 +#if ARCH_X86 INIT2( sad, _cache64_sse2 ); INIT2( sad_x3, _cache64_sse2 ); INIT2( sad_x4, _cache64_sse2 ); @@ -829,7 +829,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) pixf->intra_satd_x3_8x8c = x264_intra_satd_x3_8x8c_ssse3; pixf->intra_sad_x3_8x8c = x264_intra_sad_x3_8x8c_ssse3; pixf->intra_satd_x3_4x4 = x264_intra_satd_x3_4x4_ssse3; -#ifdef ARCH_X86_64 +#if ARCH_X86_64 pixf->intra_sa8d_x3_8x8 = x264_intra_sa8d_x3_8x8_ssse3; #endif pixf->var2_8x8 = x264_pixel_var2_8x8_ssse3; @@ -859,7 +859,7 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) } #endif //HAVE_MMX -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 if( cpu&X264_CPU_ARMV6 ) { pixf->sad[PIXEL_4x8] = x264_pixel_sad_4x8_armv6; @@ -900,13 +900,13 @@ void x264_pixel_init( int cpu, x264_pixel_function_t *pixf ) } } #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) { x264_pixel_altivec_init( pixf ); } #endif -#ifdef ARCH_UltraSparc +#if ARCH_UltraSparc INIT4( sad, _vis ); INIT4( sad_x3, _vis ); INIT4( sad_x4, _vis ); diff --git a/common/ppc/ppccommon.h b/common/ppc/ppccommon.h index e61afaa9..43974837 100644 --- a/common/ppc/ppccommon.h +++ b/common/ppc/ppccommon.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. *****************************************************************************/ -#ifdef HAVE_ALTIVEC_H +#if HAVE_ALTIVEC_H #include #endif diff --git a/common/predict.c b/common/predict.c index afc2b046..782dfa32 100644 --- a/common/predict.c +++ b/common/predict.c @@ -27,13 +27,13 @@ #include "common.h" -#ifdef HAVE_MMX +#if HAVE_MMX # include "x86/predict.h" #endif -#ifdef ARCH_PPC +#if ARCH_PPC # include "ppc/predict.h" #endif -#ifdef ARCH_ARM +#if ARCH_ARM # include "arm/predict.h" #endif @@ -716,16 +716,16 @@ void x264_predict_16x16_init( int cpu, x264_predict_t pf[7] ) pf[I_PRED_16x16_DC_TOP ]= x264_predict_16x16_dc_top_c; pf[I_PRED_16x16_DC_128 ]= x264_predict_16x16_dc_128_c; -#ifdef HAVE_MMX +#if HAVE_MMX x264_predict_16x16_init_mmx( cpu, pf ); #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) x264_predict_16x16_init_altivec( pf ); #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 x264_predict_16x16_init_arm( cpu, pf ); #endif } @@ -740,16 +740,16 @@ void x264_predict_8x8c_init( int cpu, x264_predict_t pf[7] ) pf[I_PRED_CHROMA_DC_TOP ]= x264_predict_8x8c_dc_top_c; pf[I_PRED_CHROMA_DC_128 ]= x264_predict_8x8c_dc_128_c; -#ifdef HAVE_MMX +#if HAVE_MMX x264_predict_8x8c_init_mmx( cpu, pf ); #endif -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) x264_predict_8x8c_init_altivec( pf ); #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 x264_predict_8x8c_init_arm( cpu, pf ); #endif } @@ -770,11 +770,11 @@ void x264_predict_8x8_init( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_ pf[I_PRED_8x8_DC_128] = x264_predict_8x8_dc_128_c; *predict_filter = x264_predict_8x8_filter_c; -#ifdef HAVE_MMX +#if HAVE_MMX x264_predict_8x8_init_mmx( cpu, pf, predict_filter ); #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 x264_predict_8x8_init_arm( cpu, pf, predict_filter ); #endif } @@ -794,11 +794,11 @@ void x264_predict_4x4_init( int cpu, x264_predict_t pf[12] ) pf[I_PRED_4x4_DC_TOP] = x264_predict_4x4_dc_top_c; pf[I_PRED_4x4_DC_128] = x264_predict_4x4_dc_128_c; -#ifdef HAVE_MMX +#if HAVE_MMX x264_predict_4x4_init_mmx( cpu, pf ); #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 x264_predict_4x4_init_arm( cpu, pf ); #endif } diff --git a/common/quant.c b/common/quant.c index d3ba7e36..ece52f9d 100644 --- a/common/quant.c +++ b/common/quant.c @@ -23,13 +23,13 @@ #include "common.h" -#ifdef HAVE_MMX +#if HAVE_MMX #include "x86/quant.h" #endif -#ifdef ARCH_PPC +#if ARCH_PPC # include "ppc/quant.h" #endif -#ifdef ARCH_ARM +#if ARCH_ARM # include "arm/quant.h" #endif @@ -287,10 +287,10 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf ) pf->coeff_level_run[ DCT_LUMA_AC] = x264_coeff_level_run15; pf->coeff_level_run[ DCT_LUMA_4x4] = x264_coeff_level_run16; -#ifdef HAVE_MMX +#if HAVE_MMX if( cpu&X264_CPU_MMX ) { -#ifdef ARCH_X86 +#if ARCH_X86 pf->quant_4x4 = x264_quant_4x4_mmx; pf->quant_8x8 = x264_quant_8x8_mmx; pf->dequant_4x4 = x264_dequant_4x4_mmx; @@ -308,7 +308,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf ) if( cpu&X264_CPU_MMXEXT ) { pf->quant_2x2_dc = x264_quant_2x2_dc_mmxext; -#ifdef ARCH_X86 +#if ARCH_X86 pf->quant_4x4_dc = x264_quant_4x4_dc_mmxext; pf->decimate_score15 = x264_decimate_score15_mmxext; pf->decimate_score16 = x264_decimate_score16_mmxext; @@ -395,7 +395,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf ) } #endif // HAVE_MMX -#ifdef HAVE_ALTIVEC +#if HAVE_ALTIVEC if( cpu&X264_CPU_ALTIVEC ) { pf->quant_2x2_dc = x264_quant_2x2_dc_altivec; pf->quant_4x4_dc = x264_quant_4x4_dc_altivec; @@ -407,7 +407,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf ) } #endif -#ifdef HAVE_ARMV6 +#if HAVE_ARMV6 if( cpu&X264_CPU_ARMV6 ) pf->coeff_last[DCT_CHROMA_DC] = x264_coeff_last4_arm; diff --git a/common/x86/mc-c.c b/common/x86/mc-c.c index 5906ddd4..4ddf2e5b 100644 --- a/common/x86/mc-c.c +++ b/common/x86/mc-c.c @@ -142,7 +142,7 @@ static void (* const x264_pixel_avg_wtab_##instr[6])( uint8_t *, int, uint8_t *, #define x264_pixel_avg2_w12_sse2 x264_pixel_avg2_w16_sse2 PIXEL_AVG_WTAB(mmxext, mmxext, mmxext, mmxext, mmxext, mmxext) -#ifdef ARCH_X86 +#if ARCH_X86 PIXEL_AVG_WTAB(cache32_mmxext, mmxext, cache32_mmxext, cache32_mmxext, cache32_mmxext, cache32_mmxext) PIXEL_AVG_WTAB(cache64_mmxext, mmxext, cache64_mmxext, cache64_mmxext, cache64_mmxext, cache64_mmxext) #endif @@ -256,7 +256,7 @@ static void mc_luma_##name( uint8_t *dst, int i_dst_stride,\ } MC_LUMA(mmxext,mmxext,mmx) -#ifdef ARCH_X86 +#if ARCH_X86 MC_LUMA(cache32_mmxext,cache32_mmxext,mmx) MC_LUMA(cache64_mmxext,cache64_mmxext,mmx) #endif @@ -296,7 +296,7 @@ static uint8_t *get_ref_##name( uint8_t *dst, int *i_dst_stride,\ } GET_REF(mmxext) -#ifdef ARCH_X86 +#if ARCH_X86 GET_REF(cache32_mmxext) GET_REF(cache64_mmxext) #endif @@ -333,7 +333,7 @@ static void x264_hpel_filter_##cpu( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, HPEL(8, mmxext, mmxext, mmxext, mmxext) HPEL(16, sse2_amd, mmxext, mmxext, sse2) -#ifdef ARCH_X86_64 +#if ARCH_X86_64 void x264_hpel_filter_sse2( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, int stride, int width, int height, int16_t *buf ); void x264_hpel_filter_ssse3( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, int stride, int width, int height, int16_t *buf ); #else @@ -398,7 +398,7 @@ void x264_mc_init_mmx( int cpu, x264_mc_functions_t *pf ) pf->prefetch_fenc = x264_prefetch_fenc_mmxext; pf->prefetch_ref = x264_prefetch_ref_mmxext; -#ifdef ARCH_X86 // all x86_64 cpus with cacheline split issues use sse2 instead +#if ARCH_X86 // all x86_64 cpus with cacheline split issues use sse2 instead if( cpu&X264_CPU_CACHELINE_32 ) { pf->mc_luma = mc_luma_cache32_mmxext; diff --git a/common/x86/predict-c.c b/common/x86/predict-c.c index 0e3e1c79..e771431e 100644 --- a/common/x86/predict-c.c +++ b/common/x86/predict-c.c @@ -249,7 +249,7 @@ static void x264_predict_8x8c_dc_mmxext( uint8_t *src ) x264_predict_8x8c_dc_core_mmxext( src, s2, s3 ); } -#ifdef ARCH_X86_64 +#if ARCH_X86_64 static void x264_predict_8x8c_dc_left( uint8_t *src ) { int y; @@ -358,7 +358,7 @@ void x264_intra_sa8d_x3_8x8_##cpu( uint8_t *fenc, uint8_t edge[33], int res[3] ) x264_intra_sa8d_x3_8x8_core_##cpu( fenc, sa8d_1d, res );\ } -#ifdef ARCH_X86_64 +#if ARCH_X86_64 INTRA_SA8D_X3(sse2) INTRA_SA8D_X3(ssse3) #else @@ -378,7 +378,7 @@ void x264_predict_16x16_init_mmx( int cpu, x264_predict_t pf[7] ) pf[I_PRED_16x16_DC] = x264_predict_16x16_dc_mmxext; pf[I_PRED_16x16_DC_TOP] = x264_predict_16x16_dc_top_mmxext; pf[I_PRED_16x16_DC_LEFT] = x264_predict_16x16_dc_left_mmxext; -#ifndef ARCH_X86_64 +#if !ARCH_X86_64 pf[I_PRED_16x16_P] = x264_predict_16x16_p_mmxext; #endif pf[I_PRED_16x16_H] = x264_predict_16x16_h_mmxext; @@ -403,7 +403,7 @@ void x264_predict_8x8c_init_mmx( int cpu, x264_predict_t pf[7] ) { if( !(cpu&X264_CPU_MMX) ) return; -#ifdef ARCH_X86_64 +#if ARCH_X86_64 pf[I_PRED_CHROMA_DC_LEFT] = x264_predict_8x8c_dc_left; #endif pf[I_PRED_CHROMA_V] = x264_predict_8x8c_v_mmx; @@ -411,7 +411,7 @@ void x264_predict_8x8c_init_mmx( int cpu, x264_predict_t pf[7] ) return; pf[I_PRED_CHROMA_DC_TOP] = x264_predict_8x8c_dc_top_mmxext; pf[I_PRED_CHROMA_H] = x264_predict_8x8c_h_mmxext; -#ifndef ARCH_X86_64 +#if !ARCH_X86_64 pf[I_PRED_CHROMA_P] = x264_predict_8x8c_p_mmxext; #endif pf[I_PRED_CHROMA_DC] = x264_predict_8x8c_dc_mmxext; @@ -437,7 +437,7 @@ void x264_predict_8x8_init_mmx( int cpu, x264_predict8x8_t pf[12], x264_predict_ pf[I_PRED_8x8_DC_LEFT]= x264_predict_8x8_dc_left_mmxext; pf[I_PRED_8x8_HD] = x264_predict_8x8_hd_mmxext; *predict_8x8_filter = x264_predict_8x8_filter_mmxext; -#ifdef ARCH_X86 +#if ARCH_X86 pf[I_PRED_8x8_DDL] = x264_predict_8x8_ddl_mmxext; pf[I_PRED_8x8_DDR] = x264_predict_8x8_ddr_mmxext; pf[I_PRED_8x8_VR] = x264_predict_8x8_vr_mmxext; diff --git a/configure b/configure index b35d120c..68b41684 100755 --- a/configure +++ b/configure @@ -7,10 +7,10 @@ echo "" echo "available options:" echo "" echo " --help print this message" -echo " --disable-avs-input disables avisynth input (win32 only)" -echo " --disable-lavf-input disables libavformat input" -echo " --disable-ffms-input disables ffmpegsource input" -echo " --disable-mp4-output disables mp4 output (using gpac)" +echo " --disable-avs disables avisynth support (windows only)" +echo " --disable-lavf disables libavformat support" +echo " --disable-ffms disables ffmpegsource support" +echo " --disable-gpac disables gpac support" echo " --disable-pthread disables multithreaded encoding" echo " --disable-asm disables platform-specific assembly optimizations" echo " --enable-debug adds -g, doesn't strip" @@ -95,7 +95,7 @@ as_check() { } define() { - echo "#define $1$([ -n "$2" ] && echo " $2")" >> config.h + echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h } die() { @@ -113,10 +113,10 @@ libdir='${exec_prefix}/lib' includedir='${prefix}/include' DEVNULL='/dev/null' -avs_input="auto" -lavf_input="auto" -ffms_input="auto" -mp4_output="auto" +avs="auto" +lavf="auto" +ffms="auto" +gpac="auto" pthread="auto" asm="auto" debug="no" @@ -157,17 +157,17 @@ for opt do --disable-asm) asm="no" ;; - --disable-avs-input) - avs_input="no" + --disable-avs) + avs="no" ;; - --disable-lavf-input) - lavf_input="no" + --disable-lavf) + lavf="no" ;; - --disable-ffms-input) - ffms_input="no" + --disable-ffms) + ffms="no" ;; - --disable-mp4-output) - mp4_output="no" + --disable-gpac) + gpac="no" ;; --extra-asflags=*) ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}" @@ -504,8 +504,8 @@ else vis="no" fi -if [ "$lavf_input" = "auto" ] ; then - lavf_input="no" +if [ "$lavf" = "auto" ] ; then + lavf="no" if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libswscale)" LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libswscale)" @@ -521,18 +521,18 @@ if [ "$lavf_input" = "auto" ] ; then cc_check libswscale/swscale.h "$LAVF_CFLAGS $LAVF_LIBS" ; then # avcodec_decode_video2 is currently the most recently added function that we use; it was added in r18351 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2( NULL, NULL, NULL, NULL );" ; then - lavf_input="yes" - define LAVF_INPUT + lavf="yes" + define HAVE_LAVF else echo "Warning: libavformat is too old, update to ffmpeg r18351+" fi fi fi -if [ "$ffms_input" = "auto" ] ; then +if [ "$ffms" = "auto" ] ; then ffms_major="2"; ffms_minor="13"; ffms_micro="1"; ffms_bump="0" - ffms_input="no" + ffms="no" [ $ffms_micro -gt 0 -o $ffms_bump -gt 0 ] && vmicro=".$ffms_micro" [ $ffms_bump -gt 0 ] && vbump=".$ffms_bump" if ${cross_prefix}pkg-config --atleast-version="$ffms_major.$ffms_minor$vmicro$vbump" ffms2 2>$DEVNULL; then @@ -545,13 +545,13 @@ if [ "$ffms_input" = "auto" ] ; then [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2" if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then - ffms_input="yes" + ffms="yes" elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then - ffms_input="yes" + ffms="yes" FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS" fi - if [ $api_check = "yes" -a $ffms_input = "yes" ]; then + if [ $api_check = "yes" -a $ffms = "yes" ]; then log_check "whether ffms2 version is at least $ffms_major.$ffms_minor$vmicro$vbump" $CC $CFLAGS $FFMS2_CFLAGS -c -o conftest -x c - >$DEVNULL 2>&1 < @@ -559,50 +559,50 @@ if [ "$ffms_input" = "auto" ] ; then #error Requires ffms2 version 2.13.1 #endif EOF - [ $? = 0 ] && log_ok || { ffms_input="no"; log_fail; } + [ $? = 0 ] && log_ok || { ffms="no"; log_fail; } fi fi -if [ "$ffms_input" = "yes" ]; then +if [ "$ffms" = "yes" ]; then LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI" [ -n "$FFMS2_CFLAGS" ] && CFLAGS="$CFLAGS $FFMS2_CFLAGS" - define FFMS_INPUT -elif [ "$lavf_input" = "yes" ]; then + define HAVE_FFMS +elif [ "$lavf" = "yes" ]; then LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI" [ -n "$LAVF_CFLAGS" ] && CFLAGS="$CFLAGS $LAVF_CFLAGS" fi -MP4_LDFLAGS="-lgpac_static" +GPAC_LIBS="-lgpac_static" if [ $SYS = MINGW ]; then - MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm" + GPAC_LIBS="$GPAC_LIBS -lwinmm" fi -if [ "$mp4_output" = "auto" ] ; then - mp4_output="no" - if cc_check gpac/isomedia.h "$MP4_LDFLAGS" ; then - if cc_check gpac/isomedia.h "$MP4_LDFLAGS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then - mp4_output="yes" +if [ "$gpac" = "auto" ] ; then + gpac="no" + if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then + if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then + gpac="yes" else echo "Warning: gpac is too old, update to 2007-06-21 UTC or later" fi fi fi -if [ "$mp4_output" = "yes" ] ; then - define MP4_OUTPUT - if cc_check gpac/isomedia.h "-Werror $MP4_LDFLAGS" "gf_malloc(1); gf_free(NULL);" ; then +if [ "$gpac" = "yes" ] ; then + define HAVE_GPAC + if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then define HAVE_GF_MALLOC fi - LDFLAGSCLI="$LDFLAGSCLI $MP4_LDFLAGS" + LDFLAGSCLI="$LDFLAGSCLI $GPAC_LIBS" fi -if [ "$avs_input" = "auto" ] ; then - avs_input=no +if [ "$avs" = "auto" ] ; then + avs=no if [ $SYS = MINGW ] && cc_check avisynth_c.h ; then - avs_input="yes" - define AVS_INPUT + avs="yes" + define HAVE_AVS define HAVE_AVISYNTH_C_H elif [ $SYS = MINGW ] && cc_check extras/avisynth_c.h ; then - avs_input="yes" - define AVS_INPUT + avs="yes" + define HAVE_AVS fi fi @@ -706,10 +706,10 @@ cat > conftest.log <param.i_threads = x264_clip3( h->param.i_threads, 1, X264_THREAD_MAX ); if( h->param.i_threads > 1 ) { -#ifndef HAVE_PTHREAD +#if !HAVE_PTHREAD x264_log( h, X264_LOG_WARNING, "not compiled with pthread support!\n"); h->param.i_threads = 1; #endif @@ -607,7 +607,7 @@ static int x264_validate_parameters( x264_t *h ) h->param.rc.b_mb_tree = 0; if( h->param.rc.b_stat_read ) h->param.rc.i_lookahead = 0; -#ifdef HAVE_PTHREAD +#if HAVE_PTHREAD if( h->param.i_sync_lookahead < 0 ) h->param.i_sync_lookahead = h->param.i_bframe + 1; h->param.i_sync_lookahead = X264_MIN( h->param.i_sync_lookahead, X264_LOOKAHEAD_MAX ); @@ -1035,7 +1035,7 @@ x264_t *x264_encoder_open( x264_param_t *param ) if( x264_clz( temp ) != 23 ) { x264_log( h, X264_LOG_ERROR, "CLZ test failed: x264 has been miscompiled!\n" ); -#if defined(ARCH_X86) || defined(ARCH_X86_64) +#if ARCH_X86 || ARCH_X86_64 x264_log( h, X264_LOG_ERROR, "Are you attempting to run an SSE4a-targeted build on a CPU that\n" ); x264_log( h, X264_LOG_ERROR, "doesn't support it?\n" ); #endif @@ -1894,7 +1894,7 @@ static int x264_slice_write( x264_t *h ) else h->mb.b_reencode_mb = 0; -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE if( h->param.b_visualize ) x264_visualize_mb( h ); #endif @@ -2045,13 +2045,13 @@ static void *x264_slices_write( x264_t *h ) if( h->param.i_sync_lookahead ) x264_lower_thread_priority( 10 ); -#ifdef HAVE_MMX +#if HAVE_MMX /* Misalign mask has to be set separately for each thread. */ if( h->param.cpu&X264_CPU_SSE_MISALIGN ) x264_cpu_mask_misalign_sse(); #endif -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE if( h->param.b_visualize ) if( x264_visualize_init( h ) ) return (void *)-1; @@ -2078,7 +2078,7 @@ static void *x264_slices_write( x264_t *h ) h->sh.i_first_mb = h->sh.i_last_mb + 1; } -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE if( h->param.b_visualize ) { x264_visualize_show( h ); @@ -2092,7 +2092,7 @@ static void *x264_slices_write( x264_t *h ) static int x264_threaded_slices_write( x264_t *h ) { void *ret = NULL; -#ifdef HAVE_MMX +#if HAVE_MMX if( h->param.cpu&X264_CPU_SSE_MISALIGN ) x264_cpu_mask_misalign_sse(); #endif diff --git a/encoder/lookahead.c b/encoder/lookahead.c index 942e9526..a79d4b12 100644 --- a/encoder/lookahead.c +++ b/encoder/lookahead.c @@ -62,7 +62,7 @@ static void x264_lookahead_update_last_nonb( x264_t *h, x264_frame_t *new_nonb ) new_nonb->i_reference_count++; } -#ifdef HAVE_PTHREAD +#if HAVE_PTHREAD static void x264_lookahead_slicetype_decide( x264_t *h ) { x264_stack_align( x264_slicetype_decide, h ); @@ -87,7 +87,7 @@ static void x264_lookahead_slicetype_decide( x264_t *h ) static void x264_lookahead_thread( x264_t *h ) { int shift; -#ifdef HAVE_MMX +#if HAVE_MMX if( h->param.cpu&X264_CPU_SSE_MISALIGN ) x264_cpu_mask_misalign_sse(); #endif diff --git a/encoder/me.c b/encoder/me.c index 7efd592f..3950dc37 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -672,7 +672,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, if( WORD_SIZE == 8 && sizeof(mvsad_t) == 8 ) { uint64_t mvsad = M64( &mvsads[i] ) = M64( &mvsads[j] ); -#ifdef WORDS_BIGENDIAN +#if WORDS_BIGENDIAN mvsad >>= 32; #endif sad = mvsad; diff --git a/input/avs.c b/input/avs.c index 4c91a708..07add40e 100644 --- a/input/avs.c +++ b/input/avs.c @@ -30,7 +30,7 @@ #define __declspec(i) #undef EXTERN_C -#ifdef HAVE_AVISYNTH_C_H +#if HAVE_AVISYNTH_C_H #include #else #include "extras/avisynth_c.h" diff --git a/output/mp4.c b/output/mp4.c index 0aa50707..0e3c2fc1 100644 --- a/output/mp4.c +++ b/output/mp4.c @@ -24,7 +24,7 @@ #include "muxers.h" #include -#ifdef HAVE_GF_MALLOC +#if HAVE_GF_MALLOC #undef malloc #undef free #define malloc gf_malloc diff --git a/tools/checkasm.c b/tools/checkasm.c index 87157f9c..1c6c2007 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -31,7 +31,7 @@ #include "common/cpu.h" // GCC doesn't align stack variables on ARM, so use .bss -#ifdef ARCH_ARM +#if ARCH_ARM #undef ALIGNED_16 #define ALIGNED_16( var ) DECLARE_ALIGNED( static var, 16 ) #endif @@ -85,11 +85,11 @@ static const char **intra_predict_8x8_names = intra_predict_4x4_names; static inline uint32_t read_time(void) { uint32_t a = 0; -#if defined(__GNUC__) && (defined(ARCH_X86) || defined(ARCH_X86_64)) +#if defined(__GNUC__) && (ARCH_X86 || ARCH_X86_64) asm volatile( "rdtsc" :"=a"(a) ::"edx" ); -#elif defined(ARCH_PPC) +#elif ARCH_PPC asm volatile( "mftb %0" : "=r" (a) ); -#elif defined(ARCH_ARM) // ARMv7 only +#elif ARCH_ARM // ARMv7 only asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(a) ); #endif return a; @@ -182,7 +182,7 @@ static void print_bench(void) } } -#if defined(ARCH_X86) || defined(ARCH_X86_64) +#if ARCH_X86 || ARCH_X86_64 int x264_stack_pagealign( int (*func)(), int align ); #else #define x264_stack_pagealign( func, align ) func() @@ -190,7 +190,7 @@ int x264_stack_pagealign( int (*func)(), int align ); #define call_c1(func,...) func(__VA_ARGS__) -#if defined(ARCH_X86) || defined(_WIN64) +#if ARCH_X86 || defined(_WIN64) /* detect when callee-saved regs aren't saved. * needs an explicit asm check because it only sometimes crashes in normal use. */ intptr_t x264_checkasm_call( intptr_t (*func)(), int *ok, ... ); @@ -1614,7 +1614,7 @@ static void run_cabac_terminal_##cpu( uint8_t *dst )\ x264_cabac_encode_terminal_##cpu( &cb );\ } DECL_CABAC(c) -#ifdef HAVE_MMX +#if HAVE_MMX DECL_CABAC(asm) #else #define run_cabac_decision_asm run_cabac_decision_c @@ -1729,13 +1729,13 @@ static int check_all_flags( void ) { int ret = 0; int cpu0 = 0, cpu1 = 0; -#ifdef HAVE_MMX +#if HAVE_MMX if( x264_cpu_detect() & X264_CPU_MMXEXT ) { ret |= add_flags( &cpu0, &cpu1, X264_CPU_MMX | X264_CPU_MMXEXT, "MMX" ); ret |= add_flags( &cpu0, &cpu1, X264_CPU_CACHELINE_64, "MMX Cache64" ); cpu1 &= ~X264_CPU_CACHELINE_64; -#ifdef ARCH_X86 +#if ARCH_X86 ret |= add_flags( &cpu0, &cpu1, X264_CPU_CACHELINE_32, "MMX Cache32" ); cpu1 &= ~X264_CPU_CACHELINE_32; #endif @@ -1790,13 +1790,13 @@ static int check_all_flags( void ) cpu1 &= ~X264_CPU_CACHELINE_64; ret |= add_flags( &cpu0, &cpu1, X264_CPU_SSE4, "SSE4" ); } -#elif defined(ARCH_PPC) +#elif ARCH_PPC if( x264_cpu_detect() & X264_CPU_ALTIVEC ) { fprintf( stderr, "x264: ALTIVEC against C\n" ); ret = check_all_funcs( 0, X264_CPU_ALTIVEC ); } -#elif defined(ARCH_ARM) +#elif ARCH_ARM if( x264_cpu_detect() & X264_CPU_ARMV6 ) ret |= add_flags( &cpu0, &cpu1, X264_CPU_ARMV6, "ARMv6" ); if( x264_cpu_detect() & X264_CPU_NEON ) @@ -1813,7 +1813,7 @@ int main(int argc, char *argv[]) if( argc > 1 && !strncmp( argv[1], "--bench", 7 ) ) { -#if !defined(ARCH_X86) && !defined(ARCH_X86_64) && !defined(ARCH_PPC) && !defined(ARCH_ARM) +#if !ARCH_X86 && !ARCH_X86_64 && !ARCH_PPC && !ARCH_ARM fprintf( stderr, "no --bench for your cpu until you port rdtsc\n" ); return 1; #endif diff --git a/x264.c b/x264.c index 149eaacd..50498936 100644 --- a/x264.c +++ b/x264.c @@ -71,13 +71,13 @@ static const char * const demuxer_names[] = "auto", "yuv", "y4m", -#ifdef AVS_INPUT +#if HAVE_AVS "avs", #endif -#ifdef LAVF_INPUT +#if HAVE_LAVF "lavf", #endif -#ifdef FFMS_INPUT +#if HAVE_FFMS "ffms", #endif 0 @@ -89,7 +89,7 @@ static const char * const muxer_names[] = "raw", "mkv", "flv", -#ifdef MP4_OUTPUT +#if HAVE_GPAC "mp4", #endif 0 @@ -150,7 +150,7 @@ int main( int argc, char **argv ) cli_opt_t opt; int ret; -#ifdef PTW32_STATIC_LIB +#if PTW32_STATIC_LIB pthread_win32_process_attach_np(); pthread_win32_thread_attach_np(); #endif @@ -169,7 +169,7 @@ int main( int argc, char **argv ) ret = Encode( ¶m, &opt ); -#ifdef PTW32_STATIC_LIB +#if PTW32_STATIC_LIB pthread_win32_thread_detach_np(); pthread_win32_process_detach_np(); #endif @@ -225,22 +225,22 @@ static void Help( x264_param_t *defaults, int longhelp ) " --fullhelp List all options\n" "\n", X264_BUILD, X264_VERSION, -#ifdef AVS_INPUT +#if HAVE_AVS "yes", #else "no", #endif -#ifdef LAVF_INPUT +#if HAVE_LAVF "yes", #else "no", #endif -#ifdef FFMS_INPUT +#if HAVE_FFMS "yes", #else "no", #endif -#ifdef MP4_OUTPUT +#if HAVE_GPAC "yes" #else "no" @@ -762,7 +762,7 @@ static int select_output( const char *muxer, char *filename, x264_param_t *param if( !strcasecmp( ext, "mp4" ) ) { -#ifdef MP4_OUTPUT +#if HAVE_GPAC output = mp4_output; param->b_annexb = 0; param->b_dts_compress = 0; @@ -817,7 +817,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename if( !strcasecmp( module, "avs" ) || !strcasecmp( ext, "d2v" ) || !strcasecmp( ext, "dga" ) ) { -#ifdef AVS_INPUT +#if HAVE_AVS input = avs_input; module = "avs"; #else @@ -831,7 +831,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename input = yuv_input; else { -#ifdef FFMS_INPUT +#if HAVE_FFMS if( b_regular && (b_auto || !strcasecmp( demuxer, "ffms" )) && !ffms_input.open_file( filename, p_handle, info, opt ) ) { @@ -840,7 +840,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename input = ffms_input; } #endif -#ifdef LAVF_INPUT +#if HAVE_LAVF if( (b_auto || !strcasecmp( demuxer, "lavf" )) && !lavf_input.open_file( filename, p_handle, info, opt ) ) { @@ -849,7 +849,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename input = lavf_input; } #endif -#ifdef AVS_INPUT +#if HAVE_AVS if( b_regular && (b_auto || !strcasecmp( demuxer, "avs" )) && !avs_input.open_file( filename, p_handle, info, opt ) ) { @@ -1035,7 +1035,7 @@ static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt ) opt->b_progress = 0; break; case OPT_VISUALIZE: -#ifdef HAVE_VISUALIZE +#if HAVE_VISUALIZE param->b_visualize = 1; b_exit_on_ctrl_c = 1; #else @@ -1245,7 +1245,7 @@ generic_option: param->vui.i_sar_height = info.sar_height; } -#ifdef HAVE_PTHREAD +#if HAVE_PTHREAD if( b_thread_input || param->i_threads > 1 || (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1) ) { diff --git a/x264dll.c b/x264dll.c index 2b6524df..075eaba3 100644 --- a/x264dll.c +++ b/x264dll.c @@ -26,7 +26,7 @@ /* Callback for our DLL so we can initialize pthread */ BOOL WINAPI DllMain( HANDLE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { -#ifdef PTW32_STATIC_LIB +#if PTW32_STATIC_LIB switch( fdwReason ) { case DLL_PROCESS_ATTACH: -- 2.40.0