This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 56305c460c076cf120daae73483572685d0ded79 Author: Niklas Haas <[email protected]> AuthorDate: Mon May 11 19:33:21 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Fri May 15 18:53:05 2026 +0200 swscale/graph: add ff_sws_graph_alloc() and _init() As an alternative to the current _create() API. Signed-off-by: Niklas Haas <[email protected]> --- libswscale/graph.c | 36 +++++++++++++++++++++++++++++------- libswscale/graph.h | 12 ++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index c556e0391e..f779ad45eb 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -845,6 +845,11 @@ static void sws_graph_worker(void *priv, int jobnr, int threadnr, int nb_jobs, pass->run(graph->exec.output, graph->exec.input, slice_y, slice_h, pass); } +SwsGraph *ff_sws_graph_alloc(void) +{ + return av_mallocz(sizeof(SwsGraph)); +} + static void graph_uninit(SwsGraph *graph) { avpriv_slicethread_free(&graph->slicethread); @@ -856,13 +861,14 @@ static void graph_uninit(SwsGraph *graph) memset(graph, 0, sizeof(*graph)); } -int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, - int field, SwsGraph **out_graph) +int ff_sws_graph_init(SwsGraph *graph, SwsContext *ctx, const SwsFormat *dst, + const SwsFormat *src, int field) { int ret; - SwsGraph *graph = av_mallocz(sizeof(*graph)); - if (!graph) - return AVERROR(ENOMEM); + if (graph->ctx) { + av_log(ctx, AV_LOG_ERROR, "Graph is already initialized\n"); + return AVERROR(EINVAL); + } graph->ctx = ctx; graph->src = *src; @@ -896,14 +902,30 @@ int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat * goto error; } - *out_graph = graph; return 0; error: - ff_sws_graph_free(&graph); + graph_uninit(graph); return ret; } +int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src, + int field, SwsGraph **out_graph) +{ + SwsGraph *graph = ff_sws_graph_alloc(); + if (!graph) + return AVERROR(ENOMEM); + + int ret = ff_sws_graph_init(graph, ctx, dst, src, field); + if (ret < 0) { + ff_sws_graph_free(&graph); + return ret; + } + + *out_graph = graph; + return 0; +} + void ff_sws_graph_rollback(SwsGraph *graph, int since_idx) { for (int i = since_idx; i < graph->num_passes; i++) diff --git a/libswscale/graph.h b/libswscale/graph.h index 116f2a89bf..ccf3133558 100644 --- a/libswscale/graph.h +++ b/libswscale/graph.h @@ -154,6 +154,18 @@ typedef struct SwsGraph { } exec; } SwsGraph; +/** + * Allocate an empty SwsGraph. Returns NULL on failure. + */ +SwsGraph *ff_sws_graph_alloc(void); + +/** + * Initialize the filter graph for a given pair of formats. Returns 0 or a + * negative error. + */ +int ff_sws_graph_init(SwsGraph *graph, SwsContext *ctx, const SwsFormat *dst, + const SwsFormat *src, int field); + /** * Allocate and initialize the filter graph. Returns 0 or a negative error. */ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
