From patchwork Thu Nov 18 04:24:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31472 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp234897iob; Wed, 17 Nov 2021 20:26:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhbDVEubC7yr+2fX/4LlCNl5jQjSiHpiXwwqlOUk8oCjv+M867CHKOy+vfz8h/5nFWHZMX X-Received: by 2002:aa7:d652:: with SMTP id v18mr6931299edr.68.1637209587264; Wed, 17 Nov 2021 20:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637209587; cv=none; d=google.com; s=arc-20160816; b=YZa/4j+GxoFo1DgB3p19W59GuRQZcSjzsCqWkqLiLt2h2YV7khyhfo+6mzPj7q7Jqv KQ8xCDazzhXhTw50NRJkv26uwtlj7iXIO6FtRXOw4PaB73z8ERgQ4XiTAj2GjQGg+VhG pjaJG0oHl6o1VLKaCqvMtVYwvTdM8lElseeNQlwE53cln1Ujr7SCRlsOcJ/SfsjDj9Qh sLQ/A4sJllyucrvww72z8rjSEwqY+NAvVX+1bpcBGhhsogfcDgVmg82n0Rs4HoXgHlLT JLLUp04IM+X6BEP9Rs/+TXMAzhd6I4iPdDz8nNie1Oe+Y8TkrnwhbrjdLhBCXrzcKhTu gNnw== 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:references:in-reply-to:message-id:date :to:from:delivered-to; bh=1V8lLiKu0KUZQx20b755zi/6iAXf1Y1Q76P1PRmN8kw=; b=cG9QPvsrsya60FRk5fLT68SOEtVfTeEFdrw/Tuqho3vOVAGUogbZ0qreXizxhwDV+Y OKMhjlA68mAxDgKLoG+wkhfqCxSDOhz/LdxLrkBZpl6adN/fkneEZUj6XEYVYyIlVmBB st5dbDOdJIFKa7oUll5v7Bc8qbB5VtssMFZIpSCoqleEYQfkTR2JpZ9DNgei5zODvwE0 3eFfQPgqNhyv1QMYe3NEusyScx6S2RoRcAhxQ1gWDgwe/t64YuPenmrifIzwdnJfqV+p NMXAa9k6jcNvnB3Di+dToBEORISokna9F0MJswfVrLpgti/MRCcLS5sqqoW6x49pz4Ty gQag== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p23si4299397edw.135.2021.11.17.20.26.26; Wed, 17 Nov 2021 20:26:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83F1068AED3; Thu, 18 Nov 2021 06:25:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEE9868AEA2 for ; Thu, 18 Nov 2021 06:25:04 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10171"; a="233945280" X-IronPort-AV: E=Sophos;i="5.87,243,1631602800"; d="scan'208";a="233945280" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2021 20:24:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,243,1631602800"; d="scan'208";a="495212227" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga007.jf.intel.com with ESMTP; 17 Nov 2021 20:24:58 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Nov 2021 12:24:45 +0800 Message-Id: <20211118042449.8038-6-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211118042449.8038-1-jianhua.wu@intel.com> References: <20211118042449.8038-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 06/10] avfilter/avgblur_vulkan: call av_vkfmt_from_pixfmt only one time X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Wu Jianhua MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DvUMWz1MHmAs There is a loop in av_vkfmt_from_pixfmt. And, even though some compilers will optimize it when the optimization option is on, to consider more situations, just call the function only one time here. Signed-off-by: Wu Jianhua --- libavfilter/vf_avgblur_vulkan.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c index 243e932f35..080a8b1b63 100644 --- a/libavfilter/vf_avgblur_vulkan.c +++ b/libavfilter/vf_avgblur_vulkan.c @@ -210,6 +210,10 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *tmp_f AVVkFrame *in = (AVVkFrame *)in_f->data[0]; AVVkFrame *tmp = (AVVkFrame *)tmp_f->data[0]; AVVkFrame *out = (AVVkFrame *)out_f->data[0]; + + const VkFormat *input_formats = av_vkfmt_from_pixfmt(s->vkctx.input_format); + const VkFormat *output_formats = av_vkfmt_from_pixfmt(s->vkctx.output_format); + int planes = av_pix_fmt_count_planes(s->vkctx.output_format); /* Update descriptors and init the exec context */ @@ -219,17 +223,17 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *tmp_f for (int i = 0; i < planes; i++) { RET(ff_vk_create_imageview(avctx, s->exec, &s->input_images[i].imageView, in->img[i], - av_vkfmt_from_pixfmt(s->vkctx.input_format)[i], + input_formats[i], ff_comp_identity_map)); RET(ff_vk_create_imageview(avctx, s->exec, &s->tmp_images[i].imageView, tmp->img[i], - av_vkfmt_from_pixfmt(s->vkctx.output_format)[i], + output_formats[i], ff_comp_identity_map)); RET(ff_vk_create_imageview(avctx, s->exec, &s->output_images[i].imageView, out->img[i], - av_vkfmt_from_pixfmt(s->vkctx.output_format)[i], + output_formats[i], ff_comp_identity_map)); s->input_images[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;