diff mbox

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

Message ID 20191010113851.27196-4-onemda@gmail.com
State Accepted
Commit 9f7ab36ada16ea271bf1bd5ca1a4cea7d024d5c7
Headers show

Commit Message

Paul B Mahol Oct. 10, 2019, 11:38 a.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/af_anlms.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

Comments

Lance Wang Oct. 10, 2019, 12:17 p.m. UTC | #1
On Thu, Oct 10, 2019 at 01:38:41PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/af_anlms.c | 35 ++++++++++-------------------------
>  1 file changed, 10 insertions(+), 25 deletions(-)
> 
> diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
> index 350bedaf7a..55e6946b68 100644
> --- a/libavfilter/af_anlms.c
> +++ b/libavfilter/af_anlms.c
> @@ -60,17 +60,18 @@ typedef struct AudioNLMSContext {
>  
>  #define OFFSET(x) offsetof(AudioNLMSContext, x)
>  #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +#define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_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, 2, 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" },
> -    {  "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" },
> -    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,    {.i64=NOISE_MODE},   0, 0, A, "mode" },
> +    { "mu",      "set the filter mu",      OFFSET(mu),      AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 2, AT },
> +    { "eps",     "set the filter eps",     OFFSET(eps),     AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, AT },
> +    { "leakage", "set the filter leakage", OFFSET(leakage), AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, AT },
> +    { "out_mode", "set output mode",       OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
> +    {  "i", "input",                 0,          AV_OPT_TYPE_CONST,    {.i64=IN_MODE},      0, 0, AT, "mode" },
> +    {  "d", "desired",               0,          AV_OPT_TYPE_CONST,    {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
> +    {  "o", "output",                0,          AV_OPT_TYPE_CONST,    {.i64=OUT_MODE},     0, 0, AT, "mode" },
> +    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,    {.i64=NOISE_MODE},   0, 0, AT, "mode" },
>      { NULL }
>  };
>  
> @@ -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,
Can we delete the line directly, if default is ff_filter_process_command, 
then we don't need to assign .process_command and make it default if the
runtime flags is set? 

>  };
> -- 
> 2.17.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol Oct. 10, 2019, 1:10 p.m. UTC | #2
On 10/10/19, Limin Wang <lance.lmwang@gmail.com> wrote:
> On Thu, Oct 10, 2019 at 01:38:41PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavfilter/af_anlms.c | 35 ++++++++++-------------------------
>>  1 file changed, 10 insertions(+), 25 deletions(-)
>>
>> diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
>> index 350bedaf7a..55e6946b68 100644
>> --- a/libavfilter/af_anlms.c
>> +++ b/libavfilter/af_anlms.c
>> @@ -60,17 +60,18 @@ typedef struct AudioNLMSContext {
>>
>>  #define OFFSET(x) offsetof(AudioNLMSContext, x)
>>  #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> +#define AT
>> AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_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, 2, 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" },
>> -    {  "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" },
>> -    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
>> {.i64=NOISE_MODE},   0, 0, A, "mode" },
>> +    { "mu",      "set the filter mu",      OFFSET(mu),
>> AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 2, AT },
>> +    { "eps",     "set the filter eps",     OFFSET(eps),
>> AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, AT },
>> +    { "leakage", "set the filter leakage", OFFSET(leakage),
>> AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, AT },
>> +    { "out_mode", "set output mode",       OFFSET(output_mode),
>> AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
>> +    {  "i", "input",                 0,          AV_OPT_TYPE_CONST,
>> {.i64=IN_MODE},      0, 0, AT, "mode" },
>> +    {  "d", "desired",               0,          AV_OPT_TYPE_CONST,
>> {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
>> +    {  "o", "output",                0,          AV_OPT_TYPE_CONST,
>> {.i64=OUT_MODE},     0, 0, AT, "mode" },
>> +    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
>> {.i64=NOISE_MODE},   0, 0, AT, "mode" },
>>      { NULL }
>>  };
>>
>> @@ -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,
> Can we delete the line directly, if default is ff_filter_process_command,
> then we don't need to assign .process_command and make it default if the
> runtime flags is set?

No, because this is used to show which filters support commands.
With your approach that would be lost, or some other thing would need
to mark it.

>
>>  };
>> --
>> 2.17.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Lance Wang Oct. 10, 2019, 1:27 p.m. UTC | #3
On Thu, Oct 10, 2019 at 03:10:28PM +0200, Paul B Mahol wrote:
> On 10/10/19, Limin Wang <lance.lmwang@gmail.com> wrote:
> > On Thu, Oct 10, 2019 at 01:38:41PM +0200, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> >> ---
> >>  libavfilter/af_anlms.c | 35 ++++++++++-------------------------
> >>  1 file changed, 10 insertions(+), 25 deletions(-)
> >>
> >> diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
> >> index 350bedaf7a..55e6946b68 100644
> >> --- a/libavfilter/af_anlms.c
> >> +++ b/libavfilter/af_anlms.c
> >> @@ -60,17 +60,18 @@ typedef struct AudioNLMSContext {
> >>
> >>  #define OFFSET(x) offsetof(AudioNLMSContext, x)
> >>  #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> >> +#define AT
> >> AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_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, 2, 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" },
> >> -    {  "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" },
> >> -    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
> >> {.i64=NOISE_MODE},   0, 0, A, "mode" },
> >> +    { "mu",      "set the filter mu",      OFFSET(mu),
> >> AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 2, AT },
> >> +    { "eps",     "set the filter eps",     OFFSET(eps),
> >> AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, AT },
> >> +    { "leakage", "set the filter leakage", OFFSET(leakage),
> >> AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, AT },
> >> +    { "out_mode", "set output mode",       OFFSET(output_mode),
> >> AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
> >> +    {  "i", "input",                 0,          AV_OPT_TYPE_CONST,
> >> {.i64=IN_MODE},      0, 0, AT, "mode" },
> >> +    {  "d", "desired",               0,          AV_OPT_TYPE_CONST,
> >> {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
> >> +    {  "o", "output",                0,          AV_OPT_TYPE_CONST,
> >> {.i64=OUT_MODE},     0, 0, AT, "mode" },
> >> +    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
> >> {.i64=NOISE_MODE},   0, 0, AT, "mode" },
> >>      { NULL }
> >>  };
> >>
> >> @@ -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,
> > Can we delete the line directly, if default is ff_filter_process_command,
> > then we don't need to assign .process_command and make it default if the
> > runtime flags is set?
> 
> No, because this is used to show which filters support commands.
> With your approach that would be lost, or some other thing would need
> to mark it.

Can we add a new flags like AVFILTER_FLAG_SLICE_THREADS? 

> 
> >
> >>  };
> >> --
> >> 2.17.1
> >>
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol Oct. 10, 2019, 1:40 p.m. UTC | #4
On 10/10/19, Limin Wang <lance.lmwang@gmail.com> wrote:
> On Thu, Oct 10, 2019 at 03:10:28PM +0200, Paul B Mahol wrote:
>> On 10/10/19, Limin Wang <lance.lmwang@gmail.com> wrote:
>> > On Thu, Oct 10, 2019 at 01:38:41PM +0200, Paul B Mahol wrote:
>> >> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> >> ---
>> >>  libavfilter/af_anlms.c | 35 ++++++++++-------------------------
>> >>  1 file changed, 10 insertions(+), 25 deletions(-)
>> >>
>> >> diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
>> >> index 350bedaf7a..55e6946b68 100644
>> >> --- a/libavfilter/af_anlms.c
>> >> +++ b/libavfilter/af_anlms.c
>> >> @@ -60,17 +60,18 @@ typedef struct AudioNLMSContext {
>> >>
>> >>  #define OFFSET(x) offsetof(AudioNLMSContext, x)
>> >>  #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> >> +#define AT
>> >> AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_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, 2, 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" },
>> >> -    {  "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" },
>> >> -    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
>> >> {.i64=NOISE_MODE},   0, 0, A, "mode" },
>> >> +    { "mu",      "set the filter mu",      OFFSET(mu),
>> >> AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 2, AT },
>> >> +    { "eps",     "set the filter eps",     OFFSET(eps),
>> >> AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, AT },
>> >> +    { "leakage", "set the filter leakage", OFFSET(leakage),
>> >> AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, AT },
>> >> +    { "out_mode", "set output mode",       OFFSET(output_mode),
>> >> AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
>> >> +    {  "i", "input",                 0,          AV_OPT_TYPE_CONST,
>> >> {.i64=IN_MODE},      0, 0, AT, "mode" },
>> >> +    {  "d", "desired",               0,          AV_OPT_TYPE_CONST,
>> >> {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
>> >> +    {  "o", "output",                0,          AV_OPT_TYPE_CONST,
>> >> {.i64=OUT_MODE},     0, 0, AT, "mode" },
>> >> +    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,
>> >> {.i64=NOISE_MODE},   0, 0, AT, "mode" },
>> >>      { NULL }
>> >>  };
>> >>
>> >> @@ -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,
>> > Can we delete the line directly, if default is
>> > ff_filter_process_command,
>> > then we don't need to assign .process_command and make it default if the
>> > runtime flags is set?
>>
>> No, because this is used to show which filters support commands.
>> With your approach that would be lost, or some other thing would need
>> to mark it.
>
> Can we add a new flags like AVFILTER_FLAG_SLICE_THREADS?

What for? I prefer it this way.

>
>>
>> >
>> >>  };
>> >> --
>> >> 2.17.1
>> >>
>> >> _______________________________________________
>> >> ffmpeg-devel mailing list
>> >> ffmpeg-devel@ffmpeg.org
>> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >>
>> >> To unsubscribe, visit link above, or email
>> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
index 350bedaf7a..55e6946b68 100644
--- a/libavfilter/af_anlms.c
+++ b/libavfilter/af_anlms.c
@@ -60,17 +60,18 @@  typedef struct AudioNLMSContext {
 
 #define OFFSET(x) offsetof(AudioNLMSContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_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, 2, 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" },
-    {  "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" },
-    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,    {.i64=NOISE_MODE},   0, 0, A, "mode" },
+    { "mu",      "set the filter mu",      OFFSET(mu),      AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 2, AT },
+    { "eps",     "set the filter eps",     OFFSET(eps),     AV_OPT_TYPE_FLOAT, {.dbl=1},    0, 1, AT },
+    { "leakage", "set the filter leakage", OFFSET(leakage), AV_OPT_TYPE_FLOAT, {.dbl=0},    0, 1, AT },
+    { "out_mode", "set output mode",       OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
+    {  "i", "input",                 0,          AV_OPT_TYPE_CONST,    {.i64=IN_MODE},      0, 0, AT, "mode" },
+    {  "d", "desired",               0,          AV_OPT_TYPE_CONST,    {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
+    {  "o", "output",                0,          AV_OPT_TYPE_CONST,    {.i64=OUT_MODE},     0, 0, AT, "mode" },
+    {  "n", "noise",                 0,          AV_OPT_TYPE_CONST,    {.i64=NOISE_MODE},   0, 0, AT, "mode" },
     { NULL }
 };
 
@@ -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,
 };