This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 52306246199d1c9b33a5618e79922621961434f3 Author: Niklas Haas <[email protected]> AuthorDate: Mon Mar 9 13:07:25 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Wed Mar 18 09:09:44 2026 +0000 swscale/graph: allocate output buffers after adding all passes There's no reason to immediately allocate all of these; we can do it at the end when we know for sure which passes we have. This will matter especially if we ever add a way to remove passes again after adding them (spoiler: we will). Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]> --- libswscale/graph.c | 11 +++++++---- libswscale/graph.h | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index 3b16037767..c0e2a3792e 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -141,10 +141,6 @@ int ff_sws_graph_add_pass(SwsGraph *graph, enum AVPixelFormat fmt, goto fail; } - ret = pass_alloc_output(input); - if (ret < 0) - goto fail; - if (!align) { pass->slice_h = pass->height; pass->num_slices = 1; @@ -797,6 +793,13 @@ int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat * if (ret < 0) goto error; + /* Resolve output buffers for all intermediate passes */ + for (int i = 0; i < graph->num_passes; i++) { + ret = pass_alloc_output(graph->passes[i]->input); + if (ret < 0) + goto error; + } + *out_graph = graph; return 0; diff --git a/libswscale/graph.h b/libswscale/graph.h index 4267851baa..2ee4067b26 100644 --- a/libswscale/graph.h +++ b/libswscale/graph.h @@ -52,7 +52,9 @@ typedef int (*SwsPassSetup)(const SwsFrame *out, const SwsFrame *in, const SwsPass *pass); /** - * Represents an allocated output buffer for a filter pass. + * Represents an output buffer for a filter pass. During filter graph + * construction, these merely hold the metadata. Allocation of the underlying + * storage is deferred until after all filter passes are settled. */ typedef struct SwsPassBuffer { SwsFrame frame; @@ -84,10 +86,10 @@ struct SwsPass { * Filter input. This pass's output will be resolved to form this pass's. * input. If NULL, the original input image is used. */ - const SwsPass *input; + SwsPass *input; /** - * Filter output buffer. Allocated on demand and freed automatically. + * Filter output buffer. This struct is always allocated. */ SwsPassBuffer *output; /* refstruct */ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
