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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jun 10 02:55:08 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 the SSE2
specific implementation) at compile-time for x64.

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

diff --git a/libavcodec/x86/pixblockdsp.asm b/libavcodec/x86/pixblockdsp.asm
index 440fe29bcc..4a6369d7da 100644
--- a/libavcodec/x86/pixblockdsp.asm
+++ b/libavcodec/x86/pixblockdsp.asm
@@ -25,6 +25,7 @@
 
 SECTION .text
 
+%if ARCH_X86_32
 INIT_MMX mmx
 ; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, ptrdiff_t stride)
 cglobal get_pixels, 3,4
@@ -48,6 +49,7 @@ cglobal get_pixels, 3,4
     add          r3, 32
     js .loop
     REP_RET
+%endif
 
 INIT_XMM sse2
 cglobal get_pixels, 3, 4, 5
@@ -121,8 +123,10 @@ cglobal diff_pixels, 4,5,5
     RET
 %endmacro
 
+%if ARCH_X86_32
 INIT_MMX mmx
 DIFF_PIXELS
+%endif
 
 INIT_XMM sse2
 DIFF_PIXELS
diff --git a/libavcodec/x86/pixblockdsp_init.c b/libavcodec/x86/pixblockdsp_init.c
index 3a5eb6959c..684879598e 100644
--- a/libavcodec/x86/pixblockdsp_init.c
+++ b/libavcodec/x86/pixblockdsp_init.c
@@ -36,6 +36,7 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
 {
     int cpu_flags = av_get_cpu_flags();
 
+#if ARCH_X86_32
     if (EXTERNAL_MMX(cpu_flags)) {
         if (!high_bit_depth) {
             c->get_pixels_unaligned =
@@ -44,6 +45,7 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
         c->diff_pixels_unaligned =
         c->diff_pixels = ff_diff_pixels_mmx;
     }
+#endif
 
     if (EXTERNAL_SSE2(cpu_flags)) {
         if (!high_bit_depth) {
-- 
2.34.1



More information about the ffmpeg-devel mailing list