summaryrefslogtreecommitdiff
path: root/libswscale
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2012-08-29 19:01:05 +0200
committerDiego Biurrun <diego@biurrun.de>2012-09-08 18:18:34 +0200
commite0c6cce44729d94e2a5507a4b6d031f23e8bd7b6 (patch)
tree5118ee396e1879c3f90dfc1898e9bbd868e4b583 /libswscale
parent6a0200f24de51eeb94a3a1f75ee105786a6e088d (diff)
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.
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/utils.c20
-rw-r--r--libswscale/x86/rgb2rgb.c9
-rw-r--r--libswscale/x86/swscale.c15
3 files changed, 21 insertions, 23 deletions
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");
diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index f201281fac..59626804cc 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -28,6 +28,7 @@
#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
#include "libavutil/bswap.h"
#include "libswscale/rgb2rgb.h"
@@ -133,13 +134,13 @@ av_cold void rgb2rgb_init_x86(void)
#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
- if (cpu_flags & AV_CPU_FLAG_MMX)
+ if (INLINE_MMX(cpu_flags))
rgb2rgb_init_MMX();
- if (HAVE_AMD3DNOW && cpu_flags & AV_CPU_FLAG_3DNOW)
+ if (INLINE_AMD3DNOW(cpu_flags))
rgb2rgb_init_3DNOW();
- if (HAVE_MMXEXT && cpu_flags & AV_CPU_FLAG_MMXEXT)
+ if (INLINE_MMXEXT(cpu_flags))
rgb2rgb_init_MMX2();
- if (HAVE_SSE && cpu_flags & AV_CPU_FLAG_SSE2)
+ if (INLINE_SSE2(cpu_flags))
rgb2rgb_init_SSE2();
#endif /* HAVE_INLINE_ASM */
}
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 581d6f79f7..23d09d9ffe 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -25,6 +25,7 @@
#include "libavutil/attributes.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
#include "libavutil/pixdesc.h"
@@ -314,7 +315,6 @@ av_cold void ff_sws_init_swScale_mmx(SwsContext *c)
#endif
#endif /* HAVE_INLINE_ASM */
-#if HAVE_YASM
#define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
if (c->srcBpc == 8) { \
hscalefn = c->dstBpc <= 10 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
@@ -357,7 +357,7 @@ switch(c->dstBpc){ \
c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
break
#if ARCH_X86_32
- if (cpu_flags & AV_CPU_FLAG_MMX) {
+ if (EXTERNAL_MMX(cpu_flags)) {
ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmx2, cpu_flags & AV_CPU_FLAG_MMXEXT);
@@ -392,7 +392,7 @@ switch(c->dstBpc){ \
break;
}
}
- if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
+ if (EXTERNAL_MMXEXT(cpu_flags)) {
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmx2, , 1);
}
#endif /* ARCH_X86_32 */
@@ -404,7 +404,7 @@ switch(c->dstBpc){ \
else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
break; \
}
- if (cpu_flags & AV_CPU_FLAG_SSE2) {
+ if (EXTERNAL_SSE2(cpu_flags)) {
ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
@@ -441,7 +441,7 @@ switch(c->dstBpc){ \
break;
}
}
- if (cpu_flags & AV_CPU_FLAG_SSSE3) {
+ if (EXTERNAL_SSSE3(cpu_flags)) {
ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
switch (c->srcFormat) {
@@ -451,7 +451,7 @@ switch(c->dstBpc){ \
break;
}
}
- if (cpu_flags & AV_CPU_FLAG_SSE4) {
+ if (EXTERNAL_SSE4(cpu_flags)) {
/* Xto15 don't need special sse4 functions */
ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
@@ -462,7 +462,7 @@ switch(c->dstBpc){ \
c->yuv2plane1 = ff_yuv2plane1_16_sse4;
}
- if (cpu_flags & AV_CPU_FLAG_AVX) {
+ if (EXTERNAL_AVX(cpu_flags)) {
ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
HAVE_ALIGNED_STACK || ARCH_X86_64);
ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
@@ -490,5 +490,4 @@ switch(c->dstBpc){ \
break;
}
}
-#endif
}