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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jun 10 02:54:56 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/tests/x86/dct.c    |  2 ++
 libavcodec/x86/fdct.c         | 12 ++++++++----
 libavcodec/x86/fdctdsp_init.c |  2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavcodec/tests/x86/dct.c b/libavcodec/tests/x86/dct.c
index b332c9642d..1eb9400567 100644
--- a/libavcodec/tests/x86/dct.c
+++ b/libavcodec/tests/x86/dct.c
@@ -58,12 +58,14 @@ PR_WRAP(avx)
 #endif
 
 static const struct algo fdct_tab_arch[] = {
+#if ARCH_X86_32
 #if HAVE_MMX_INLINE
     { "MMX",    ff_fdct_mmx,    FF_IDCT_PERM_NONE, AV_CPU_FLAG_MMX },
 #endif
 #if HAVE_MMXEXT_INLINE
     { "MMXEXT", ff_fdct_mmxext, FF_IDCT_PERM_NONE, AV_CPU_FLAG_MMXEXT },
 #endif
+#endif
 #if HAVE_SSE2_INLINE
     { "SSE2",   ff_fdct_sse2,   FF_IDCT_PERM_NONE, AV_CPU_FLAG_SSE2 },
 #endif
diff --git a/libavcodec/x86/fdct.c b/libavcodec/x86/fdct.c
index 835fcc2b28..5e00287764 100644
--- a/libavcodec/x86/fdct.c
+++ b/libavcodec/x86/fdct.c
@@ -71,8 +71,6 @@ DECLARE_ALIGNED(16, static const int16_t, ocos_4_16)[8] = {
 
 DECLARE_ALIGNED(16, static const int16_t, fdct_one_corr)[8] = { X8(1) };
 
-DECLARE_ALIGNED(8, static const int32_t, fdct_r_row)[2] = {RND_FRW_ROW, RND_FRW_ROW };
-
 static const struct
 {
  DECLARE_ALIGNED(16, const int32_t, fdct_r_row_sse2)[4];
@@ -375,7 +373,6 @@ static av_always_inline void fdct_col_##cpu(const int16_t *in, int16_t *out, int
           "r" (out + offset), "r" (ocos_4_16)); \
 }
 
-FDCT_COL(mmx, mm, movq)
 FDCT_COL(sse2, xmm, movdqa)
 
 static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
@@ -443,6 +440,12 @@ static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
     );
 }
 
+#if ARCH_X86_32
+
+DECLARE_ALIGNED(8, static const int32_t, fdct_r_row)[2] = { RND_FRW_ROW, RND_FRW_ROW };
+
+FDCT_COL(mmx, mm, movq)
+
 static av_always_inline void fdct_row_mmxext(const int16_t *in, int16_t *out,
                                              const int16_t *table)
 {
@@ -559,9 +562,10 @@ void ff_fdct_mmx(int16_t *block)
     }
 }
 
+#endif /* ARCH_X86_32 */
 #endif /* HAVE_MMX_INLINE */
 
-#if HAVE_MMXEXT_INLINE
+#if HAVE_MMXEXT_INLINE && ARCH_X86_32
 
 void ff_fdct_mmxext(int16_t *block)
 {
diff --git a/libavcodec/x86/fdctdsp_init.c b/libavcodec/x86/fdctdsp_init.c
index 0cb5fd625b..b801e57701 100644
--- a/libavcodec/x86/fdctdsp_init.c
+++ b/libavcodec/x86/fdctdsp_init.c
@@ -31,11 +31,13 @@ av_cold void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx,
 
     if (!high_bit_depth) {
         if ((dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) {
+#if ARCH_X86_32
             if (INLINE_MMX(cpu_flags))
                 c->fdct = ff_fdct_mmx;
 
             if (INLINE_MMXEXT(cpu_flags))
                 c->fdct = ff_fdct_mmxext;
+#endif
 
             if (INLINE_SSE2(cpu_flags))
                 c->fdct = ff_fdct_sse2;
-- 
2.34.1



More information about the ffmpeg-devel mailing list