From patchwork Thu Aug 10 11:46:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4683 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp2308902vsu; Thu, 10 Aug 2017 04:48:28 -0700 (PDT) X-Received: by 10.223.170.144 with SMTP id h16mr8117991wrc.227.1502365706965; Thu, 10 Aug 2017 04:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502365706; cv=none; d=google.com; s=arc-20160816; b=ALe7YLfKweWoTVTtFucqKJpfOGpMISuARQB7gtVNcWmjIsbgRSTEiaI222uNWDVgEQ 21BiBgfbKCfVwZytwxJitqP9mie4iB4PRVqORvlSa5INM956Du2OvOAOsShAoqmXTLsD Sa/ejfHX7UjQRjebQdXx+XPSe1OGqIQfyrfJ/57Hox0VMAnsR8BlZvWpMABvjR7jhEMB yZOe14OqlmdtTjfTPk9OxhqOsBH9EihByEV1nSeCOQVV0GunFJk0F6/wIBAIIOssZvp1 lh5pr0FtaHF42WHosg/iylppkQuGg46dQ74/SUPUYMve1fNdD9cQCGcCo62nk5xee4+a a2dA== 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=RY19efFLCa0md1mDff2Yx1ulNGMnJ6WPBs+WFC7npd4=; b=DfeV31HgZhlCo9sRYt8+TarFGUezA7tv198VvqgTiIJ9lfvCliNMFeeQITmBOjaMHn eaAduo955oe+2vSRYm9XALGII/OObzWKkaybcWXBKj5pSW6wTaetkCBici5By4qjkmsi C/xxfINPYLTskcpFJN7rULPBq9LXLexIjmvx1ruiVtrg3E//e3b9oX9Xmj9X2iu9aBI2 DfVhWzc9kXs1/RuM22cuyPtePIjXW6gVmVA0R+vS+/UOZcoViYCYfywUmtc8RlhPOmSe HE7ggxvGBUjwFsT6MkffcpYLNySAX7YkeIeVYkkxUCo8JSg9NTyGbaKhENvdg6+nGTjp SYTw== 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 k8si5090302wre.240.2017.08.10.04.48.26; Thu, 10 Aug 2017 04:48:26 -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 D58F2689C33; Thu, 10 Aug 2017 14:46:56 +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 AE6CC689B5C for ; Thu, 10 Aug 2017 14:46:48 +0300 (EEST) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef2.ens.fr (8.13.6/1.01.28121999) with ESMTP id v7ABkov7043703 for ; Thu, 10 Aug 2017 13:46:51 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id EBEA3E00F5; Thu, 10 Aug 2017 13:46:50 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Aug 2017 13:46:34 +0200 Message-Id: <20170810114642.26779-8-george@nsup.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170810114642.26779-1-george@nsup.org> References: <20170810114642.26779-1-george@nsup.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Thu, 10 Aug 2017 13:46:51 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 08/16] lavfi/vf_overlay: use framesync2 options. 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/vf_overlay.c | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) Unchanged. diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 80365ce8df..5a76fa2ee9 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -70,16 +70,6 @@ enum var_name { VAR_VARS_NB }; -enum EOFAction { - EOF_ACTION_REPEAT, - EOF_ACTION_ENDALL, - EOF_ACTION_PASS -}; - -static const char * const eof_action_str[] = { - "repeat", "endall", "pass" -}; - #define MAIN 0 #define OVERLAY 1 @@ -131,10 +121,6 @@ typedef struct OverlayContext { double var_values[VAR_VARS_NB]; char *x_expr, *y_expr; - int eof_action; ///< action to take on EOF from source - int opt_shortest; - int opt_repeatlast; - AVExpr *x_pexpr, *y_pexpr; void (*blend_image)(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y); @@ -377,12 +363,11 @@ static int config_input_overlay(AVFilterLink *inlink) } av_log(ctx, AV_LOG_VERBOSE, - "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n", + "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s\n", ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h, av_get_pix_fmt_name(ctx->inputs[MAIN]->format), ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h, - av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format), - eof_action_str[s->eof_action]); + av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format)); return 0; } @@ -394,12 +379,6 @@ static int config_output(AVFilterLink *outlink) if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0) return ret; - if (s->opt_shortest) - s->fs.in[0].after = s->fs.in[1].after = EXT_STOP; - if (!s->opt_repeatlast) { - s->fs.in[1].after = EXT_NULL; - s->fs.in[1].sync = 0; - } outlink->w = ctx->inputs[MAIN]->w; outlink->h = ctx->inputs[MAIN]->h; @@ -818,15 +797,6 @@ static av_cold int init(AVFilterContext *ctx) { OverlayContext *s = ctx->priv; - if (!s->opt_repeatlast || s->eof_action == EOF_ACTION_PASS) { - s->opt_repeatlast = 0; - s->eof_action = EOF_ACTION_PASS; - } - if (s->opt_shortest || s->eof_action == EOF_ACTION_ENDALL) { - s->opt_shortest = 1; - s->eof_action = EOF_ACTION_ENDALL; - } - s->fs.on_event = do_blend; return 0; } @@ -843,16 +813,9 @@ static int activate(AVFilterContext *ctx) static const AVOption overlay_options[] = { { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "eof_action", "Action to take when encountering EOF from secondary input ", - OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT }, - EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" }, - { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" }, - { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" }, - { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" }, { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_FRAME}, 0, EVAL_MODE_NB-1, FLAGS, "eval" }, { "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" }, { "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" }, - { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1, FLAGS, "format" }, { "yuv420", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420}, .flags = FLAGS, .unit = "format" }, { "yuv422", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422}, .flags = FLAGS, .unit = "format" }, @@ -860,11 +823,10 @@ static const AVOption overlay_options[] = { { "rgb", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB}, .flags = FLAGS, .unit = "format" }, { "gbrp", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_GBRP}, .flags = FLAGS, .unit = "format" }, { "auto", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_AUTO}, .flags = FLAGS, .unit = "format" }, - { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS }, { NULL } }; -AVFILTER_DEFINE_CLASS(overlay); +FRAMESYNC_DEFINE_CLASS(overlay, OverlayContext, fs); static const AVFilterPad avfilter_vf_overlay_inputs[] = { { @@ -892,6 +854,7 @@ static const AVFilterPad avfilter_vf_overlay_outputs[] = { AVFilter ff_vf_overlay = { .name = "overlay", .description = NULL_IF_CONFIG_SMALL("Overlay a video source on top of the input."), + .preinit = overlay_framesync_preinit, .init = init, .uninit = uninit, .priv_size = sizeof(OverlayContext),