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

Git pushed a commit to branch master
in repository ffmpeg.

commit 27ff50f6abb7b5e4e4ecf39cbfcd0c46211c5e7b
Author:     Niklas Haas <[email protected]>
AuthorDate: Thu Jun 18 13:06:38 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Jun 23 11:48:13 2026 +0000

    swscale/ops_dispatch: add SWS_OP_FLAG_DRY_RUN
    
    Avoids us having to write awkward code like `output ? &pass : NULL`.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_dispatch.c  | 9 +++++----
 libswscale/ops_dispatch.h  | 8 +++++---
 libswscale/tests/sws_ops.c | 3 ++-
 libswscale/uops.c          | 3 ++-
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/libswscale/ops_dispatch.c b/libswscale/ops_dispatch.c
index 5dcbcaaaac..4af53676f0 100644
--- a/libswscale/ops_dispatch.c
+++ b/libswscale/ops_dispatch.c
@@ -512,7 +512,8 @@ static void align_pass(SwsPass *pass, int block_size, const 
int *over_rw,
 }
 
 static int compile(SwsGraph *graph, const SwsOpBackend *backend,
-                   const SwsOpList *ops, SwsPass *input, SwsPass **output)
+                   const SwsOpList *ops, int flags, SwsPass *input,
+                   SwsPass **output)
 {
     SwsContext *ctx = graph->ctx;
     SwsOpPass *p = av_mallocz(sizeof(*p));
@@ -522,7 +523,7 @@ static int compile(SwsGraph *graph, const SwsOpBackend 
*backend,
     int ret = ff_sws_ops_compile(ctx, backend, ops, &p->comp);
     if (ret < 0)
         goto fail;
-    else if (!output)
+    else if (flags & SWS_OP_FLAG_DRY_RUN)
         goto fail; /* nothing to do, just return */
 
     const SwsCompiledOp *comp = &p->comp;
@@ -686,7 +687,7 @@ int ff_sws_compile_pass(SwsGraph *graph, const SwsOpBackend 
*backend,
         goto out;
     }
 
-    ret = compile(graph, backend, ops, input, output);
+    ret = compile(graph, backend, ops, flags, input, output);
     if (ret != AVERROR(ENOTSUP))
         goto out;
 
@@ -705,7 +706,7 @@ int ff_sws_compile_pass(SwsGraph *graph, const SwsOpBackend 
*backend,
             goto out;
         }
 
-        ret = compile(graph, backend, ops, prev, output ? &prev : NULL);
+        ret = compile(graph, backend, ops, flags, prev, &prev);
         if (ret < 0) {
             ff_sws_op_list_free(&rest);
             goto out;
diff --git a/libswscale/ops_dispatch.h b/libswscale/ops_dispatch.h
index a558486e66..4581cf93eb 100644
--- a/libswscale/ops_dispatch.h
+++ b/libswscale/ops_dispatch.h
@@ -165,6 +165,9 @@ int ff_sws_ops_compile(SwsContext *ctx, const SwsOpBackend 
*backend,
 enum SwsOpCompileFlags {
     /* Automatically optimize the operations when compiling */
     SWS_OP_FLAG_OPTIMIZE = 1 << 0,
+
+    /* Discard the compiled op lists instead of generating passes */
+    SWS_OP_FLAG_DRY_RUN = 1 << 1,
 };
 
 /**
@@ -175,9 +178,8 @@ enum SwsOpCompileFlags {
  *            will be set to NULL, even on failure.
  * @param flags Set of SwsOpCompileFlags
  * @param input The input for the compiled passes. (Optional)
- * @param output The resulting final output pass will be stored here. If NULL,
- *               no output passes are created, and any compiled functions are
- *               instead immediately freed.
+ * @param output The resulting final output pass will be stored here.
+ *               Optional if using SWS_OP_FLAG_DRY_RUN.
  */
 int ff_sws_compile_pass(SwsGraph *graph, const SwsOpBackend *backend,
                         SwsOpList **ops, int flags, SwsPass *input,
diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c
index 5264cd55d1..a247eb3f76 100644
--- a/libswscale/tests/sws_ops.c
+++ b/libswscale/tests/sws_ops.c
@@ -93,7 +93,8 @@ static int print_passes(SwsContext *ctx, void *graph, 
SwsOpList *ops)
         return AVERROR(ENOMEM);
 
     pass_idx = 0;
-    return ff_sws_compile_pass(graph, &backend_print, &copy, 0, NULL, NULL);
+    const int flags = SWS_OP_FLAG_DRY_RUN;
+    return ff_sws_compile_pass(graph, &backend_print, &copy, flags, NULL, 
NULL);
 }
 static void log_stdout(void *avcl, int level, const char *fmt, va_list vl)
 {
diff --git a/libswscale/uops.c b/libswscale/uops.c
index 6045dd4bfd..6873c2f2aa 100644
--- a/libswscale/uops.c
+++ b/libswscale/uops.c
@@ -952,7 +952,8 @@ static int register_all_uops(SwsContext *ctx, void *graph, 
SwsOpList *ops)
     if (!copy)
         return AVERROR(ENOMEM);
 
-    return ff_sws_compile_pass(graph, &backend_uops, &copy, 0, NULL, NULL);
+    const int flags = SWS_OP_FLAG_DRY_RUN;
+    return ff_sws_compile_pass(graph, &backend_uops, &copy, flags, NULL, NULL);
 }
 
 static const SwsFlags flags[] = {

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

Reply via email to