This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 1d2e616d5f72fe535ec6ab0650c65ce9e9a24ff4
Author:     Lynne <[email protected]>
AuthorDate: Mon Feb 23 21:04:02 2026 +0100
Commit:     Lynne <[email protected]>
CommitDate: Thu Feb 26 14:10:22 2026 +0100

    swscale: add a Vulkan backend for ops.c
    
    Sponsored-by: Sovereign Tech Fund
---
 libswscale/Makefile                               |   2 +
 libswscale/graph.h                                |   2 +
 libswscale/ops.c                                  |   4 +
 libswscale/swscale_internal.h                     |   3 +
 libswscale/vulkan/Makefile                        |   4 +
 libswscale/vulkan/ops.c                           | 124 ++++++++++++++++++++++
 libavcodec/aacenc_is.h => libswscale/vulkan/ops.h |  27 ++---
 {libavcodec => libswscale/vulkan}/vulkan.c        |   0
 8 files changed, 153 insertions(+), 13 deletions(-)

diff --git a/libswscale/Makefile b/libswscale/Makefile
index bde1144897..4331768cfa 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -33,6 +33,8 @@ OBJS-$(CONFIG_UNSTABLE) +=                              \
        ops_memcpy.o                                     \
        ops_optimizer.o                                  \
 
+include $(SRC_PATH)/libswscale/vulkan/Makefile
+
 # Objects duplicated from other libraries for shared builds
 SHLIBOBJS                    += log2_tab.o half2float.o
 
