From patchwork Mon Jul 31 12:02:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4536 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp2324175vsb; Mon, 31 Jul 2017 05:03:45 -0700 (PDT) X-Received: by 10.223.135.87 with SMTP id 23mr11379396wrz.258.1501502624815; Mon, 31 Jul 2017 05:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501502624; cv=none; d=google.com; s=arc-20160816; b=Un0IYimwMY5b54Duqfp9aYkb0jGPFPaSPhMBclCYWaMTiB/6OFqBSfIj2tujOcOUF0 f5HQVBrlP8vLPNQa+9Yx6AmGNYKjRhco4mxvMJxCfFEqyMXXFfp9WzSEDfVEyu6okU6X ZL6AfAZ+btLq3JEOwbNPIeySOcLnZZFs/RbJZXS6xJMPkGjliTqyMFS4kAxKU7WfFImV zgBEZEjh6TSPG2nDYRa6zMG4stz9ma7MFdI5kYfPf/eeM3QFv5aIJFionWq2G2a30kus 67Y2/hC+ldNi1Luq0tzjlNyZUGmw4TAN5k+x90tn75d4nKsYEoHcfL1YBbf1Cr5ODOgT 1pZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=DVTwDzu/C7UTmnmdcL9EBFLLc6b4Fx5m3oQ68ZaCfFQ=; b=o1g9CmHSFx9R6ohKno0OlUzqrgxzXYXmARhoImAbejz24IKuDQRpsYJ/x1CGO+dU2n 7c5vQLVQIBHI5cOEMp4MK9zABR6BPvYFr9U/j6pSFqOo5ORigq8pCVCKT7xG/cWU23uw +Ji0khZ7kmrwEipX/AecFXxSv0Jl9RjOExfkUvS2rfDwQJ8XrwYVNfZ/hnaD1iSeObMm zipOMBtKMUezRyU1e1rMx6+tWBGvd1lYYtu7x+6o/qy5a47egXRCGFjIXSFvfIy3rP1D t6viUDV5GZvoBU/iQQ/9+IhjTnZY9vXYq+GeJLOTAuDDCVCtVOwOeR+oxrEmOB1K1zEt pZjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k39si22312129wrc.533.2017.07.31.05.03.44; Mon, 31 Jul 2017 05:03:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 176B568A1EF; Mon, 31 Jul 2017 15:02:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef2.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B64368A200 for ; Mon, 31 Jul 2017 15:02:32 +0300 (EEST) Received: from phare.normalesup.org (archicubes.ens.fr [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v6VC2YFO071520 for ; Mon, 31 Jul 2017 14:02:34 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 01504E00FB; Mon, 31 Jul 2017 14:02:33 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Jul 2017 14:02:21 +0200 Message-Id: <20170731120227.31047-8-george@nsup.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170731120227.31047-1-george@nsup.org> References: <20170731120227.31047-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Mon, 31 Jul 2017 14:02:34 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 08/14] lavfi/vf_blend: convert to framesync2. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Nicolas George --- libavfilter/Makefile | 4 ++-- libavfilter/vf_blend.c | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 2c7f715166..8cfbe10ea4 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -136,7 +136,7 @@ OBJS-$(CONFIG_BENCH_FILTER) += f_bench.o OBJS-$(CONFIG_BITPLANENOISE_FILTER) += vf_bitplanenoise.o OBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o -OBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o dualinput.o framesync.o +OBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o framesync2.o OBJS-$(CONFIG_BOXBLUR_FILTER) += vf_boxblur.o OBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o OBJS-$(CONFIG_CHROMAKEY_FILTER) += vf_chromakey.o @@ -306,7 +306,7 @@ OBJS-$(CONFIG_SUBTITLES_FILTER) += vf_subtitles.o OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o OBJS-$(CONFIG_SWAPRECT_FILTER) += vf_swaprect.o OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o -OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o dualinput.o framesync.o +OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync2.o OBJS-$(CONFIG_TELECINE_FILTER) += vf_telecine.o OBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o framesync2.o OBJS-$(CONFIG_THUMBNAIL_FILTER) += vf_thumbnail.o diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 9bde3b22a1..24f8729892 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -25,8 +25,8 @@ #include "avfilter.h" #include "bufferqueue.h" #include "formats.h" +#include "framesync2.h" #include "internal.h" -#include "dualinput.h" #include "video.h" #include "blend.h" @@ -35,7 +35,7 @@ typedef struct BlendContext { const AVClass *class; - FFDualInputContext dinput; + FFFrameSync fs; int hsub, vsub; ///< chroma subsampling values int nb_planes; char *all_expr; @@ -114,12 +114,10 @@ typedef struct ThreadData { static const AVOption blend_options[] = { COMMON_OPTIONS, - { "shortest", "force termination when the shortest input terminates", OFFSET(dinput.shortest), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, - { "repeatlast", "repeat last bottom frame", OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS }, { NULL } }; -AVFILTER_DEFINE_CLASS(blend); +FRAMESYNC_DEFINE_CLASS(blend, BlendContext, fs); #define COPY(src) \ static void blend_copy ## src(const uint8_t *top, ptrdiff_t top_linesize, \ @@ -405,13 +403,28 @@ static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame *top_buf, return dst_buf; } +static int blend_frame_for_dualinput(FFFrameSync *fs) +{ + AVFilterContext *ctx = fs->parent; + AVFrame *top_buf, *bottom_buf, *dst_buf; + int ret; + + ret = ff_framesync2_dualinput_get(fs, &top_buf, &bottom_buf); + if (ret < 0) + return ret; + if (!bottom_buf) + return ff_filter_frame(ctx->outputs[0], top_buf); + dst_buf = blend_frame(ctx, top_buf, bottom_buf); + return ff_filter_frame(ctx->outputs[0], dst_buf); +} + static av_cold int init(AVFilterContext *ctx) { BlendContext *s = ctx->priv; s->tblend = !strcmp(ctx->filter->name, "tblend"); - s->dinput.process = blend_frame; + s->fs.on_event = blend_frame_for_dualinput; return 0; } @@ -439,7 +452,7 @@ static av_cold void uninit(AVFilterContext *ctx) BlendContext *s = ctx->priv; int i; - ff_dualinput_uninit(&s->dinput); + ff_framesync2_uninit(&s->fs); av_frame_free(&s->prev_frame); for (i = 0; i < FF_ARRAY_ELEMS(s->params); i++) @@ -539,7 +552,7 @@ static int config_output(AVFilterLink *outlink) s->nb_planes = av_pix_fmt_count_planes(toplink->format); if (!s->tblend) - if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0) + if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0) return ret; for (plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) { @@ -566,32 +579,24 @@ static int config_output(AVFilterLink *outlink) } } - return 0; + return s->tblend ? 0 : ff_framesync2_configure(&s->fs); } #if CONFIG_BLEND_FILTER -static int request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { - BlendContext *s = outlink->src->priv; - return ff_dualinput_request_frame(&s->dinput, outlink); -} - -static int filter_frame(AVFilterLink *inlink, AVFrame *buf) -{ - BlendContext *s = inlink->dst->priv; - return ff_dualinput_filter_frame(&s->dinput, inlink, buf); + BlendContext *s = ctx->priv; + return ff_framesync2_activate(&s->fs); } static const AVFilterPad blend_inputs[] = { { .name = "top", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame, },{ .name = "bottom", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame, }, { NULL } }; @@ -601,7 +606,6 @@ static const AVFilterPad blend_outputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_output, - .request_frame = request_frame, }, { NULL } }; @@ -609,10 +613,12 @@ static const AVFilterPad blend_outputs[] = { AVFilter ff_vf_blend = { .name = "blend", .description = NULL_IF_CONFIG_SMALL("Blend two video frames into each other."), + .preinit = blend_framesync_preinit, .init = init, .uninit = uninit, .priv_size = sizeof(BlendContext), .query_formats = query_formats, + .activate = activate, .inputs = blend_inputs, .outputs = blend_outputs, .priv_class = &blend_class,