This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 18060a8820accbee5a5d6e4921575a9e2f7a5f17 Author: Niklas Haas <[email protected]> AuthorDate: Sat Feb 7 14:51:35 2026 +0100 Commit: Niklas Haas <[email protected]> CommitDate: Mon Feb 23 19:39:17 2026 +0000 swscale/graph: simplify ff_sws_graph_run() API There's little reason not to directly take an SwsImg here; it's already an internally visible struct. Signed-off-by: Niklas Haas <[email protected]> --- libswscale/graph.c | 28 ++++++++++------------------ libswscale/graph.h | 9 +++------ libswscale/swscale.c | 27 ++++++++++++++------------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/libswscale/graph.c b/libswscale/graph.c index 97329b4b63..6b9e6f4b25 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -173,7 +173,7 @@ static void setup_legacy_swscale(const SwsImg *out, const SwsImg *in, const SwsPass *pass) { const SwsGraph *graph = pass->graph; - const SwsImg *in_orig = &graph->exec.input; + const SwsImg *in_orig = graph->exec.input; SwsContext *sws = pass->priv; SwsInternal *c = sws_internal(sws); if (sws->flags & SWS_BITEXACT && sws->dither == SWS_DITHER_ED && c->dither_error[0]) { @@ -671,8 +671,8 @@ 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 : &graph->exec.input; - const SwsImg *output = pass->output.data[0] ? &pass->output : &graph->exec.output; + const SwsImg *input = pass->input ? &pass->input->output : graph->exec.input; + const SwsImg *output = pass->output.data[0] ? &pass->output : graph->exec.output; const int slice_y = jobnr * pass->slice_h; const int slice_h = FFMIN(pass->slice_h, pass->height - slice_y); @@ -693,9 +693,6 @@ int ff_sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat * graph->field = field; graph->opts_copy = *ctx; - graph->exec.input.fmt = src->format; - graph->exec.output.fmt = dst->format; - ret = avpriv_slicethread_create(&graph->slicethread, (void *) graph, sws_graph_worker, NULL, ctx->threads); if (ret == AVERROR(ENOSYS)) @@ -779,24 +776,19 @@ void ff_sws_graph_update_metadata(SwsGraph *graph, const SwsColor *color) ff_color_update_dynamic(&graph->src.color, color); } -void ff_sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4], - const int out_linesize[4], - const uint8_t *const in_data[4], - const int in_linesize[4]) +void ff_sws_graph_run(SwsGraph *graph, const SwsImg *output, const SwsImg *input) { - SwsImg *out = &graph->exec.output; - SwsImg *in = &graph->exec.input; - memcpy(out->data, out_data, sizeof(out->data)); - memcpy(out->linesize, out_linesize, sizeof(out->linesize)); - memcpy(in->data, in_data, sizeof(in->data)); - memcpy(in->linesize, in_linesize, sizeof(in->linesize)); + 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.data[0] ? &pass->output : out, - pass->input ? &pass->input->output : in, pass); + pass->setup(pass->output.data[0] ? &pass->output : output, + pass->input ? &pass->input->output : input, pass); } avpriv_slicethread_execute(graph->slicethread, pass->num_slices, 0); } diff --git a/libswscale/graph.h b/libswscale/graph.h index b829bac88c..44944a3c35 100644 --- a/libswscale/graph.h +++ b/libswscale/graph.h @@ -131,8 +131,8 @@ typedef struct SwsGraph { /** Temporary execution state inside ff_sws_graph_run */ struct { const SwsPass *pass; /* current filter pass */ - SwsImg input; - SwsImg output; + const SwsImg *input; /* arguments passed to ff_sws_graph_run() */ + const SwsImg *output; } exec; } SwsGraph; @@ -182,9 +182,6 @@ int ff_sws_graph_reinit(SwsContext *ctx, const SwsFormat *dst, const SwsFormat * /** * Dispatch the filter graph on a single field. Internally threaded. */ -void ff_sws_graph_run(SwsGraph *graph, uint8_t *const out_data[4], - const int out_linesize[4], - const uint8_t *const in_data[4], - const int in_linesize[4]); +void ff_sws_graph_run(SwsGraph *graph, const SwsImg *output, const SwsImg *input); #endif /* SWSCALE_GRAPH_H */ diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 219382505c..4ae0f25b9d 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1317,24 +1317,26 @@ int sws_receive_slice(SwsContext *sws, unsigned int slice_start, dst, c->frame_dst->linesize, slice_start, slice_height); } -static void get_frame_pointers(const AVFrame *frame, uint8_t *data[4], - int linesize[4], int field) +static SwsImg get_frame_img(const AVFrame *frame, int field) { + SwsImg img = {0}; + + img.fmt = frame->format; for (int i = 0; i < 4; i++) { - data[i] = frame->data[i]; - linesize[i] = frame->linesize[i]; + img.data[i] = frame->data[i]; + img.linesize[i] = frame->linesize[i]; } if (!(frame->flags & AV_FRAME_FLAG_INTERLACED)) { av_assert1(!field); - return; + return img; } if (field == FIELD_BOTTOM) { /* Odd rows, offset by one line */ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); for (int i = 0; i < 4; i++) { - data[i] += linesize[i]; + img.data[i] += img.linesize[i]; if (desc->flags & AV_PIX_FMT_FLAG_PAL) break; } @@ -1342,7 +1344,9 @@ static void get_frame_pointers(const AVFrame *frame, uint8_t *data[4], /* Take only every second line */ for (int i = 0; i < 4; i++) - linesize[i] <<= 1; + img.linesize[i] <<= 1; + + return img; } /* Subset of av_frame_ref() that only references (video) data buffers */ @@ -1409,12 +1413,9 @@ int sws_scale_frame(SwsContext *sws, AVFrame *dst, const AVFrame *src) for (int field = 0; field < 2; field++) { SwsGraph *graph = c->graph[field]; - uint8_t *dst_data[4], *src_data[4]; - int dst_linesize[4], src_linesize[4]; - get_frame_pointers(dst, dst_data, dst_linesize, field); - get_frame_pointers(src, src_data, src_linesize, field); - ff_sws_graph_run(graph, dst_data, dst_linesize, - (const uint8_t **) src_data, src_linesize); + SwsImg input = get_frame_img(src, field); + SwsImg output = get_frame_img(dst, field); + ff_sws_graph_run(graph, &output, &input); if (!graph->dst.interlaced) break; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
