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

Git pushed a commit to branch master
in repository ffmpeg.

commit da8f9c4cacc2abac68855bf702ed4add2c43f5c3
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Wed Jun 24 16:51:27 2026 +0200
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Thu Jul 2 20:39:29 2026 +0200

    swscale/ops: Move stuff for enumerating op lists out
    
    It is not used for normal builds, so move the code into
    a new file, uops_macros_gen_template.c to be included
    by its only users, namely tests/sws_ops{,_aarch64}.c
    and uops_macros_gen.c.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libswscale/op_list_gen_template.c  | 116 +++++++++++++++++++++++++++++++++++++
 libswscale/ops.c                   |  76 ------------------------
 libswscale/ops.h                   |  15 -----
 libswscale/tests/sws_ops.c         |   1 +
 libswscale/tests/sws_ops_aarch64.c |   1 +
 libswscale/uops_macros_gen.c       |   1 +
 6 files changed, 119 insertions(+), 91 deletions(-)

diff --git a/libswscale/op_list_gen_template.c 
b/libswscale/op_list_gen_template.c
new file mode 100644
index 0000000000..0030fddec2
--- /dev/null
+++ b/libswscale/op_list_gen_template.c
@@ -0,0 +1,116 @@
+/*
+ * 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 <stdbool.h>
+
+#include "libswscale/format.h"
+#include "libswscale/ops.h"
+#include "libswscale/swscale.h"
+
+#include "libavutil/error.h"
+#include "libavutil/macros.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/pixfmt.h"
+
+#define DUMMY_SIZE 16
+
+static int enum_ops_fmt(SwsContext *ctx, void *opaque,
+                        enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
+                        int (*cb)(SwsContext *ctx, void *opaque, SwsOpList 
*ops))
+{
+    int ret = 0;
+    SwsOpList *ops = NULL;
+    SwsFormat src, dst;
+    ff_fmt_from_pixfmt(src_fmt, &src);
+    ff_fmt_from_pixfmt(dst_fmt, &dst);
+    bool incomplete = ff_infer_colors(&src.color, &dst.color);
+    src.width = src.height = DUMMY_SIZE;
+
+    static const int dst_sizes[][2] = {
+        { DUMMY_SIZE,     DUMMY_SIZE     },
+        { DUMMY_SIZE,     DUMMY_SIZE * 2 },
+        { DUMMY_SIZE * 2, DUMMY_SIZE     },
+        { DUMMY_SIZE * 2, DUMMY_SIZE * 2 },
+    };
+
+    for (int i = 0; i < FF_ARRAY_ELEMS(dst_sizes); i++) {
+        dst.width  = dst_sizes[i][0];
+        dst.height = dst_sizes[i][1];
+
+        ret = ff_sws_op_list_generate(ctx, &src, &dst, &ops, &incomplete);
+        if (ret == AVERROR(ENOTSUP))
+            return 0; /* silently skip unsupported formats */
+        else if (ret < 0)
+            return ret;
+
+        ret = ff_sws_op_list_optimize(ops);
+        if (ret < 0)
+            goto fail;
+
+        ret = cb(ctx, opaque, ops);
+        if (ret < 0)
+            goto fail;
+
+        ff_sws_op_list_free(&ops);
+    }
+
+fail:
+    ff_sws_op_list_free(&ops);
+    return ret;
+}
+
+/**
+ * Helper function to enumerate over all possible (optimized) operation lists,
+ * under the current set of options in `ctx`, and run the given callback on
+ * each list.
+ *
+ * @param src_fmt If set (not AV_PIX_FMT_NONE), constrain the source format
+ * @param dst_fmt If set (not AV_PIX_FMT_NONE), constrain the destination 
format
+ * @return 0 on success, the return value if cb() < 0, or a negative error code
+ *
+ * @note `ops` belongs to sws_enum_op_lists(), but may be mutated by `cb`.
+ */
+static inline
+int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque,
+                         enum AVPixelFormat src_fmt, enum AVPixelFormat 
dst_fmt,
+                         int (*cb)(SwsContext *ctx, void *opaque, SwsOpList 
*ops))
+{
+    const AVPixFmtDescriptor *src_start = av_pix_fmt_desc_next(NULL);
+    const AVPixFmtDescriptor *dst_start = src_start;
+    if (src_fmt != AV_PIX_FMT_NONE)
+        src_start = av_pix_fmt_desc_get(src_fmt);
+    if (dst_fmt != AV_PIX_FMT_NONE)
+        dst_start = av_pix_fmt_desc_get(dst_fmt);
+
+    const AVPixFmtDescriptor *src, *dst;
+    for (src = src_start; src; src = av_pix_fmt_desc_next(src)) {
+        const enum AVPixelFormat src_f = av_pix_fmt_desc_get_id(src);
+        for (dst = dst_start; dst; dst = av_pix_fmt_desc_next(dst)) {
+            const enum AVPixelFormat dst_f = av_pix_fmt_desc_get_id(dst);
+            int ret = enum_ops_fmt(ctx, opaque, src_f, dst_f, cb);
+            if (ret < 0)
+                return ret;
+            if (dst_fmt != AV_PIX_FMT_NONE)
+                break;
+        }
+        if (src_fmt != AV_PIX_FMT_NONE)
+            break;
+    }
+
+    return 0;
+}
diff --git a/libswscale/ops.c b/libswscale/ops.c
index 7d7c22a006..a57b942981 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -1007,79 +1007,3 @@ void ff_sws_op_list_print(void *log, int lev, int 
lev_extra,
 
     av_log(log, lev, "    ('X' unused, 'z' byteswapped, '=' copied, '$' const, 
'+' integer, '0' zero)\n");
 }
