Commit 5f2a38d11c for ffmpeg

commit 5f2a38d11ce2e074daef320c5357afcdd2b9e8ff
Author: Niklas Haas <git@haasn.dev>
Date:   Thu Oct 8 12:14:36 2026 +0200

    swscale/ops: add link back to owning SwsOpList

    This makes some helper functions more convenient to implement in a way that's
    less dependent on SwsOpList design decisions, and without requiring threading
    that parameter through every function.

    Signed-off-by: Niklas Haas <git@haasn.dev>

diff --git a/libswscale/ops.c b/libswscale/ops.c
index 07159b57d8..1100ce59ba 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -702,7 +702,9 @@ SwsOpList *ff_sws_op_list_duplicate(const SwsOpList *ops)
     }

     for (int i = 0; i < copy->num_ops; i++) {
-        const SwsOp *op = &copy->ops[i];
+        SwsOp *op = &copy->ops[i];
+        op->ops = copy;
+
         switch (op->op) {
         case SWS_OP_READ:
             if (op->rw.filter.kernel)
@@ -764,6 +766,7 @@ int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
     for (int i = ops->num_ops - 1; i > index; i--)
         ops->ops[i] = ops->ops[i - 1];
     ops->ops[index] = *op;
+    ops->ops[index].ops = ops;
     return 0;
 }

diff --git a/libswscale/ops.h b/libswscale/ops.h
index 2045630022..5a74434c9f 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -238,7 +238,10 @@ typedef struct SwsOpPad {
     SwsCompMask dep_in, dep_out;
 } SwsOpPad;

-typedef struct SwsOp {
+typedef struct SwsOp     SwsOp;
+typedef struct SwsOpList SwsOpList;
+
+struct SwsOp {
     SwsOpType op;      /* operation to perform */
     SwsPixelType type; /* pixel type to operate on */
     union {
@@ -264,7 +267,10 @@ typedef struct SwsOp {
      * metadata for all operations, during ff_sws_ops_compile().
      */
     SwsOpPad outputs[4];
-} SwsOp;
+
+    /* Link back to the SwsOpList that owns this operation */
+    SwsOpList *ops;
+};

 #define SWS_OP_NEEDED(op, idx) (!((op)->outputs[idx].flags & SWS_COMP_GARBAGE))