[FFmpeg-devel] [PATCH] lavfi: add init2 callback

Clément Bœsch ubitux at gmail.com
Fri Jul 6 08:04:53 CEST 2012


On Fri, Jul 06, 2012 at 01:22:17AM +0200, Stefano Sabatini wrote:
> This will be used by filters which require an opaque field to be passed.
> Should be required only for filters which imply a programmatic use.
> ---
>  libavfilter/avfilter.c |    4 +++-
>  libavfilter/avfilter.h |    6 ++++++
>  2 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 01f3442..2e9a825 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -554,7 +554,9 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
>  {
>      int ret=0;
>  
> -    if (filter->filter->init)
> +    if (filter->filter->init2)
> +        ret = filter->filter->init2(filter, args, opaque);
> +    else if (filter->filter->init)
>          ret = filter->filter->init(filter, args);
>      return ret;
>  }
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index e08a389..dd45ed7 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -412,6 +412,12 @@ typedef struct AVFilter {
>      int (*init)(AVFilterContext *ctx, const char *args);
>  
>      /**
> +     * Filter initialization function. Args contains the user-supplied
> +     * parameters, opaque is used for providing binary data.
> +     */
> +    int (*init2)(AVFilterContext *ctx, const char *args, void *opaque);
> +
> +    /**
>       * Filter uninitialization function. Should deallocate any memory held
>       * by the filter, release any buffer references, etc. This does not need
>       * to deallocate the AVFilterContext->priv memory itself.

I'm not very fond of "init2"; do you mind using something more explicit
like "init_wstruct", "init_opaque_arg" or whatever?

Also, do we need the args argument in the case of opaque?

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120706/bd4d99c0/attachment.asc>


More information about the ffmpeg-devel mailing list