[FFmpeg-devel] [PATCH] lavfi/idet: switch to filter_frame API

Stefano Sabatini stefasab at gmail.com
Thu Dec 6 22:47:47 CET 2012


On date Thursday 2012-12-06 21:09:17 +0100, Matthieu Bouron encoded:
> ---
>  libavfilter/vf_idet.c | 29 +++++++----------------------
>  1 file changed, 7 insertions(+), 22 deletions(-)
> 
> diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
> index cc20fac..7470b51 100644
> --- a/libavfilter/vf_idet.c
> +++ b/libavfilter/vf_idet.c
> @@ -165,17 +165,17 @@ static void filter(AVFilterContext *ctx)
>      av_log(ctx, AV_LOG_DEBUG, "Single frame:%s, Multi frame:%s\n", type2str(type), type2str(idet->last_type));
>  }
>  
> -static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
> +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
>  {
> -    AVFilterContext *ctx = link->dst;
> +    AVFilterContext *ctx = inlink->dst;
>      IDETContext *idet = ctx->priv;
>  
>      if (idet->prev)
>          avfilter_unref_buffer(idet->prev);
>      idet->prev = idet->cur;
>      idet->cur  = idet->next;
> -    idet->next = picref;
> -    link->cur_buf = NULL;
> +    idet->next = inpicref;

> +    inlink->cur_buf = NULL;

This can be safely skipped.
  
>      if (!idet->cur)
>          return 0;
> @@ -183,26 +183,14 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
>      if (!idet->prev)
>          idet->prev = avfilter_ref_buffer(idet->cur, ~0);
>  
> -    return ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(idet->cur, ~0));
> -}
> -
> -static int end_frame(AVFilterLink *link)
> -{
> -    AVFilterContext *ctx = link->dst;
> -    IDETContext *idet = ctx->priv;
> -
> -    if (!idet->cur)
> -        return 0;
> -
>      if (!idet->csp)
> -        idet->csp = av_pix_fmt_desc_get(link->format);
> +        idet->csp = av_pix_fmt_desc_get(inlink->format);
>      if (idet->csp->comp[0].depth_minus1 / 8 == 1)
>          idet->filter_line = (void*)filter_line_c_16bit;
>  
>      filter(ctx);
>  
> -    ff_draw_slice(ctx->outputs[0], 0, link->h, 1);
> -    return ff_end_frame(ctx->outputs[0]);
> +    return ff_filter_frame(ctx->outputs[0], avfilter_ref_buffer(idet->next, ~0));
>  }
>  
>  static int request_frame(AVFilterLink *link)
> @@ -308,15 +296,12 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
>      return 0;
>  }
>  
> -static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; }
>  
>  static const AVFilterPad idet_inputs[] = {
>      {
>          .name         = "default",
>          .type         = AVMEDIA_TYPE_VIDEO,
> -        .start_frame  = start_frame,
> -        .draw_slice   = null_draw_slice,
> -        .end_frame    = end_frame,
> +        .filter_frame = filter_frame,
>          .min_perms    = AV_PERM_PRESERVE,
>      },
>      { NULL }

inlink->link and picref->inpicref can be avoided to shrink the diff,
but looks good anyway, thanks.
-- 
FFmpeg = Fostering Funny Mythic Political Eretic Geek


More information about the ffmpeg-devel mailing list