[FFmpeg-devel] [PATCH 11/41] avcodec/x86/audiodsp_init: Disable overridden functions on x64

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jun 10 02:54:53 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 such audiodsp functions
at compile-time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/x86/audiodsp.asm    | 4 ++++
 libavcodec/x86/audiodsp_init.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/x86/audiodsp.asm b/libavcodec/x86/audiodsp.asm
index de395e5fa8..e4a498b516 100644
--- a/libavcodec/x86/audiodsp.asm
+++ b/libavcodec/x86/audiodsp.asm
@@ -48,8 +48,10 @@ cglobal scalarproduct_int16, 3,3,3, v1, v2, order
     RET
 %endmacro
 
+%if ARCH_X86_32
 INIT_MMX mmxext
 SCALARPRODUCT
+%endif
 INIT_XMM sse2
 SCALARPRODUCT
 
@@ -117,8 +119,10 @@ cglobal vector_clip_int32%5, 5,5,%1, dst, src, min, max, len
     REP_RET
 %endmacro
 
+%if ARCH_X86_32
 INIT_MMX mmx
 VECTOR_CLIP_INT32 0, 1, 0, 0
+%endif
 INIT_XMM sse2
 VECTOR_CLIP_INT32 6, 1, 0, 0, _int
 VECTOR_CLIP_INT32 6, 2, 0, 1
diff --git a/libavcodec/x86/audiodsp_init.c b/libavcodec/x86/audiodsp_init.c
index 98e296c264..ebb28ece78 100644
--- a/libavcodec/x86/audiodsp_init.c
+++ b/libavcodec/x86/audiodsp_init.c
@@ -44,11 +44,13 @@ av_cold void ff_audiodsp_init_x86(AudioDSPContext *c)
 {
     int cpu_flags = av_get_cpu_flags();
 
+#if ARCH_X86_32
     if (EXTERNAL_MMX(cpu_flags))
         c->vector_clip_int32 = ff_vector_clip_int32_mmx;
 
     if (EXTERNAL_MMXEXT(cpu_flags))
         c->scalarproduct_int16 = ff_scalarproduct_int16_mmxext;
+#endif
 
     if (EXTERNAL_SSE(cpu_flags))
         c->vector_clipf = ff_vector_clipf_sse;
-- 
2.34.1



More information about the ffmpeg-devel mailing list