From d39791bf398bedd842ed75260e9de6fcc64c6fe0 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 28 Aug 2012 17:37:54 +0200 Subject: [PATCH 1/6] x86: mpegvideoenc: Do not abuse HAVE_ variables for template instantiation This avoids trouble if HAVE_ variables are used elsewhere in the file. --- libavcodec/x86/mpegvideoenc.c | 39 +++++++++++++++----------- libavcodec/x86/mpegvideoenc_template.c | 8 +++--- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 5949a63c45..184912da94 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -30,39 +30,44 @@ extern uint16_t ff_inv_zigzag_direct16[64]; -#if HAVE_SSSE3 -#define HAVE_SSSE3_BAK -#endif -#undef HAVE_SSSE3 -#define HAVE_SSSE3 0 - -#undef HAVE_SSE2 -#undef HAVE_MMXEXT -#define HAVE_SSE2 0 -#define HAVE_MMXEXT 0 +#define COMPILE_TEMPLATE_MMXEXT 0 +#define COMPILE_TEMPLATE_SSE2 0 +#define COMPILE_TEMPLATE_SSSE3 0 #define RENAME(a) a ## _MMX #define RENAMEl(a) a ## _mmx #include "mpegvideoenc_template.c" -#undef HAVE_MMXEXT -#define HAVE_MMXEXT 1 +#undef COMPILE_TEMPLATE_SSSE3 +#undef COMPILE_TEMPLATE_SSE2 +#undef COMPILE_TEMPLATE_MMXEXT +#define COMPILE_TEMPLATE_MMXEXT 1 +#define COMPILE_TEMPLATE_SSE2 0 +#define COMPILE_TEMPLATE_SSSE3 0 #undef RENAME #undef RENAMEl #define RENAME(a) a ## _MMX2 #define RENAMEl(a) a ## _mmx2 #include "mpegvideoenc_template.c" -#undef HAVE_SSE2 -#define HAVE_SSE2 1 +#undef COMPILE_TEMPLATE_MMXEXT +#undef COMPILE_TEMPLATE_SSE2 +#undef COMPILE_TEMPLATE_SSSE3 +#define COMPILE_TEMPLATE_MMXEXT 0 +#define COMPILE_TEMPLATE_SSE2 1 +#define COMPILE_TEMPLATE_SSSE3 0 #undef RENAME #undef RENAMEl #define RENAME(a) a ## _SSE2 #define RENAMEl(a) a ## _sse2 #include "mpegvideoenc_template.c" -#ifdef HAVE_SSSE3_BAK -#undef HAVE_SSSE3 -#define HAVE_SSSE3 1 +#if HAVE_SSSE3 +#undef COMPILE_TEMPLATE_MMXEXT +#undef COMPILE_TEMPLATE_SSE2 +#undef COMPILE_TEMPLATE_SSSE3 +#define COMPILE_TEMPLATE_MMXEXT 0 +#define COMPILE_TEMPLATE_SSE2 1 +#define COMPILE_TEMPLATE_SSSE3 1 #undef RENAME #undef RENAMEl #define RENAME(a) a ## _SSSE3 diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c index 195298d8f3..a6e7ba45ee 100644 --- a/libavcodec/x86/mpegvideoenc_template.c +++ b/libavcodec/x86/mpegvideoenc_template.c @@ -29,7 +29,7 @@ #undef SAVE_SIGN #undef RESTORE_SIGN -#if HAVE_SSE2 +#if COMPILE_TEMPLATE_SSE2 #define MMREG_WIDTH "16" #define MM "%%xmm" #define MOVQ "movdqa" @@ -48,7 +48,7 @@ #define MMREG_WIDTH "8" #define MM "%%mm" #define MOVQ "movq" -#if HAVE_MMXEXT +#if COMPILE_TEMPLATE_MMXEXT #define SPREADW(a) "pshufw $0, "a", "a" \n\t" #define PMAXW(a,b) "pmaxsw "a", "b" \n\t" #define PMAX(a,b) \ @@ -74,7 +74,7 @@ #endif #endif -#if HAVE_SSSE3 +#if COMPILE_TEMPLATE_SSSE3 #define SAVE_SIGN(a,b) \ "movdqa "b", "a" \n\t"\ "pabsw "b", "b" \n\t" @@ -212,7 +212,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, SPREADW(MM"1") "psubusw "MM"1, "MM"4 \n\t" "packuswb "MM"4, "MM"4 \n\t" -#if HAVE_SSE2 +#if COMPILE_TEMPLATE_SSE2 "packuswb "MM"4, "MM"4 \n\t" #endif "movd "MM"4, %0 \n\t" // *overflow From 2f2aa2e5426d89762b3c156275d903419e9cf570 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 28 Aug 2012 17:45:24 +0200 Subject: [PATCH 2/6] x86: mpegvideoenc: fix linking with --disable-mmx The optimized dct_quantize template functions reference optimized fdct symbols, so these functions must only be enabled if the relevant optimizations have been enabled by configure. --- libavcodec/x86/mpegvideoenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 184912da94..946240dcd7 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -89,11 +89,11 @@ void ff_MPV_encode_init_x86(MpegEncContext *s) s->dct_quantize = dct_quantize_SSSE3; } else #endif - if (mm_flags & AV_CPU_FLAG_SSE2) { + if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) { s->dct_quantize = dct_quantize_SSE2; - } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { + } else if (mm_flags & AV_CPU_FLAG_MMXEXT && HAVE_MMXEXT) { s->dct_quantize = dct_quantize_MMX2; - } else { + } else if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) { s->dct_quantize = dct_quantize_MMX; } } From 2e6f93a2845e4b917e7e7aab45ec1a49d76d11bb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 28 Aug 2012 17:47:39 +0200 Subject: [PATCH 3/6] x86: Always compile files with functions that are called unconditionally --- libavcodec/x86/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 43e1a3afb4..ffa5ad94c1 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -1,4 +1,7 @@ +OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc.o OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp.o +OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o +OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoenc.o OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp_init.o OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o @@ -14,7 +17,6 @@ MMX-OBJS += x86/dsputil_mmx.o \ MMX-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o MMX-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o -MMX-OBJS-$(CONFIG_DNXHD_ENCODER) += x86/dnxhdenc.o MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp.o MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o MMX-OBJS-$(CONFIG_FFT) += x86/fft_init.o @@ -22,8 +24,6 @@ MMX-OBJS-$(CONFIG_H264DSP) += x86/h264dsp_init.o MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o MMX-OBJS-$(CONFIG_LPC) += x86/lpc.o MMX-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodec.o -MMX-OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o -MMX-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoenc.o MMX-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o MMX-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o MMX-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o From 2763587c8323983b2c3d2691ed05072e19394f3f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Aug 2012 12:50:09 +0100 Subject: [PATCH 4/6] configure: probe_cc: use separate variable for linker output flag Some tools use different command line syntax for specifying output when compiling and linking. To accomodate these, separate variables must be used. No currently supported compilers/linkers are affected by the change. Signed-off-by: Mans Rullgard --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 8ba2c3c1c1..6177943877 100755 --- a/configure +++ b/configure @@ -2129,7 +2129,7 @@ probe_cc(){ pfx=$1 _cc=$2 - unset _type _ident _cc_c _cc_e _cc_o _flags _cflags _ldflags + unset _type _ident _cc_c _cc_e _cc_o _ld_o _flags _cflags _ldflags unset _depflags _DEPCMD _DEPFLAGS _flags_filter=echo @@ -2291,7 +2291,7 @@ probe_cc ld "$ld" ldflags_filter=$_flags_filter add_ldflags $_flags $_ldflags test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags -LD_O=${_cc_o-$LD_O} +LD_O=${_ld_o-$LD_O} if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then probe_cc depcc "$dep_cc" From 095792f25351fbbaeb29504ae0a5d15c3f4b41d7 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Aug 2012 13:02:35 +0100 Subject: [PATCH 5/6] build: add separate setting for host linker This adds new HOSTLD and related settings for host linker allowing it to be different from HOSTCC. Signed-off-by: Mans Rullgard --- Makefile | 2 +- common.mak | 2 +- configure | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a2d89c5f68..c49e38171e 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ vpath %.texi $(SRC_PATH) ifndef V Q = @ ECHO = printf "$(1)\t%s\n" $(2) -BRIEF = CC HOSTCC AS YASM AR LD +BRIEF = CC HOSTCC HOSTLD AS YASM AR LD SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM MSG = $@ M = @$(call ECHO,$(TAG),$@); diff --git a/common.mak b/common.mak index ae87e76bbd..01adfeca41 100644 --- a/common.mak +++ b/common.mak @@ -38,7 +38,7 @@ $(HOSTOBJS): %.o: %.c $(call COMPILE,HOSTCC) $(HOSTPROGS): %$(HOSTEXESUF): %.o - $(HOSTCC) $(HOSTLDFLAGS) $(HOSTCC_O) $< $(HOSTLIBS) + $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $< $(HOSTLIBS) $(OBJS): | $(sort $(dir $(OBJS))) $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS))) diff --git a/configure b/configure index 6177943877..06bcc1cc7c 100755 --- a/configure +++ b/configure @@ -213,6 +213,7 @@ Advanced options (experts only): --ld=LD use linker LD --host-cc=HOSTCC use host C compiler HOSTCC --host-cflags=HCFLAGS use HCFLAGS when compiling for host + --host-ld=HOSTLD use host linker HOSTLD --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host --host-libs=HLIBS use libs HLIBS when linking for host --host-os=OS compiler host OS [$target_os] @@ -1282,6 +1283,7 @@ CMDLINE_SET=" extra_version host_cc host_cflags + host_ld host_ldflags host_libs host_os @@ -1785,6 +1787,7 @@ CC_O='-o $@' LD_O='-o $@' HOSTCC_C='-c' HOSTCC_O='-o $@' +HOSTLD_O='-o $@' host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g' host_libs='-lm' @@ -2269,9 +2272,7 @@ set_ccvars CC probe_cc hostcc "$host_cc" host_cflags_filter=$_flags_filter -host_ldflags_filter=$_flags_filter add_host_cflags $_flags $_cflags -add_host_ldflags $_flags $_ldflags set_ccvars HOSTCC test -n "$cc_type" && enable $cc_type || @@ -2280,7 +2281,8 @@ test -n "$cc_type" && enable $cc_type || : ${as_default:=$cc} : ${dep_cc_default:=$cc} : ${ld_default:=$cc} -set_default ar as dep_cc ld +: ${host_ld_default:=$host_cc} +set_default ar as dep_cc ld host_ld probe_cc as "$as" asflags_filter=$_flags_filter @@ -2293,6 +2295,11 @@ add_ldflags $_flags $_ldflags test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags LD_O=${_ld_o-$LD_O} +probe_cc hostld "$host_ld" +host_ldflags_filter=$_flags_filter +add_host_ldflags $_flags $_ldflags +HOSTLD_O=${_ld_o-$HOSTLD_O} + if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then probe_cc depcc "$dep_cc" CCDEP=${_DEPCMD:-$DEPCMD} @@ -3537,6 +3544,7 @@ ASDEP_FLAGS=$ASDEP_FLAGS CC_DEPFLAGS=$CC_DEPFLAGS AS_DEPFLAGS=$AS_DEPFLAGS HOSTCC=$host_cc +HOSTLD=$host_ld HOSTCFLAGS=$host_cflags HOSTEXESUF=$HOSTEXESUF HOSTLDFLAGS=$host_ldflags @@ -3548,6 +3556,7 @@ HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS HOSTCC_C=$HOSTCC_C HOSTCC_O=$HOSTCC_O +HOSTLD_O=$HOSTLD_O TARGET_EXEC=$target_exec TARGET_PATH=$target_path LIBS-avplay=$sdl_libs From 7baa115a33ab516c85ac94f6c5cdaee73e65ddf8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 28 Aug 2012 16:24:09 +0100 Subject: [PATCH 6/6] build: export filtered -lz flag in config.mak This is needed to link tools/cws2fws using a linker with non-standard command line syntax. Signed-off-by: Mans Rullgard --- Makefile | 2 +- configure | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c49e38171e..b766e6d00d 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ all: $(PROGS) $(TOOLS): %$(EXESUF): %.o $(LD) $(LDFLAGS) $(LD_O) $< $(ELIBS) -tools/cws2fws$(EXESUF): ELIBS = -lz +tools/cws2fws$(EXESUF): ELIBS = $(ZLIB) config.h: .config .config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) diff --git a/configure b/configure index 06bcc1cc7c..32118d0140 100755 --- a/configure +++ b/configure @@ -3561,6 +3561,7 @@ TARGET_EXEC=$target_exec TARGET_PATH=$target_path LIBS-avplay=$sdl_libs CFLAGS-avplay=$sdl_cflags +ZLIB=$($ldflags_filter -lz) LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD EXTRALIBS=$extralibs INSTALL=install