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

Git pushed a commit to branch master
in repository ffmpeg.

commit 3fba3ba5390d6aa3232a03185e2f483c52f380f5
Author:     Niklas Haas <[email protected]>
AuthorDate: Wed Sep 2 14:59:49 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Sun Nov 8 00:36:29 2026 +0000

    swscale/ops_chain: add ff_sws_op_chain_attach() to eliminate duplicate code
    
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/aarch64/ops.c  |  8 +++-----
 libswscale/ops_chain.c    | 10 ++++++++++
 libswscale/ops_chain.h    |  8 ++++++++
 libswscale/uops_backend.c | 10 ++--------
 libswscale/x86/ops.c      |  8 +-------
 5 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/libswscale/aarch64/ops.c b/libswscale/aarch64/ops.c
index 0c4fb7d768..1018c9b9dc 100644
--- a/libswscale/aarch64/ops.c
+++ b/libswscale/aarch64/ops.c
@@ -169,10 +169,8 @@ static int compile_uops_aarch64(SwsContext *ctx, const 
SwsUOpList *uops,
     chain->cpu_flags = AV_CPU_FLAG_NEON;
 
     *out = (SwsCompiledOp) {
-        .priv        = chain,
-        .slice_align = 1,
-        .free        = ff_sws_op_chain_free_cb,
         .block_size  = block_size,
+        .slice_align = 1,
     };
 
     /* Look up kernel functions. */
@@ -207,8 +205,8 @@ static int compile_uops_aarch64(SwsContext *ctx, const 
SwsUOpList *uops,
     case 4: process_func = (SwsOpFunc) ff_sws_process_1111_neon; break;
     }
 
-    out->func      = process_func;
-    out->cpu_flags = chain->cpu_flags;
+    out->func = process_func;
+    ff_sws_op_chain_attach(chain, out);
 
     return 0;
 
diff --git a/libswscale/ops_chain.c b/libswscale/ops_chain.c
index 42f26035a7..ff48ede4a2 100644
--- a/libswscale/ops_chain.c
+++ b/libswscale/ops_chain.c
@@ -57,6 +57,16 @@ int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr 
func,
     return 0;
 }
 
+void ff_sws_op_chain_attach(const SwsOpChain *chain, SwsCompiledOp *out)
+{
+    av_assert0(!out->priv);
+    out->priv = (void *) chain;
+    out->free = ff_sws_op_chain_free_cb;
+    out->cpu_flags = chain->cpu_flags;
+    memcpy(out->over_read,  chain->over_read,  sizeof(out->over_read));
+    memcpy(out->over_write, chain->over_write, sizeof(out->over_write));
+}
+
 int ff_sws_uop_lookup(SwsContext *ctx, const SwsUOpTable *const tables[],
                       int num_tables, const SwsUOp *uop, const int block_size,
                       SwsOpChain *chain)
diff --git a/libswscale/ops_chain.h b/libswscale/ops_chain.h
index e3a25e3af5..f68b3f72ad 100644
--- a/libswscale/ops_chain.h
+++ b/libswscale/ops_chain.h
@@ -102,6 +102,14 @@ static inline void ff_sws_op_chain_free(SwsOpChain *chain)
 int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
                            void (*free)(SwsOpPriv *), const SwsOpPriv *priv);
 
+/**
+ * Attach a SwsOpChain and all metadata to a SwsCompiledOp (as out->priv).
+ *
+ * Note: This does not initialize *out. The caller is responsible for
+ * assigning out->func.
+ */
+void ff_sws_op_chain_attach(const SwsOpChain *chain, SwsCompiledOp *out);
+
 typedef struct SwsImplParams {
     const SwsUOpTable *table;
     const SwsUOp *uop;
diff --git a/libswscale/uops_backend.c b/libswscale/uops_backend.c
index 1fd07fdeee..3f62cbff96 100644
--- a/libswscale/uops_backend.c
+++ b/libswscale/uops_backend.c
@@ -154,19 +154,13 @@ static int compile_uops_c(SwsContext *ctx, const 
SwsUOpList *uops, SwsCompiledOp
     }
 
     *out = (SwsCompiledOp) {
-        .slice_align = 1,
         .block_size  = SWS_BLOCK_SIZE,
-        .cpu_flags   = chain->cpu_flags,
-        .priv        = chain,
-        .free        = ff_sws_op_chain_free_cb,
+        .slice_align = 1,
         .func        = process_c,
     };
 
-    memcpy(out->over_read,  chain->over_read,  sizeof(out->over_read));
-    memcpy(out->over_write, chain->over_write, sizeof(out->over_write));
-
     ff_sws_uop_list_print(ctx, AV_LOG_DEBUG, uops);
-
+    ff_sws_op_chain_attach(chain, out);
     return 0;
 
 fail:
diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c
index e477c3e917..35e8bc9a6d 100644
--- a/libswscale/x86/ops.c
+++ b/libswscale/x86/ops.c
@@ -647,8 +647,6 @@ static int compile_uops_x86(SwsContext *ctx, const 
SwsUOpList *uops, SwsCompiled
         /* Use at most two full YMM regs during the widest precision section */
         .block_size  = 2 * FFMIN(mmsize, 32) / uops->pixel_size_max,
         .slice_align = 1,
-        .free        = ff_sws_op_chain_free_cb,
-        .priv        = chain,
     };
 
     for (int i = 0; i < uops->num_ops; i++) {
@@ -678,12 +676,8 @@ static int compile_uops_x86(SwsContext *ctx, const 
SwsUOpList *uops, SwsCompiled
         return ret;
     }
 
-    out->cpu_flags = chain->cpu_flags;
-    memcpy(out->over_read,  chain->over_read,  sizeof(out->over_read));
-    memcpy(out->over_write, chain->over_write, sizeof(out->over_write));
-
     ff_sws_uop_list_print(ctx, AV_LOG_DEBUG, uops);
-
+    ff_sws_op_chain_attach(chain, out);
     return 0;
 
 fail:

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to