This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit d3db2dc5187e8d28996eab26ea4b4e8a8af4c7b8 Author: Niklas Haas <[email protected]> AuthorDate: Fri Mar 27 14:24:46 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Sat Mar 28 16:48:13 2026 +0000 swscale/tests/sws_ops: simplify using ff_sws_enum_op_lists() Signed-off-by: Niklas Haas <[email protected]> --- libswscale/tests/sws_ops.c | 75 ++++++++++------------------------------------ 1 file changed, 16 insertions(+), 59 deletions(-) diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c index 504fc34f6b..ccd5c7ddcb 100644 --- a/libswscale/tests/sws_ops.c +++ b/libswscale/tests/sws_ops.c @@ -27,47 +27,19 @@ #include <fcntl.h> #endif -static int run_test(SwsContext *const ctx, AVFrame *frame, - const AVPixFmtDescriptor *const src_desc, - const AVPixFmtDescriptor *const dst_desc) +static int print_ops(SwsContext *const ctx, void *opaque, SwsOpList *ops) { - /* Reuse ff_fmt_from_frame() to ensure correctly sanitized metadata */ - frame->format = av_pix_fmt_desc_get_id(src_desc); - SwsFormat src = ff_fmt_from_frame(frame, 0); - frame->format = av_pix_fmt_desc_get_id(dst_desc); - SwsFormat dst = ff_fmt_from_frame(frame, 0); - bool incomplete = ff_infer_colors(&src.color, &dst.color); + av_log(opaque, AV_LOG_INFO, "%s -> %s:\n", + av_get_pix_fmt_name(ops->src.format), + av_get_pix_fmt_name(ops->dst.format)); - SwsOpList *ops = ff_sws_op_list_alloc(); - if (!ops) - return AVERROR(ENOMEM); - ops->src = src; - ops->dst = dst; - - if (ff_sws_decode_pixfmt(ops, src.format) < 0) - goto fail; - if (ff_sws_decode_colors(ctx, SWS_PIXEL_F32, ops, &src, &incomplete) < 0) - goto fail; - if (ff_sws_encode_colors(ctx, SWS_PIXEL_F32, ops, &src, &dst, &incomplete) < 0) - goto fail; - if (ff_sws_encode_pixfmt(ops, dst.format) < 0) - goto fail; - - av_log(NULL, AV_LOG_INFO, "%s -> %s:\n", - av_get_pix_fmt_name(src.format), av_get_pix_fmt_name(dst.format)); - - ff_sws_op_list_optimize(ops); if (ff_sws_op_list_is_noop(ops)) - av_log(NULL, AV_LOG_INFO, " (no-op)\n"); + av_log(opaque, AV_LOG_INFO, " (no-op)\n"); else - ff_sws_op_list_print(NULL, AV_LOG_INFO, AV_LOG_INFO, ops); + ff_sws_op_list_print(opaque, AV_LOG_INFO, AV_LOG_INFO, ops); -fail: - /* silently skip unsupported formats */ - ff_sws_op_list_free(&ops); return 0; } - static void log_stdout(void *avcl, int level, const char *fmt, va_list vl) { if (level != AV_LOG_INFO) { @@ -79,10 +51,8 @@ static void log_stdout(void *avcl, int level, const char *fmt, va_list vl) int main(int argc, char **argv) { - enum AVPixelFormat src_fmt_min = 0; - enum AVPixelFormat dst_fmt_min = 0; - enum AVPixelFormat src_fmt_max = AV_PIX_FMT_NB - 1; - enum AVPixelFormat dst_fmt_max = AV_PIX_FMT_NB - 1; + enum AVPixelFormat src_fmt = AV_PIX_FMT_NONE; + enum AVPixelFormat dst_fmt = AV_PIX_FMT_NONE; int ret = 1; #ifdef _WIN32 @@ -105,14 +75,14 @@ int main(int argc, char **argv) if (argv[i][0] != '-' || i + 1 == argc) goto bad_option; if (!strcmp(argv[i], "-src")) { - src_fmt_min = src_fmt_max = av_get_pix_fmt(argv[i + 1]); - if (src_fmt_min == AV_PIX_FMT_NONE) { + src_fmt = av_get_pix_fmt(argv[i + 1]); + if (src_fmt == AV_PIX_FMT_NONE) { fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]); goto error; } } else if (!strcmp(argv[i], "-dst")) { - dst_fmt_min = dst_fmt_max = av_get_pix_fmt(argv[i + 1]); - if (dst_fmt_min == AV_PIX_FMT_NONE) { + dst_fmt = av_get_pix_fmt(argv[i + 1]); + if (dst_fmt == AV_PIX_FMT_NONE) { fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]); goto error; } @@ -124,29 +94,16 @@ bad_option: } SwsContext *ctx = sws_alloc_context(); - AVFrame *frame = av_frame_alloc(); - if (!ctx || !frame) + if (!ctx) goto fail; - frame->width = frame->height = 16; av_log_set_callback(log_stdout); - for (const AVPixFmtDescriptor *src = NULL; (src = av_pix_fmt_desc_next(src));) { - enum AVPixelFormat src_fmt = av_pix_fmt_desc_get_id(src); - if (src_fmt < src_fmt_min || src_fmt > src_fmt_max) - continue; - for (const AVPixFmtDescriptor *dst = NULL; (dst = av_pix_fmt_desc_next(dst));) { - enum AVPixelFormat dst_fmt = av_pix_fmt_desc_get_id(dst); - if (dst_fmt < dst_fmt_min || dst_fmt > dst_fmt_max) - continue; - int err = run_test(ctx, frame, src, dst); - if (err < 0) - goto fail; - } - } + ret = ff_sws_enum_op_lists(ctx, NULL, src_fmt, dst_fmt, print_ops); + if (ret < 0) + goto fail; ret = 0; fail: - av_frame_free(&frame); sws_free_context(&ctx); return ret; _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
