This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 5a6602e95938c353eef39bbe5b30bbb720d1c708
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Dec 22 14:29:52 2025 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Wed Dec 24 16:37:22 2025 +0000

    swscale/format: add pixel range metadata to SWS_OP_READ
---
 libswscale/format.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index 9e1121f484..6b88fa4c5d 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -896,16 +896,39 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, enum 
AVPixelFormat fmt)
     SwsReadWriteOp rw_op;
     SwsSwizzleOp swizzle;
     SwsPackOp unpack;
+    SwsComps comps = {0};
     int shift;
 
     RET(fmt_analyze(fmt, &rw_op, &unpack, &swizzle, &shift,
                     &pixel_type, &raw_type));
 
+    swizzle = swizzle_inv(swizzle);
+
+    /* Set baseline pixel content flags */
+    const int integer = ff_sws_pixel_type_is_int(raw_type);
+    for (int i = 0; i < rw_op.elems; i++)
+        comps.flags[i] = (integer ? SWS_COMP_EXACT : 0);
+
+    /* Generate value range information for simple unpacked formats */
+    if (integer && !unpack.pattern[0]) {
+        /* YA formats have desc->comp[] in the order {Y, A} instead of the
+         * canonical order {Y, U, V, A} */
+        const int is_ya = desc->nb_components == 2;
+        for (int c = 0; c < desc->nb_components; c++) {
+            const int bits   = desc->comp[c].depth + shift;
+            const int idx    = swizzle.in[is_ya ? 3 * c : c];
+            comps.min[idx]   = Q0;
+            if (bits < 32) /* FIXME: AVRational is limited to INT_MAX */
+                comps.max[idx] = Q((1ULL << bits) - 1);
+        }
+    }
+
     /* TODO: handle subsampled or semipacked input formats */
     RET(ff_sws_op_list_append(ops, &(SwsOp) {
-        .op   = SWS_OP_READ,
-        .type = raw_type,
-        .rw   = rw_op,
+        .op    = SWS_OP_READ,
+        .type  = raw_type,
+        .rw    = rw_op,
+        .comps = comps,
     }));
 
     if ((desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG) {
@@ -932,7 +955,7 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, enum AVPixelFormat 
fmt)
     RET(ff_sws_op_list_append(ops, &(SwsOp) {
         .op      = SWS_OP_SWIZZLE,
         .type    = pixel_type,
-        .swizzle = swizzle_inv(swizzle),
+        .swizzle = swizzle,
     }));
 
     if (shift) {

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to