From 157f586e5cd3bf0bc083f02c9f8e16740bb5ceba Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 30 Apr 2026 17:26:35 +0200 Subject: [PATCH] swscale/uops: thread SwsContext through ff_sws_ops_translate() Needed to access ctx->flags, in particular SWS_BITEXACT. Signed-off-by: Niklas Haas --- libswscale/tests/sws_ops.c | 2 +- libswscale/uops.c | 11 ++++++----- libswscale/uops.h | 5 +++-- libswscale/uops_backend.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c index 6b5ad486b9..fdd618775a 100644 --- a/libswscale/tests/sws_ops.c +++ b/libswscale/tests/sws_ops.c @@ -43,7 +43,7 @@ static int print_ops(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out) if (!uops) return AVERROR(ENOMEM); - int ret = ff_sws_ops_translate(ops, 0, uops); + int ret = ff_sws_ops_translate(ctx, ops, 0, uops); if (ret == AVERROR(ENOTSUP)) { av_log(NULL, AV_LOG_INFO, " Retrying with split passes:\n"); goto fail; diff --git a/libswscale/uops.c b/libswscale/uops.c index 4a3d264c14..e09f3cbe03 100644 --- a/libswscale/uops.c +++ b/libswscale/uops.c @@ -540,8 +540,8 @@ static bool is_expand_bit(SwsPixelType type, AVRational factor) return false; } -static int translate_op(SwsUOpList *uops, SwsUOpFlags flags, const SwsOp *op, - const SwsComps *input) +static int translate_op(SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags, + const SwsOp *op, const SwsComps *input) { switch (op->op) { case SWS_OP_FILTER_H: @@ -641,11 +641,12 @@ static int translate_op(SwsUOpList *uops, SwsUOpFlags flags, const SwsOp *op, return ff_sws_uop_list_append(uops, &uop); } -int ff_sws_ops_translate(const SwsOpList *ops, SwsUOpFlags flags, SwsUOpList *uops) +int ff_sws_ops_translate(SwsContext *ctx, const SwsOpList *ops, + SwsUOpFlags flags, SwsUOpList *uops) { SwsComps input = ops->comps_src; for (int i = 0; i < ops->num_ops; i++) { - int ret = translate_op(uops, flags, &ops->ops[i], &input); + int ret = translate_op(ctx, uops, flags, &ops->ops[i], &input); if (ret < 0) return ret; input = ops->ops[i].comps; @@ -680,7 +681,7 @@ static int register_flags(SwsContext *ctx, SwsOpList *ops, SwsUOpFlags flags) if (!uops) return AVERROR(ENOMEM); - int ret = ff_sws_ops_translate(ops, flags, uops); + int ret = ff_sws_ops_translate(ctx, ops, flags, uops); if (ret < 0) goto fail; diff --git a/libswscale/uops.h b/libswscale/uops.h index 21bb8cb2e2..01197fd09f 100644 --- a/libswscale/uops.h +++ b/libswscale/uops.h @@ -31,6 +31,7 @@ #include "libavutil/attributes.h" +typedef struct SwsContext SwsContext; typedef struct SwsFilterWeights SwsFilterWeights; typedef struct SwsOpList SwsOpList; @@ -225,8 +226,8 @@ int ff_sws_uop_list_append(SwsUOpList *uops, SwsUOp *uop); * * Return 0 or a negative error code. */ -int ff_sws_ops_translate(const SwsOpList *ops, SwsUOpFlags flags, - SwsUOpList *uops); +int ff_sws_ops_translate(SwsContext *ctx, const SwsOpList *ops, + SwsUOpFlags flags, SwsUOpList *uops); /** * Generate a set of boilerplate C preprocessor macros for describing and diff --git a/libswscale/uops_backend.c b/libswscale/uops_backend.c index 87b50453d1..46e429cc5b 100644 --- a/libswscale/uops_backend.c +++ b/libswscale/uops_backend.c @@ -149,7 +149,7 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out) goto fail; } - ret = ff_sws_ops_translate(ops, 0, uops); + ret = ff_sws_ops_translate(ctx, ops, 0, uops); if (ret < 0) goto fail;