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

Git pushed a commit to branch master
in repository ffmpeg.

commit 2509eb3e8c6f029c0cc44c2e06c629b145921ec8
Author:     Niklas Haas <[email protected]>
AuthorDate: Thu Jun 18 12:23:40 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Jun 23 11:48:13 2026 +0000

    swscale/ops_optimizer: extract subpass splitting logic to helper
    
    I will also delete the old name in an upcoming commit.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_internal.h  | 17 +++++++++++++++++
 libswscale/ops_optimizer.c | 38 +++++++++++++++++++++-----------------
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/libswscale/ops_internal.h b/libswscale/ops_internal.h
index 9d8da6bbb5..01bc921697 100644
--- a/libswscale/ops_internal.h
+++ b/libswscale/ops_internal.h
@@ -80,6 +80,23 @@ static inline void ff_sws_pack_op_decode(const SwsOp *op, 
uint64_t mask[4], int
 int ff_sws_solve_shuffle(const SwsOpList *ops, uint8_t shuffle[], int size,
                          uint8_t clear_val, int *read_bytes, int *write_bytes);
 
+/**
+ * Split an op list into two at the given index. The split will be mediated
+ * by a set of planar read/write operations, plus a swizzle (if necessary)
+ * to re-order only used components. If a split is performed, both output
+ * lists will be optimized before returning.
+ *
+ * @param ops1 The first part of the split op list. Will be modified in-place.
+ * @param ops2 The second part of the split op list will be returned here, or
+ *             NULL if no split was necessary.
+ * @param index The index of the operation to split before. The operation
+ *              itself will be absent from `ops1` and instead moved to the
+ *              start of `ops2`.
+ *
+ * Returnse 0 or a negative error code.
+ */
+int ff_sws_op_list_split_at(SwsOpList *ops1, SwsOpList **ops2, int index);
+
 /**
  * Eliminate SWS_OP_FILTER_* operations by merging them with prior SWS_OP_READ
  * operations. This may require splitting the op list into multiple subpasses,
diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index e41af380e9..103df0bcd6 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -956,24 +956,16 @@ static void get_input_size(const SwsOpList *ops, 
SwsFormat *fmt)
     }
 }
 
-int ff_sws_op_list_subpass(SwsOpList *ops1, SwsOpList **out_rest)
+int ff_sws_op_list_split_at(SwsOpList *ops1, SwsOpList **out_ops2, int index)
 {
-    const SwsOp *op;
-    int ret, idx;
-
-    for (idx = 0; idx < ops1->num_ops; idx++) {
-        op = &ops1->ops[idx];
-        if (op->op == SWS_OP_FILTER_H || op->op == SWS_OP_FILTER_V)
-            break;
-    }
-
-    if (idx == ops1->num_ops) {
-        *out_rest = NULL;
+    int ret;
+    if (index <= 0 || index >= ops1->num_ops) {
+        *out_ops2 = NULL;
         return 0;
     }
 
-    av_assert0(idx > 0);
-    const SwsOp *prev = &ops1->ops[idx - 1];
+    const SwsOp *op = &ops1->ops[index];
+    const SwsOp *prev = &ops1->ops[index - 1];
 
     SwsOpList *ops2 = ff_sws_op_list_duplicate(ops1);
     if (!ops2)
@@ -1010,8 +1002,8 @@ int ff_sws_op_list_subpass(SwsOpList *ops1, SwsOpList 
**out_rest)
         ops2->comps_src.max[i]    = prev->comps.max[idx];
     }
 
-    ff_sws_op_list_remove_at(ops1, idx, ops1->num_ops - idx);
-    ff_sws_op_list_remove_at(ops2, 0, idx);
+    ff_sws_op_list_remove_at(ops1, index, ops1->num_ops - index);
+    ff_sws_op_list_remove_at(ops2, 0, index);
     op = NULL; /* the above command may invalidate op */
 
     if (swiz_wr.mask != SWS_SWIZZLE(0, 1, 2, 3).mask) {
@@ -1058,10 +1050,22 @@ int ff_sws_op_list_subpass(SwsOpList *ops1, SwsOpList 
**out_rest)
     if (ret < 0)
         goto fail;
 
-    *out_rest = ops2;
+    *out_ops2 = ops2;
     return 0;
 
 fail:
     ff_sws_op_list_free(&ops2);
     return ret;
 }
+
+int ff_sws_op_list_subpass(SwsOpList *ops, SwsOpList **out_rest)
+{
+    for (int idx = 0; idx < ops->num_ops; idx++) {
+        const SwsOp *op = &ops->ops[idx];
+        if (op->op == SWS_OP_FILTER_H || op->op == SWS_OP_FILTER_V)
+            return ff_sws_op_list_split_at(ops, out_rest, idx);
+    }
+
+    *out_rest = NULL;
+    return 0;
+}

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

Reply via email to