Browse Source

avfilter/vf_deband: add support for commands

tags/n4.4
Paul B Mahol 4 years ago
parent
commit
dd01165f19
2 changed files with 21 additions and 3 deletions
  1. +4
    -0
      doc/filters.texi
  2. +17
    -3
      libavfilter/vf_deband.c

+ 4
- 0
doc/filters.texi View File

@@ -9486,6 +9486,10 @@ e.g. banding detection threshold is triggered for all color components.
The default is disabled. The default is disabled.
@end table @end table


@subsection Commands

This filter supports the all above options as @ref{commands}.

@section deblock @section deblock


Remove blocking artifacts from input video. Remove blocking artifacts from input video.


+ 17
- 3
libavfilter/vf_deband.c View File

@@ -49,7 +49,7 @@ typedef struct DebandContext {
} DebandContext; } DebandContext;


#define OFFSET(x) offsetof(DebandContext, x) #define OFFSET(x) offsetof(DebandContext, 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 deband_options[] = { static const AVOption deband_options[] = {
{ "1thr", "set 1st plane threshold", OFFSET(threshold[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS }, { "1thr", "set 1st plane threshold", OFFSET(threshold[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.02}, 0.00003, 0.5, FLAGS },
@@ -389,8 +389,10 @@ static int config_input(AVFilterLink *inlink)
s->thr[2] = ((1 << desc->comp[2].depth) - 1) * s->threshold[2]; s->thr[2] = ((1 << desc->comp[2].depth) - 1) * s->threshold[2];
s->thr[3] = ((1 << desc->comp[3].depth) - 1) * s->threshold[3]; s->thr[3] = ((1 << desc->comp[3].depth) - 1) * s->threshold[3];


s->x_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->x_pos));
s->y_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->y_pos));
if (!s->x_pos)
s->x_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->x_pos));
if (!s->y_pos)
s->y_pos = av_malloc(s->planewidth[0] * s->planeheight[0] * sizeof(*s->y_pos));
if (!s->x_pos || !s->y_pos) if (!s->x_pos || !s->y_pos)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);


@@ -432,6 +434,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_input(ctx->inputs[0]);
}

static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
{ {
DebandContext *s = ctx->priv; DebandContext *s = ctx->priv;
@@ -468,4 +481,5 @@ AVFilter ff_vf_deband = {
.inputs = avfilter_vf_deband_inputs, .inputs = avfilter_vf_deband_inputs,
.outputs = avfilter_vf_deband_outputs, .outputs = avfilter_vf_deband_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,
}; };

Loading…
Cancel
Save