mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
swscale/ops_chain: add optional check() call to SwsOpEntry
Allows implementations to implement more advanced logic to determine if an operation is compatible or not. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
@@ -212,34 +212,38 @@ int ff_sws_op_compile_tables(SwsContext *ctx, const SwsOpTable *const tables[],
|
||||
const SwsOp *op = &ops->ops[0];
|
||||
int ret, best_score = 0;
|
||||
|
||||
SwsImplParams params = {
|
||||
.ctx = ctx,
|
||||
.op = op
|
||||
};
|
||||
|
||||
for (int n = 0; n < num_tables; n++) {
|
||||
const SwsOpTable *table = tables[n];
|
||||
if (table->block_size && table->block_size != block_size ||
|
||||
table->cpu_flags & ~cpu_flags)
|
||||
continue;
|
||||
|
||||
params.table = table;
|
||||
for (int i = 0; table->entries[i]; i++) {
|
||||
const SwsOpEntry *entry = table->entries[i];
|
||||
int score = op_match(op, entry, next->comps);
|
||||
if (score > best_score) {
|
||||
best_score = score;
|
||||
best_table = table;
|
||||
best = entry;
|
||||
}
|
||||
if (score <= best_score)
|
||||
continue;
|
||||
if (entry->check && !entry->check(¶ms))
|
||||
continue;
|
||||
best_score = score;
|
||||
best_table = table;
|
||||
best = entry;
|
||||
}
|
||||
}
|
||||
|
||||
if (!best)
|
||||
return AVERROR(ENOTSUP);
|
||||
|
||||
params.table = best_table;
|
||||
|
||||
SwsImplResult res = {0};
|
||||
if (best->setup) {
|
||||
const SwsImplParams params = {
|
||||
.ctx = ctx,
|
||||
.op = op,
|
||||
.table = best_table,
|
||||
};
|
||||
|
||||
ret = best->setup(¶ms, &res);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -137,6 +137,7 @@ typedef struct SwsOpEntry {
|
||||
/* Kernel implementation */
|
||||
SwsFuncPtr func;
|
||||
int (*setup)(const SwsImplParams *params, SwsImplResult *out); /* optional */
|
||||
bool (*check)(const SwsImplParams *params); /* optional, return true if supported */
|
||||
} SwsOpEntry;
|
||||
|
||||
/* Setup helpers */
|
||||
|
||||
Reference in New Issue
Block a user