From patchwork Sun Jul 30 22:51:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4522 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp1772762vsb; Sun, 30 Jul 2017 15:51:46 -0700 (PDT) X-Received: by 10.223.170.217 with SMTP id i25mr10104610wrc.140.1501455106006; Sun, 30 Jul 2017 15:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501455105; cv=none; d=google.com; s=arc-20160816; b=oGDk1i+1R/OwYFztSK6WlQh9ZZW2ecTbW991zGeAu1BqJ4qqXW3LMhlnicsBKT8b72 stjUuKqmcOYQ03HZ2tuPo0eWuCb372k6rw3kIsMWKJGjH5v7CuQHGVm2GzkNFYXlDHwJ rmfA/WtRkWMipRNG6d2iak5awFl9BMLoVX5jrHO+r4fopLX2/O5uNjijonrdhkIS4JC6 T5AZMIS8ovFSMga7PuHIqT5svzp0FqQ8b93sjEdo3SghztuZ6qNTtWsAomZeNGTwF+gG 5woYtG8NiyiecNwDOlU0wKgablIEhuahtongPEf5WLB/7aTrGfjYizBuHvAxyuBvHaQh v8Cw== 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=O036zClSPy5uC/uxsfGTU/xoJe+gUHLrNjSTO6n579k=; b=0Xk24VsCtAuUxucPA7m15pEYaH9cTcLo7Ke3pDE5ekqqK6CRd3VnBQeC1wWImsikp7 X3jJtaiYGMISdhAq6ybn5/XisoDp3Oqs1cb0ftjQlKZOjnr5G9iQngNk0d+piscGYhXN ipc7V/g8j35zvtRWyJUVQDHMvojKn+delt3Wk2G6LWfisoxbCTagL5hB/g6Q12ejffm5 fTEOxVZOj/H4Ys27o7NW49mrKoIHrky7bJD5HuEQpaXvXVUZG6rCAy8uxZDw8bwZl10c xh04l1o9dEdGNXQTYDtHMCdQ9Aagv/9U646sWPZ/v2heNOuv7esLsWUTlkdlA9zUw9dh kq8Q== 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 h82si16201566wmh.91.2017.07.30.15.51.45; Sun, 30 Jul 2017 15:51:45 -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 4EF1368A0FE; Mon, 31 Jul 2017 01:51:15 +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 37F19689FDC for ; Mon, 31 Jul 2017 01:51:08 +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 v6UMp9XA076109 for ; Mon, 31 Jul 2017 00:51:10 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id E2A2CE00D6; Mon, 31 Jul 2017 00:51:09 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Jul 2017 00:51:06 +0200 Message-Id: <20170730225106.31923-4-george@nsup.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170730225106.31923-1-george@nsup.org> References: <20170730225106.31923-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 00:51:10 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 4/4] 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(-) For the other dualinput filters, I will probably do the conversion and that in a single patch. 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),