avfilter/vf_lut: add support for commands
While here remove excessive log and uninit() call in negate_init().
This commit is contained in:
parent
dd01165f19
commit
a00ff56321
@ -14114,6 +14114,10 @@ expression
|
|||||||
|
|
||||||
All expressions default to "val".
|
All expressions default to "val".
|
||||||
|
|
||||||
|
@subsection Commands
|
||||||
|
|
||||||
|
This filter supports same @ref{commands} as options.
|
||||||
|
|
||||||
@subsection Examples
|
@subsection Examples
|
||||||
|
|
||||||
@itemize
|
@itemize
|
||||||
@ -14776,6 +14780,10 @@ It accepts the following option:
|
|||||||
With value 1, it negates the alpha component, if present. Default value is 0.
|
With value 1, it negates the alpha component, if present. Default value is 0.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@subsection Commands
|
||||||
|
|
||||||
|
This filter supports same @ref{commands} as options.
|
||||||
|
|
||||||
@anchor{nlmeans}
|
@anchor{nlmeans}
|
||||||
@section nlmeans
|
@section nlmeans
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ typedef struct LutContext {
|
|||||||
#define A 3
|
#define A 3
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(LutContext, x)
|
#define OFFSET(x) offsetof(LutContext, x)
|
||||||
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
|
||||||
|
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
{ "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "clipval" }, .flags = FLAGS },
|
{ "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "clipval" }, .flags = FLAGS },
|
||||||
@ -566,6 +566,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
return ff_filter_frame(outlink, out);
|
return ff_filter_frame(outlink, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
|
||||||
|
char *res, int res_len, int flags)
|
||||||
|
{
|
||||||
|
int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return config_props(ctx->inputs[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static const AVFilterPad inputs[] = {
|
static const AVFilterPad inputs[] = {
|
||||||
{ .name = "default",
|
{ .name = "default",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
@ -592,7 +603,9 @@ static const AVFilterPad outputs[] = {
|
|||||||
.query_formats = query_formats, \
|
.query_formats = query_formats, \
|
||||||
.inputs = inputs, \
|
.inputs = inputs, \
|
||||||
.outputs = outputs, \
|
.outputs = outputs, \
|
||||||
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, \
|
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | \
|
||||||
|
AVFILTER_FLAG_SLICE_THREADS, \
|
||||||
|
.process_command = process_command, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_LUT_FILTER
|
#if CONFIG_LUT_FILTER
|
||||||
@ -654,17 +667,12 @@ AVFILTER_DEFINE_CLASS(negate);
|
|||||||
static av_cold int negate_init(AVFilterContext *ctx)
|
static av_cold int negate_init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
LutContext *s = ctx->priv;
|
LutContext *s = ctx->priv;
|
||||||
int i;
|
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", s->negate_alpha);
|
for (int i = 0; i < 4; i++) {
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
s->comp_expr_str[i] = av_strdup((i == 3 && !s->negate_alpha) ?
|
s->comp_expr_str[i] = av_strdup((i == 3 && !s->negate_alpha) ?
|
||||||
"val" : "negval");
|
"val" : "negval");
|
||||||
if (!s->comp_expr_str[i]) {
|
if (!s->comp_expr_str[i])
|
||||||
uninit(ctx);
|
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user