From patchwork Sat Sep 7 15:11:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 14968 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D2612449690 for ; Sat, 7 Sep 2019 18:11:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD41A680BC2; Sat, 7 Sep 2019 18:11:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3BA35680BC2 for ; Sat, 7 Sep 2019 18:11:36 +0300 (EEST) Received: by mail-pf1-f193.google.com with SMTP id s12so6472269pfe.6 for ; Sat, 07 Sep 2019 08:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vgjvSQJlk2d9JP3UBhpP2e82egLGVqCMcwrU97YsUTI=; b=FH08byY+idTVczaPieRhe0n2TNbTLZLhLP+D5uYs5YX8NSgU8mkFOzsS1Kr4AnWIig p7QBQKZrM1WBrYEmpSJj+oKFMcQD4uOgzeHeIvDt/zFKJUrOAQVWZrdLTd7/QFA01rU7 qyfcBfQ8ERr6N/xlGdRkTpyatTtpdMDcwIOGduKW4/yerwnmEp8O5MfGPGaAo5+vzUb0 TPxUyZamor2AQpxQ1anMPmaeWwjgUJ/WXy7oYwCLxxfI2GNHeW25tnyF0gNXUDDM7ZYV /7IGouPW82w0kPvLA2vv7SNsGtXrqBu81YgUAmROaR1Xr3yO8UAt1sLwVRrqDDk7+S9G 8gOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vgjvSQJlk2d9JP3UBhpP2e82egLGVqCMcwrU97YsUTI=; b=KDmEfynOtsFqRcgcbiVraLoO5MsljCaKfNm3eNSHYc7KhZx4QaJ4BHns2C6LDoG40Y 6LYPpe1/AkEGxfEwJ4pNy+qShKVbTLbdZLFxhG5E1ybmaqoI9iBtzyYmEdS5Kh2HqngI +e6+3QHovzIQhpqkL1gAIZhD/v2uDuFuhmHbMvzjCSdWSQbXegs175OYW/1DrYbYZ2cB J9YyrqxYqStTzaPSoUJSMl/XHF0ofwEU2sdVRlYRmkc8UeGJHKyouEeNorOKHk8aqxBr 5tSO2RLHfVqB2Y9SKGs3U5iynOkakan8LKPOzoTaxsO2Ko9Q1v2y2X/yamjc+vjAvF1X x44A== X-Gm-Message-State: APjAAAVd9ro82MPLK5scuXZo/fj013YuKVEA5Zp9Lx3T17Ofx0Qhx7FX KPnNVGFVTFikjSDCZkNUIfyDjubE X-Google-Smtp-Source: APXvYqz3NzrN6aKTD7N9N8IFRQKJjmevQ4blQ7qm55RboKyvzjDqb7JiuWwd+Ox1ZYmRp6UooUgc5A== X-Received: by 2002:a63:7887:: with SMTP id t129mr13119811pgc.309.1567869094049; Sat, 07 Sep 2019 08:11:34 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id r2sm17397370pfq.60.2019.09.07.08.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Sep 2019 08:11:33 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 Sep 2019 23:11:26 +0800 Message-Id: <20190907151126.2112-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190907151126.2112-1-lance.lmwang@gmail.com> References: <20190727121817.22390-1-lance.lmwang@gmail.com> <20190907151126.2112-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 2/2] avfilter/vf_scale: change filter_frame interface to activate interface 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_scale.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index cb42794..5c1d811 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -27,6 +27,7 @@ #include #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "scale.h" @@ -554,6 +555,39 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) return ret; } +static int activate(AVFilterContext *ctx) +{ + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *in, *out = NULL; + int64_t pts; + int ret, status; + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + + ret = ff_inlink_consume_frame(inlink, &in); + if (ret > 0) { + ret = scale_frame(inlink, in, &out); + if (ret) + return ret; + if (out) + return ff_filter_frame(outlink, out); + } + + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { + if (status == AVERROR_EOF) { + /* frame flushing */ + } + + ff_outlink_set_status(outlink, status, pts); + return ret; + } + + FF_FILTER_FORWARD_WANTED(outlink, inlink); + + return FFERROR_NOT_READY; +} + static int filter_frame_ref(AVFilterLink *link, AVFrame *in) { AVFilterLink *outlink = link->dst->outputs[1]; @@ -653,7 +687,6 @@ static const AVFilterPad avfilter_vf_scale_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame, }, { NULL } }; @@ -672,6 +705,7 @@ AVFilter ff_vf_scale = { .description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."), .init_dict = init_dict, .uninit = uninit, + .activate = activate, .query_formats = query_formats, .priv_size = sizeof(ScaleContext), .priv_class = &scale_class,