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

Git pushed a commit to branch master
in repository ffmpeg.

commit b5db7c7354c791da2c74a951bbe1451d68b4b261
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Mar 9 12:53:07 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Mar 12 21:02:48 2026 +0000

    swscale/ops_dispatch: have ff_sws_compile_pass() take ownership of `ops`
    
    More useful than just allowing it to "modify" the ops; in practice this 
means
    the contents will be undefined anyways - might as well have this function
    take care of freeing it afterwards as well.
    
    Will make things simpler with regards to subpass splitting.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/graph.c        |  2 +-
 libswscale/ops.h          |  4 +++-
 libswscale/ops_dispatch.c | 19 +++++++++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/libswscale/graph.c b/libswscale/graph.c
index 0402485f68..dda23ddca2 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -608,7 +608,7 @@ static int add_convert_pass(SwsGraph *graph, const 
SwsFormat *src,
     av_log(ctx, AV_LOG_DEBUG, "Unoptimized operation list:\n");
     ff_sws_op_list_print(ctx, AV_LOG_DEBUG, AV_LOG_TRACE, ops);
 
-    ret = ff_sws_compile_pass(graph, ops, SWS_OP_FLAG_OPTIMIZE, dst, input, 
output);
+    ret = ff_sws_compile_pass(graph, &ops, SWS_OP_FLAG_OPTIMIZE, dst, input, 
output);
     if (ret < 0)
         goto fail;
 
diff --git a/libswscale/ops.h b/libswscale/ops.h
index 37e8f06331..20c9c25605 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -312,9 +312,11 @@ enum SwsOpCompileFlags {
  * Resolves an operation list to a graph pass. The first and last operations
  * must be a read/write respectively. `flags` is a list of SwsOpCompileFlags.
  *
+ * Takes over ownership of `ops` and sets it to NULL, even on failure.
+ *
  * Note: `ops` may be modified by this function.
  */
-int ff_sws_compile_pass(SwsGraph *graph, SwsOpList *ops, int flags,
+int ff_sws_compile_pass(SwsGraph *graph, SwsOpList **ops, int flags,
                         const SwsFormat *dst, SwsPass *input, SwsPass 
**output);
 
 #endif
diff --git a/libswscale/ops_dispatch.c b/libswscale/ops_dispatch.c
index 1c3d3239f6..37ad4fc940 100644
--- a/libswscale/ops_dispatch.c
+++ b/libswscale/ops_dispatch.c
@@ -369,16 +369,17 @@ fail:
     return ret;
 }
 
-int ff_sws_compile_pass(SwsGraph *graph, SwsOpList *ops, int flags,
+int ff_sws_compile_pass(SwsGraph *graph, SwsOpList **pops, int flags,
                         const SwsFormat *dst, SwsPass *input, SwsPass **output)
 {
     SwsContext *ctx = graph->ctx;
-    int ret;
+    SwsOpList *ops = *pops;
+    int ret = 0;
 
     /* Check if the whole operation graph is an end-to-end no-op */
     if (ff_sws_op_list_is_noop(ops)) {
         *output = input;
-        return 0;
+        goto out;
     }
 
     const SwsOp *read  = ff_sws_op_list_input(ops);
@@ -386,14 +387,20 @@ int ff_sws_compile_pass(SwsGraph *graph, SwsOpList *ops, 
int flags,
     if (!read || !write) {
         av_log(ctx, AV_LOG_ERROR, "First and last operations must be a read "
                "and write, respectively.\n");
-        return AVERROR(EINVAL);
+        ret = AVERROR(EINVAL);
+        goto out;
     }
 
     if (flags & SWS_OP_FLAG_OPTIMIZE) {
         ret = ff_sws_op_list_optimize(ops);
         if (ret < 0)
-            return ret;
+            goto out;
     }
 
-    return compile(graph, ops, dst, input, output);
+    ret = compile(graph, ops, dst, input, output);
+
+out:
+    ff_sws_op_list_free(&ops);
+    *pops = NULL;
+    return ret;
 }

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

Reply via email to