swscale/graph: add metadata about backends in use

Not currently publicly visible, but useful inside the test framework
nonetheless.

Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-06-03 21:10:30 +02:00
committed by Niklas Haas
parent 6df223ce02
commit dfeb4fdbc7
4 changed files with 15 additions and 3 deletions

View File

@@ -487,6 +487,7 @@ static int init_legacy_subpass(SwsGraph *graph, SwsContext *sws,
setup_legacy_swscale, sws, free_legacy_swscale, &pass);
if (ret < 0)
return ret;
pass->backend = SWS_BACKEND_LEGACY;
/**
* For slice threading, we need to create sub contexts, similar to how
@@ -853,6 +854,7 @@ int ff_sws_graph_init(SwsGraph *graph, SwsContext *ctx, const SwsFormat *dst,
/* Resolve output buffers for all intermediate passes */
for (int i = 0; i < graph->num_passes; i++) {
graph->backend |= graph->passes[i]->backend;
ret = pass_alloc_output(graph->passes[i]->input);
if (ret < 0)
goto error;

View File

@@ -81,6 +81,7 @@ struct SwsPass {
* are always equal to (or smaller than, for the last slice) `slice_h`.
*/
SwsPassFunc run;
SwsBackend backend; /* backend this pass is using, or 0 */
enum AVPixelFormat format; /* new pixel format */
int width, height; /* new output size */
int slice_h; /* filter granularity */
@@ -124,6 +125,7 @@ typedef struct SwsGraph {
int num_threads; /* resolved at init() time */
bool incomplete; /* set during init() if formats had to be inferred */
bool noop; /* set during init() if the graph is a no-op */
SwsBackend backend; /* backends this graph is using, set during init() */
AVBufferRef *hw_frames_ref;

View File

@@ -77,6 +77,7 @@ static int compile_backend(SwsContext *ctx, const SwsOpBackend *backend,
goto fail;
}
compiled.backend = backend;
*out = compiled;
av_log(ctx, AV_LOG_VERBOSE, "Compiled using backend '%s': "
@@ -515,9 +516,12 @@ static int compile(SwsGraph *graph, const SwsOpBackend *backend,
if (p->comp.opaque) {
SwsCompiledOp c = *comp;
av_free(p);
return ff_sws_graph_add_pass(graph, dst->format, dst->width, dst->height,
input, c.slice_align, c.func_opaque,
NULL, c.priv, c.free, output);
ret = ff_sws_graph_add_pass(graph, dst->format, dst->width, dst->height,
input, c.slice_align, c.func_opaque,
NULL, c.priv, c.free, output);
if (ret >= 0)
(*output)->backend = comp->backend->flags;
return ret;
}
const SwsOp *read = ff_sws_op_list_input(ops);
@@ -599,6 +603,7 @@ static int compile(SwsGraph *graph, const SwsOpBackend *backend,
if (ret < 0)
return ret;
(*output)->backend = comp->backend->flags;
align_pass(input, comp->block_size, comp->over_read, p->pixel_bits_in);
align_pass(*output, comp->block_size, comp->over_write, p->pixel_bits_out);
return 0;

View File

@@ -111,6 +111,9 @@ typedef struct SwsCompiledOp {
*/
bool opaque;
/* Set by ff_sws_ops_compile(), informative */
const struct SwsOpBackend *backend;
/* Execution parameters for all functions */
int slice_align; /* slice height alignment */
int cpu_flags; /* active set of CPU flags (informative) */