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

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/x86/mpegvideoenc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index 3691cce26c..d9c89d568b 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -42,6 +42,7 @@ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = {
 
 #if HAVE_6REGS
 
+#if ARCH_X86_32
 #if HAVE_MMX_INLINE
 #define COMPILE_TEMPLATE_MMXEXT 0
 #define COMPILE_TEMPLATE_SSE2   0
@@ -64,6 +65,7 @@ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = {
 #define RENAME_FDCT(a) a ## _mmxext
 #include "mpegvideoenc_template.c"
 #endif /* HAVE_MMXEXT_INLINE */
+#endif /* ARCH_X86_32 */
 
 #if HAVE_SSE2_INLINE
 #undef COMPILE_TEMPLATE_MMXEXT
@@ -96,7 +98,7 @@ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = {
 #endif /* HAVE_6REGS */
 
 #if HAVE_INLINE_ASM
-#if HAVE_MMX_INLINE
+#if HAVE_MMX_INLINE && ARCH_X86_32
 static void  denoise_dct_mmx(MpegEncContext *s, int16_t *block){
     const int intra= s->mb_intra;
     int *sum= s->dct_error_sum[intra];
@@ -218,17 +220,18 @@ av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
     if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
 #if HAVE_MMX_INLINE
         int cpu_flags = av_get_cpu_flags();
+#if ARCH_X86_32
         if (INLINE_MMX(cpu_flags)) {
 #if HAVE_6REGS
             s->dct_quantize = dct_quantize_mmx;
 #endif
             s->denoise_dct  = denoise_dct_mmx;
         }
-#endif
 #if HAVE_6REGS && HAVE_MMXEXT_INLINE
         if (INLINE_MMXEXT(cpu_flags))
             s->dct_quantize = dct_quantize_mmxext;
 #endif
+#endif
 #if HAVE_SSE2_INLINE
         if (INLINE_SSE2(cpu_flags)) {
 #if HAVE_6REGS
@@ -240,6 +243,7 @@ av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
 #if HAVE_6REGS && HAVE_SSSE3_INLINE
         if (INLINE_SSSE3(cpu_flags))
             s->dct_quantize = dct_quantize_ssse3;
+#endif
 #endif
     }
 }
-- 
2.34.1



More information about the ffmpeg-devel mailing list