PR #23087 opened by Ramiro Polla (ramiro) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23087 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23087.patch
A subset of !22840 while that PR doesn't advance. >From b4282ee51a40eb57ef17d5534e3068dfc0953c22 Mon Sep 17 00:00:00 2001 From: Ramiro Polla <[email protected]> Date: Thu, 16 Apr 2026 22:01:59 +0200 Subject: [PATCH 1/3] swscale/tests/swscale: improve help text for -p option --- libswscale/tests/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c index 49682e8fec..5246d6deeb 100644 --- a/libswscale/tests/swscale.c +++ b/libswscale/tests/swscale.c @@ -828,7 +828,7 @@ static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) " -ref <file>\n" " Uses file as reference to compare tests against. Tests that have become worse will contain the string worse or WORSE\n" " -p <number between 0.0 and 1.0>\n" - " The percentage of tests or comparisons to perform. Doing all tests will take long and generate over a hundred MB text output\n" + " The proportion of tests or comparisons to perform.\n" " It is often convenient to perform a random subset\n" " -dst <pixfmt>\n" " Only test the specified destination pixel format\n" -- 2.52.0 >From 87d51ff528ea27ae9ab2edc7077151d9c35ef4a9 Mon Sep 17 00:00:00 2001 From: Ramiro Polla <[email protected]> Date: Thu, 16 Apr 2026 17:16:18 +0200 Subject: [PATCH 2/3] swscale/tests/swscale: fix -p option when -flags and/or -unscaled are used The -p, -flags, and -unscaled options all affected the decision to select a subsample of the tests to run. When specifying -p 0.1, about 57% of the tests would run instead of the expect 10%. This commit fixes this by separating -p from -flags and -unscaled. --- libswscale/tests/swscale.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c index 5246d6deeb..b08ae5fac4 100644 --- a/libswscale/tests/swscale.c +++ b/libswscale/tests/swscale.c @@ -682,13 +682,12 @@ static int run_self_tests(const AVFrame *ref, const struct options *opts) .dither = opts->dither >= 0 ? opts->dither : SWS_DITHER_AUTO, }; - if (ff_sfc64_get(&prng_state) > UINT64_MAX * opts->prob) - continue; - - ret = run_test(src_fmt, dst_fmt, dst_w[w], dst_h[h], - &mode, opts, ref, src, NULL); - if (ret < 0) - goto error; + if (ff_sfc64_get(&prng_state) <= UINT64_MAX * opts->prob) { + ret = run_test(src_fmt, dst_fmt, dst_w[w], dst_h[h], + &mode, opts, ref, src, NULL); + if (ret < 0) + goto error; + } if (opts->flags >= 0 || opts->unscaled) break; -- 2.52.0 >From 52b60237c92c0c5315147a6b2ed9c1c3d7615429 Mon Sep 17 00:00:00 2001 From: Ramiro Polla <[email protected]> Date: Fri, 1 May 2026 01:12:04 +0200 Subject: [PATCH 3/3] swscale/tests/swscale: log test parameters on loss error When running with "-v 0", the test parameters were not being printed, which made it hard to track down which conversion the error referred to. Now the test parameters are logged with av_log() when a loss error happens. --- libswscale/tests/swscale.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c index b08ae5fac4..868fc6e1f1 100644 --- a/libswscale/tests/swscale.c +++ b/libswscale/tests/swscale.c @@ -426,6 +426,22 @@ error: return ret; } +static void print_test_params(char *buf, size_t buf_size, + const AVFrame *src, const AVFrame *dst, + const struct mode *mode, const struct options *opts) +{ + snprintf(buf, buf_size, + "%-*s %*dx%*d -> %-*s %*dx%*d, flags=0x%0*x dither=%u", + opts->pretty ? 14 : 0, av_get_pix_fmt_name(src->format), + opts->pretty ? 4 : 0, src->width, + opts->pretty ? 4 : 0, src->height, + opts->pretty ? 14 : 0, av_get_pix_fmt_name(dst->format), + opts->pretty ? 4 : 0, dst->width, + opts->pretty ? 4 : 0, dst->height, + opts->pretty ? 8 : 0, mode->flags, + mode->dither); +} + static void print_results(const AVFrame *ref, const AVFrame *src, const AVFrame *dst, int dst_w, int dst_h, const struct mode *mode, const struct options *opts, @@ -433,16 +449,11 @@ static void print_results(const AVFrame *ref, const AVFrame *src, const AVFrame const struct test_results *ref_r, float expected_loss) { + char buf[128]; + if (av_log_get_level() >= AV_LOG_INFO) { - printf("%-*s %*dx%*d -> %-*s %*dx%*d, flags=0x%0*x dither=%u", - opts->pretty ? 14 : 0, av_get_pix_fmt_name(src->format), - opts->pretty ? 4 : 0, src->width, - opts->pretty ? 4 : 0, src->height, - opts->pretty ? 14 : 0, av_get_pix_fmt_name(dst->format), - opts->pretty ? 4 : 0, dst->width, - opts->pretty ? 4 : 0, dst->height, - opts->pretty ? 8 : 0, mode->flags, - mode->dither); + print_test_params(buf, sizeof(buf), src, dst, mode, opts); + printf("%s", buf); if (!opts->bench || !ref_r) { printf(", SSIM={Y=%f U=%f V=%f A=%f} loss=%e", @@ -480,6 +491,10 @@ static void print_results(const AVFrame *ref, const AVFrame *src, const AVFrame const int bad = r->loss - expected_loss > 1e-2; const int level = bad ? AV_LOG_ERROR : AV_LOG_WARNING; const char *worse_str = bad ? "WORSE" : "worse"; + if (bad) { + print_test_params(buf, sizeof(buf), src, dst, mode, opts); + av_log(NULL, level, "%s\n", buf); + } av_log(NULL, level, " loss %e is %s by %e, expected loss %e\n", r->loss, worse_str, r->loss - expected_loss, expected_loss); @@ -498,6 +513,10 @@ static void print_results(const AVFrame *ref, const AVFrame *src, const AVFrame const int bad = r->loss - ref_r->loss > 1e-2 && dst_bits > 1; const int level = bad ? AV_LOG_ERROR : AV_LOG_WARNING; const char *worse_str = bad ? "WORSE" : "worse"; + if (bad) { + print_test_params(buf, sizeof(buf), src, dst, mode, opts); + av_log(NULL, level, "%s\n", buf); + } av_log(NULL, level, " loss %e is %s by %e, ref loss %e SSIM={Y=%f U=%f V=%f A=%f}\n", r->loss, worse_str, r->loss - ref_r->loss, ref_r->loss, -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
