From patchwork Fri Nov 26 09:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31745 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp1946545iob; Fri, 26 Nov 2021 01:15:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTbplagLzPQfpv0uwYXcwC3YhkMzdHQh3RyEhR5ui5ifC1K+NH8Z/Akih5MCWnHFOf2j0k X-Received: by 2002:a05:6402:1292:: with SMTP id w18mr45733248edv.46.1637918140299; Fri, 26 Nov 2021 01:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637918140; cv=none; d=google.com; s=arc-20160816; b=ck+951MbE3GrEwP6LUWHOsKnt2rJeXXSUqlnGFtXK6mB6Y2aXLAytl/Obasu+GZMKv rq9Ip/P/IzDdXN+ol79V435dk86wfhDv/e2Cb+LnURPKF/QPKbFmSKUI7/AV/j8/9Ci0 ugfX5jG+UkUmZrsrHWJGS2GfOlLmTo3i3NukgUlSpWvPrQzwfrtLkRza0kSYV5GJBrES THAJvqFlqG4XZMq1x4dJmGljvJe4rdYEgdibQODycF6LGe+jrVRq3DPLo1eJ8c3zbzc/ 2WK0osQWoRXkVKGcuPdWe9fXF3XF1Li6kSwJqFrpOpmkChBn3GRNPDpMKGLDkwl2wx5y jRUQ== 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=kM3Bj7FRittjMNGCYZ5bj5VpEG0ayJaslHM0nQJ8ZGM=; b=fERwy3AKycOHGTG+QzvWRnAhevlrtHMBPaNr9CwL8qtqZWNfcRGca/YEz2ypzdR9ym hNFxjC9lc9BQk4UOpkCsxgTwF1EUFSK1jMRfKpC8SXrmCVAEdSfT9qBvcM/kqq1Uuy3l deaFkzXSc0fsJpKfiHyK3AiVJ5LMsFZ1YOU8vZaCIKyCZaNfaT4tsghsVsc1qEBHY7UF tuaLv0qOUxZNoqNX981PMNXbiIQaxmk+i6VQNM6kLLEbAib0Ox55Fhi13V9Mw6zvVjKr 6cTy2i7sTN2L+2FgO+ZBJYs8i7M8B/wTGVS5XFdaf/edDSxUCDDHMhneABMLXPWnTQRc BqNA== 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 r15si8872500edo.157.2021.11.26.01.15.39; Fri, 26 Nov 2021 01:15:40 -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 5F18768A703; Fri, 26 Nov 2021 11:15:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C10B16883DB for ; Fri, 26 Nov 2021 11:15:22 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10179"; a="321869186" X-IronPort-AV: E=Sophos;i="5.87,265,1631602800"; d="scan'208";a="321869186" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2021 01:15:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,265,1631602800"; d="scan'208";a="607790527" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga004.jf.intel.com with ESMTP; 26 Nov 2021 01:15:14 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Nov 2021 17:10:57 +0800 Message-Id: <20211126091057.118653-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126091057.118653-1-jianhua.wu@intel.com> References: <20211126091057.118653-1-jianhua.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/2] avfilter: add a flip_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: eSCDlsGapxNx 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 | 61 +++++++++++++++++++++++++++++------- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/configure b/configure index d068b11073..7112d830c9 100755 --- a/configure +++ b/configure @@ -3608,6 +3608,7 @@ fftdnoiz_filter_select="fft" find_rect_filter_deps="avcodec avformat gpl" firequalizer_filter_deps="avcodec" firequalizer_filter_select="rdft" +flip_vulkan_filter_deps="vulkan spirv_compiler" flite_filter_deps="libflite" framerate_filter_select="scene_sad" freezedetect_filter_select="scene_sad" diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 4bf17ef292..e014833bea 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -263,6 +263,7 @@ extern const AVFilter ff_vf_fieldmatch; extern const AVFilter ff_vf_fieldorder; extern const AVFilter ff_vf_fillborders; extern const AVFilter ff_vf_find_rect; +extern const AVFilter ff_vf_flip_vulkan; extern const AVFilter ff_vf_floodfill; extern const AVFilter ff_vf_format; extern const AVFilter ff_vf_fps; diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c index e9e04db91b..0223786ef1 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; @@ -226,7 +230,7 @@ fail: return err; } -static int flip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in, enum FlipType type) +static int filter_frame(AVFilterLink *link, AVFrame *in, enum FlipType type) { int err; AVFrame *out = NULL; @@ -259,14 +263,27 @@ fail: static int hflip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) { - return flip_vulkan_filter_frame(link, in, FLIP_HORIZONTAL); + return filter_frame(link, in, FLIP_HORIZONTAL); } static int vflip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) { - return flip_vulkan_filter_frame(link, in, FLIP_VERTICAL); + return filter_frame(link, in, FLIP_VERTICAL); } +static int flip_vulkan_filter_frame(AVFilterLink *link, AVFrame *in) +{ + return filter_frame(link, in, FLIP_BOTH); +} + +static const AVFilterPad flip_vulkan_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = &ff_vk_filter_config_output, + } +}; + static const AVOption hflip_vulkan_options[] = { { NULL }, }; @@ -282,14 +299,6 @@ static const AVFilterPad hflip_vulkan_inputs[] = { } }; -static const AVFilterPad flip_vulkan_outputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = &ff_vk_filter_config_output, - } -}; - const AVFilter ff_vf_hflip_vulkan = { .name = "hflip_vulkan", .description = NULL_IF_CONFIG_SMALL("Horizontally flip the input video in Vulkan"), @@ -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 flip_vulkan_options[] = { + { NULL }, +}; + +AVFILTER_DEFINE_CLASS(flip_vulkan); + +static const AVFilterPad flip_vulkan_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = &flip_vulkan_filter_frame, + .config_props = &ff_vk_filter_config_input, + } +}; + +const AVFilter ff_vf_flip_vulkan = { + .name = "flip_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(flip_vulkan_inputs), + FILTER_OUTPUTS(flip_vulkan_outputs), + FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN), + .priv_class = &flip_vulkan_class, + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, +};