swscale/uops: loop over all flags when generating macros

This list is currently empty but will be expanded by the following commit.

I briefly tested whether it would be worth avoiding the free/realloc on
the uops array, but found the performance difference to be negligible.

Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-06-09 18:27:20 +02:00
parent 02a168a576
commit f97ba8cbe7
+18 -3
View File
@@ -674,13 +674,13 @@ static int register_uop(struct AVTreeNode **root, const SwsUOp *uop)
return 0;
}
static int register_uops(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
static int register_flags(SwsContext *ctx, SwsOpList *ops, SwsUOpFlags flags)
{
SwsUOpList *uops = ff_sws_uop_list_alloc();
if (!uops)
return AVERROR(ENOMEM);
int ret = ff_sws_ops_translate(ops, 0, uops);
int ret = ff_sws_ops_translate(ops, flags, uops);
if (ret < 0)
goto fail;
@@ -692,11 +692,26 @@ static int register_uops(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
}
fail:
*out = (SwsCompiledOp) {0}; /* dummy value, will be immediately freed */
ff_sws_uop_list_free(&uops);
return ret;
}
static const SwsUOpFlags uop_flags[] = {
0,
};
static int register_uops(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
{
for (int i = 0; i < FF_ARRAY_ELEMS(uop_flags); i++) {
int ret = register_flags(ctx, ops, uop_flags[i]);
if (ret < 0)
return ret;
}
*out = (SwsCompiledOp) {0}; /* dummy value, will be immediately freed */
return 0;
}
/* Dummy backend that just registers all seen uops */
static const SwsOpBackend backend_uops = {
.name = "uops_gen",