[FFmpeg-devel] [PATCH 39/41] swscale/x86/swscale: Disable overridden functions on x64

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jun 10 02:55:21 EEST 2022


x64 always has MMX, MMXEXT, SSE and SSE2 and this means
that some functions for MMX, MMXEXT, SSE and 3dnow are always
overridden by other functions (unless one e.g. explicitly
disables SSE2). This commit therefore disables
the MMX implementation (which is overridden by MMXEXT)
at compile-time for x64.

Notice that yuv2yuvX_mmx is not removed, because it is used
by SSE3 and AVX2 as fallback in case of unaligned data and
also for tail processing. I don't know why yuv2yuvX_mmxext
isn't being used for this; an earlier version [1] of
554c2bc7086f49ef5a6a989ad6bc4bc11807eb6f used it, but
the version that was eventually applied does not.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-November/272124.html

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
There is some issue with 32bit versions of some of the MMX functions
here, leading to failures with the f32le and f32be versions of
gray, gbrp and gbrap. See
https://fate.ffmpeg.org/report.cgi?time=20220609221253&slot=x86_32-debian-kfreebsd-gcc-4.4-cpuflags-mmx
It does not affect x64 and if SSE2 is available, the MMX functions
are overridden by SSE2 functions that don't suffer from this defect.
This is a good reason to remove these overridden functions for x86, too.

 libswscale/x86/swscale.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 73869355b8..5cc174694c 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -55,7 +55,7 @@ DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w1111)        = 0x0001000100010001ULL;
 
 
 //MMX versions
-#if HAVE_MMX_INLINE
+#if ARCH_X86_32 && HAVE_MMX_INLINE
 #undef RENAME
 #define COMPILE_TEMPLATE_MMXEXT 0
 #define RENAME(a) a ## _mmx
@@ -470,7 +470,7 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
 {
     int cpu_flags = av_get_cpu_flags();
 
-#if HAVE_MMX_INLINE
+#if ARCH_X86_32 && HAVE_MMX_INLINE
     if (INLINE_MMX(cpu_flags))
         sws_init_swscale_mmx(c);
 #endif
@@ -479,7 +479,7 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
         sws_init_swscale_mmxext(c);
 #endif
     if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)) {
-#if HAVE_MMX_EXTERNAL
+#if ARCH_X86_32 && HAVE_MMX_EXTERNAL
         if (EXTERNAL_MMX(cpu_flags))
             c->yuv2planeX = yuv2yuvX_mmx;
 #endif
-- 
2.34.1



More information about the ffmpeg-devel mailing list