* [FFmpeg-devel] [PATCH] swscale/tests/sws_ops: add optional -src and -dst parameters (PR #21283)
@ 2025-12-23 18:40 Ramiro Polla via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Ramiro Polla via ffmpeg-devel @ 2025-12-23 18:40 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Ramiro Polla
PR #21283 opened by Ramiro Polla (ramiro)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21283
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21283.patch
This is helpful for debugging specific input/output combinations.
>From 040e15ca6b3af80332ee28a2afc31146b4f2c880 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Tue, 23 Dec 2025 17:18:19 +0100
Subject: [PATCH] swscale/tests/sws_ops: add optional -src and -dst parameters
---
libswscale/tests/sws_ops.c | 47 ++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c
index 1c17cf24a0..69852fc1e0 100644
--- a/libswscale/tests/sws_ops.c
+++ b/libswscale/tests/sws_ops.c
@@ -76,12 +76,50 @@ 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;
int ret = 1;
#ifdef _WIN32
_setmode(_fileno(stdout), _O_BINARY);
#endif
+ for (int i = 1; i < argc; i += 2) {
+ if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) {
+ fprintf(stderr,
+ "sws_ops [options...]\n"
+ " -help\n"
+ " This text\n"
+ " -dst <pixfmt>\n"
+ " Only test the specified destination pixel format\n"
+ " -src <pixfmt>\n"
+ " Only test the specified source pixel format\n"
+ );
+ return 0;
+ }
+ 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) {
+ 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) {
+ fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
+ goto error;
+ }
+ } else {
+bad_option:
+ fprintf(stderr, "bad option or argument missing (%s) see -help\n", argv[i]);
+ goto error;
+ }
+ }
+
SwsContext *ctx = sws_alloc_context();
AVFrame *frame = av_frame_alloc();
if (!ctx || !frame)
@@ -90,7 +128,13 @@ int main(int argc, char **argv)
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;
@@ -102,4 +146,7 @@ fail:
av_frame_free(&frame);
sws_free_context(&ctx);
return ret;
+
+error:
+ return AVERROR(EINVAL);
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-23 18:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-23 18:40 [FFmpeg-devel] [PATCH] swscale/tests/sws_ops: add optional -src and -dst parameters (PR #21283) Ramiro Polla via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git