History

avfilter/af_stereotools: add support for commands

Paul B Mahol committed 5 years ago

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

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/af_stereotools.c+17−7
@@ -57,7 +57,7 @@ typedef struct StereoToolsContext { · 56 unmodified lines
57} StereoToolsContext;57} StereoToolsContext;
58 58
59#define OFFSET(x) offsetof(StereoToolsContext, x)59#define OFFSET(x) offsetof(StereoToolsContext, x)
60#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM60#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
61 61
62static const AVOption stereotools_options[] = {62static const AVOption stereotools_options[] = {
63 { "level_in", "set level in", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A },63 { "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
120 AVFilterContext *ctx = inlink->dst;120 AVFilterContext *ctx = inlink->dst;
121 StereoToolsContext *s = ctx->priv;121 StereoToolsContext *s = ctx->priv;
122 122
123 s->length = 2 * inlink->sample_rate * 0.05;123 s->length = FFALIGN(inlink->sample_rate / 10, 2);
124 if (s->length <= 1 || s->length & 1) {124 if (!s->buffer)
125 av_log(ctx, AV_LOG_ERROR, "sample rate is too small\n");125 s->buffer = av_calloc(s->length, sizeof(*s->buffer));
126 return AVERROR(EINVAL);
127 }
128 s->buffer = av_calloc(s->length, sizeof(*s->buffer));
129 if (!s->buffer)126 if (!s->buffer)
130 return AVERROR(ENOMEM);127 return AVERROR(ENOMEM);
131 128
@@ -341,6 +338,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 209 unmodified lines
341 return ff_filter_frame(outlink, out);338 return ff_filter_frame(outlink, out);
342}339}
343 340
341static 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
344static av_cold void uninit(AVFilterContext *ctx)353static av_cold void uninit(AVFilterContext *ctx)
345{354{
346 StereoToolsContext *s = ctx->priv;355 StereoToolsContext *s = ctx->priv;
@@ -375,5 +384,6 @@ AVFilter ff_af_stereotools = { · 28 unmodified lines
375 .uninit = uninit,384 .uninit = uninit,
376 .inputs = inputs,385 .inputs = inputs,
377 .outputs = outputs,386 .outputs = outputs,
387 .process_command = process_command,
378 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,388 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
379};389};

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