From ef1868351d82bb9435138c8de2828178fd900825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 2 Dec 2012 02:21:44 +0100 Subject: [PATCH] lavfi/removelogo: switch to ff_filter_frame. --- libavfilter/vf_removelogo.c | 45 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/libavfilter/vf_removelogo.c b/libavfilter/vf_removelogo.c index f2228be2fb..f3d8d7bd44 100644 --- a/libavfilter/vf_removelogo.c +++ b/libavfilter/vf_removelogo.c @@ -72,6 +72,7 @@ #include "libavutil/imgutils.h" #include "avfilter.h" #include "formats.h" +#include "internal.h" #include "video.h" #include "bbox.h" #include "lavfutils.h" @@ -472,24 +473,24 @@ static void blur_image(int ***mask, } } -static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) -{ - AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *outpicref; - - outpicref = inpicref; - - outlink->out_buf = outpicref; - return ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); -} - -static int end_frame(AVFilterLink *inlink) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { RemovelogoContext *removelogo = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *inpicref = inlink ->cur_buf; - AVFilterBufferRef *outpicref = outlink->out_buf; - int direct = inpicref == outpicref; + AVFilterBufferRef *outpicref; + int direct = 0; + + if (inpicref->perms & AV_PERM_WRITE) { + direct = 1; + outpicref = inpicref; + } else { + outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); + if (!outpicref) { + avfilter_unref_bufferp(&inpicref); + return AVERROR(ENOMEM); + } + avfilter_copy_buffer_ref_props(outpicref, inpicref); + } blur_image(removelogo->mask, inpicref ->data[0], inpicref ->linesize[0], @@ -507,8 +508,10 @@ static int end_frame(AVFilterLink *inlink) removelogo->half_mask_data, inlink->w/2, inlink->w/2, inlink->h/2, direct, &removelogo->half_mask_bbox); - ff_draw_slice(outlink, 0, inlink->h, 1); - return ff_end_frame(outlink); + if (!direct) + avfilter_unref_bufferp(&inpicref); + + return ff_filter_frame(outlink, outpicref); } static void uninit(AVFilterContext *ctx) @@ -533,18 +536,14 @@ static void uninit(AVFilterContext *ctx) } } -static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } - static const AVFilterPad removelogo_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .get_video_buffer = ff_null_get_video_buffer, .config_props = config_props_input, - .draw_slice = null_draw_slice, - .start_frame = start_frame, - .end_frame = end_frame, - .min_perms = AV_PERM_WRITE | AV_PERM_READ, + .filter_frame = filter_frame, + .min_perms = AV_PERM_READ, }, { NULL } };