[FFmpeg-devel,04/14] avfilter/af_anlms: switch to ff_filter_process_command()

Submitted by Paul B Mahol on Oct. 9, 2019, 10:16 a.m.

Details

Message ID 20191009101705.7072-4-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Oct. 9, 2019, 10:16 a.m.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/af_anlms.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

Comments

Michael Niedermayer Oct. 9, 2019, 5:10 p.m.
On Wed, Oct 09, 2019 at 12:16:55PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/af_anlms.c | 27 ++++++---------------------
>  1 file changed, 6 insertions(+), 21 deletions(-)

LGTM if it works (i didnt test)

Thanks

[...]

Patch hide | download patch | download mbox

diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
index 75bd969a83..b618e2367d 100644
--- a/libavfilter/af_anlms.c
+++ b/libavfilter/af_anlms.c
@@ -60,13 +60,14 @@  typedef struct AudioNLMSContext {
 
 #define OFFSET(x) offsetof(AudioNLMSContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define C AV_OPT_FLAG_COMMAND_PARAM
 
 static const AVOption anlms_options[] = {
     { "order",   "set the filter order",   OFFSET(order),   AV_OPT_TYPE_INT,   {.i64=256},  1, INT16_MAX, A },
-    { "mu",      "set the filter mu",      OFFSET(mu),      AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, A },
-    { "eps",     "set the filter eps",     OFFSET(eps),     AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, A },
-    { "leakage", "set the filter leakage", OFFSET(leakage), AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, A },
-    { "out_mode", "set output mode",       OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, A, "mode" },
+    { "mu",      "set the filter mu",      OFFSET(mu),      AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, A|C },
+    { "eps",     "set the filter eps",     OFFSET(eps),     AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, A|C },
+    { "leakage", "set the filter leakage", OFFSET(leakage), AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, A|C },
+    { "out_mode", "set output mode",       OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, A|C, "mode" },
     {  "i", "input",                 0,          AV_OPT_TYPE_CONST,    {.i64=IN_MODE},      0, 0, A, "mode" },
     {  "d", "desired",               0,          AV_OPT_TYPE_CONST,    {.i64=DESIRED_MODE}, 0, 0, A, "mode" },
     {  "o", "output",                0,          AV_OPT_TYPE_CONST,    {.i64=OUT_MODE},     0, 0, A, "mode" },
@@ -281,22 +282,6 @@  static av_cold int init(AVFilterContext *ctx)
     return 0;
 }
 
-static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
-                           char *res, int res_len, int flags)
-{
-    AudioNLMSContext *s = ctx->priv;
-    int ret;
-
-    if (   !strcmp(cmd, "mu") || !strcmp(cmd, "eps")
-        || !strcmp(cmd, "leakage") || !strcmp(cmd, "out_mode")) {
-        ret = av_opt_set(s, cmd, args, 0);
-    } else {
-        ret = AVERROR(ENOSYS);
-    }
-
-    return ret;
-}
-
 static av_cold void uninit(AVFilterContext *ctx)
 {
     AudioNLMSContext *s = ctx->priv;
@@ -341,5 +326,5 @@  AVFilter ff_af_anlms = {
     .inputs         = inputs,
     .outputs        = outputs,
     .flags          = AVFILTER_FLAG_SLICE_THREADS,
-    .process_command = process_command,
+    .process_command = ff_filter_process_command,
 };