From patchwork Wed Apr 4 10:07:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhong Li X-Patchwork-Id: 8322 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp4693841jad; Wed, 4 Apr 2018 03:10:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fKL/S9QY7DXObb+8QU6PwGCExBSPhAZeW0NESqm20wfSIvyrDHHd39jBzS4yrTKwyMEtA X-Received: by 10.28.1.197 with SMTP id 188mr6607447wmb.49.1522836640307; Wed, 04 Apr 2018 03:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522836640; cv=none; d=google.com; s=arc-20160816; b=avJtow1SJx2JFK0sHqYj9jIwCZh1ipoClw143x5HPILhKpvhK1PIqiOv2Piz1q5iuj MRSjxzHMLHssqBpVEGFSc/YbHIDfR3ui4/A3FU2o3sXHJML+tXxqXN0i59eYrP6jTFlB jtyPF7T5MlMEm7LMHuq3+nQ/BGRznWCvTj10Xg+8A8g50kNdrBnuQFY0g59Qc72fFeLE Ft5ak3DrYDG2nIJu0OQTCczFN6Q5A5XrusxJywkoc4zjcsZW73TC3BUkv4fkDKcLSnuz SzvMMT9+1izkB9x7Ad/6u7Euim+qh05JL3jrN4qhKkBrF9UfrG5q807kik26+dnI26Lv XeFw== 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:cc: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=Mqgjou0S1JBEEP3Lus6kykJyngCzPanmuzGgp/24ocQ=; b=YsGzR4Q5Xamq64yyTP7zNg95u1eYPrEC3y9y6HgOm6kMtzTaMPPZQBgBS0jLlrhMTm antKpRcBfTLmMmAXNLaifqfJ7UYXpzcXCeDoQIIEZESkdKEAa7VbA6m26Yg1FaHGYV2u fie3cO2riZOprPI3MWnhYzuk+gkuNLoPwTWatgvRDTuPD1Sl1ESQhCmGGLTlCGivvKtg hlmXByXugk/nVad9VQLKQOJ/dc0MSkMxNgPw76rCCNimRFEcv17NS0g57ON95mOFfkvb EOnbpTDAfCUX0wx66vSbfkS1F31cZK96yCpTVD5jBjSYOWEkHICxCQdgu4RlNDLbG98Y w7fg== 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 p9si3393123wre.457.2018.04.04.03.10.39; Wed, 04 Apr 2018 03:10:40 -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 AFC1B68039D; Wed, 4 Apr 2018 13:10:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2C3568015D for ; Wed, 4 Apr 2018 13:10:09 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 03:10:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,405,1517904000"; d="scan'208";a="188547777" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.13.18]) by orsmga004.jf.intel.com with ESMTP; 04 Apr 2018 03:10:25 -0700 From: Zhong Li To: ffmpeg-devel@ffmpeg.org Date: Wed, 4 Apr 2018 18:07:57 +0800 Message-Id: <1522836478-4907-1-git-send-email-zhong.li@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH] lavf/qsvvpp: bypass vpp if not needed. 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: Zhong Li MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently vpp pipeline is always created, even for the unnecessary cases such as setting the option "vpp_qsv=w=1280:h=720" for an input with native resolution 1280x720. Thus introduces unnecessary performance dropping, so bypass vpp if not needed. Signed-off-by: Zhong Li --- libavfilter/vf_vpp_qsv.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index bd5fc32..6be7098 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -27,6 +27,7 @@ #include "libavutil/eval.h" #include "libavutil/avassert.h" #include "libavutil/pixdesc.h" +#include "libavutil/mathematics.h" #include "formats.h" #include "internal.h" @@ -249,6 +250,7 @@ static int config_output(AVFilterLink *outlink) QSVVPPParam param = { NULL }; QSVVPPCrop crop = { 0 }; mfxExtBuffer *ext_buf[ENH_FILTERS_COUNT]; + AVFilterLink *inlink = ctx->inputs[0]; outlink->w = vpp->out_width; outlink->h = vpp->out_height; @@ -320,14 +322,34 @@ static int config_output(AVFilterLink *outlink) param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->procamp_conf; } - return ff_qsvvpp_create(ctx, &vpp->qsv, ¶m); + if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise || + vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != outlink->h) + return ff_qsvvpp_create(ctx, &vpp->qsv, ¶m); + else { + av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n"); + if (inlink->hw_frames_ctx) + outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx); + } + + return 0; } static int filter_frame(AVFilterLink *inlink, AVFrame *picref) { - VPPContext *vpp = inlink->dst->priv; + int ret = 0; + AVFilterContext *ctx = inlink->dst; + VPPContext *vpp = inlink->dst->priv; + AVFilterLink *outlink = ctx->outputs[0]; + + if (vpp->qsv) + ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref); + else { + if (picref->pts != AV_NOPTS_VALUE) + picref->pts = av_rescale_q(picref->pts, inlink->time_base, outlink->time_base); + ret = ff_filter_frame(outlink, picref); + } - return ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref); + return ret; } static int query_formats(AVFilterContext *ctx)