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

Git pushed a commit to branch master
in repository ffmpeg.

commit 62aad4513cc1de34f8ee0ea2fe34b4381b760453
Author:     Niklas Haas <[email protected]>
AuthorDate: Wed Apr 22 15:56:07 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Fri May 15 18:53:05 2026 +0200

    swscale/graph: move format conversion logic to formats.c
    
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/format.c | 40 ++++++++++++++++++++++++++++++++++++++++
 libswscale/format.h |  9 +++++++++
 libswscale/graph.c  | 30 ++----------------------------
 3 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index 365f3a7297..7782a0233d 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -1630,4 +1630,44 @@ int ff_sws_add_filters(SwsContext *ctx, SwsPixelType 
type, SwsOpList *ops,
     return add_filter(ctx, type, ops, SWS_OP_FILTER_V, src->height, 
dst->height);
 }
 
+int ff_sws_op_list_generate(SwsContext *ctx, const SwsFormat *src,
+                            const SwsFormat *dst, SwsOpList **out_ops,
+                            bool *incomplete)
+{
+    /* The new code does not yet support alpha blending */
+    if (src->desc->flags & AV_PIX_FMT_FLAG_ALPHA &&
+        ctx->alpha_blend != SWS_ALPHA_BLEND_NONE)
+        return AVERROR(ENOTSUP);
+
+    SwsOpList *ops = ff_sws_op_list_alloc();
+    if (!ops)
+        return AVERROR(ENOMEM);
+    ops->src = *src;
+    ops->dst = *dst;
+
+    const SwsPixelType type = SWS_PIXEL_F32;
+    int ret = ff_sws_decode_pixfmt(ops, src->format);
+    if (ret < 0)
+        goto fail;
+    ret = ff_sws_decode_colors(ctx, type, ops, src, incomplete);
+    if (ret < 0)
+        goto fail;
+    ret = ff_sws_add_filters(ctx, type, ops, src, dst);
+    if (ret < 0)
+        goto fail;
+    ret = ff_sws_encode_colors(ctx, type, ops, src, dst, incomplete);
+    if (ret < 0)
+        goto fail;
+    ret = ff_sws_encode_pixfmt(ops, dst->format);
+    if (ret < 0)
+        goto fail;
+
+    *out_ops = ops;
+    return 0;
+
+fail:
+    ff_sws_op_list_free(&ops);
+    return ret;
+}
+
 #endif /* CONFIG_UNSTABLE */
diff --git a/libswscale/format.h b/libswscale/format.h
index 4f2d1427cb..844ea353b3 100644
--- a/libswscale/format.h
+++ b/libswscale/format.h
@@ -186,6 +186,15 @@ int ff_sws_encode_colors(SwsContext *ctx, SwsPixelType 
type, SwsOpList *ops,
 int ff_sws_add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
                        const SwsFormat *src, const SwsFormat *dst);
 
+/**
+ * Generate an SwsOpList defining a conversion from `src` to `dst`.
+ *
+ * Returns 0 on success, or a negative error code on failure.
+ */
+int ff_sws_op_list_generate(SwsContext *ctx, const SwsFormat *src,
+                            const SwsFormat *dst, SwsOpList **out_ops,
+                            bool *incomplete);
+
 /**
  * Represents a view into a single field of frame data.
  *
diff --git a/libswscale/graph.c b/libswscale/graph.c
index 543ac5973c..24882b8a95 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -574,40 +574,15 @@ static int add_convert_pass(SwsGraph *graph, const 
SwsFormat *src,
                             const SwsFormat *dst, SwsPass *input,
                             SwsPass **output)
 {
-    const SwsPixelType type = SWS_PIXEL_F32;
-
     SwsContext *ctx = graph->ctx;
-    SwsOpList *ops = NULL;
     int ret = AVERROR(ENOTSUP);
 
     /* Mark the entire new ops infrastructure as experimental for now */
     if (!(ctx->flags & SWS_UNSTABLE))
         goto fail;
 
-    /* The new code does not yet support alpha blending */
-    if (src->desc->flags & AV_PIX_FMT_FLAG_ALPHA &&
-        ctx->alpha_blend != SWS_ALPHA_BLEND_NONE)
-        goto fail;
-
-    ops = ff_sws_op_list_alloc();
-    if (!ops)
-        return AVERROR(ENOMEM);
-    ops->src = *src;
-    ops->dst = *dst;
-
-    ret = ff_sws_decode_pixfmt(ops, src->format);
-    if (ret < 0)
-        goto fail;
-    ret = ff_sws_decode_colors(ctx, type, ops, src, &graph->incomplete);
-    if (ret < 0)
-        goto fail;
-    ret = ff_sws_add_filters(ctx, type, ops, src, dst);
-    if (ret < 0)
-        goto fail;
-    ret = ff_sws_encode_colors(ctx, type, ops, src, dst, &graph->incomplete);
-    if (ret < 0)
-        goto fail;
-    ret = ff_sws_encode_pixfmt(ops, dst->format);
+    SwsOpList *ops;
+    ret = ff_sws_op_list_generate(ctx, src, dst, &ops, &graph->incomplete);
     if (ret < 0)
         goto fail;
 
@@ -625,7 +600,6 @@ static int add_convert_pass(SwsGraph *graph, const 
SwsFormat *src,
     /* fall through */
 
 fail:
-    ff_sws_op_list_free(&ops);
     if (ret == AVERROR(ENOTSUP))
         return add_legacy_sws_pass(graph, src, dst, input, output);
     return ret;

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

Reply via email to