From patchwork Fri Nov 19 13:52: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: 31499 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp2413897iob; Fri, 19 Nov 2021 05:53:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXrIj3KIWgtNDB/wdyBCRnptAly6YPomLQK7tVHdWE6Av0TRZnAbhpIB/rVN804F01U2dm X-Received: by 2002:a05:6402:90c:: with SMTP id g12mr24288405edz.36.1637330038955; Fri, 19 Nov 2021 05:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637330038; cv=none; d=google.com; s=arc-20160816; b=DwBzu9zwC9LnOp7TR1Ad4iUAsI2tdk3QiErXDnHXH2OEE0rnUZQnSNcEkl7fZW3quo V0Xqr+8GNBjSvqfclbF5BBFgERjs5OJcscCx6ClXS/vCe2igId7JmSV+T6g4+8KlCEqR TWyNIo9Nv5nlj++DPDmZ0ODstrUADeEGnq6T//bHDYHwJ8cOV3jZOUZOgrU7Pk8Evb3S Q1IOxNFCSGCIIPeVvsDEnowCS8NnBpmhKE4C+zEhrt42TlTdukV5aQN028FaXPlcBuJ7 5eehf2NJKsCmXMShTuHvKVggcPB+E+sYkVxDMCIsO0nxvXZAi3iwcV4AMPavTFUFHanV RDIw== 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=jdCeueS8Z8toMHi8OqDIe7z3ZMEfXksxoAadcpRqkqU=; b=rF4GhJdEo0mjyW0A6sJ4sSXICvJ4CVReGW2WpuPjpClyNnH4G/pIc8mIAzrBvPQ/nN 6JCAFhT/ZBqPFvPt8iX4q3hJIu5UOF1ue7G1RpUqeySq7DfauHJpZCuh7SRWOQlvOagE mzNRZOEHFtgEMsFw6nK7OLm5h8liZ8w2QRBg+3yn6SLx7aAznh2VxmI2Dz9jTdj1LrDo ZSHx9HjDTT1sfxb9SB4mOMWsLpltiLKXQ4dMD0Jk4WwA4tkipJnA4bBMYJgOQPexNRXG S9LiztmoQKXdTXzgAHXh9WGAUUsLv34bIe0hRBPYQLfZA/Q4XIea+GbCLJJnHhhczB63 p1dA== 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 hp29si8115064ejc.80.2021.11.19.05.53.58; Fri, 19 Nov 2021 05:53:58 -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 F277B68AAE6; Fri, 19 Nov 2021 15:53:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C961768A842 for ; Fri, 19 Nov 2021 15:53:09 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="231896469" X-IronPort-AV: E=Sophos;i="5.87,247,1631602800"; d="scan'208";a="231896469" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 05:53:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,247,1631602800"; d="scan'208";a="507906011" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga008.jf.intel.com with ESMTP; 19 Nov 2021 05:53:01 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Nov 2021 21:52:45 +0800 Message-Id: <20211119135248.14518-8-jianhua.wu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119135248.14518-1-jianhua.wu@intel.com> References: <20211119135248.14518-1-jianhua.wu@intel.com> Subject: [FFmpeg-devel] [PATCH 08/11] avfilter/scale_vulkan: call av_pix_fmt_count_planes 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: 4GJwMfB0k8Or Signed-off-by: Wu Jianhua --- libavfilter/vf_scale_vulkan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c index ff67c80e33..caa08ff19b 100644 --- a/libavfilter/vf_scale_vulkan.c +++ b/libavfilter/vf_scale_vulkan.c @@ -303,32 +303,30 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *in_f) AVVkFrame *out = (AVVkFrame *)out_f->data[0]; VkImageMemoryBarrier barriers[AV_NUM_DATA_POINTERS*2]; int barrier_count = 0; + const int planes = av_pix_fmt_count_planes(s->vkctx.input_format); /* Update descriptors and init the exec context */ ff_vk_start_exec_recording(vkctx, s->exec); cmd_buf = ff_vk_get_exec_buf(s->exec); - for (int i = 0; i < av_pix_fmt_count_planes(s->vkctx.input_format); i++) { + for (int i = 0; i < planes; i++) { RET(ff_vk_create_imageview(vkctx, s->exec, &s->input_images[i].imageView, in->img[i], av_vkfmt_from_pixfmt(s->vkctx.input_format)[i], ff_comp_identity_map)); - s->input_images[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - } - - for (int i = 0; i < av_pix_fmt_count_planes(s->vkctx.output_format); i++) { RET(ff_vk_create_imageview(vkctx, s->exec, &s->output_images[i].imageView, out->img[i], av_vkfmt_from_pixfmt(s->vkctx.output_format)[i], ff_comp_identity_map)); + s->input_images[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; s->output_images[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL; } ff_vk_update_descriptor_set(vkctx, s->pl, 0); - for (int i = 0; i < av_pix_fmt_count_planes(s->vkctx.input_format); i++) { + for (int i = 0; i < planes; i++) { VkImageMemoryBarrier bar = { .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .srcAccessMask = 0,