swscale/ops: also include scaling ops in ff_sws_enum_op_lists()

Using the configured scaler from the SwsContext implicitly. This does affect
the output of libswscale/tests/sws_ops.c, which now prints about 4x as much
data (taking roughly 4x as long, but still within a second on my machine).

We can make this process a lot faster by forcing SWS_SCALE_POINT as the
scaler, which skips calculating any actual filter weights in favor of
generating a trivial 1-tap filter.

Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-05-15 18:53:05 +02:00
parent eec9f712f5
commit 1d841635a4
3 changed files with 36 additions and 17 deletions
+30 -14
View File
@@ -1009,31 +1009,47 @@ void ff_sws_op_list_print(void *log, int lev, int lev_extra,
av_log(log, lev, " (X = unused, z = byteswapped, + = exact, 0 = zero)\n");
}
#define DUMMY_SIZE 16
static int enum_ops_fmt(SwsContext *ctx, void *opaque,
enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
int (*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops))
{
int ret = 0;
SwsOpList *ops = NULL;
SwsFormat src, dst;
ff_fmt_from_pixfmt(src_fmt, &src);
ff_fmt_from_pixfmt(dst_fmt, &dst);
bool incomplete = ff_infer_colors(&src.color, &dst.color);
src.width = dst.width = 16;
src.height = dst.height = 16;
src.width = src.height = DUMMY_SIZE;
SwsOpList *ops;
int ret = ff_sws_op_list_generate(ctx, &src, &dst, &ops, &incomplete);
if (ret == AVERROR(ENOTSUP))
return 0; /* silently skip unsupported formats */
else if (ret < 0)
return ret;
static const int dst_sizes[][2] = {
{ DUMMY_SIZE, DUMMY_SIZE },
{ DUMMY_SIZE, DUMMY_SIZE * 2 },
{ DUMMY_SIZE * 2, DUMMY_SIZE },
{ DUMMY_SIZE * 2, DUMMY_SIZE * 2 },
};
ret = ff_sws_op_list_optimize(ops);
if (ret < 0)
goto fail;
for (int i = 0; i < FF_ARRAY_ELEMS(dst_sizes); i++) {
dst.width = dst_sizes[i][0];
dst.height = dst_sizes[i][1];
ret = cb(ctx, opaque, ops);
if (ret < 0)
goto fail;
ret = ff_sws_op_list_generate(ctx, &src, &dst, &ops, &incomplete);
if (ret == AVERROR(ENOTSUP))
return 0; /* silently skip unsupported formats */
else if (ret < 0)
return ret;
ret = ff_sws_op_list_optimize(ops);
if (ret < 0)
goto fail;
ret = cb(ctx, opaque, ops);
if (ret < 0)
goto fail;
ff_sws_op_list_free(&ops);
}
fail:
ff_sws_op_list_free(&ops);
+5 -2
View File
@@ -33,9 +33,11 @@
static int print_ops(SwsContext *const ctx, void *opaque, SwsOpList *ops)
{
av_log(opaque, AV_LOG_INFO, "%s -> %s:\n",
av_log(opaque, AV_LOG_INFO, "%s %dx%d -> %s %dx%d:\n",
av_get_pix_fmt_name(ops->src.format),
av_get_pix_fmt_name(ops->dst.format));
ops->src.width, ops->src.height,
av_get_pix_fmt_name(ops->dst.format),
ops->dst.width, ops->dst.height);
if (ff_sws_op_list_is_noop(ops))
av_log(opaque, AV_LOG_INFO, " (no-op)\n");
@@ -183,6 +185,7 @@ bad_option:
SwsContext *ctx = sws_alloc_context();
if (!ctx)
goto fail;
ctx->scaler = SWS_SCALE_POINT; /* reduce filter generation overhead */
av_log_set_callback(log_stdout);
+1 -1
View File
@@ -1 +1 @@
374319dfd2b74cb5b69dac68b627fa9b
e8d02618e7d3d275e65e9adb8499e6a7