Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] swscale/optimizer: improve and properly document range tracking (PR #21135)
@ 2025-12-08 17:56 Niklas Haas via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Niklas Haas via ffmpeg-devel @ 2025-12-08 17:56 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

PR #21135 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21135
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21135.patch


>From b1b2c20d1cfc71765e51fdb0e30abe8ded0eb20b Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Mon, 8 Dec 2025 18:38:36 +0100
Subject: [PATCH 1/2] swscale/ops_optimizer: set correct value range for
 subpixel reads

e.g. rgb4 only reads values up to 15, not 255.

Setting this correctly eliminates a number of redundant clamps in cases
like e.g. rgb4 -> monow.
---
 libswscale/ops_optimizer.c  | 2 +-
 tests/ref/fate/sws-ops-list | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index b13e7ebdc1..f173e1f78f 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -97,7 +97,7 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
         case SWS_OP_READ:
             for (int i = 0; i < op->rw.elems; i++) {
                 if (ff_sws_pixel_type_is_int(op->type)) {
-                    int bits = 8 * ff_sws_pixel_type_size(op->type);
+                    int bits = 8 * ff_sws_pixel_type_size(op->type) >> op->rw.frac;
                     if (!op->rw.packed && ops->src.desc) {
                         /* Use legal value range from pixdesc if available;
                          * we don't need to do this for packed formats because
diff --git a/tests/ref/fate/sws-ops-list b/tests/ref/fate/sws-ops-list
index f77c60fde3..132f66f4fc 100644
--- a/tests/ref/fate/sws-ops-list
+++ b/tests/ref/fate/sws-ops-list
@@ -1 +1 @@
-e124847bc6663ca538b784de17bf42f0
+eae3a49ac3af42c13ad274883611ac21
-- 
2.49.1


>From 8383bd2db8ba30693912f536deb32d2ddea53a13 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Mon, 8 Dec 2025 18:53:33 +0100
Subject: [PATCH 2/2] swscale/ops: clarify SwsOpList.src/dst semantics

Turns out these are not, in fact, purely informative - but the optimizer
can take them into account. This should be documented properly.

I tried to think of a way to avoid needing this in the optimizer, but any
way I could think of would require shoving this to SwsReadWriteOp, which I
am particularly unwilling to do.
---
 libswscale/ops.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libswscale/ops.h b/libswscale/ops.h
index dccc00d2f0..14edc77978 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -209,8 +209,8 @@ typedef struct SwsOpList {
     SwsOp *ops;
     int num_ops;
 
-    /* Purely informative metadata associated with this operation list */
-    SwsFormat src, dst;
+    /* Metadata associated with this operation list */
+    SwsFormat src, dst; /* if set; may inform the optimizer about e.g value ranges */
 } SwsOpList;
 
 SwsOpList *ff_sws_op_list_alloc(void);
-- 
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-08 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-08 17:56 [FFmpeg-devel] [PATCH] swscale/optimizer: improve and properly document range tracking (PR #21135) Niklas Haas 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