[FFmpeg-cvslog] avfilter/af_sidechaincompress: add support for commands
Paul B Mahol
git at videolan.org
Mon Jan 6 20:43:11 EET 2020
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Jan 6 19:40:07 2020 +0100| [e21ba176c92b61977330b9aa8d9c49e4fe5a3c23] | committer: Paul B Mahol
avfilter/af_sidechaincompress: add support for commands
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e21ba176c92b61977330b9aa8d9c49e4fe5a3c23
---
doc/filters.texi | 8 ++++++
libavfilter/af_sidechaincompress.c | 53 +++++++++++++++++++++++++-------------
2 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 428f15efe5..fc2d198077 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -443,6 +443,10 @@ How much to use compressed signal in output. Default is 1.
Range is between 0 and 1.
@end table
+ at subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
@section acontrast
Simple audio dynamic range compression/expansion filter.
@@ -4680,6 +4684,10 @@ How much to use compressed signal in output. Default is 1.
Range is between 0 and 1.
@end table
+ at subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
@subsection Examples
@itemize
diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c
index 8199ec6b44..e79c04d40e 100644
--- a/libavfilter/af_sidechaincompress.c
+++ b/libavfilter/af_sidechaincompress.c
@@ -70,26 +70,27 @@ typedef struct SidechainCompressContext {
#define OFFSET(x) offsetof(SidechainCompressContext, x)
#define A AV_OPT_FLAG_AUDIO_PARAM
#define F AV_OPT_FLAG_FILTERING_PARAM
+#define R AV_OPT_FLAG_RUNTIME_PARAM
static const AVOption options[] = {
- { "level_in", "set input gain", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F },
- { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F, "mode" },
- { "downward",0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F, "mode" },
- { "upward", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F, "mode" },
- { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0.125}, 0.000976563, 1, A|F },
- { "ratio", "set ratio", OFFSET(ratio), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 20, A|F },
- { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 0.01, 2000, A|F },
- { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=250}, 0.01, 9000, A|F },
- { "makeup", "set make up gain", OFFSET(makeup), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 64, A|F },
- { "knee", "set knee", OFFSET(knee), AV_OPT_TYPE_DOUBLE, {.dbl=2.82843}, 1, 8, A|F },
- { "link", "set link type", OFFSET(link), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F, "link" },
- { "average", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F, "link" },
- { "maximum", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F, "link" },
- { "detection", "set detection", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, A|F, "detection" },
- { "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F, "detection" },
- { "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F, "detection" },
- { "level_sc", "set sidechain gain", OFFSET(level_sc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F },
- { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A|F },
+ { "level_in", "set input gain", OFFSET(level_in), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
+ { "mode", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, "mode" },
+ { "downward",0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, "mode" },
+ { "upward", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, "mode" },
+ { "threshold", "set threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0.125}, 0.000976563, 1, A|F|R },
+ { "ratio", "set ratio", OFFSET(ratio), AV_OPT_TYPE_DOUBLE, {.dbl=2}, 1, 20, A|F|R },
+ { "attack", "set attack", OFFSET(attack), AV_OPT_TYPE_DOUBLE, {.dbl=20}, 0.01, 2000, A|F|R },
+ { "release", "set release", OFFSET(release), AV_OPT_TYPE_DOUBLE, {.dbl=250}, 0.01, 9000, A|F|R },
+ { "makeup", "set make up gain", OFFSET(makeup), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 1, 64, A|F|R },
+ { "knee", "set knee", OFFSET(knee), AV_OPT_TYPE_DOUBLE, {.dbl=2.82843}, 1, 8, A|F|R },
+ { "link", "set link type", OFFSET(link), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, A|F|R, "link" },
+ { "average", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, "link" },
+ { "maximum", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, "link" },
+ { "detection", "set detection", OFFSET(detection), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, A|F|R, "detection" },
+ { "peak", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, A|F|R, "detection" },
+ { "rms", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, A|F|R, "detection" },
+ { "level_sc", "set sidechain gain", OFFSET(level_sc), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.015625, 64, A|F|R },
+ { "mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, A|F|R },
{ NULL }
};
@@ -214,6 +215,20 @@ static void compressor(SidechainCompressContext *s,
}
}
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+ char *res, int res_len, int flags)
+{
+ int ret;
+
+ ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+ if (ret < 0)
+ return ret;
+
+ compressor_config_output(ctx->outputs[0]);
+
+ return 0;
+}
+
#if CONFIG_SIDECHAINCOMPRESS_FILTER
static int activate(AVFilterContext *ctx)
{
@@ -382,6 +397,7 @@ AVFilter ff_af_sidechaincompress = {
.uninit = uninit,
.inputs = sidechaincompress_inputs,
.outputs = sidechaincompress_outputs,
+ .process_command = process_command,
};
#endif /* CONFIG_SIDECHAINCOMPRESS_FILTER */
@@ -475,5 +491,6 @@ AVFilter ff_af_acompressor = {
.query_formats = acompressor_query_formats,
.inputs = acompressor_inputs,
.outputs = acompressor_outputs,
+ .process_command = process_command,
};
#endif /* CONFIG_ACOMPRESSOR_FILTER */
More information about the ffmpeg-cvslog
mailing list