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 = ©->ops[i]; + SwsOp *op = ©->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))