[FFmpeg-devel] [PATCH 01/14] lavfi: add common code to handle options parsing.

Stefano Sabatini stefasab at gmail.com
Sun Mar 17 01:51:41 CET 2013


On date Saturday 2013-03-16 21:39:21 +0100, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavfilter/avfilter.c |   12 ++++++++++++
>  libavfilter/avfilter.h |    8 ++++++++
>  2 files changed, 20 insertions(+)
> 
> 
> The next patches change a few filters (those I had time to do and know how
> to test easily) to use this new feature
> 
> The overall diffstat is:
>  15 files changed, 65 insertions(+), 117 deletions(-)
> 
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 1d27817..83d2651 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -24,6 +24,7 @@
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/common.h"
>  #include "libavutil/imgutils.h"
> +#include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/rational.h"
>  #include "libavutil/samplefmt.h"
> @@ -600,6 +601,17 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
>  {
>      int ret=0;
>  
> +    if (filter->filter->shorthand) {
> +        av_assert0(filter->priv);
> +        av_assert0(filter->filter->priv_class);
> +        *(const AVClass **)filter->priv = filter->filter->priv_class;
> +        av_opt_set_defaults(filter->priv);
> +        ret = av_opt_set_from_string(filter->priv, args,
> +                                     filter->filter->shorthand, "=", ":");
> +        if (ret < 0)
> +            return ret;
> +        args = NULL;
> +    }

I suggest to set options whenever the priv_class is defined. This
should work fine for all filters with a few exceptions (out of my mind
only hue, which may/should be simplified, at the cost of changing the
command interface).

At this point we could free the context in uninint, as suggested by
Clement, which should allow more factorization.
-- 
FFmpeg = Formidable Fundamental Mysterious Picky Extensive Gladiator


More information about the ffmpeg-devel mailing list