From patchwork Thu Nov 18 04:24:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31467 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp234620iob; Wed, 17 Nov 2021 20:26:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv2YT1efTOIgF/2aZ0Al7URLuVkXVsiZHAbQhxplmELJkV5OcoSs1kWf2wVh+wEhqjFkRF X-Received: by 2002:a05:6402:4394:: with SMTP id o20mr6646213edc.342.1637209568181; Wed, 17 Nov 2021 20:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637209568; cv=none; d=google.com; s=arc-20160816; b=lDKPCQbLPzRYUe+sdToxXHnLak99X/xi5dXxVuEu0DxZzhDbinsASJ2ukikDTDRjzo 88Y/Ho4G1DGwSaoGeRn0Ujx5O7dDxgHhNE+Y8Ypfyo03pH0FrqQuukl3iiBmaa71D6Ie 7T9qoMox1+SfmzsLP7PCIxK7cdDnHd0gSvIN+8+VC/qW7qWQUVSYKf903WZ1sCpDer1L 1tCtY5zKPRAJDSSANEJBrMTj8Nz5Aear4+0SPeYMNqre4z7NAXkAT0Pp9Cs9LUSzvpEN A7hLPZP8P05XyD49qT0Noni2nd7L0qDeOYn4k4hpKbRR8ubgsImCsDuo2brwM12B5fBY iCDw== 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=0pMZ5kp7iXW4UBRf0WMBT2yTxo5hGS2XtOvPhAlX3UQ=; b=SlKbbOHLC1vN+lUcXJZWepm89ew3VGLt45gZrUeoC9Ouyw8DquwS27YCQdxxGhlZrQ 5KktZEUr46c+IlWImWFnV4JTRRyBO3A3bv0V/8MExyArXw9xViDSxFBdFli70RVBIPR7 C6JE9zaRcE8qOuR3bzMEUwkY9jfB9LJZQ31UpJ9LPZceNwPY9KFXANn7TgigXwFs3A9G eivM4q/0u8w4fCp0uaIy9iogQZyptzheQ9CTwiOPjLonXnqT4Onn9n7ZEvy6lFYQmGHi lvmEGC7CP8QYlZeNz8/NJlD8allbeJg8bP5cgax5c/q+YRpaQknKa5IdaeMutynUo3VO 9bqg== 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 hb14si4711495ejc.610.2021.11.17.20.26.07; Wed, 17 Nov 2021 20:26:08 -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 5493E68AEC5; Thu, 18 Nov 2021 06:25:13 +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 0655468AEA2 for ; Thu, 18 Nov 2021 06:25:08 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10171"; a="233945283" X-IronPort-AV: E=Sophos;i="5.87,243,1631602800"; d="scan'208";a="233945283" 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:25:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,243,1631602800"; d="scan'208";a="495212244" Received: from otc-skl-e5-server.sh.intel.com ([10.239.43.106]) by orsmga007.jf.intel.com with ESMTP; 17 Nov 2021 20:25:01 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Nov 2021 12:24:47 +0800 Message-Id: <20211118042449.8038-8-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 08/10] 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: 6Swf1ByGlKOy 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 7d7120df79..413c2cb294 100644 --- a/libavfilter/vf_scale_vulkan.c +++ b/libavfilter/vf_scale_vulkan.c @@ -301,32 +301,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(avctx, s->exec); cmd_buf = ff_vk_get_exec_buf(avctx, 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(avctx, 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(avctx, 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(avctx, 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,