[FFmpeg-cvslog] avfilter/af_acrusher: add commands support

Paul B Mahol git at videolan.org
Sun Jan 31 00:54:14 EET 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Jan 30 23:39:55 2021 +0100| [54de7dc372dc77cae0cb9b45987d365e5446399d] | committer: Paul B Mahol

avfilter/af_acrusher: add commands support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54de7dc372dc77cae0cb9b45987d365e5446399d
---

 doc/filters.texi          |  4 ++++
 libavfilter/af_acrusher.c | 19 +++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6782be3762..d2f62972dd 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -640,6 +640,10 @@ Set LFO range.
 Set LFO rate.
 @end table
 
+ at subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
 @section acue
 
 Delay audio filtering until a given wallclock timestamp. See the @ref{cue}
diff --git a/libavfilter/af_acrusher.c b/libavfilter/af_acrusher.c
index ddce74465d..d3c31c20bd 100644
--- a/libavfilter/af_acrusher.c
+++ b/libavfilter/af_acrusher.c
@@ -68,7 +68,7 @@ typedef struct ACrusherContext {
 } ACrusherContext;
 
 #define OFFSET(x) offsetof(ACrusherContext, x)
-#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption acrusher_options[] = {
     { "level_in", "set level in",         OFFSET(level_in),  AV_OPT_TYPE_DOUBLE, {.dbl=1},    0.015625, 64, A },
@@ -325,13 +325,27 @@ static int config_input(AVFilterLink *inlink)
     s->lfo.srate = inlink->sample_rate;
     s->lfo.amount = .5;
 
-    s->sr = av_calloc(inlink->channels, sizeof(*s->sr));
+    if (!s->sr)
+        s->sr = av_calloc(inlink->channels, sizeof(*s->sr));
     if (!s->sr)
         return AVERROR(ENOMEM);
 
     return 0;
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    AVFilterLink *inlink = ctx->inputs[0];
+    int ret;
+
+    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+    if (ret < 0)
+        return ret;
+
+    return config_input(inlink);
+}
+
 static const AVFilterPad avfilter_af_acrusher_inputs[] = {
     {
         .name         = "default",
@@ -359,4 +373,5 @@ AVFilter ff_af_acrusher = {
     .query_formats = query_formats,
     .inputs        = avfilter_af_acrusher_inputs,
     .outputs       = avfilter_af_acrusher_outputs,
+    .process_command = process_command,
 };



More information about the ffmpeg-cvslog mailing list