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

Git pushed a commit to branch master
in repository ffmpeg.

commit 4b5122bfb2070577df29acec66281ce0bfabf596
Author:     Niklas Haas <[email protected]>
AuthorDate: Thu Mar 5 18:09:41 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Mar 5 23:34:56 2026 +0000

    swscale/ops_dispatch: move on-stack mutation to ops backends
    
    And move the remainder printing there as well.
    
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_backend.c  |  9 ++++++++-
 libswscale/ops_dispatch.c | 12 ++----------
 libswscale/x86/ops.c      | 12 ++++++++++--
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/libswscale/ops_backend.c b/libswscale/ops_backend.c
index 7be2b941d8..ceecae4f99 100644
--- a/libswscale/ops_backend.c
+++ b/libswscale/ops_backend.c
@@ -66,12 +66,19 @@ static int compile(SwsContext *ctx, SwsOpList *ops, 
SwsCompiledOp *out)
     av_assert0(ops->num_ops > 0);
     const SwsPixelType read_type = ops->ops[0].type;
 
+    /* Make on-stack copy of `ops` to iterate over */
+    SwsOpList rest = *ops;
     do {
-        ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), ops,
+        ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), &rest,
                                        SWS_BLOCK_SIZE, chain);
     } while (ret == AVERROR(EAGAIN));
+
     if (ret < 0) {
         ff_sws_op_chain_free(chain);
+        if (rest.num_ops < ops->num_ops) {
+            av_log(ctx, AV_LOG_TRACE, "Uncompiled remainder:\n");
+            ff_sws_op_list_print(ctx, AV_LOG_TRACE, AV_LOG_TRACE, &rest);
+        }
         return ret;
     }
 
diff --git a/libswscale/ops_dispatch.c b/libswscale/ops_dispatch.c
index 5d3bb73123..80dcfe23dd 100644
--- a/libswscale/ops_dispatch.c
+++ b/libswscale/ops_dispatch.c
@@ -47,7 +47,7 @@ typedef struct SwsOpPass {
 int ff_sws_ops_compile_backend(SwsContext *ctx, const SwsOpBackend *backend,
                                const SwsOpList *ops, SwsCompiledOp *out)
 {
-    SwsOpList *copy, rest;
+    SwsOpList *copy;
     SwsCompiledOp compiled = {0};
     int ret = 0;
 
@@ -58,19 +58,11 @@ int ff_sws_ops_compile_backend(SwsContext *ctx, const 
SwsOpBackend *backend,
     /* Ensure these are always set during compilation */
     ff_sws_op_list_update_comps(copy);
 
-    /* Make an on-stack copy of `ops` to ensure we can still properly clean up
-     * the copy afterwards */
-    rest = *copy;
-
-    ret = backend->compile(ctx, &rest, &compiled);
+    ret = backend->compile(ctx, copy, &compiled);
     if (ret < 0) {
         int msg_lev = ret == AVERROR(ENOTSUP) ? AV_LOG_TRACE : AV_LOG_ERROR;
         av_log(ctx, msg_lev, "Backend '%s' failed to compile operations: %s\n",
                backend->name, av_err2str(ret));
-        if (rest.num_ops != ops->num_ops) {
-            av_log(ctx, msg_lev, "Uncompiled remainder:\n");
-            ff_sws_op_list_print(ctx, msg_lev, AV_LOG_TRACE, &rest);
-        }
     } else {
         *out = compiled;
     }
diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c
index 61288cc229..8a7ad3ecca 100644
--- a/libswscale/x86/ops.c
+++ b/libswscale/x86/ops.c
@@ -708,9 +708,12 @@ static int compile(SwsContext *ctx, SwsOpList *ops, 
SwsCompiledOp *out)
     if (write->rw.packed && write->rw.elems == 3)
         out->over_write = sizeof(uint32_t);
 
+
+    /* Make on-stack copy of `ops` to iterate over */
+    SwsOpList rest = *ops;
     do {
         int op_block_size = out->block_size;
-        SwsOp *op = &ops->ops[0];
+        SwsOp *op = &rest.ops[0];
 
         if (op_is_type_invariant(op)) {
             if (op->op == SWS_OP_CLEAR)
@@ -719,11 +722,16 @@ static int compile(SwsContext *ctx, SwsOpList *ops, 
SwsCompiledOp *out)
             op->type = SWS_PIXEL_U8;
         }
 
-        ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), ops,
+        ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), &rest,
                                        op_block_size, chain);
     } while (ret == AVERROR(EAGAIN));
+
     if (ret < 0) {
         ff_sws_op_chain_free(chain);
+        if (rest.num_ops < ops->num_ops) {
+            av_log(ctx, AV_LOG_TRACE, "Uncompiled remainder:\n");
+            ff_sws_op_list_print(ctx, AV_LOG_TRACE, AV_LOG_TRACE, &rest);
+        }
         return ret;
     }
 

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

Reply via email to