PR #22641 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22641
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22641.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 using ff_emulated_edge_mc_8()
instead when x86asm is unavailable.

This unfortunately readds the uglyness to videodsp.

(Alternatives would be to always use ff_gmc_c if edge emulation is needed, but 
SSE2_EXTERNAL is not available; or to simply restrict this function to the case 
of SSE2_EXTERNAL.)


>From 3a1f37b9d7a65c2eda342b723c1c849f4f6c1a4f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Fri, 27 Mar 2026 18:04:01 +0100
Subject: [PATCH] avcodec/{videodsp,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 using ff_emulated_edge_mc_8()
instead when x86asm is unavailable.

This unfortunately readds the uglyness to videodsp.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/videodsp.c          |  4 ++--
 libavcodec/videodsp.h          |  8 ++++++++
 libavcodec/videodsp_template.c | 14 +++++++++-----
 libavcodec/x86/mpeg4videodsp.c |  6 ++++++
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
index 230a1bfb74..c66757ce83 100644
--- a/libavcodec/videodsp.c
+++ b/libavcodec/videodsp.c
@@ -40,9 +40,9 @@ av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
 {
     ctx->prefetch = just_return;
     if (bpc <= 8) {
-        ctx->emulated_edge_mc = emulated_edge_mc_8;
+        ctx->emulated_edge_mc = ff_emulated_edge_mc_8;
     } else {
-        ctx->emulated_edge_mc = emulated_edge_mc_16;
+        ctx->emulated_edge_mc = ff_emulated_edge_mc_16;
     }
 
 #if ARCH_AARCH64
diff --git a/libavcodec/videodsp.h b/libavcodec/videodsp.h
index 4f081e0869..1be3188d09 100644
--- a/libavcodec/videodsp.h
+++ b/libavcodec/videodsp.h
@@ -29,6 +29,14 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#define EMULATED_EDGE(depth) \
+void ff_emulated_edge_mc_ ## depth(uint8_t *dst, const uint8_t *src, \
+                                   ptrdiff_t dst_stride, ptrdiff_t src_stride, 
\
+                                   int block_w, int block_h,\
+                                   int src_x, int src_y, int w, int h);
+
+EMULATED_EDGE(8)
+
 typedef struct VideoDSPContext {
     /**
      * Copy a rectangular area of samples to a temporary buffer and replicate
diff --git a/libavcodec/videodsp_template.c b/libavcodec/videodsp_template.c
index 2475366157..89b4edc5e1 100644
--- a/libavcodec/videodsp_template.c
+++ b/libavcodec/videodsp_template.c
@@ -21,11 +21,15 @@
 
 #include "bit_depth_template.c"
 
-static void FUNC(emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
-                                   ptrdiff_t buf_linesize,
-                                   ptrdiff_t src_linesize,
-                                   int block_w, int block_h,
-                                   int src_x, int src_y, int w, int h)
+#if BIT_DEPTH != 8
+// ff_emulated_edge_mc_8 is used by the x86 MpegVideoDSP API.
+static
+#endif
+void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
+                               ptrdiff_t buf_linesize,
+                               ptrdiff_t src_linesize,
+                               int block_w, int block_h,
+                               int src_x, int src_y, int w, int h)
 {
     int x, y;
     int start_y, start_x, end_y, end_x;
diff --git a/libavcodec/x86/mpeg4videodsp.c b/libavcodec/x86/mpeg4videodsp.c
index 47fd413da7..2977139756 100644
--- a/libavcodec/x86/mpeg4videodsp.c
+++ b/libavcodec/x86/mpeg4videodsp.c
@@ -23,6 +23,7 @@
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/mpeg4videodsp.h"
+#include "libavcodec/videodsp.h"
 #include "videodsp.h"
 
 #if HAVE_SSSE3_INLINE
@@ -83,8 +84,13 @@ static void gmc_ssse3(uint8_t *dst, const uint8_t *src,
     const ptrdiff_t dst_stride = stride;
     ptrdiff_t src_stride = stride;
     if (need_emu) {
+#if HAVE_SSE2_EXTERNAL
         ff_emulated_edge_mc_sse2(edge_buf, src, EDGE_EMU_STRIDE, src_stride,
                                  w + 1, h + 1, ix, iy, width, height);
+#else
+        ff_emulated_edge_mc_8(edge_buf, src, EDGE_EMU_STRIDE, src_stride,
+                              w + 1, h + 1, ix, iy, width, height);
+#endif
         src        = edge_buf;
         src_stride = EDGE_EMU_STRIDE;
     }
-- 
2.52.0

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

Reply via email to