PR #22642 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22642
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22642.patch

Since ba793127c413ba27386cea4c23db021b1eaa8d56,
the x86 mpeg4videodsp code uses ff_emulated_edge_mc_sse2()
instead of ff_emulated_edge_mc_8. This leads to linker errors
when x86asm is disabled. Fix this by also falling back to ff_gmc_c()
in case edge emulation is needed with external SSE2 being unavailable.

An alternative is to go back to ff_emulated_edge_mc_8(), but this
would readd the uglyness to videodsp for a niche case.

This is an alternative to #22641. I prefer this version. What do others think?


>From b002fadebe8ef3258a8432b3e273394d4d2aff5a Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 27 Mar 2026 18:40:31 +0100
Subject: [PATCH] avcodec/x86/mpeg4videodsp: Fix build failure without x86asm

Since ba793127c413ba27386cea4c23db021b1eaa8d56,
the x86 mpeg4videodsp code uses ff_emulated_edge_mc_sse2()
instead of ff_emulated_edge_mc_8. This leads to linker errors
when x86asm is disabled. Fix this by also falling back to ff_gmc_c()
in case edge emulation is needed with external SSE2 being unavailable.

An alternative is to go back to ff_emulated_edge_mc_8(), but this
would readd the uglyness to videodsp for a niche case.

Reported-by: James Almer <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/x86/mpeg4videodsp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/x86/mpeg4videodsp.c b/libavcodec/x86/mpeg4videodsp.c
index 47fd413da7..ea28bb1d3b 100644
--- a/libavcodec/x86/mpeg4videodsp.c
+++ b/libavcodec/x86/mpeg4videodsp.c
@@ -59,7 +59,6 @@ static void gmc_ssse3(uint8_t *dst, const uint8_t *src,
     const int dxys = dxy >> 4;
     const int dyxs = dyx >> 4;
     const int dyys = dyy2 >> 4;
-    uint8_t edge_buf[(MAX_H + 1) * EDGE_EMU_STRIDE];
 
     const int dxw = dxx2 * (w - 1);
     const int dyh = dyy2 * (h - 1);
@@ -73,7 +72,8 @@ static void gmc_ssse3(uint8_t *dst, const uint8_t *src,
         ((ox2 + dxw) | (ox2 + dxh) | (ox2 + dxw + dxh) |
          (oy2 + dyw) | (oy2 + dyh) | (oy2 + dyw + dyh)) >> (16 + shift) ||
         // uses more than 16 bits of subpel mv (only at huge resolution)
-        (dxx | dxy | dyx | dyy) & 15) {
+        (dxx | dxy | dyx | dyy) & 15 ||
+        (!HAVE_SSE2_EXTERNAL && need_emu)) {
         ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy,
                  shift, r, width, height);
         return;
@@ -82,12 +82,15 @@ static void gmc_ssse3(uint8_t *dst, const uint8_t *src,
     src += ix + iy * stride;
     const ptrdiff_t dst_stride = stride;
     ptrdiff_t src_stride = stride;
+#if HAVE_SSE2_EXTERNAL
+    uint8_t edge_buf[(MAX_H + 1) * EDGE_EMU_STRIDE];
     if (need_emu) {
         ff_emulated_edge_mc_sse2(edge_buf, src, EDGE_EMU_STRIDE, src_stride,
                                  w + 1, h + 1, ix, iy, width, height);
         src        = edge_buf;
         src_stride = EDGE_EMU_STRIDE;
     }
+#endif
 
 #if ARCH_X86_32
     xmm_u16 dxy8, dyy8, r8;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to