From patchwork Thu Nov 25 09:08:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 31657 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp355638iob; Thu, 25 Nov 2021 01:13:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCQ86Pp9QzX6Tmrqh5ZrGDUPkb+GjDYcTZShgsNp4oFsayvSndvAnnV9jG4fb7UAYIP3PP X-Received: by 2002:a05:6402:710:: with SMTP id w16mr37055208edx.218.1637831579878; Thu, 25 Nov 2021 01:12:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637831579; cv=none; d=google.com; s=arc-20160816; b=QEZ8mJgCIadKN2M7vBbYuvp6pjB16+NIGvBaxq11QcG1qs2NyLRZVEhaKAErlhar+x T+ivyhKO96a3AuvJs+1shMh2zH7zkTf3Y1OR8XlesZUG5bf1sY6gOph+JFnEtIs0WHZa Bj+zif7YoeOL93502k+4rBKoZurZfE7fHMUoQqXpn+UZDj/+QkHB15wlXVZ5YMmQ9i6P WM6RemfXtwyf8+cZtasqI21jeh6E53Lb5soqOd17bSmFSXWJM9/+zNJFqq/cxfc6pmPb ee8p3aq6/QoNVsqNhLMe8C47fuef7ntRhERaqp8djA1/UMacCWmXCV56Mey8en0MTxUB zZ2w== 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:message-id:date:to:from :delivered-to; bh=5uMEd0Mt9pYIlHpXfY50hcxlR3O75GzPNPSRs8ATO6c=; b=HNZLhxFGQaYUGqSVi/UlD5FqBwngo+BmNuAiXtXcThha+3rxxbOS5kEydrykePILNz ftd+LSXJ+CS0ub06E0BtjRHhqVdbuH3Pd8etAejHSbFo/FpId1zrsWhINR1ifMbgKn+P oF3sUg0XBwP73l32NbSovS1V43GQOzMz1f4sIRYTvM6GvExZ37/kbByX8Zf5YK8ioUW3 6nYv4Fmu56wyW8HrD0JOl9CjoMAt/UtnP7+PEBzgz+DAOsSDrnc/C/n/bqasqTHzj2l5 JtqYMr2lO8bLUy8bl1gFvhVkh/MWbMBmtMv1i6Mp0hMwLeTPx/SE5yX4p7/4eVjaN4eu ZuAA== 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 sh8si7441931ejc.629.2021.11.25.01.12.59; Thu, 25 Nov 2021 01:12:59 -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 C10E068AE6D; Thu, 25 Nov 2021 11:12:56 +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 284B468AC48 for ; Thu, 25 Nov 2021 11:12:49 +0200 (EET) X-IronPort-AV: E=McAfee;i="6200,9189,10178"; a="235721973" X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="235721973" 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:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="650688200" 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:47 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Nov 2021 17:08:41 +0800 Message-Id: <20211125090842.4067876-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/2] avutil/hwcontext_vulkan: fully support customizable validation layers 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: QITWd1Z30bRq Validation layer is an indispensable part of developing on Vulkan. The following commands is on how to enable validation layers: ffmpeg -init_hw_device vulkan=0,debug=1,validation_layers=VK_LAYER_LUNARG_monitor+VK_LAYER_LUNARG_api_dump Signed-off-by: Wu Jianhua --- libavutil/hwcontext_vulkan.c | 164 ++++++++++++++++++++++++++++------- libavutil/vulkan_functions.h | 1 + 2 files changed, 136 insertions(+), 29 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 644ed947f8..515e27aad8 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -146,6 +146,13 @@ typedef struct AVVkFrameInternal { } \ } while(0) +#define RELEASE_PROPS(props, count) \ + if (props) { \ + for (int i = 0; i < count; i++) \ + av_free((void *)((props)[i])); \ + av_free((void *)props); \ + } + static const struct { enum AVPixelFormat pixfmt; const VkFormat vkfmts[4]; @@ -511,25 +518,129 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts, return 0; fail: - if (extension_names) - for (int i = 0; i < extensions_found; i++) - av_free((void *)extension_names[i]); - av_free(extension_names); + RELEASE_PROPS(extension_names, extensions_found); av_free(user_exts_str); av_free(sup_ext); return err; } +static int check_validation_layers(AVHWDeviceContext *ctx, AVDictionary *opts, + const char * const **dst, uint32_t *num, int *debug_mode) +{ + static const char default_layer[] = { "VK_LAYER_KHRONOS_validation" }; + + int found = 0, err = 0; + VulkanDevicePriv *priv = ctx->internal->priv; + FFVulkanFunctions *vk = &priv->vkfn; + + uint32_t sup_layer_count; + VkLayerProperties *sup_layers; + + AVDictionaryEntry *user_layers; + char *user_layers_str = NULL; + char *save, *token; + + const char **enabled_layers = NULL; + uint32_t enabled_layers_count = 0; + + AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0); + int debug = debug_opt && strtol(debug_opt->value, NULL, 10); + + /* If `debug=0`, enable no layers at all. */ + if (debug_opt && !debug) + return 0; + + vk->EnumerateInstanceLayerProperties(&sup_layer_count, NULL); + sup_layers = av_malloc_array(sup_layer_count, sizeof(VkLayerProperties)); + if (!sup_layers) + return AVERROR(ENOMEM); + vk->EnumerateInstanceLayerProperties(&sup_layer_count, sup_layers); + + av_log(ctx, AV_LOG_VERBOSE, "Supported validation layers:\n"); + for (int i = 0; i < sup_layer_count; i++) + av_log(ctx, AV_LOG_VERBOSE, "\t%s\n", sup_layers[i].layerName); + + /* If `debug=1` is specified, enable the standard validation layer extension */ + if (debug) { + *debug_mode = debug; + for (int i = 0; i < sup_layer_count; i++) { + if (!strcmp(default_layer, sup_layers[i].layerName)) { + found = 1; + av_log(ctx, AV_LOG_VERBOSE, + "Default validation layer %s is enabled\n", default_layer); + ADD_VAL_TO_LIST(enabled_layers, enabled_layers_count, default_layer); + break; + } + } + } + + user_layers = av_dict_get(opts, "validation_layers", NULL, 0); + if (!user_layers) + goto end; + + user_layers_str = av_strdup(user_layers->value); + if (!user_layers_str) { + err = AVERROR(EINVAL); + goto fail; + } + + token = av_strtok(user_layers_str, "+", &save); + while (token) { + found = 0; + if (!strcmp(default_layer, token)) { + if (debug) { + /* if the `debug=1`, default_layer is enabled, skip here */ + token = av_strtok(NULL, "+", &save); + continue; + } + else { + /* if the `debug=0, enable debug mode to load its callback properly */ + *debug_mode = debug; + } + } + for (int j = 0; j < sup_layer_count; j++) { + if (!strcmp(token, sup_layers[j].layerName)) { + found = 1; + break; + } + } + if (found) { + av_log(ctx, AV_LOG_VERBOSE, "Requested Validation Layer: %s\n", token); + ADD_VAL_TO_LIST(enabled_layers, enabled_layers_count, token); + } else { + av_log(ctx, AV_LOG_ERROR, + "Validation Layer \"%s\" not support.\n", token); + err = AVERROR(EINVAL); + goto fail; + } + token = av_strtok(NULL, "+", &save); + } + + av_free(user_layers_str); + +end: + av_free(sup_layers); + + *dst = enabled_layers; + *num = enabled_layers_count; + + return 0; + +fail: + RELEASE_PROPS(enabled_layers, enabled_layers_count); + av_free(sup_layers); + av_free(user_layers_str); + return err; +} + /* Creates a VkInstance */ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) { - int err = 0; + int err = 0, debug_mode = 0; VkResult ret; VulkanDevicePriv *p = ctx->internal->priv; FFVulkanFunctions *vk = &p->vkfn; AVVulkanDeviceContext *hwctx = ctx->hwctx; - AVDictionaryEntry *debug_opt = av_dict_get(opts, "debug", NULL, 0); - const int debug_mode = debug_opt && strtol(debug_opt->value, NULL, 10); VkApplicationInfo application_info = { .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pEngineName = "libavutil", @@ -555,17 +666,18 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) return err; } + err = check_validation_layers(ctx, opts, &inst_props.ppEnabledLayerNames, + &inst_props.enabledLayerCount, &debug_mode); + if (err) + goto fail; + /* Check for present/missing extensions */ err = check_extensions(ctx, 0, opts, &inst_props.ppEnabledExtensionNames, &inst_props.enabledExtensionCount, debug_mode); + hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; + hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount; if (err < 0) - return err; - - if (debug_mode) { - static const char *layers[] = { "VK_LAYER_KHRONOS_validation" }; - inst_props.ppEnabledLayerNames = layers; - inst_props.enabledLayerCount = FF_ARRAY_ELEMS(layers); - } + goto fail; /* Try to create the instance */ ret = vk->CreateInstance(&inst_props, hwctx->alloc, &hwctx->inst); @@ -574,16 +686,14 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) if (ret != VK_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Instance creation failure: %s\n", vk_ret2str(ret)); - for (int i = 0; i < inst_props.enabledExtensionCount; i++) - av_free((void *)inst_props.ppEnabledExtensionNames[i]); - av_free((void *)inst_props.ppEnabledExtensionNames); - return AVERROR_EXTERNAL; + err = AVERROR_EXTERNAL; + goto fail; } err = ff_vk_load_functions(ctx, vk, p->extensions, 1, 0); if (err < 0) { av_log(ctx, AV_LOG_ERROR, "Unable to load instance functions!\n"); - return err; + goto fail; } if (debug_mode) { @@ -604,10 +714,11 @@ static int create_instance(AVHWDeviceContext *ctx, AVDictionary *opts) hwctx->alloc, &p->debug_ctx); } - hwctx->enabled_inst_extensions = inst_props.ppEnabledExtensionNames; - hwctx->nb_enabled_inst_extensions = inst_props.enabledExtensionCount; + err = 0; - return 0; +fail: + RELEASE_PROPS(inst_props.ppEnabledLayerNames, inst_props.enabledLayerCount); + return err; } typedef struct VulkanDeviceSelection { @@ -1163,13 +1274,8 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) if (p->libvulkan) dlclose(p->libvulkan); - for (int i = 0; i < hwctx->nb_enabled_inst_extensions; i++) - av_free((void *)hwctx->enabled_inst_extensions[i]); - av_free((void *)hwctx->enabled_inst_extensions); - - for (int i = 0; i < hwctx->nb_enabled_dev_extensions; i++) - av_free((void *)hwctx->enabled_dev_extensions[i]); - av_free((void *)hwctx->enabled_dev_extensions); + RELEASE_PROPS(hwctx->enabled_inst_extensions, hwctx->nb_enabled_inst_extensions); + RELEASE_PROPS(hwctx->enabled_dev_extensions, hwctx->nb_enabled_dev_extensions); } static int vulkan_device_create_internal(AVHWDeviceContext *ctx, diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h index 85a9f943c8..96922d7286 100644 --- a/libavutil/vulkan_functions.h +++ b/libavutil/vulkan_functions.h @@ -45,6 +45,7 @@ typedef enum FFVulkanExtensions { #define FN_LIST(MACRO) \ /* Instance */ \ MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceExtensionProperties) \ + MACRO(0, 0, FF_VK_EXT_NO_FLAG, EnumerateInstanceLayerProperties) \ MACRO(0, 0, FF_VK_EXT_NO_FLAG, CreateInstance) \ MACRO(1, 0, FF_VK_EXT_NO_FLAG, DestroyInstance) \ \ 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, +};