mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-08-09 01:21:06 +00:00
swscale/ops_dispatch: add SwsOpBackend.compile_uops()
This can be used as an alternative to the existing compile() backend, that takes SwsUOpList instead of SwsOpList. Down the line, I plan on also moving the uops translation to the dispatch layer itself, but this requires some further changes which have not yet been merged, so this commit represents a stopgap solution. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "libavutil/frame.h"
|
||||
#include "graph.h"
|
||||
#include "uops.h"
|
||||
|
||||
/**
|
||||
* Global execution context for all compiled functions.
|
||||
@@ -141,6 +142,11 @@ typedef struct SwsOpBackend {
|
||||
*/
|
||||
int (*compile)(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out);
|
||||
|
||||
/**
|
||||
* Alternative to `compile` that takes a list of micro-ops directly.
|
||||
*/
|
||||
int (*compile_uops)(SwsContext *ctx, const SwsUOpList *uops, SwsCompiledOp *out);
|
||||
|
||||
/**
|
||||
* If NONE, backend only supports software frames.
|
||||
* Otherwise, frame hardware format must match hw_format for the backend
|
||||
|
||||
@@ -135,7 +135,7 @@ static void process(const SwsOpExec *exec, const void *priv,
|
||||
}
|
||||
}
|
||||
|
||||
static int compile(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
|
||||
static int compile_uops_c(SwsContext *ctx, const SwsUOpList *uops, SwsCompiledOp *out)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -143,16 +143,6 @@ static int compile(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
|
||||
if (!chain)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
SwsUOpList *uops = ff_sws_uop_list_alloc();
|
||||
if (!uops) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = ff_sws_ops_translate(ctx, ops, 0, uops);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
av_assert0(uops->num_ops > 0);
|
||||
for (int i = 0; i < uops->num_ops; i++) {
|
||||
const SwsUOpTable *table = &uop_table;
|
||||
@@ -181,18 +171,34 @@ static int compile(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
|
||||
av_log(ctx, AV_LOG_DEBUG, " %s\n", name);
|
||||
}
|
||||
|
||||
ff_sws_uop_list_free(&uops);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_sws_uop_list_free(&uops);
|
||||
ff_sws_op_chain_free(chain);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int compile_c(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
|
||||
{
|
||||
SwsUOpList *uops = ff_sws_uop_list_alloc();
|
||||
if (!uops)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
int ret = ff_sws_ops_translate(ctx, ops, 0, uops);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
ret = compile_uops_c(ctx, uops, out);
|
||||
|
||||
fail:
|
||||
ff_sws_uop_list_free(&uops);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const SwsOpBackend backend_c = {
|
||||
.name = "c",
|
||||
.flags = SWS_BACKEND_C,
|
||||
.compile = compile,
|
||||
.hw_format = AV_PIX_FMT_NONE,
|
||||
.name = "c",
|
||||
.flags = SWS_BACKEND_C,
|
||||
.compile = compile_c,
|
||||
.compile_uops = compile_uops_c,
|
||||
.hw_format = AV_PIX_FMT_NONE,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user