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

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/x86/ac3dsp.asm    | 5 +++++
 libavcodec/x86/ac3dsp_init.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/libavcodec/x86/ac3dsp.asm b/libavcodec/x86/ac3dsp.asm
index 4ddaa94320..050cbfe06a 100644
--- a/libavcodec/x86/ac3dsp.asm
+++ b/libavcodec/x86/ac3dsp.asm
@@ -64,6 +64,7 @@ cglobal ac3_exponent_min, 3, 4, 2, exp, reuse_blks, expn, offset
 %endmacro
 
 %define LOOP_ALIGN
+%if ARCH_X86_32
 INIT_MMX mmx
 AC3_EXPONENT_MIN
 %if HAVE_MMXEXT_EXTERNAL
@@ -71,7 +72,9 @@ AC3_EXPONENT_MIN
 INIT_MMX mmxext
 AC3_EXPONENT_MIN
 %endif
+%endif
 %if HAVE_SSE2_EXTERNAL
+%define LOOP_ALIGN ALIGN 16
 INIT_XMM sse2
 AC3_EXPONENT_MIN
 %endif
@@ -81,6 +84,7 @@ AC3_EXPONENT_MIN
 ; void ff_float_to_fixed24(int32_t *dst, const float *src, unsigned int len)
 ;-----------------------------------------------------------------------------
 
+%if ARCH_X86_32
 ; The 3DNow! version is not bit-identical because pf2id uses truncation rather
 ; than round-to-nearest.
 INIT_MMX 3dnow
@@ -134,6 +138,7 @@ cglobal float_to_fixed24, 3, 3, 3, dst, src, len
     ja .loop
     emms
     RET
+%endif
 
 INIT_XMM sse2
 cglobal float_to_fixed24, 3, 3, 9, dst, src, len
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index 5f20e6dc31..47ec5d8070 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -41,6 +41,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
 {
     int cpu_flags = av_get_cpu_flags();
 
+#if ARCH_X86_32
     if (EXTERNAL_MMX(cpu_flags)) {
         c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
     }
@@ -55,6 +56,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
     if (EXTERNAL_SSE(cpu_flags)) {
         c->float_to_fixed24 = ff_float_to_fixed24_sse;
     }
+#endif
     if (EXTERNAL_SSE2(cpu_flags)) {
         c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
         c->float_to_fixed24 = ff_float_to_fixed24_sse2;
-- 
2.34.1



More information about the ffmpeg-devel mailing list