mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
swscale/ops_dispatch: move on-stack mutation to ops backends
And move the remainder printing there as well. Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
@@ -66,12 +66,19 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
|
||||
av_assert0(ops->num_ops > 0);
|
||||
const SwsPixelType read_type = ops->ops[0].type;
|
||||
|
||||
/* Make on-stack copy of `ops` to iterate over */
|
||||
SwsOpList rest = *ops;
|
||||
do {
|
||||
ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), ops,
|
||||
ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), &rest,
|
||||
SWS_BLOCK_SIZE, chain);
|
||||
} while (ret == AVERROR(EAGAIN));
|
||||
|
||||
if (ret < 0) {
|
||||
ff_sws_op_chain_free(chain);
|
||||
if (rest.num_ops < ops->num_ops) {
|
||||
av_log(ctx, AV_LOG_TRACE, "Uncompiled remainder:\n");
|
||||
ff_sws_op_list_print(ctx, AV_LOG_TRACE, AV_LOG_TRACE, &rest);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef struct SwsOpPass {
|
||||
int ff_sws_ops_compile_backend(SwsContext *ctx, const SwsOpBackend *backend,
|
||||
const SwsOpList *ops, SwsCompiledOp *out)
|
||||
{
|
||||
SwsOpList *copy, rest;
|
||||
SwsOpList *copy;
|
||||
SwsCompiledOp compiled = {0};
|
||||
int ret = 0;
|
||||
|
||||
@@ -58,19 +58,11 @@ int ff_sws_ops_compile_backend(SwsContext *ctx, const SwsOpBackend *backend,
|
||||
/* Ensure these are always set during compilation */
|
||||
ff_sws_op_list_update_comps(copy);
|
||||
|
||||
/* Make an on-stack copy of `ops` to ensure we can still properly clean up
|
||||
* the copy afterwards */
|
||||
rest = *copy;
|
||||
|
||||
ret = backend->compile(ctx, &rest, &compiled);
|
||||
ret = backend->compile(ctx, copy, &compiled);
|
||||
if (ret < 0) {
|
||||
int msg_lev = ret == AVERROR(ENOTSUP) ? AV_LOG_TRACE : AV_LOG_ERROR;
|
||||
av_log(ctx, msg_lev, "Backend '%s' failed to compile operations: %s\n",
|
||||
backend->name, av_err2str(ret));
|
||||
if (rest.num_ops != ops->num_ops) {
|
||||
av_log(ctx, msg_lev, "Uncompiled remainder:\n");
|
||||
ff_sws_op_list_print(ctx, msg_lev, AV_LOG_TRACE, &rest);
|
||||
}
|
||||
} else {
|
||||
*out = compiled;
|
||||
}
|
||||
|
||||
@@ -708,9 +708,12 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
|
||||
if (write->rw.packed && write->rw.elems == 3)
|
||||
out->over_write = sizeof(uint32_t);
|
||||
|
||||
|
||||
/* Make on-stack copy of `ops` to iterate over */
|
||||
SwsOpList rest = *ops;
|
||||
do {
|
||||
int op_block_size = out->block_size;
|
||||
SwsOp *op = &ops->ops[0];
|
||||
SwsOp *op = &rest.ops[0];
|
||||
|
||||
if (op_is_type_invariant(op)) {
|
||||
if (op->op == SWS_OP_CLEAR)
|
||||
@@ -719,11 +722,16 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
|
||||
op->type = SWS_PIXEL_U8;
|
||||
}
|
||||
|
||||
ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), ops,
|
||||
ret = ff_sws_op_compile_tables(tables, FF_ARRAY_ELEMS(tables), &rest,
|
||||
op_block_size, chain);
|
||||
} while (ret == AVERROR(EAGAIN));
|
||||
|
||||
if (ret < 0) {
|
||||
ff_sws_op_chain_free(chain);
|
||||
if (rest.num_ops < ops->num_ops) {
|
||||
av_log(ctx, AV_LOG_TRACE, "Uncompiled remainder:\n");
|
||||
ff_sws_op_list_print(ctx, AV_LOG_TRACE, AV_LOG_TRACE, &rest);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user