-
-#define DUMMY_SIZE 16
-
-static int enum_ops_fmt(SwsContext *ctx, void *opaque,
-                        enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
-                        int (*cb)(SwsContext *ctx, void *opaque, SwsOpList 
*ops))
-{
-    int ret = 0;
-    SwsOpList *ops = NULL;
-    SwsFormat src, dst;
-    ff_fmt_from_pixfmt(src_fmt, &src);
-    ff_fmt_from_pixfmt(dst_fmt, &dst);
-    bool incomplete = ff_infer_colors(&src.color, &dst.color);
-    src.width = src.height = DUMMY_SIZE;
-
-    static const int dst_sizes[][2] = {
-        { DUMMY_SIZE,     DUMMY_SIZE     },
-        { DUMMY_SIZE,     DUMMY_SIZE * 2 },
-        { DUMMY_SIZE * 2, DUMMY_SIZE     },
-        { DUMMY_SIZE * 2, DUMMY_SIZE * 2 },
-    };
-
-    for (int i = 0; i < FF_ARRAY_ELEMS(dst_sizes); i++) {
-        dst.width  = dst_sizes[i][0];
-        dst.height = dst_sizes[i][1];
-
-        ret = ff_sws_op_list_generate(ctx, &src, &dst, &ops, &incomplete);
-        if (ret == AVERROR(ENOTSUP))
-            return 0; /* silently skip unsupported formats */
-        else if (ret < 0)
-            return ret;
-
-        ret = ff_sws_op_list_optimize(ops);
-        if (ret < 0)
-            goto fail;
-
-        ret = cb(ctx, opaque, ops);
-        if (ret < 0)
-            goto fail;
-
-        ff_sws_op_list_free(&ops);
-    }
-
-fail:
-    ff_sws_op_list_free(&ops);
-    return ret;
-}
-
-int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque,
-                         enum AVPixelFormat src_fmt, enum AVPixelFormat 
dst_fmt,
-                         int (*cb)(SwsContext *ctx, void *opaque, SwsOpList 
*ops))
-{
-    const AVPixFmtDescriptor *src_start = av_pix_fmt_desc_next(NULL);
-    const AVPixFmtDescriptor *dst_start = src_start;
-    if (src_fmt != AV_PIX_FMT_NONE)
-        src_start = av_pix_fmt_desc_get(src_fmt);
-    if (dst_fmt != AV_PIX_FMT_NONE)
-        dst_start = av_pix_fmt_desc_get(dst_fmt);
-
-    const AVPixFmtDescriptor *src, *dst;
-    for (src = src_start; src; src = av_pix_fmt_desc_next(src)) {
-        const enum AVPixelFormat src_f = av_pix_fmt_desc_get_id(src);
-        for (dst = dst_start; dst; dst = av_pix_fmt_desc_next(dst)) {
-            const enum AVPixelFormat dst_f = av_pix_fmt_desc_get_id(dst);
-            int ret = enum_ops_fmt(ctx, opaque, src_f, dst_f, cb);
-            if (ret < 0)
-                return ret;
-            if (dst_fmt != AV_PIX_FMT_NONE)
-                break;
-        }
-        if (src_fmt != AV_PIX_FMT_NONE)
-            break;
-    }
-
-    return 0;
-}
diff --git a/libswscale/ops.h b/libswscale/ops.h
index 22ace4fef9..67dd04d227 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -344,19 +344,4 @@ void ff_sws_op_list_update_comps(SwsOpList *ops);
  */
 int ff_sws_op_list_optimize(SwsOpList *ops);
 
