Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PR] swscale/tests/sws_ops: print range values in the output (PR #21809)
@ 2026-02-19 22:35 Ramiro Polla via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Ramiro Polla via ffmpeg-devel @ 2026-02-19 22:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Ramiro Polla

PR #21809 opened by Ramiro Polla (ramiro)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21809
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21809.patch


>From 50f122947f9369500ebea64c3971c38f48c84d74 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 19 Feb 2026 22:54:32 +0100
Subject: [PATCH 1/4] swscale/tests/sws_ops: print range values in the output

This gives more information about each operation and helps catch issues
earlier on.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
---
 libswscale/tests/sws_ops.c  | 7 ++++---
 tests/ref/fate/sws-ops-list | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c
index bf84128291..bf3b2627f5 100644
--- a/libswscale/tests/sws_ops.c
+++ b/libswscale/tests/sws_ops.c
@@ -70,10 +70,11 @@ fail:
 
 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 {
+    if (level == AV_LOG_INFO ||
+        (level == AV_LOG_TRACE && !strcmp(fmt, "    min: {%s, %s, %s, %s}, max: {%s, %s, %s, %s}\n"))) {
         vfprintf(stdout, fmt, vl);
+    } else {
+        av_log_default_callback(avcl, level, fmt, vl);
     }
 }
 
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index af3cf2f4e9..aa97811bbe 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-3505d38dc669faf6f14036516b6caf61
+2cf9d8a755726bc80f60ca9f4dc31380
-- 
2.52.0


>From d9c9d596ca2c041d8cf3e834501d8c2f3a567ca9 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 19 Feb 2026 22:59:29 +0100
Subject: [PATCH 2/4] swscale/format: print an underscore instead of nan for
 undefined range values

This makes the output smaller and cleaner.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
---
 libswscale/ops.c            | 12 ++++++++----
 tests/ref/fate/sws-ops-list |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libswscale/ops.c b/libswscale/ops.c
index 900077584a..d0ef12f706 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -805,10 +805,14 @@ void ff_sws_op_list_print(void *log, int lev, const SwsOpList *ops)
             op->comps.max[2].den || op->comps.max[3].den)
         {
             av_log(log, AV_LOG_TRACE, "    min: {%s, %s, %s, %s}, max: {%s, %s, %s, %s}\n",
-                PRINTQ(op->comps.min[0]), PRINTQ(op->comps.min[1]),
-                PRINTQ(op->comps.min[2]), PRINTQ(op->comps.min[3]),
-                PRINTQ(op->comps.max[0]), PRINTQ(op->comps.max[1]),
-                PRINTQ(op->comps.max[2]), PRINTQ(op->comps.max[3]));
+                   op->comps.min[0].den ? PRINTQ(op->comps.min[0]) : "_",
+                   op->comps.min[1].den ? PRINTQ(op->comps.min[1]) : "_",
+                   op->comps.min[2].den ? PRINTQ(op->comps.min[2]) : "_",
+                   op->comps.min[3].den ? PRINTQ(op->comps.min[3]) : "_",
+                   op->comps.max[0].den ? PRINTQ(op->comps.max[0]) : "_",
+                   op->comps.max[1].den ? PRINTQ(op->comps.max[1]) : "_",
+                   op->comps.max[2].den ? PRINTQ(op->comps.max[2]) : "_",
+                   op->comps.max[3].den ? PRINTQ(op->comps.max[3]) : "_");
         }
 
     }
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index aa97811bbe..5e6bc18060 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-2cf9d8a755726bc80f60ca9f4dc31380
+ff9217864eb50375b74de8671815348f
-- 
2.52.0


>From afddc033bceacb3b13cc050e5afae6d18292e5bf Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 19 Feb 2026 23:11:08 +0100
Subject: [PATCH 3/4] swscale/ops: clear unused components after each op update

Instead of leaving it up to each case to clear it.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
---
 libswscale/ops.c            | 18 +++++++++++-------
 libswscale/ops_optimizer.c  |  1 -
 tests/ref/fate/sws-ops-list |  2 +-
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libswscale/ops.c b/libswscale/ops.c
index d0ef12f706..9d5ce08c9d 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -216,9 +216,7 @@ void ff_sws_apply_op_q(const SwsOp *op, AVRational x[4])
 static const unsigned flags_identity = SWS_COMP_ZERO | SWS_COMP_EXACT;
 static unsigned merge_comp_flags(unsigned a, unsigned b)
 {
-    const unsigned flags_or  = SWS_COMP_GARBAGE;
-    const unsigned flags_and = SWS_COMP_ZERO | SWS_COMP_EXACT;
-    return ((a & b) & flags_and) | ((a | b) & flags_or);
+    return ((a & b) & flags_identity);
 }
 
 /* Infer + propagate known information about components */
