[FFmpeg-devel] [PATCH] avfilter: Handle =help to show Filter options documentation

Paul B Mahol onemda at gmail.com
Sat Mar 30 13:19:39 CET 2013


On 3/30/13, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Friday 2013-03-29 17:26:19 +0100, Michael Niedermayer encoded:
>> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
>
> The commit log may state somethink like:
>
> Log help message in case the filter configuration failed, the filter
> has a private class *and* the user specified "help" as arguments.
>
> This behavior has to be considered like a temporary hack and may be
> removed at some point (for example in case we switch to an
> AVDictionary-based filter configuration system), thus the library user
> should not rely on this behavior.
>
>> ---
>>  libavfilter/avfilter.c |   14 +++++++++++++-
>>  libavfilter/avfilter.h |    1 +
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
>> index 8a907dc..df7c84b 100644
>> --- a/libavfilter/avfilter.c
>> +++ b/libavfilter/avfilter.c
>> @@ -236,6 +236,9 @@ int avfilter_config_links(AVFilterContext *filter)
>>                      return AVERROR(EINVAL);
>>                  }
>>              } else if ((ret = config_link(link)) < 0) {
>> +                if (link->src->help) {
>> +                    av_opt_show2(&link->src->filter->priv_class, NULL,
>> AV_OPT_FLAG_FILTERING_PARAM, 0);
>> +                } else
>>                  av_log(link->src, AV_LOG_ERROR,
>>                         "Failed to configure output pad on %s\n",
>>                         link->src->name);
>> @@ -279,6 +282,9 @@ int avfilter_config_links(AVFilterContext *filter)
>>
>>              if ((config_link = link->dstpad->config_props))
>>                  if ((ret = config_link(link)) < 0) {
>> +                    if (link->dst->help) {
>> +                        av_opt_show2(&link->dst->filter->priv_class,
>> NULL, AV_OPT_FLAG_FILTERING_PARAM, 0);
>> +                    } else
>>                      av_log(link->src, AV_LOG_ERROR,
>>                             "Failed to configure input pad on %s\n",
>>                             link->dst->name);
>> @@ -602,6 +608,7 @@ void avfilter_free(AVFilterContext *filter)
>>  int avfilter_init_filter(AVFilterContext *filter, const char *args, void
>> *opaque)
>>  {
>>      int ret=0;
>> +    filter->help = args && !strncmp(args, "help", 4);
>>
>>      if (filter->filter->shorthand) {
>>          av_assert0(filter->priv);
>> @@ -610,14 +617,19 @@ int avfilter_init_filter(AVFilterContext *filter,
>> const char *args, void *opaque
>>          av_opt_set_defaults(filter->priv);
>>          ret = av_opt_set_from_string(filter->priv, args,
>>                                       filter->filter->shorthand, "=",
>> ":");
>> -        if (ret < 0)
>> +        if (ret < 0) {
>> +            if(filter->help)
>
> nit: if_(...
>
>> +                av_opt_show2(&filter->filter->priv_class, NULL,
>> AV_OPT_FLAG_FILTERING_PARAM, 0);
>
>>              return ret;
>> +        }
>>          args = NULL;
>>      }
>>      if (filter->filter->init_opaque)
>>          ret = filter->filter->init_opaque(filter, args, opaque);
>>      else if (filter->filter->init)
>>          ret = filter->filter->init(filter, args);
>> +    if(filter->help && ret<0)
>
> nit: if_(... && ret < 0)
>
>> +        av_opt_show2(&filter->filter->priv_class, NULL,
>> AV_OPT_FLAG_FILTERING_PARAM, 0);
>>      return ret;
>>  }
>>
>> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
>> index 455161f..7b5c0f7 100644
>> --- a/libavfilter/avfilter.h
>> +++ b/libavfilter/avfilter.h
>> @@ -522,6 +522,7 @@ struct AVFilterContext {
>>      void *priv;                     ///< private data for use by the
>> filter
>>
>>      struct AVFilterCommand *command_queue;
>> +    int help;                       ///< avfilter internal flag
>> indicating that help text possibly was requested
>>  };
>
> LGTM otherwise if you insist with the feature, and you agree that the
> "feature" may be removed in case we change the initialization system
> (for example if we switch to an AVDictionary-based configuration
> system).
> --
> FFmpeg = Fu**i*g & Fundamental Majestic Proud Elegant Game
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

I'm still against this nonsense feature.


More information about the ffmpeg-devel mailing list