From patchwork Thu Nov 25 09:08:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31656 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp355991iob; Thu, 25 Nov 2021 01:13:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDXUZwfFmXoN1k+Lu90H/win0BwMfUNOuc+ufjV7C0O1N3BYvParpBsM41Ucgh3ETZUEoc X-Received: by 2002:a05:6402:2790:: with SMTP id b16mr36269477ede.24.1637831601622; Thu, 25 Nov 2021 01:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637831601; cv=none; d=google.com; s=arc-20160816; b=nLstaqfnngapiUuSlkYkCFEUdijdGT/7UOvNzhVtmNRo0ufR9jd9n+PESjSM6faEU3 y/3yEt9qZ6/oYA5RE58Cg2iqWE3MekG4tr8ak29eq9rjJo04SGhkOj5VvG4l0b9dRfkw uqnQfHL5N4ycpU7peqrYnJ2Ypon+BwZ/86siY3Ww5L2IlyIIcLc6RVI39M4WcTtP2VS4 cSF03AUPJ7u4UAEBfHQonpgYg88fWVHmgg1TovLLU7hxIVTR8rJqEeG9A2CLiGbV2Igu NhVpsxjyEUNsmXq34JAk4K9rgBUQWPG9b69NSMF0SFteb+AlATCmfMRrRquqm4k7Q5pC SbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=t5ReSYe6lEWGpP26iYi3/tgaT+ziTBoih87X2Al7iLI=; b=YFGrft62YhMa5lX6pr2qllqyb8jGIpx7wstTIQrnJX6JfOSm9FTfvZ1B7D/zTafXMZ l5FEOFA4raiVTjTJGLZaaDoKcdDYWCxoBjB5zObRVIlOg1u1cjpeEdsDMNhTHDdTrMdu DAHzrgLxhV5cFGgiK7qKlUifQrDIHr5/Td4svCnQj91Bnbk+wAIEjcLolfZfery5Vh0B j3r/LwYep+24ZZsnJvrvke4nrV4UbLczMFnMscJNVZohwr/ZsYxlfQUub2pf1jKZFCto SAEY37uPHTYjKC5n89kVeulLtbWAfc9p4CzOed2a8N3mxFYBywrk+cgr5YYjXwQxUQhZ TZ2w== 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 z11si7668837edb.194.2021.11.25.01.13.10; Thu, 25 Nov 2021 01:13:21 -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 CAE7E68AE46; Thu, 25 Nov 2021 11:13:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FDF168AE46 for ; Thu, 25 Nov 2021 11:12:55 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10178"; a="235721978" X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="235721978" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2021 01:12:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="650688205" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by fmsmga001.fm.intel.com with ESMTP; 25 Nov 2021 01:12:48 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 17:08:42 +0800 Message-Id: <20211125090842.4067876-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125090842.4067876-1-jianhua.wu@intel.com> References: <20211125090842.4067876-1-jianhua.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/2] avfilter: add a bflip_vulkan filter 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: I6LuALUbIBSt This filter flips the input video both horizontally and vertically in one compute pipeline, and it's no need to use two pipelines for hflip_vulkan,vflip_vulkan anymore. Signed-off-by: Wu Jianhua --- configure | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_flip_vulkan.c | 39 +++++++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/configure b/configure index d068b11073..a7562b53c3 100755 --- a/configure +++ b/configure @@ -3569,6 +3569,7 @@ atempo_filter_select="rdft" avgblur_opencl_filter_deps="opencl" avgblur_vulkan_filter_deps="vulkan spirv_compiler" azmq_filter_deps="libzmq" +bflip_vulkan_filter_deps="vulkan spirv_compiler" blackframe_filter_deps="gpl" bm3d_filter_deps="avcodec" bm3d_filter_select="dct" diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 4bf17ef292..041292853a 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -175,6 +175,7 @@ extern const AVFilter ff_vf_avgblur_opencl; extern const AVFilter ff_vf_avgblur_vulkan; extern const AVFilter ff_vf_bbox; extern const AVFilter ff_vf_bench; +extern const AVFilter ff_vf_bflip_vulkan; extern const AVFilter ff_vf_bilateral; extern const AVFilter ff_vf_bitplanenoise; extern const AVFilter ff_vf_blackdetect; diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c index e9e04db91b..e20766e9ed 100644 --- a/libavfilter/vf_flip_vulkan.c +++ b/libavfilter/vf_flip_vulkan.c @@ -26,7 +26,8 @@ enum FlipType { FLIP_VERTICAL, - FLIP_HORIZONTAL + FLIP_HORIZONTAL, + FLIP_BOTH }; typedef struct FlipVulkanContext { @@ -104,6 +105,9 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType case FLIP_VERTICAL: GLSLF(2, vec4 res = texture(input_image[%i], ivec2(pos.x, size.y - pos.y)); ,i); break; + case FLIP_BOTH: + GLSLF(2, vec4 res = texture(input_image[%i], ivec2(size.xy - pos.xy));, i); + break; default: GLSLF(2, vec4 res = texture(input_image[%i], pos); ,i); break; @@ -267,6 +271,11 @@ static int vflip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) return flip_vulkan_filter_frame(link, in, FLIP_VERTICAL); } +static int bflip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) +{ + return flip_vulkan_filter_frame(link, in, FLIP_BOTH); +} + static const AVOption hflip_vulkan_options[] = { { NULL }, }; @@ -330,3 +339,31 @@ const AVFilter ff_vf_vflip_vulkan = { .priv_class = &vflip_vulkan_class, .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; + +static const AVOption bflip_vulkan_options[] = { + { NULL }, +}; + +AVFILTER_DEFINE_CLASS(bflip_vulkan); + +static const AVFilterPad bflip_vulkan_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = &bflip_vulkan_filter_frame, + .config_props = &ff_vk_filter_config_input, + } +}; + +const AVFilter ff_vf_bflip_vulkan = { + .name = "bflip_vulkan", + .description = NULL_IF_CONFIG_SMALL("Flip both horizontally and vertically"), + .priv_size = sizeof(FlipVulkanContext), + .init = &ff_vk_filter_init, + .uninit = &flip_vulkan_uninit, + FILTER_INPUTS(bflip_vulkan_inputs), + FILTER_OUTPUTS(flip_vulkan_outputs), + FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN), + .priv_class = &bflip_vulkan_class, + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, +};