History

avfilter/af_stereotools: add support for commands

Paul B Mahol committed 5 years ago

Commit 51f88481 parent eebf19c2 files · +21 −7Browse files

Unified · Split

2 files
  1. doc/filters.texi +4 −0
  2. libavfilter/af_stereotools.c +17 −7
doc/filters.texi+4−0
@@ -5554,6 +5554,10 @@ Equal power distribution, from -6dB to +6dB range. · 5553 unmodified lines
55545554 @end table
55555555 @end table
55565556
5557+@subsection Commands
5558+
5559+This filter supports the all above options as @ref{commands}.
5560+
55575561 @subsection Examples
55585562
55595563 @itemize
libavfilter/af_stereotools.c+17−7
@@ -57,7 +57,7 @@ typedef struct StereoToolsContext { · 56 unmodified lines
5757 } StereoToolsContext;
5858
5959 #define OFFSET(x) offsetof(StereoToolsContext, x)
60−#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
60+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
6161
6262 static const AVOption stereotools_options[] = {
6363 { "level_in", "set level in", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },
@@ -120,12 +120,9 @@ static int config_input(AVFilterLink *inlink) · 56 unmodified lines
120120 AVFilterContext *ctx = inlink->dst;
121121 StereoToolsContext *s = ctx->priv;
122122
123− s->length = 2 * inlink->sample_rate * 0.05;
124− if (s->length <= 1 || s->length & 1) {
125− av_log(ctx, AV_LOG_ERROR, "sample rate is too small\n");
126− return AVERROR(EINVAL);
127− }
128− s->buffer = av_calloc(s->length, sizeof(*s->buffer));
123+ s->length = FFALIGN(inlink->sample_rate / 10, 2);
124+ if (!s->buffer)
125+ s->buffer = av_calloc(s->length, sizeof(*s->buffer));
129126 if (!s->buffer)
130127 return AVERROR(ENOMEM);
131128
@@ -341,6 +338,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 209 unmodified lines
341338 return ff_filter_frame(outlink, out);
342339 }
343340
341+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
342+ char *res, int res_len, int flags)
343+{
344+ int ret;
345+
346+ ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
347+ if (ret < 0)
348+ return ret;
349+
350+ return config_input(ctx->inputs[0]);
351+}
352+
344353 static av_cold void uninit(AVFilterContext *ctx)
345354 {
346355 StereoToolsContext *s = ctx->priv;
@@ -375,5 +384,6 @@ AVFilter ff_af_stereotools = { · 28 unmodified lines
375384 .uninit = uninit,
376385 .inputs = inputs,
377386 .outputs = outputs,
387+ .process_command = process_command,
378388 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
379389 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t