From patchwork Mon Jul 31 12:02:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4538 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp2324314vsb; Mon, 31 Jul 2017 05:03:53 -0700 (PDT) X-Received: by 10.223.146.164 with SMTP id 33mr12768324wrn.134.1501502633337; Mon, 31 Jul 2017 05:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501502633; cv=none; d=google.com; s=arc-20160816; b=gfKIzy7ZNRbdmwJcjj9hsOnGsBKRdDqvRsSlzHT6iJX0D5lubgdSmgz9p/RGNOW4QE 369wn+MYGi+u5t4eYmMszd/2hWPn01Eq3Y2bNxJMrsWisdxNcWMHjzr9wxk2q3OfW+ng esf1GW3RdXScYzqcM65n21p4PMawIWBQmIGQunXJc5V9NnxbpOtOdl1Vu/zLM7DDqA0M FysJnUJFJ7lYUhEJ1zWGlKarIKlyNk6gnqZS2FlCdhFSdR5kLTj2l2bEbW07re+4Jrdj 2Q8vL1og5kXepP9CIAl1+yzk8oTlpbnfPbNO7dLir/dWx2ERTzHCiFF1mwO0mzUAW4pI y8GA== 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=sihk6GXZWle7OJItNGk5lxhD5hVsbIUzZOrrbxNc/yo=; b=eUwjZ2cOCie6pW5nZoHIBzOcvcLX69neL/ZsSt8VlmQS6nEVDXw3jCKfRoJNbw6EQW YAvSZ5hjqOsv7DUT8eOiIT9crIHyQ2AYEj33rC4BXajm+Tw4dYxkLjDP8PuxNk54ZYVc 6FgycTMWwDh2hzimOSIRYmaUm4vpOLTUU6HkBlsmiIYBz7vO8hKgZe2Rm9AgEURYUoSU jA1y5g3hKDB54/x9T9FOnKtCUFtQ76T706f4K+oC2rqwVtpPXFDkfh6u6JjbqQrCV4CD GzVbgtTVeBh8Q4kB6dbCih5216zOqE3PUWO0vhvoHwOp0FptTbXsYmOkZ/zefh1WWlpb zfMw== 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 i4si27047970wra.237.2017.07.31.05.03.52; Mon, 31 Jul 2017 05:03:53 -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 690D368A234; 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 73C5B68988E for ; Mon, 31 Jul 2017 15:02:31 +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 v6VC2XQ1071516 for ; Mon, 31 Jul 2017 14:02:33 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 5EC3EE00FB; Mon, 31 Jul 2017 14:02:33 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Jul 2017 14:02:20 +0200 Message-Id: <20170731120227.31047-7-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:33 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 07/14] 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(-) diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index c1d2a21c05..512df87630 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[] = { { @@ -893,6 +855,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),