From e0c6cce44729d94e2a5507a4b6d031f23e8bd7b6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 29 Aug 2012 19:01:05 +0200 Subject: x86: Replace checks for CPU extensions and flags by convenience macros This separates code relying on inline from that relying on external assembly and fixes instances where the coalesced check was incorrect. --- libswscale/utils.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'libswscale/utils.c') diff --git a/libswscale/utils.c b/libswscale/utils.c index 200346cab5..34e4744347 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -46,6 +46,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" #include "rgb2rgb.h" #include "swscale.h" #include "swscale_internal.h" @@ -473,7 +474,7 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos, filterAlign = 1; } - if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { + if (INLINE_MMX(cpu_flags)) { // special case for unscaled vertical filtering if (minFilterSize == 1 && filterAlign == 2) filterAlign = 1; @@ -973,8 +974,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, (FFALIGN(srcW, 16) * 2 * FFALIGN(c->srcBpc, 8) >> 3) + 16, fail); - if (HAVE_MMXEXT && HAVE_INLINE_ASM && cpu_flags & AV_CPU_FLAG_MMXEXT && - c->srcBpc == 8 && c->dstBpc <= 10) { + if (INLINE_MMXEXT(cpu_flags) && c->srcBpc == 8 && c->dstBpc <= 10) { c->canMMX2BeUsed = (dstW >= srcW && (dstW & 31) == 0 && (srcW & 15) == 0) ? 1 : 0; if (!c->canMMX2BeUsed && dstW >= srcW && (srcW & 15) == 0 @@ -1004,7 +1004,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, c->chrXInc += 20; } // we don't use the x86 asm scaler if MMX is available - else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { + else if (INLINE_MMX(cpu_flags)) { c->lumXInc = ((int64_t)(srcW - 2) << 16) / (dstW - 2) - 20; c->chrXInc = ((int64_t)(c->chrSrcW - 2) << 16) / (c->chrDstW - 2) - 20; } @@ -1050,8 +1050,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } else #endif /* HAVE_MMXEXT_INLINE */ { - const int filterAlign = - (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 4 : + const int filterAlign = INLINE_MMX(cpu_flags) ? 4 : (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 : 1; @@ -1074,8 +1073,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, /* precalculate vertical scaler filter coefficients */ { - const int filterAlign = - (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 2 : + const int filterAlign = INLINE_MMX(cpu_flags) ? 2 : (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 : 1; @@ -1208,11 +1206,11 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, #endif sws_format_name(dstFormat)); - if (HAVE_MMXEXT && cpu_flags & AV_CPU_FLAG_MMXEXT) + if (INLINE_MMXEXT(cpu_flags)) av_log(c, AV_LOG_INFO, "using MMX2\n"); - else if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW) + else if (INLINE_AMD3DNOW(cpu_flags)) av_log(c, AV_LOG_INFO, "using 3DNOW\n"); - else if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) + else if (INLINE_MMX(cpu_flags)) av_log(c, AV_LOG_INFO, "using MMX\n"); else if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) av_log(c, AV_LOG_INFO, "using AltiVec\n"); -- cgit v1.2.3