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

Git pushed a commit to branch master
in repository ffmpeg.

commit 57d7bf51946d2cedc892b65cf5e3d359d0071dd3
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue May 12 20:12:08 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Thu Jun 11 16:27:47 2026 +0000

    swscale/ops_optimizer: fix broken convert->filter commute check
    
    This one failed to adjust prev->type to the result of filtering,
    leading to basically broken intermediate op lists. Fortunately, the
    optimizer usually ended up eliminating these cases altogether.
    
    Replace it by a fixed check to merge filters with any prior conversion
    op that satisfies the criteria (and is deemed beneficial).
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_optimizer.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libswscale/ops_optimizer.c b/libswscale/ops_optimizer.c
index 829bd3d0c9..52f84062ec 100644
--- a/libswscale/ops_optimizer.c
+++ b/libswscale/ops_optimizer.c
@@ -191,12 +191,6 @@ static bool op_commute_filter(SwsOp *op, SwsOp *prev)
         prev->type = SWS_PIXEL_F32;
         return true;
     case SWS_OP_CONVERT:
-        if (prev->convert.to == SWS_PIXEL_F32) {
-            av_assert0(!prev->convert.expand);
-            FFSWAP(SwsPixelType, op->type, prev->type);
-            return true;
-        }
-        return false;
     case SWS_OP_INVALID:
     case SWS_OP_READ:
     case SWS_OP_WRITE:
@@ -367,6 +361,18 @@ retry:
                 FFSWAP(SwsOp, *op, *prev);
                 goto retry;
             }
+
+            /* Merge filter with prior conversion */
+            if (prev->op == SWS_OP_CONVERT && !prev->convert.expand) {
+                int size_from = ff_sws_pixel_type_size(prev->type);
+                int size_to   = ff_sws_pixel_type_size(op->type);
+                av_assert1(prev->convert.to == op->type);
+                if (size_from < size_to) {
+                    op->type = prev->type;
+                    ff_sws_op_list_remove_at(ops, n - 1, 1);
+                    goto retry;
+                }
+            }
             break;
         }
     }

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

Reply via email to