[FFmpeg-devel] [PATCH] lavfi/decimate: switch to ff_filter_frame() API

Clément Bœsch ubitux at gmail.com
Sun Dec 2 02:05:51 CET 2012


On Sun, Dec 02, 2012 at 01:53:48AM +0100, Stefano Sabatini wrote:
> ---
>  libavfilter/vf_decimate.c |   23 ++++++-----------------
>  1 file changed, 6 insertions(+), 17 deletions(-)
> 
> diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
> index 0f516e2..7f49b96 100644
> --- a/libavfilter/vf_decimate.c
> +++ b/libavfilter/vf_decimate.c
> @@ -187,36 +187,27 @@ static int config_input(AVFilterLink *inlink)
>      return 0;
>  }
>  
> -static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { return 0; }
> -
> -static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { return 0; }
> -
> -static int end_frame(AVFilterLink *inlink)
> +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
>  {
>      DecimateContext *decimate = inlink->dst->priv;
> -    AVFilterBufferRef *cur = inlink->cur_buf;
>      AVFilterLink *outlink = inlink->dst->outputs[0];
>      int ret;
>  
> -    if (decimate->ref && decimate_frame(inlink->dst, cur, decimate->ref)) {
> +    if (decimate->ref && decimate_frame(inlink->dst, frame, decimate->ref)) {
>          decimate->drop_count = FFMAX(1, decimate->drop_count+1);
>      } else {
>          avfilter_unref_buffer(decimate->ref);
> -        decimate->ref = cur;
> -        inlink->cur_buf = NULL;
> +        decimate->ref = frame;
>          decimate->drop_count = FFMIN(-1, decimate->drop_count-1);
>  
> -        if ((ret = ff_start_frame(outlink,
> -                                  avfilter_ref_buffer(cur, ~AV_PERM_WRITE)) < 0) ||
> -            (ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 ||
> -            (ret = ff_end_frame(outlink)) < 0)
> +        if (ret = ff_filter_frame(outlink, avfilter_ref_buffer(frame, ~AV_PERM_WRITE)) < 0)
>              return ret;
>      }
>  
>      av_log(inlink->dst, AV_LOG_DEBUG,
>             "%s pts:%s pts_time:%s drop_count:%d\n",
>             decimate->drop_count > 0 ? "drop" : "keep",
> -           av_ts2str(cur->pts), av_ts2timestr(cur->pts, &inlink->time_base),
> +           av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base),
>             decimate->drop_count);
>  
>      return 0;
> @@ -241,9 +232,7 @@ static const AVFilterPad decimate_inputs[] = {
>          .type             = AVMEDIA_TYPE_VIDEO,
>          .get_video_buffer = ff_null_get_video_buffer,

You may want to drop this.

>          .config_props     = config_input,
> -        .start_frame      = start_frame,
> -        .draw_slice       = draw_slice,
> -        .end_frame        = end_frame,
> +        .filter_frame     = filter_frame,
>          .min_perms        = AV_PERM_READ | AV_PERM_PRESERVE,
>      },
>      { NULL }

I've secretly tried to do that one a while ago, but miserably failed at
spotting the memleak I introduced. Please check with valgrind if there is
none. If so, LGTM.

-- 
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/20121202/2effd6c4/attachment.asc>


More information about the ffmpeg-devel mailing list