From patchwork Thu Dec 29 14:33:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 1976 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2439545vsb; Thu, 29 Dec 2016 06:35:29 -0800 (PST) X-Received: by 10.194.146.131 with SMTP id tc3mr37805105wjb.129.1483022128924; Thu, 29 Dec 2016 06:35:28 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x62si54530379wmb.132.2016.12.29.06.35.28; Thu, 29 Dec 2016 06:35:28 -0800 (PST) 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 CECC5689CAD; Thu, 29 Dec 2016 16:34:13 +0200 (EET) 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 9C8C2689ACB for ; Thu, 29 Dec 2016 16:34:05 +0200 (EET) 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 uBTEY8GK080422 for ; Thu, 29 Dec 2016 15:34:08 +0100 (CET) Received: by phare.normalesup.org (Postfix, from userid 1001) id 9D8F2E00F9; Thu, 29 Dec 2016 15:34:08 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Dec 2016 15:33:52 +0100 Message-Id: <20161229143403.2851-6-george@nsup.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161229143403.2851-1-george@nsup.org> References: <20161229143403.2851-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, 29 Dec 2016 15:34:08 +0100 (CET) Subject: [FFmpeg-devel] [PATCH 06/17] lavfi: add ff_inlink_process_timeline(). 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/avfilter.c | 34 +++++++++++++++++++++------------- libavfilter/filters.h | 6 ++++++ 2 files changed, 27 insertions(+), 13 deletions(-) Changes in this commit: rename ff_link -> ff_inlink and move to filters.h. Already LGTM by Michael. diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 2fe8b980e0..d1ba7d9bad 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1099,7 +1099,6 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame) AVFilterContext *dstctx = link->dst; AVFilterPad *dst = link->dstpad; int ret; - int64_t pts; if (!(filter_frame = dst->filter_frame)) filter_frame = default_filter_frame; @@ -1111,24 +1110,15 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame) } ff_inlink_process_commands(link, frame); + ff_inlink_process_timeline(link, frame); - pts = frame->pts; - if (dstctx->enable_str) { - int64_t pos = av_frame_get_pkt_pos(frame); - dstctx->var_values[VAR_N] = link->frame_count_out; - dstctx->var_values[VAR_T] = pts == AV_NOPTS_VALUE ? NAN : pts * av_q2d(link->time_base); - dstctx->var_values[VAR_W] = link->w; - dstctx->var_values[VAR_H] = link->h; - dstctx->var_values[VAR_POS] = pos == -1 ? NAN : pos; - - dstctx->is_disabled = fabs(av_expr_eval(dstctx->enable, dstctx->var_values, NULL)) < 0.5; + /* TODO reindent */ if (dstctx->is_disabled && (dstctx->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC)) filter_frame = default_filter_frame; - } ret = filter_frame(link, frame); link->frame_count_out++; - ff_update_link_current_pts(link, pts); + ff_update_link_current_pts(link, frame->pts); return ret; fail: @@ -1571,6 +1561,24 @@ void ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame) } } +void ff_inlink_process_timeline(AVFilterLink *link, const AVFrame *frame) +{ + AVFilterContext *dstctx = link->dst; + int64_t pts = frame->pts; + int64_t pos = av_frame_get_pkt_pos(frame); + + if (!dstctx->enable_str) + return; + + dstctx->var_values[VAR_N] = link->frame_count_out; + dstctx->var_values[VAR_T] = pts == AV_NOPTS_VALUE ? NAN : pts * av_q2d(link->time_base); + dstctx->var_values[VAR_W] = link->w; + dstctx->var_values[VAR_H] = link->h; + dstctx->var_values[VAR_POS] = pos == -1 ? NAN : pos; + + dstctx->is_disabled = fabs(av_expr_eval(dstctx->enable, dstctx->var_values, NULL)) < 0.5; +} + const AVClass *avfilter_get_class(void) { return &avfilter_class; diff --git a/libavfilter/filters.h b/libavfilter/filters.h index efbef2918d..69a29c640f 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -39,6 +39,12 @@ void ff_filter_set_ready(AVFilterContext *filter, unsigned priority); void ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame); /** + * Process the timeline expression of the link for the time of the frame. + * It will update link->is_disabled. + */ +void ff_inlink_process_timeline(AVFilterLink *link, const AVFrame *frame); + +/** * Make sure a frame is writable. * This is similar to av_frame_make_writable() except it uses the link's * buffer allocation callback, and therefore allows direct rendering.