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

Git pushed a commit to branch master
in repository ffmpeg.

commit 11900e4e1235843f664609a9e56a414fbf177d29
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue May 12 21:12:55 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Jun 11 16:27:47 2026 +0000

    swscale/ops: generalize SWS_OP_FILTER_* result type
    
    Instead of hard-coding SWS_PIXEL_F32 here. This is not really useful
    yet, but I wanted to clean up the semantics here regardless.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/format.c        |  1 +
 libswscale/ops.h           |  2 ++
 libswscale/ops_optimizer.c | 13 ++++++++++---
 libswscale/uops.c          |  2 +-
 tests/checkasm/sw_ops.c    |  1 +
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index b9a25ed5a1..16ab524ce0 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -1640,6 +1640,7 @@ static int add_filter(SwsContext *ctx, SwsPixelType type, 
SwsOpList *ops,
         .type = type,
         .op   = filter,
         .filter.kernel = kernel,
+        .filter.type   = type,
     });
 }
 
diff --git a/libswscale/ops.h b/libswscale/ops.h
index b58a060c6e..b38cd915de 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -107,6 +107,7 @@ typedef struct SwsReadWriteOp {
     struct {
         SwsOpType op;               /* some value of SWS_OP_FILTER_* */
         SwsFilterWeights *kernel;   /* (refstruct) */
+        SwsPixelType type;          /* pixel type to store result as */
     } filter;
 } SwsReadWriteOp;
 
@@ -205,6 +206,7 @@ uint32_t ff_sws_linear_mask(SwsLinearOp);
 
 typedef struct SwsFilterOp {
     SwsFilterWeights *kernel; /* filter kernel (refstruct) */
+    SwsPixelType type;        /* pixel type to store result as */
 } SwsFilterOp;
 
 typedef struct SwsOp {
diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index 52f84062ec..38483b96ac 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -54,9 +54,11 @@ static bool op_commute_clear(SwsOp *op, SwsOp *next)
     case SWS_OP_MAX:
     case SWS_OP_SCALE:
     case SWS_OP_READ:
+        ff_sws_apply_op_q(next, op->clear.value);
+        return true;
     case SWS_OP_FILTER_H:
     case SWS_OP_FILTER_V:
-        ff_sws_apply_op_q(next, op->clear.value);
+        op->type = next->filter.type;
         return true;
     case SWS_OP_SWIZZLE:
         op->clear.mask = ff_sws_comp_mask_swizzle(op->clear.mask, 
next->swizzle);
@@ -115,8 +117,10 @@ static bool op_commute_swizzle(SwsOp *op, SwsOp *next)
     case SWS_OP_LSHIFT:
     case SWS_OP_RSHIFT:
     case SWS_OP_SCALE:
+        return true;
     case SWS_OP_FILTER_H:
     case SWS_OP_FILTER_V:
+        op->type = next->filter.type;
         return true;
 
     /**
@@ -183,12 +187,14 @@ static bool op_commute_swizzle(SwsOp *op, SwsOp *next)
  */
 static bool op_commute_filter(SwsOp *op, SwsOp *prev)
 {
+    av_assert0(!ff_sws_pixel_type_is_int(op->filter.type));
+
     switch (prev->op) {
     case SWS_OP_SWIZZLE:
     case SWS_OP_SCALE:
     case SWS_OP_LINEAR:
     case SWS_OP_DITHER:
-        prev->type = SWS_PIXEL_F32;
+        prev->type = op->filter.type;
         return true;
     case SWS_OP_CONVERT:
     case SWS_OP_INVALID:
@@ -418,7 +424,7 @@ retry:
                     op->rw.elems = nb_planes;
                     RET(ff_sws_op_list_insert_at(ops, n + 1, &(SwsOp) {
                         .op = SWS_OP_SWIZZLE,
-                        .type = op->rw.filter.op ? SWS_PIXEL_F32 : op->type,
+                        .type = op->rw.filter.op ? op->rw.filter.type : 
op->type,
                         .swizzle = swiz,
                     }));
                     goto retry;
@@ -745,6 +751,7 @@ retry:
                 !prev->rw.packed && !prev->rw.frac) {
                 prev->rw.filter.op = op->op;
                 prev->rw.filter.kernel = av_refstruct_ref(op->filter.kernel);
+                prev->rw.filter.type = op->filter.type;
                 ff_sws_op_list_remove_at(ops, n, 1);
                 goto retry;
             }
diff --git a/libswscale/uops.c b/libswscale/uops.c
index 2de9c33eac..b2d11d996c 100644
--- a/libswscale/uops.c
+++ b/libswscale/uops.c
@@ -482,7 +482,7 @@ static int translate_rw_op(SwsContext *ctx, SwsUOpList 
*ops, SwsUOpFlags flags,
     if (op->rw.filter.op) {
         if (op->op == SWS_OP_WRITE || op->rw.frac || op->rw.packed)
             return AVERROR(ENOTSUP);
-        uop.par.filter.type = SWS_PIXEL_F32;
+        uop.par.filter.type = op->rw.filter.type;
         uop.data.kernel = av_refstruct_ref(op->rw.filter.kernel);
         if (op->rw.filter.op == SWS_OP_FILTER_H) {
             uop.uop = SWS_UOP_READ_PLANAR_FH;
diff --git a/tests/checkasm/sw_ops.c b/tests/checkasm/sw_ops.c
index 01ffb0e048..e09635abd4 100644
--- a/tests/checkasm/sw_ops.c
+++ b/tests/checkasm/sw_ops.c
@@ -469,6 +469,7 @@ static void check_filter(const char *name, const SwsUOp 
*uop)
                     .rw.filter = {
                         .op     = is_vert ? SWS_OP_FILTER_V : SWS_OP_FILTER_H,
                         .kernel = filter,
+                        .type   = SWS_PIXEL_F32,
                     },
                 }, {
                     .op        = SWS_OP_WRITE,

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

Reply via email to