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

Git pushed a commit to branch master
in repository ffmpeg.

commit d803957307d3b6ffda8d998d2282f11531477595
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Jul 24 15:41:28 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Mon Aug 3 09:32:30 2026 +0000

    swscale/graph: lift SwsLut3D to SwsGraph top level
    
    Since this depends on the overall picture parameters anyways, updating it
    directly from the private setup() function was always a bit hacky. More
    importantly, this needed for the ops-based 3DLUT implementation, which is
    already using the pass priv pointer to store the compiled function.
    
    Overall, simpler to just lift it to the top level and update it directly as
    needed.
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/graph.c | 40 ++++++++++++----------------------------
 libswscale/graph.h |  6 ++++++
 2 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/libswscale/graph.c b/libswscale/graph.c
index 1c3fa188d5..1514272c95 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -679,25 +679,10 @@ static int add_convert_pass(SwsGraph *graph, const 
SwsFormat *src,
  * Gamut and tone mapping *
  **************************/
 
-static void free_lut3d(void *priv)
-{
-    SwsLut3D *lut = priv;
-    av_refstruct_unref(&lut);
-}
-
-static int setup_lut3d(const SwsFrame *out, const SwsFrame *in, const SwsPass 
*pass)
-{
-    SwsLut3D *lut = pass->priv;
-
-    /* Update dynamic frame metadata from the original source frame */
-    ff_sws_lut3d_update(lut, &pass->graph->src.color);
-    return 0;
-}
-
 static void run_lut3d(const SwsFrame *out, const SwsFrame *in, int y, int h,
                       const SwsPass *pass)
 {
-    SwsLut3D *lut = pass->priv;
+    const SwsLut3D *lut = pass->graph->lut3d;
     uint8_t *in_data[4], *out_data[4];
     frame_shift(in,  y, in_data);
     frame_shift(out, y, out_data);
@@ -713,7 +698,6 @@ static int adapt_colors(SwsGraph *graph, const SwsFormat 
*src_fmt,
     SwsFormat src = *src_fmt;
     SwsFormat dst = *dst_fmt;
     SwsColorMap map = {0};
-    SwsLut3D *lut;
     int ret;
 
     /**
@@ -741,30 +725,25 @@ static int adapt_colors(SwsGraph *graph, const SwsFormat 
*src_fmt,
     if (src.hw_format != AV_PIX_FMT_NONE || dst.hw_format != AV_PIX_FMT_NONE)
         return AVERROR(ENOTSUP);
 
-    lut = ff_sws_lut3d_alloc();
-    if (!lut)
+    graph->lut3d = ff_sws_lut3d_alloc();
+    if (!graph->lut3d)
         return AVERROR(ENOMEM);
 
-    ret = ff_sws_lut3d_generate(lut, &map);
-    if (ret < 0) {
-        av_refstruct_unref(&lut);
+    ret = ff_sws_lut3d_generate(graph->lut3d, &map);
+    if (ret < 0)
         return ret;
-    }
 
     const enum AVPixelFormat fmt = AV_PIX_FMT_RGBA64;
     if (src.format != fmt) {
         SwsFormat tmp = src;
         tmp.format = fmt;
         ret = add_convert_pass(graph, &src, &tmp, input, &input);
-        if (ret < 0) {
-            av_refstruct_unref(&lut);
+        if (ret < 0)
             return ret;
-        }
     }
 
     return ff_sws_graph_add_pass(graph, fmt, src.width, src.height,
-                                 input, 0, 1, run_lut3d, setup_lut3d, lut,
-                                 free_lut3d, output);
+                                 input, 0, 1, run_lut3d, NULL, NULL, NULL, 
output);
 }
 
 /***************************************
@@ -825,6 +804,8 @@ static void graph_uninit(SwsGraph *graph)
         pass_free(graph->passes[i]);
     av_free(graph->passes);
 
+    av_refstruct_unref(&graph->lut3d);
+
     memset(graph, 0, sizeof(*graph));
 }
 
@@ -936,6 +917,9 @@ void ff_sws_graph_update_metadata(SwsGraph *graph, const 
SwsColor *color)
         return;
 
     ff_color_update_dynamic(&graph->src.color, color);
+
+    if (graph->lut3d)
+        ff_sws_lut3d_update(graph->lut3d, &graph->src.color);
 }
 
 static void get_field(SwsGraph *graph, const SwsFormat *fmt,
diff --git a/libswscale/graph.h b/libswscale/graph.h
index 68c6a0b9eb..4399346d46 100644
--- a/libswscale/graph.h
+++ b/libswscale/graph.h
@@ -28,6 +28,7 @@
 
 #include "swscale.h"
 #include "format.h"
+#include "lut3d.h"
 
 static av_always_inline av_const int ff_fmt_vshift(enum AVPixelFormat fmt, int 
plane)
 {
@@ -144,6 +145,11 @@ typedef struct SwsGraph {
      */
     SwsFormat src, dst;
 
+    /**
+     * 3DLUT state used for gamut/tone mapping. (Optional)
+     */
+    SwsLut3D *lut3d; /* refstruct */
+
     /**
      * Temporary execution state inside ff_sws_graph_run(); used to pass
      * data to worker threads.

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

Reply via email to