@@ -295,8 +293,7 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
                     op->comps.flags[i] = prev.flags[0];
                     op->comps.min[i]   = Q(0);
                     op->comps.max[i]   = Q((1ULL << pattern) - 1);
-                } else
-                    op->comps.flags[i] = SWS_COMP_GARBAGE;
+                }
             }
             break;
         case SWS_OP_PACK: {
@@ -304,8 +301,6 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
             for (int i = 0; i < 4; i++) {
                 if (op->pack.pattern[i])
                     flags = merge_comp_flags(flags, prev.flags[i]);
-                if (i > 0) /* clear remaining comps for sanity */
-                    op->comps.flags[i] = SWS_COMP_GARBAGE;
             }
             op->comps.flags[0] = flags;
             break;
@@ -451,6 +446,15 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
             break;
         }
 
+        /* Clear unused components */
+        for (int i = (op->op == SWS_OP_WRITE) ? op->rw.elems : 0; i < 4; i++) {
+            if (next.unused[i]) {
+                op->comps.flags[i] = SWS_COMP_GARBAGE;
+                op->comps.min[i].den = 0;
+                op->comps.max[i].den = 0;
+            }
+        }
+
         next = op->comps;
     }
 }
diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index c8713352a1..204a4e9208 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -378,7 +378,6 @@ retry:
                     continue;
 
                 if ((prev->comps.flags[i] & SWS_COMP_ZERO) &&
-                    !(prev->comps.flags[i] & SWS_COMP_GARBAGE) &&
                     op->c.q4[i].num == 0)
                 {
                     /* Redundant clear-to-zero of zero component */
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index 5e6bc18060..605d47ca66 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-ff9217864eb50375b74de8671815348f
+8bbe2820f5e57bfdd6b2de000e0f1c97
-- 
2.52.0


>From bbd03652056596f9564962fef659215495598afb Mon Sep 17 00:00:00 2001
From: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu, 19 Feb 2026 23:20:08 +0100
Subject: [PATCH 4/4] swscale/ops: clear range values SWS_OP_{MIN,MAX}

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
---
 libswscale/ops.c            | 26 +++++++++++++++++++++++---
 tests/ref/fate/sws-ops-list |  2 +-
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/libswscale/ops.c b/libswscale/ops.c
index 9d5ce08c9d..a472799962 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -219,6 +219,22 @@ static unsigned merge_comp_flags(unsigned a, unsigned b)
     return ((a & b) & flags_identity);
 }
 
+/* Linearly propagate flags per component */
+static void propagate_flags(SwsOp *op, const SwsComps *prev)
+{
+    for (int i = 0; i < 4; i++)
+        op->comps.flags[i] = prev->flags[i];
+}
+
+/* Clear undefined values in dst with src */
+static void clear_undefined_values(AVRational dst[4], const AVRational src[4])
+{
+    for (int i = 0; i < 4; i++) {
+        if (dst[i].den == 0)
+            dst[i] = src[i];
+    }
+}
+
 /* Infer + propagate known information about components */
 void ff_sws_op_list_update_comps(SwsOpList *ops)
 {
@@ -274,11 +290,15 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
             /* fall through */
         case SWS_OP_LSHIFT:
         case SWS_OP_RSHIFT:
+            propagate_flags(op, &prev);
+            break;
         case SWS_OP_MIN:
+            propagate_flags(op, &prev);
+            clear_undefined_values(op->comps.max, op->c.q4);
+            break;
         case SWS_OP_MAX:
-            /* Linearly propagate flags per component */
-            for (int i = 0; i < 4; i++)
-                op->comps.flags[i] = prev.flags[i];
+            propagate_flags(op, &prev);
+            clear_undefined_values(op->comps.min, op->c.q4);
             break;
         case SWS_OP_DITHER:
             /* Strip zero flag because of the nonzero dithering offset */
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index 605d47ca66..b09e792005 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-8bbe2820f5e57bfdd6b2de000e0f1c97
+2b5ba168f2ad1287718d73c1c234511a
-- 
2.52.0

_______________________________________________
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:[~2026-02-19 22:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-19 22:35 [FFmpeg-devel] [PR] swscale/tests/sws_ops: print range values in the output (PR #21809) 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