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 <[email protected]>
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 <[email protected]>
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 -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to