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

Git pushed a commit to branch master
in repository ffmpeg.

commit 4ff32b6e86c02a03ed25bd41f93eca88adee005f
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Mar 13 14:02:18 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Mar 28 18:50:14 2026 +0100

    swscale/ops_chain: add optional check() call to SwsOpEntry
    
    Allows implementations to implement more advanced logic to determine if an
    operation is compatible or not.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops_chain.c | 26 +++++++++++++++-----------
 libswscale/ops_chain.h |  1 +
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/libswscale/ops_chain.c b/libswscale/ops_chain.c
index dedc5f3026..092133426e 100644
--- a/libswscale/ops_chain.c
+++ b/libswscale/ops_chain.c
@@ -212,34 +212,38 @@ int ff_sws_op_compile_tables(SwsContext *ctx, const 
SwsOpTable *const tables[],
     const SwsOp *op = &ops->ops[0];
     int ret, best_score = 0;
 
+    SwsImplParams params = {
+        .ctx    = ctx,
+        .op     = op
+    };
+
     for (int n = 0; n < num_tables; n++) {
         const SwsOpTable *table = tables[n];
         if (table->block_size && table->block_size != block_size ||
             table->cpu_flags & ~cpu_flags)
             continue;
 
+        params.table = table;
         for (int i = 0; table->entries[i]; i++) {
             const SwsOpEntry *entry = table->entries[i];
             int score = op_match(op, entry, next->comps);
-            if (score > best_score) {
-                best_score = score;
-                best_table = table;
-                best = entry;
-            }
+            if (score <= best_score)
+                continue;
+            if (entry->check && !entry->check(&params))
+                continue;
+            best_score = score;
+            best_table = table;
+            best = entry;
         }
     }
 
     if (!best)
         return AVERROR(ENOTSUP);
 
+    params.table = best_table;
+
     SwsImplResult res = {0};
     if (best->setup) {
-        const SwsImplParams params = {
-            .ctx    = ctx,
-            .op     = op,
-            .table  = best_table,
-        };
-
         ret = best->setup(&params, &res);
         if (ret < 0)
             return ret;
diff --git a/libswscale/ops_chain.h b/libswscale/ops_chain.h
index ffdcc577dd..0dbab689f5 100644
--- a/libswscale/ops_chain.h
+++ b/libswscale/ops_chain.h
@@ -137,6 +137,7 @@ typedef struct SwsOpEntry {
     /* Kernel implementation */
     SwsFuncPtr func;
     int (*setup)(const SwsImplParams *params, SwsImplResult *out); /* optional 
*/
+    bool (*check)(const SwsImplParams *params); /* optional, return true if 
supported */
 } SwsOpEntry;
 
 /* Setup helpers */

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

Reply via email to