PR #25581 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25581 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25581.patch
This is still guarded by the runtime check, but now the code is always compiled. While this increases binary size in --disable-unstable builds, we have two good reasons for wanting this: 1. The unstable code handles some formats that the legacy code does not, notably yaf32, needed by e.g. !25567 2. This will allow us to gradually start removing the unscaled special converters in legacy in favor of preferring the new ops backend for all unscaled conversions, which the new backend already demonstrably handles better than the legacy code However, I wanted to separate this PR from such a cleanup/deletion PR, mostly because of the test framework self-dependency. >From a773a26d190ceb71d2dc7faa7dbab5bc50ab9ba9 Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Thu, 29 Oct 2026 12:43:04 +0100 Subject: [PATCH 1/3] configure: make swscale_vulkan depend on unstable The SPIR-V backend is built on top of the ops code, which is only compiled with CONFIG_UNSTABLE. Express this dependency in configure instead of guarding the vulkan Makefile include and ff_sws_vk_init() call separately. This also fixes linking with --disable-unstable when vulkan is enabled, as graph.c referenced ff_sws_vk_device_ref() from the excluded vulkan objects. Fixes: 51d4406e07 ("swscale/graph: support allocating hardware intermediate frames") Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Niklas Haas <[email protected]> --- configure | 2 +- libswscale/Makefile | 2 -- libswscale/swscale.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/configure b/configure index c84c4b07929..ae7950270e2 100755 --- a/configure +++ b/configure @@ -3354,7 +3354,7 @@ vulkan_deps="threads" vulkan_deps_any="libdl LoadLibrary" spirv_headers_spirv_h_deps="vulkan" spirv_unified1_spirv_h_deps="vulkan" -swscale_vulkan_deps="vulkan" +swscale_vulkan_deps="vulkan unstable" swscale_vulkan_if_any="spirv_headers_spirv_h spirv_unified1_spirv_h" apv_vulkan_hwaccel_deps="vulkan spirv_compiler" diff --git a/libswscale/Makefile b/libswscale/Makefile index 9c49d6d7098..86e2666f8e2 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -38,9 +38,7 @@ OBJS-$(CONFIG_UNSTABLE) += \ uops.o \ uops_backend.o \ -ifeq ($(CONFIG_UNSTABLE),yes) include $(SRC_PATH)/libswscale/vulkan/Makefile -endif # Objects duplicated from other libraries for shared builds SHLIBOBJS += framepool.o log2_tab.o half2float.o diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 5fb64519618..05a59a5d330 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1580,7 +1580,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src) if (dev_ctx->type != AV_HWDEVICE_TYPE_VULKAN) return AVERROR(ENOTSUP); -#if CONFIG_UNSTABLE && CONFIG_SWSCALE_VULKAN +#if CONFIG_SWSCALE_VULKAN ret = ff_sws_vk_init(ctx, src_hwfc->device_ref); if (ret < 0) return ret; -- 2.54.0 >From 1806f7d5f1372e2abc329b52c2965544778435aa Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Thu, 29 Oct 2026 12:45:22 +0100 Subject: [PATCH 2/3] swscale: compile ops code unconditionally The ops backends remain disabled by default at runtime, and are only auto-selected with SWS_UNSTABLE (or explicitly via the backends option). The SPIR-V backend still depends on CONFIG_UNSTABLE. The main motivating reason here is the fact that the test framework itself wants to depend on formats only properly introduced by the new unstable ops code. It also means we can start preferring the ops path for format conversions that are wholly unsupported otherwise. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Niklas Haas <[email protected]> --- libswscale/Makefile | 2 +- libswscale/aarch64/Makefile | 4 ++-- libswscale/format.c | 18 +----------------- libswscale/graph.c | 4 ---- libswscale/x86/Makefile | 2 +- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/libswscale/Makefile b/libswscale/Makefile index 86e2666f8e2..ddbafd4e6b9 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -28,7 +28,7 @@ OBJS = alphablend.o \ yuv2rgb.o \ vscale.o \ -OBJS-$(CONFIG_UNSTABLE) += \ +OBJS += \ ops.o \ ops_chain.o \ ops_dispatch.o \ diff --git a/libswscale/aarch64/Makefile b/libswscale/aarch64/Makefile index 8fdcf000cc8..734ad324790 100644 --- a/libswscale/aarch64/Makefile +++ b/libswscale/aarch64/Makefile @@ -11,8 +11,8 @@ NEON-OBJS += aarch64/hscale.o \ aarch64/xyz2rgb_neon.o \ aarch64/yuv2rgb_neon.o \ -NEON-OBJS-$(CONFIG_UNSTABLE) += aarch64/ops.o -NEON-OBJS-$(CONFIG_UNSTABLE) += aarch64/ops_neon.gen.o +NEON-OBJS += aarch64/ops.o \ + aarch64/ops_neon.gen.o \ $(SUBDIR)aarch64/ops_neon.gen.S: $(SUBDIR)aarch64/ops_static$(HOSTEXESUF) $(M)$< > [email protected] diff --git a/libswscale/format.c b/libswscale/format.c index f0a2670a96e..fbe2d813f9c 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -21,6 +21,7 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/hdr_dynamic_metadata.h" +#include "libavutil/hwcontext.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/refstruct.h" @@ -29,10 +30,6 @@ #include "ops_internal.h" #include "config_components.h" -#if CONFIG_UNSTABLE -#include "libavutil/hwcontext.h" -#endif - #define RET(x) \ do { \ int _ret = (x); \ @@ -350,7 +347,6 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field) enum AVPixelFormat format = frame->format; enum AVPixelFormat hw_format = AV_PIX_FMT_NONE; -#if CONFIG_UNSTABLE const AVPixFmtDescriptor *hw_desc = av_pix_fmt_desc_get(frame->format); av_assert0(hw_desc); @@ -361,7 +357,6 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field) hw_format = frame->format; format = hwfc->sw_format; } -#endif const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format); @@ -743,8 +738,6 @@ void ff_sws_frame_from_avframe(SwsFrame *dst, const AVFrame *src) } } -#if CONFIG_UNSTABLE - /** * Returns the underlying descriptor for fake formats like PAL8 whose * descriptors alone do not fully describe the pixel data. @@ -1851,12 +1844,3 @@ fail: ff_sws_op_list_free(&ops); return ret; } - -#else /* !CONFIG_UNSTABLE */ - -static int test_format_ops(enum AVPixelFormat format, int output) -{ - return 0; -} - -#endif diff --git a/libswscale/graph.c b/libswscale/graph.c index e9ee32052aa..f4ae0f5871d 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -698,7 +698,6 @@ static int add_ops_convert_pass(SwsGraph *graph, const SwsFormat *src, const SwsFormat *dst, const SwsLut3D *lut3d, SwsPass *input, SwsPass **output) { -#if CONFIG_UNSTABLE SwsContext *ctx = graph->ctx; /* Preemptively skip the ops list generation if the backend was @@ -723,9 +722,6 @@ static int add_ops_convert_pass(SwsGraph *graph, const SwsFormat *src, const int flags = SWS_OP_FLAG_OPTIMIZE | SWS_OP_FLAG_SPLIT_MEMCPY; return ff_sws_compile_pass(graph, NULL, &ops, flags, input, output); -#else - return AVERROR(ENOTSUP); -#endif } static bool prefer_ops_backend(SwsContext *ctx, const SwsFormat *src, const SwsFormat *dst) diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile index 552eea5cb5a..89b1bea091b 100644 --- a/libswscale/x86/Makefile +++ b/libswscale/x86/Makefile @@ -20,7 +20,7 @@ X86ASM-OBJS += x86/input.o \ x86/yuv2yuvX.o \ ifdef ARCH_X86_64 -X86ASM-OBJS-$(CONFIG_UNSTABLE) += x86/ops_common.o \ +X86ASM-OBJS += x86/ops_common.o \ x86/ops_int.o \ x86/ops_float.o \ x86/ops.o -- 2.54.0 >From a9fd0d9b87abde8f0148d248999c6cc41f180644 Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Thu, 29 Oct 2026 12:46:14 +0100 Subject: [PATCH 3/3] swscale: build and run ops tests unconditionally Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Niklas Haas <[email protected]> --- libswscale/Makefile | 9 ++++----- tests/fate/libswscale.mak | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libswscale/Makefile b/libswscale/Makefile index ddbafd4e6b9..4bd5ff551be 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -50,11 +50,10 @@ TESTPROGS = colorspace \ floatimg_cmp \ pixdesc_query \ range_convert \ + rational64 \ swscale \ + sws_ops \ + sws_ops_aarch64 \ unscaled_threaded \ -TESTPROGS-$(CONFIG_UNSTABLE) = sws_ops \ - sws_ops_aarch64 \ - rational64 \ - -DEVPROGS-$(CONFIG_UNSTABLE) = uops_macros_gen \ +DEVPROGS = uops_macros_gen \ diff --git a/tests/fate/libswscale.mak b/tests/fate/libswscale.mak index 97a410bc620..044215ed66b 100644 --- a/tests/fate/libswscale.mak +++ b/tests/fate/libswscale.mak @@ -54,7 +54,6 @@ fate-sws-monow-ed-tail: CMD = framecrc -lavfi color=black:s=100x8:r=1,scale=flag fate-sws-monob-ed-tail-bilinear: CMD = framecrc -lavfi color=white:s=102x8:r=1,scale=102:16:flags=bilinear+bitexact:sws_dither=ed,format=monob -frames:v 1 fate-sws-monow-ed-tail-bilinear: CMD = framecrc -lavfi color=black:s=102x8:r=1,scale=102:16:flags=bilinear+bitexact:sws_dither=ed,format=monow -frames:v 1 -ifeq ($(CONFIG_UNSTABLE),yes) SWS_UNSTABLE_BACKENDS-yes += c memcpy ifeq ($(ARCH_X86_64),yes) SWS_UNSTABLE_BACKENDS-$(HAVE_X86ASM) += x86 @@ -96,13 +95,12 @@ $(FATE_SWS_FLIPPED): REF = /dev/null fate-sws-flipped: $(FATE_SWS_FLIPPED) FATE_LIBSWSCALE += $(FATE_SWS_UNSCALED) $(FATE_SWS_UNSTABLE) $(FATE_SWS_UNPADDED) $(FATE_SWS_FLIPPED) -endif ifneq ($(HAVE_BIGENDIAN),yes) # Disable on big endian because big endian platforms generate different op # lists for le vs be formats; this breaks the checksum otherwise -FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += fate-sws-ops-list +FATE_LIBSWSCALE += fate-sws-ops-list fate-sws-ops-list: libswscale/tests/sws_ops$(EXESUF) fate-sws-ops-list: CMD = run libswscale/tests/sws_ops$(EXESUF) | do_md5sum | cut -d" " -f1 @@ -112,7 +110,7 @@ FATE_SWS_UOPS_MACROS = fate-sws-uops-macros-c \ ifeq ($(HAVE_INT128),yes) # Disable by default without int128 because it is too slow (several minutes) -FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += $(FATE_SWS_UOPS_MACROS) +FATE_LIBSWSCALE += $(FATE_SWS_UOPS_MACROS) endif # Disable on bigendian because it would result in a different iteration order @@ -135,12 +133,12 @@ fate-sws-uops-macros: $(FATE_SWS_UOPS_MACROS) endif -FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += fate-sws-rational64 +FATE_LIBSWSCALE += fate-sws-rational64 fate-sws-rational64: libswscale/tests/rational64$(EXESUF) fate-sws-rational64: CMD = run libswscale/tests/rational64$(EXESUF) fate-sws-rational64: CMP = null -FATE_LIBSWSCALE-$(CONFIG_UNSTABLE) += fate-sws-ops-entries-aarch64 +FATE_LIBSWSCALE += fate-sws-ops-entries-aarch64 fate-sws-ops-entries-aarch64: libswscale/tests/sws_ops_aarch64$(EXESUF) fate-sws-ops-entries-aarch64: REF = $(SRC_PATH)/libswscale/aarch64/ops_entries.c fate-sws-ops-entries-aarch64: CMD = run libswscale/tests/sws_ops_aarch64$(EXESUF) -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
