X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_delogo.c;h=c52036228c07f26dc17257f285ad40bf1726a592;hb=7d1918affee4bc70fb8ac139ba9235e7fed2979b;hp=2949d7e9311b3bedb2c83cc853b35a6761001f37;hpb=75f8f702217fdeae9e2868c7ba80c03f9ec0958a;p=ffmpeg diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 2949d7e9311..c52036228c0 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -30,6 +30,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" +#include "internal.h" #include "video.h" /** @@ -150,11 +151,7 @@ static const AVOption delogo_options[]= { {NULL}, }; -static const AVClass delogo_class = { - .class_name = "DelogoContext", - .item_name = av_default_item_name, - .option = delogo_options, -}; +AVFILTER_DEFINE_CLASS(delogo); static int query_formats(AVFilterContext *ctx) { @@ -169,7 +166,7 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int init(AVFilterContext *ctx, const char *args) { DelogoContext *delogo = ctx->priv; int ret = 0; @@ -201,7 +198,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) if (delogo->show) delogo->band = 4; - av_log(ctx, AV_LOG_INFO, "x:%d y:%d, w:%d h:%d band:%d show:%d\n", + av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n", delogo->x, delogo->y, delogo->w, delogo->h, delogo->band, delogo->show); delogo->w += delogo->band*2; @@ -212,36 +209,22 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) return 0; } -static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) +static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { - AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *outpicref; - - if (inpicref->perms & AV_PERM_PRESERVE) { - outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, - outlink->w, outlink->h); - avfilter_copy_buffer_ref_props(outpicref, inpicref); - outpicref->video->w = outlink->w; - outpicref->video->h = outlink->h; - } else - outpicref = inpicref; - - outlink->out_buf = outpicref; - ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); + return 0; } -static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } - -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { DelogoContext *delogo = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *inpicref = inlink ->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; - int direct = inpicref == outpicref; + int direct = inpicref->buf == outpicref->buf; int hsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; int vsub0 = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; int plane; + int ret; for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) { int hsub = plane == 1 || plane == 2 ? hsub0 : 0; @@ -256,11 +239,10 @@ static void end_frame(AVFilterLink *inlink) delogo->show, direct); } - ff_draw_slice(outlink, 0, inlink->h, 1); - ff_end_frame(outlink); - avfilter_unref_buffer(inpicref); - if (!direct) - avfilter_unref_buffer(outpicref); + if ((ret = ff_draw_slice(outlink, 0, inlink->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_delogo = { @@ -270,16 +252,16 @@ AVFilter avfilter_vf_delogo = { .init = init, .query_formats = query_formats, - .inputs = (const AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .get_video_buffer = ff_null_get_video_buffer, - .start_frame = start_frame, - .draw_slice = null_draw_slice, - .end_frame = end_frame, - .min_perms = AV_PERM_WRITE | AV_PERM_READ, - .rej_perms = AV_PERM_PRESERVE }, - { .name = NULL}}, - .outputs = (const AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, }, - { .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .get_video_buffer = ff_null_get_video_buffer, + .start_frame = ff_inplace_start_frame, + .draw_slice = null_draw_slice, + .end_frame = end_frame, + .min_perms = AV_PERM_WRITE | AV_PERM_READ, + .rej_perms = AV_PERM_PRESERVE }, + { .name = NULL}}, + .outputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, };