From patchwork Sun Jul 30 10:48:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 4515 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp1231878vsb; Sun, 30 Jul 2017 03:48:22 -0700 (PDT) X-Received: by 10.28.210.149 with SMTP id j143mr8450553wmg.146.1501411702654; Sun, 30 Jul 2017 03:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501411702; cv=none; d=google.com; s=arc-20160816; b=HuF4qj/767ooWCXX5QSNNx8G087wIteoC+w+ksHGOrltDGL4dgnZCIDE3jN9FLDHcw ALRFSFMT+Bb+PqOqiSgSrriFsCSqKrD9/t2JzdSbYnf6TWZcqdLHydFG5hNkbxVJD4J9 6iNXvbBwaJdA7qSZubwrYUD+iy6sn/skqiYV8sR5XKbV+DjShyQmTwIhMT7wrHVL+e2s dMj8l1SVkBkNToYSSi6tJ1in0r5+FIqbGAAqVsAf9D6bTu91/mtHLMOaMDuBm9R9+Opy 37aLkqKQvIFcM+IdkcDUBdOoTEW25crPRV53iPDFuBwEu2jTh/wmdduB4QRLdUKmIPup XWFw== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=P0lURUhrBnS1MuNaqdqiUXd/pyWKDaTnZi312DqpDJg=; b=pyLLzjrcz06Lnb7E3mGow9KUX/ikLg8RCu3RkcEltex0pXqGvOmZz5ZhXut2BtjWrv FX7M0LwFa4izjfY3O5QM9bVZnHbKsBQkwIY2NeFuXF73aeIXpazggcC2OMjYgkIuVbTr ES74OjKu+yObVWzT/so09cpv1pDHZWitnMsb7WQiDcvdH3VfM8kofrR/iqPzsWCuBZCT /BcPmny/YAfWC+1f+C1Jxhrlouv4TAP0ECKulyRVn2e6x/XYtkxoR09cmbe9F9cgqC5o 7mLrtSgChVKugY4EX8nKhiCsCC/sX30GdH/Qpz7fsmCMasq1Lv6Ne3iSvyHRVw3qOFCi MIUA== 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 i30si15228259wrb.314.2017.07.30.03.48.22; Sun, 30 Jul 2017 03:48:22 -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 9B267689FE0; Sun, 30 Jul 2017 13:48:17 +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 E3E6E689FCF for ; Sun, 30 Jul 2017 13:48:10 +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 v6UAmCXo054080 for ; Sun, 30 Jul 2017 12:48:12 +0200 (CEST) Received: by phare.normalesup.org (Postfix, from userid 1001) id 4E2CAE00D1; Sun, 30 Jul 2017 12:48:12 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sun, 30 Jul 2017 12:48:09 +0200 Message-Id: <20170730104810.19068-1-george@nsup.org> X-Mailer: git-send-email 2.13.2 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef2.ens.fr [129.199.96.32]); Sun, 30 Jul 2017 12:48:12 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/2] WIP lavfi/framesync2: add dualinput helper function. 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/framesync2.c | 20 ++++++++++++++++++++ libavfilter/framesync2.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+) Both patches work in progress. They work, but the code needs to be enhanced, otherwise the other filters will require boilerplace code. diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c index 0e9f6f210c..ed8f913b7d 100644 --- a/libavfilter/framesync2.c +++ b/libavfilter/framesync2.c @@ -311,3 +311,23 @@ int ff_framesync2_activate(FFFrameSync *fs) return 0; } + +int ff_framesync2_get_dualinput(FFFrameSync *fs, AVFrame **f0, AVFrame **f1) +{ + AVFilterContext *ctx = fs->parent; + AVFrame *mainpic = NULL, *secondpic = NULL; + int ret = 0; + + if ((ret = ff_framesync2_get_frame(fs, 0, &mainpic, 1)) < 0 || + (ret = ff_framesync2_get_frame(fs, 1, &secondpic, 0)) < 0) { + av_frame_free(&mainpic); + return ret; + } + av_assert0(mainpic); + mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base); + if (ctx->is_disabled) + secondpic = NULL; + *f0 = mainpic; + *f1 = secondpic; + return 0; +} diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h index 2b37636ebb..07e422b309 100644 --- a/libavfilter/framesync2.h +++ b/libavfilter/framesync2.h @@ -245,4 +245,18 @@ int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, */ int ff_framesync2_activate(FFFrameSync *fs); +/** + * Get dualinput frames. + * + * Compared to generic framesync, dualinput assumes the first input is the + * main one and the filtering is performed on it. The first input will be + * the only one with sync set and generic timeline support will just pass it + * unchanged when disabled. + * + * @param f0 used to return the main frame + * @param f1 used to return the second frame, or NULL if disabled + * @return >=0 for success or AVERROR code + */ +int ff_framesync2_get_dualinput(FFFrameSync *fs, AVFrame **f0, AVFrame **f1); + #endif /* AVFILTER_FRAMESYNC2_H */