This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit cc346b232dc8c84e8169fd82051b7d768d6e598f Author: Niklas Haas <[email protected]> AuthorDate: Tue Feb 10 18:22:57 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Mon Feb 23 19:39:17 2026 +0000 swscale/graph: store current pass input instead of global args The global args to ff_sws_graph_run() really shouldn't matter inside thread workers. If they ever do, it indicates a leaky abstraction. The only reason it was needed in the first place was because of the way the input/output buffers implicitly defaulted to the global args. However, we can solve this much more elegantly by just calculating it in ff_sws_graph_run() directly and storing the computed SwsImg inside the execution state. Signed-off-by: Niklas Haas <[email protected]> --- libswscale/graph.c | 32 ++++++++++++++++++++++---------- libswscale/graph.h | 9 ++++++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index b44964e625..7a9985f56a 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -718,12 +718,10 @@ static void sws_graph_worker(void *priv, int jobnr, int threadnr, int nb_jobs, { SwsGraph *graph = priv; const SwsPass *pass = graph->exec.pass; - const SwsImg *input = pass->input ? &pass->input->output.img : graph->exec.input; - const SwsImg *output = pass->output.img.data[0] ? &pass->output.img : graph->exec.output; const int slice_y = jobnr * pass->slice_h; const int slice_h = FFMIN(pass->slice_h, pass->height - slice_y); - pass->run(output, input, slice_y, slice_h, pass); + pass->run(&graph->exec.output, &graph->exec.input, slice_y, slice_h, pass); } int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, @@ -824,20 +822,34 @@ void ff_sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color) ff_color_update_dynamic(&graph->src.color, color); } +static SwsImg pass_output(const SwsPass *pass, const SwsImg *fallback) +{ + if (!pass) + return *fallback; + + SwsImg img = pass->output.img; + for (int i = 0; i < FF_ARRAY_ELEMS(img.data); i++) { + if (!img.data[i]) { + img.data[i] = fallback->data[i]; + img.linesize[i] = fallback->linesize[i]; + } + } + + return img; +} + void ff_sws_graph_run(SwsGraph *graph, const SwsImg *output, const SwsImg *input) { av_assert0(output->fmt == graph->dst.format); av_assert0(input->fmt == graph->src.format); - graph->exec.output = output; - graph->exec.input = input; for (int i = 0; i < graph->num_passes; i++) { const SwsPass *pass = graph->passes[i]; - graph->exec.pass = pass; - if (pass->setup) { - pass->setup(pass->output.img.data[0] ? &pass->output.img : output, - pass->input ? &pass->input->output.img : input, pass); - } + graph->exec.pass = pass; + graph->exec.input = pass_output(pass->input, input); + graph->exec.output = pass_output(pass, output); + if (pass->setup) + pass->setup(&graph->exec.output, &graph->exec.input, pass); avpriv_slicethread_execute(graph->slicethread, pass->num_slices, 0); } } diff --git a/libswscale/graph.h b/libswscale/graph.h index f8eed09132..f7a17aef59 100644 --- a/libswscale/graph.h +++ b/libswscale/graph.h @@ -139,11 +139,14 @@ typedef struct SwsGraph { SwsFormat src, dst; int field; - /** Temporary execution state inside ff_sws_graph_run */ + /** + * Temporary execution state inside ff_sws_graph_run(); used to pass + * data to worker threads. + */ struct { const SwsPass *pass; /* current filter pass */ - const SwsImg *input; /* arguments passed to ff_sws_graph_run() */ - const SwsImg *output; + SwsImg input; /* current filter pass input/output */ + SwsImg output; } exec; } SwsGraph; _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