-/**
- * Helper function to enumerate over all possible (optimized) operation lists,
- * under the current set of options in `ctx`, and run the given callback on
- * each list.
- *
- * @param src_fmt If set (not AV_PIX_FMT_NONE), constrain the source format
- * @param dst_fmt If set (not AV_PIX_FMT_NONE), constrain the destination 
format
- * @return 0 on success, the return value if cb() < 0, or a negative error code
- *
- * @note `ops` belongs to ff_sws_enum_op_lists(), but may be mutated by `cb`.
- */
-int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque,
-                         enum AVPixelFormat src_fmt, enum AVPixelFormat 
dst_fmt,
-                         int (*cb)(SwsContext *ctx, void *opaque, SwsOpList 
*ops));
-
 #endif
diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c
index e18b6e5ac0..bb494b1f4e 100644
--- a/libswscale/tests/sws_ops.c
+++ b/libswscale/tests/sws_ops.c
@@ -23,6 +23,7 @@
 #include "libswscale/ops.h"
 #include "libswscale/ops_dispatch.h"
 #include "libswscale/ops_internal.h"
+#include "libswscale/op_list_gen_template.c"
 #include "libswscale/format.h"
 
 #ifdef _WIN32
diff --git a/libswscale/tests/sws_ops_aarch64.c 
b/libswscale/tests/sws_ops_aarch64.c
index 3dc68bf5c1..1dc90c7e60 100644
--- a/libswscale/tests/sws_ops_aarch64.c
+++ b/libswscale/tests/sws_ops_aarch64.c
@@ -24,6 +24,7 @@
 #include "libavutil/tree.h"
 #include "libswscale/ops.h"
 #include "libswscale/ops_chain.h"
+#include "libswscale/op_list_gen_template.c"
 
 #include "libswscale/aarch64/ops_impl.c"
 #include "libswscale/aarch64/ops_impl_conv.c"
diff --git a/libswscale/uops_macros_gen.c b/libswscale/uops_macros_gen.c
index e01ec4c6c8..4181b3abde 100644
--- a/libswscale/uops_macros_gen.c
+++ b/libswscale/uops_macros_gen.c
@@ -31,6 +31,7 @@
 #include "libavutil/tree.h"
 #include "ops.h"
 #include "ops_dispatch.h"
+#include "op_list_gen_template.c"
 #include "swscale.h"
 #include "uops.h"
 #include "uops_list.h"

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

Reply via email to