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

Git pushed a commit to branch master
in repository ffmpeg.

commit f76aa4e4087569f99af1b4d87c04f160fb2378ce
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Mar 27 17:49:41 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Mar 28 16:48:13 2026 +0000

    swscale/tests/sws_ops: add option for summarizing all operation patterns
    
    This can be used to either manually verify, or perhaps programmatically
    generate, the list of operation patterns that need to be supported by a
    backend to be feature-complete.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/tests/sws_ops.c | 88 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 85 insertions(+), 3 deletions(-)

diff --git a/libswscale/tests/sws_ops.c b/libswscale/tests/sws_ops.c
index 616840c1ec..91b3d8c4b7 100644
--- a/libswscale/tests/sws_ops.c
+++ b/libswscale/tests/sws_ops.c
@@ -18,7 +18,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/tree.h"
 #include "libswscale/ops.h"
 #include "libswscale/format.h"
 
@@ -40,6 +44,69 @@ static int print_ops(SwsContext *const ctx, void *opaque, 
SwsOpList *ops)
 
     return 0;
 }
+
+static int cmp_str(const void *a, const void *b)
+{
+    return strcmp(a, b);
+}
+
+static const bool unused[4] = { false, false, false, false };
+static int register_op(SwsContext *ctx, void *opaque, SwsOp *op)
+{
+    struct AVTreeNode **root = opaque;
+    AVBPrint bp;
+    char *desc;
+
+    /* Strip irrelevant constant data from some operations */
+    switch (op->op) {
+    case SWS_OP_LINEAR:
+        for (int i = 0; i < 4; i++) {
+            for (int j = 0; j < 5; j++)
+                op->lin.m[i][j] = (AVRational) { 0, 1 };
+        }
+        break;
+    case SWS_OP_SCALE:
+    case SWS_OP_MIN:
+    case SWS_OP_MAX:
+    case SWS_OP_CLEAR:
+        for (int i = 0; i < 4; i++)
+            op->c.q4[i] = (AVRational) { 0, !!op->c.q4[i].den };
+        break;
+    case SWS_OP_DITHER:
+        /* Strip arbitrary offset */
+        for (int i = 0; i < 4; i++)
+            op->dither.y_offset[i] = op->dither.y_offset[i] >= 0 ? 0 : -1;
+        break;
+    }
+
+    av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
+    ff_sws_op_desc(&bp, op, unused);
+    int ret = av_bprint_finalize(&bp, &desc);
+    if (ret < 0)
+        return ret;
+
+    struct AVTreeNode *node = av_tree_node_alloc();
+    if (!node) {
+        av_free(desc);
+        return AVERROR(ENOMEM);
+    }
+
+    av_tree_insert(root, desc, cmp_str, &node);
+    if (node) {
+        av_free(node);
+        av_free(desc);
+    }
+    return ret;
+}
+
+static int print_and_free_summary(void *opaque, void *key)
+{
+    char *desc = key;
+    av_log(opaque, AV_LOG_INFO, "%s\n", desc);
+    av_free(desc);
+    return 0;
+}
+
 static void log_stdout(void *avcl, int level, const char *fmt, va_list vl)
 {
     if (level != AV_LOG_INFO) {
@@ -53,6 +120,7 @@ int main(int argc, char **argv)
 {
     enum AVPixelFormat src_fmt = AV_PIX_FMT_NONE;
     enum AVPixelFormat dst_fmt = AV_PIX_FMT_NONE;
+    bool summarize = false;
     int ret = 1;
 
 #ifdef _WIN32
@@ -71,6 +139,8 @@ int main(int argc, char **argv)
                     "       Only test the specified source pixel format\n"
                     "   -v <level>\n"
                     "       Enable log verbosity at given level\n"
+                    "   -summarize\n"
+                    "       Summarize operation types, instead of printing op 
lists\n"
             );
             return 0;
         }
@@ -97,6 +167,8 @@ int main(int argc, char **argv)
                 goto bad_option;
             av_log_set_level(atoi(argv[i + 1]));
             i++;
+        } else if (!strcmp(argv[i], "-summarize")) {
+            summarize = true;
         } else {
 bad_option:
             fprintf(stderr, "bad option or argument missing (%s) see -help\n", 
argv[i]);
@@ -109,9 +181,19 @@ bad_option:
         goto fail;
 
     av_log_set_callback(log_stdout);
-    ret = ff_sws_enum_op_lists(ctx, NULL, src_fmt, dst_fmt, print_ops);
-    if (ret < 0)
-        goto fail;
+
+    if (summarize) {
+        struct AVTreeNode *root = NULL;
+        ret = ff_sws_enum_ops(ctx, &root, src_fmt, dst_fmt, register_op);
+        if (ret < 0)
+            goto fail;
+        av_tree_enumerate(root, NULL, NULL, print_and_free_summary);
+        av_tree_destroy(root);
+    } else {
+        ret = ff_sws_enum_op_lists(ctx, NULL, src_fmt, dst_fmt, print_ops);
+        if (ret < 0)
+            goto fail;
+    }
 
     ret = 0;
 fail:

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

Reply via email to