From ec36aa69448f20a78d8c4588265022e0b2272ab5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 29 Aug 2012 11:14:17 +0200 Subject: [PATCH] x86: Fix linking with some or all of yasm, mmx, optimizations disabled Some optimized template functions reference optimized symbols, so they must be explicitly disabled when those symbols are unavailable. --- libavcodec/x86/mpegaudiodec.c | 2 ++ libavcodec/x86/mpegvideoenc.c | 34 ++++++++++++++++++++++------------ libavcodec/x86/rv40dsp_init.c | 3 +++ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/libavcodec/x86/mpegaudiodec.c b/libavcodec/x86/mpegaudiodec.c index 701ae75138..d2573dd274 100644 --- a/libavcodec/x86/mpegaudiodec.c +++ b/libavcodec/x86/mpegaudiodec.c @@ -182,6 +182,7 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out, #endif /* HAVE_INLINE_ASM */ +#if HAVE_YASM #define DECL_IMDCT_BLOCKS(CPU1, CPU2) \ static void imdct36_blocks_ ## CPU1(float *out, float *buf, float *in, \ int count, int switch_point, int block_type) \ @@ -219,6 +220,7 @@ DECL_IMDCT_BLOCKS(sse2,sse) DECL_IMDCT_BLOCKS(sse3,sse) DECL_IMDCT_BLOCKS(ssse3,sse) DECL_IMDCT_BLOCKS(avx,avx) +#endif /* HAVE_YASM */ void ff_mpadsp_init_mmx(MPADSPContext *s) { diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 946240dcd7..c3d8b835e5 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -30,13 +30,16 @@ extern uint16_t ff_inv_zigzag_direct16[64]; +#if HAVE_MMX #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" +#endif /* HAVE_MMX */ +#if HAVE_MMXEXT #undef COMPILE_TEMPLATE_SSSE3 #undef COMPILE_TEMPLATE_SSE2 #undef COMPILE_TEMPLATE_MMXEXT @@ -48,7 +51,9 @@ extern uint16_t ff_inv_zigzag_direct16[64]; #define RENAME(a) a ## _MMX2 #define RENAMEl(a) a ## _mmx2 #include "mpegvideoenc_template.c" +#endif /* HAVE_MMXEXT */ +#if HAVE_SSE2 #undef COMPILE_TEMPLATE_MMXEXT #undef COMPILE_TEMPLATE_SSE2 #undef COMPILE_TEMPLATE_SSSE3 @@ -60,6 +65,7 @@ extern uint16_t ff_inv_zigzag_direct16[64]; #define RENAME(a) a ## _SSE2 #define RENAMEl(a) a ## _sse2 #include "mpegvideoenc_template.c" +#endif /* HAVE_SSE2 */ #if HAVE_SSSE3 #undef COMPILE_TEMPLATE_MMXEXT @@ -73,7 +79,7 @@ extern uint16_t ff_inv_zigzag_direct16[64]; #define RENAME(a) a ## _SSSE3 #define RENAMEl(a) a ## _sse2 #include "mpegvideoenc_template.c" -#endif +#endif /* HAVE_SSSE3 */ #endif /* HAVE_INLINE_ASM */ @@ -84,18 +90,22 @@ void ff_MPV_encode_init_x86(MpegEncContext *s) const int dct_algo = s->avctx->dct_algo; if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) { -#if HAVE_SSSE3 - if (mm_flags & AV_CPU_FLAG_SSSE3) { - s->dct_quantize = dct_quantize_SSSE3; - } else -#endif - if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) { - s->dct_quantize = dct_quantize_SSE2; - } else if (mm_flags & AV_CPU_FLAG_MMXEXT && HAVE_MMXEXT) { - s->dct_quantize = dct_quantize_MMX2; - } else if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) { +#if HAVE_MMX + if (mm_flags & AV_CPU_FLAG_MMX && HAVE_MMX) s->dct_quantize = dct_quantize_MMX; - } +#endif +#if HAVE_MMXEXT + if (mm_flags & AV_CPU_FLAG_MMXEXT && HAVE_MMXEXT) + s->dct_quantize = dct_quantize_MMX2; +#endif +#if HAVE_SSE2 + if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE2) + s->dct_quantize = dct_quantize_SSE2; +#endif +#if HAVE_SSSE3 + if (mm_flags & AV_CPU_FLAG_SSSE3) + s->dct_quantize = dct_quantize_SSSE3; +#endif } #endif /* HAVE_INLINE_ASM */ } diff --git a/libavcodec/x86/rv40dsp_init.c b/libavcodec/x86/rv40dsp_init.c index 3541ddfb70..3fccf49d0f 100644 --- a/libavcodec/x86/rv40dsp_init.c +++ b/libavcodec/x86/rv40dsp_init.c @@ -30,6 +30,7 @@ #include "libavutil/mem.h" #include "dsputil_mmx.h" +#if HAVE_YASM void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); void ff_avg_rv40_chroma_mc8_mmx2 (uint8_t *dst, uint8_t *src, @@ -183,6 +184,8 @@ QPEL_FUNCS_SET (OP, 3, 1, OPT) \ QPEL_FUNCS_SET (OP, 3, 2, OPT) /** @} */ +#endif /* HAVE_YASM */ + void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp) { #if HAVE_YASM