diff --git a/libswscale/graph.h b/libswscale/graph.h
index e2703dfded..c93c37a98e 100644
--- a/libswscale/graph.h
+++ b/libswscale/graph.h
@@ -124,6 +124,8 @@ typedef struct SwsGraph {
     bool incomplete; /* set during init() if formats had to be inferred */
     bool noop;       /* set during init() if the graph is a no-op */
 
+    AVBufferRef *hw_frames_ref;
+
     /** Sorted sequence of filter passes to apply */
     SwsPass **passes;
     int num_passes;
diff --git a/libswscale/ops.c b/libswscale/ops.c
index 0f9bb8d473..e90960832e 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -31,6 +31,7 @@
 extern const SwsOpBackend backend_c;
 extern const SwsOpBackend backend_murder;
 extern const SwsOpBackend backend_x86;
+extern const SwsOpBackend backend_vulkan;
 
 const SwsOpBackend * const ff_sws_op_backends[] = {
     &backend_murder,
@@ -38,6 +39,9 @@ const SwsOpBackend * const ff_sws_op_backends[] = {
     &backend_x86,
 #endif
     &backend_c,
+#if CONFIG_VULKAN
+    &backend_vulkan,
+#endif
     NULL
 };
 
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 5c58272664..81ec5ef0cc 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -701,6 +701,9 @@ struct SwsInternal {
     int          color_conversion_warned;
 
     Half2FloatTables *h2f_tables;
+
+    // Hardware specific private data
+    void *hw_priv;
 };
 //FIXME check init (where 0)
 
diff --git a/libswscale/vulkan/Makefile b/libswscale/vulkan/Makefile
new file mode 100644
index 0000000000..396cdeb936
--- /dev/null
+++ b/libswscale/vulkan/Makefile
@@ -0,0 +1,4 @@
+clean::
+       $(RM) $(CLEANSUFFIXES:%=libswscale/vulkan/%)
+
+OBJS-$(CONFIG_VULKAN) += vulkan/ops.o vulkan/vulkan.o
diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
new file mode 100644
index 0000000000..0b39e08830
--- /dev/null
+++ b/libswscale/vulkan/ops.c
@@ -0,0 +1,124 @@
+/**
+ * Copyright (C) 2026 Lynne
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../ops_internal.h"
+#include "../swscale_internal.h"
+#include "libavutil/mem.h"
+#include "ops.h"
+
+void ff_sws_vk_uninit(SwsContext *sws)
+{
+    SwsInternal *c = sws_internal(sws);
+    FFVulkanOpsCtx *s = c->hw_priv;
+    if (!s)
+        return;
+
+    ff_vk_exec_pool_free(&s->vkctx, &s->e);
+    ff_vk_uninit(&s->vkctx);
+    av_freep(&c->hw_priv);
+}
+
+int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref)
+{
+    int err;
+    SwsInternal *c = sws_internal(sws);
+
+    if (!c->hw_priv) {
+        c->hw_priv = av_mallocz(sizeof(FFVulkanOpsCtx));
+        if (!c->hw_priv)
+            return AVERROR(ENOMEM);
+    }
+
+    FFVulkanOpsCtx *s = c->hw_priv;
+    if (s->vkctx.device_ref && s->vkctx.device_ref->data != dev_ref->data) {
+        /* Reinitialize with new context */
+        ff_vk_exec_pool_free(&s->vkctx, &s->e);
+        ff_vk_uninit(&s->vkctx);
+    } else if (s->vkctx.device_ref && s->vkctx.device_ref->data == 
dev_ref->data) {
+        return 0;
+    }
+
+    err = ff_vk_init(&s->vkctx, sws, dev_ref, NULL);
+    if (err < 0)
+        return err;
+
+    s->qf = ff_vk_qf_find(&s->vkctx, VK_QUEUE_COMPUTE_BIT, 0);
+    if (!s->qf) {
+        av_log(sws, AV_LOG_ERROR, "Device has no compute queues\n");
+        return AVERROR(ENOTSUP);
+    }
+
+    err = ff_vk_exec_pool_init(&s->vkctx, s->qf, &s->e, 1,
+                               0, 0, 0, NULL);
+    if (err < 0)
+        return err;
+
+    return 0;
+}
+
+typedef struct VulkanPriv {
+    FFVulkanOpsCtx *s;
+    FFVulkanShader shd;
+} VulkanPriv;
+
+static void process(const SwsOpExec *exec, const void *priv,
+                    int x_start, int y_start, int x_end, int y_end)
+{
+    const VulkanPriv *p = priv;
+    FFVkExecContext *ec = ff_vk_exec_get(&p->s->vkctx, &p->s->e);
+    ff_vk_exec_start(&p->s->vkctx, ec);
+
+
+    ff_vk_exec_submit(&p->s->vkctx, ec);
+}
+
+static void free_fn(void *priv)
+{
+    VulkanPriv *p = priv;
+    ff_vk_shader_free(&p->s->vkctx, &p->shd);
+    av_free(priv);
+}
+
+static int compile(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out)
+{
+    SwsInternal *c = sws_internal(sws);
+    FFVulkanOpsCtx *s = c->hw_priv;
+    if (!s)
+        return AVERROR(ENOTSUP);
+
+    VulkanPriv p = {
+        .s = c->hw_priv,
+    };
+
+    *out = (SwsCompiledOp) {
+        .slice_align = 0,
+        .block_size  = 1,
+        .func        = process,
+        .priv        = av_memdup(&p, sizeof(p)),
+        .free        = free_fn,
+    };
+    return 0;
+}
+
+const SwsOpBackend backend_vulkan = {
+    .name      = "vulkan",
+    .compile   = compile,
+    .hw_format = AV_PIX_FMT_VULKAN,
+};
diff --git a/libavcodec/aacenc_is.h b/libswscale/vulkan/ops.h
similarity index 65%
copy from libavcodec/aacenc_is.h
copy to libswscale/vulkan/ops.h
index beaa70c790..55aaea12ed 100644
--- a/libavcodec/aacenc_is.h
+++ b/libswscale/vulkan/ops.h
@@ -1,6 +1,5 @@
-/*
- * AAC encoder intensity stereo
- * Copyright (C) 2015 Rostislav Pehlivanov
+/**
+ * Copyright (C) 2026 Lynne
  *
  * This file is part of FFmpeg.
  *
@@ -19,17 +18,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/**
- * @file
- * AAC encoder Intensity Stereo
- * @author Rostislav Pehlivanov ( atomnuker gmail com )
- */
+#ifndef SWSCALE_VULKAN_OPS_H
+#define SWSCALE_VULKAN_OPS_H
 
-#ifndef AVCODEC_AACENC_IS_H
-#define AVCODEC_AACENC_IS_H
+#include "libavutil/vulkan.h"
+#include "../swscale.h"
 
-#include "aacenc.h"
+typedef struct FFVulkanOpsCtx {
+    FFVulkanContext vkctx;
+    AVVulkanDeviceQueueFamily *qf;
+    FFVkExecPool e;
+} FFVulkanOpsCtx;
 
-void ff_aac_search_for_is(AACEncContext *s, AVCodecContext *avctx, 
ChannelElement *cpe);
+int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref);
+void ff_sws_vk_uninit(SwsContext *sws);
 
-#endif /* AVCODEC_AACENC_IS_H */
+#endif /* SWSCALE_VULKAN_OPS_H */
diff --git a/libavcodec/vulkan.c b/libswscale/vulkan/vulkan.c
similarity index 100%
copy from libavcodec/vulkan.c
copy to libswscale/vulkan/vulkan.c

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

Reply via email to