swscale/ops: add ff_sws_op_list_is_noop()

And use it in ff_sws_compile_pass() instead of hard-coding the check there.
This check will become more sophisticated in the following commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-01-09 12:47:55 +01:00
committed by Niklas Haas
parent c91634dfe6
commit e96332cb65
3 changed files with 17 additions and 8 deletions

View File

@@ -515,15 +515,7 @@ static int add_convert_pass(SwsGraph *graph, SwsFormat src, SwsFormat dst,
av_log(ctx, AV_LOG_DEBUG, "Unoptimized operation list:\n");
ff_sws_op_list_print(ctx, AV_LOG_DEBUG, ops);
av_log(ctx, AV_LOG_DEBUG, "Optimized operation list:\n");
ff_sws_op_list_optimize(ops);
if (ops->num_ops == 0) {
av_log(ctx, AV_LOG_VERBOSE, " optimized into memcpy\n");
ff_sws_op_list_free(&ops);
*output = input;
return 0;
}
ff_sws_op_list_print(ctx, AV_LOG_VERBOSE, ops);
ret = ff_sws_compile_pass(graph, ops, 0, dst, input, output);

View File

@@ -542,6 +542,11 @@ int ff_sws_op_list_append(SwsOpList *ops, SwsOp *op)
return ff_sws_op_list_insert_at(ops, ops->num_ops, op);
}
bool ff_sws_op_list_is_noop(const SwsOpList *ops)
{
return !ops->num_ops;
}
int ff_sws_op_list_max_size(const SwsOpList *ops)
{
int max_size = 0;
@@ -1040,6 +1045,12 @@ int ff_sws_compile_pass(SwsGraph *graph, SwsOpList *ops, int flags, SwsFormat ds
SwsPass *pass;
int ret;
/* Check if the whole operation graph is an end-to-end no-op */
if (ff_sws_op_list_is_noop(ops)) {
*output = input;
return 0;
}
if (ops->num_ops < 2) {
av_log(ctx, AV_LOG_ERROR, "Need at least two operations.\n");
return AVERROR(EINVAL);

View File

@@ -242,6 +242,12 @@ void ff_sws_op_list_free(SwsOpList **ops);
*/
SwsOpList *ff_sws_op_list_duplicate(const SwsOpList *ops);
/**
* Returns whether an op list represents a true no-op operation, i.e. may be
* eliminated entirely from an execution graph.
*/
bool ff_sws_op_list_is_noop(const SwsOpList *ops);
/**
* Returns the size of the largest pixel type used in `ops`.
*/