This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 016749f2e1c8726b2f5cf7800af923a78834240a Author: Niklas Haas <[email protected]> AuthorDate: Thu Dec 4 19:25:51 2025 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Mon Dec 8 16:58:53 2025 +0000 swscale/tests: add new test for generated operation lists This is similar to swscale/tests/swscale.c, but significantly cheaper - it merely prints the generated (optimized) operation list for every format conversion. Mostly useful for my own purposes as a regression test when making changes to the ops optimizer. Note the distinction between this and tests/swscale.c, the latter of which tests the result of *applying* an operation list for equality. There is an argument to be made that the two tests could be merged, but I think the amount of overlap is small enough to not be worth the amount of differences. --- libswscale/Makefile | 1 + libswscale/tests/sws_ops.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/libswscale/Makefile b/libswscale/Makefile index a096ed331e..bde1144897 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -43,3 +43,4 @@ TESTPROGS = colorspace \ floatimg_cmp \ pixdesc_query \ swscale \ + sws_ops \ diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c new file mode 100644 index 0000000000..8bb44d634d --- /dev/null +++ b/libswscale/tests/sws_ops.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2025 Niklas Haas + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/pixdesc.h" +#include "libswscale/ops.h" +#include "libswscale/format.h" + +static int run_test(SwsContext *const ctx, AVFrame *frame, + const AVPixFmtDescriptor *const src_desc, + const AVPixFmtDescriptor *const dst_desc) +{ + /* 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); + + 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, 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); + ff_sws_op_list_print(NULL, 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) { + av_log_default_callback(avcl, level, fmt, vl); + } else { + vfprintf(stdout, fmt, vl); + } +} + +int main(int argc, char **argv) +{ + int ret = 1; + + SwsContext *ctx = sws_alloc_context(); + AVFrame *frame = av_frame_alloc(); + if (!ctx || !frame) + 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));) { + for (const AVPixFmtDescriptor *dst = NULL; (dst = av_pix_fmt_desc_next(dst));) { + int err = run_test(ctx, frame, src, dst); + if (err < 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]
