From patchwork Thu Dec 9 09:36:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 32216 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp106131iog; Thu, 9 Dec 2021 01:37:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzo6wWak2vNj292n4TQcc6AJ/QEd/lbZdwt7IzvxYKgP8M9v/jwZBgzY1zJEDL/Z1CKE99d X-Received: by 2002:a17:907:6d10:: with SMTP id sa16mr14744657ejc.532.1639042650277; Thu, 09 Dec 2021 01:37:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639042650; cv=none; d=google.com; s=arc-20160816; b=F0ta+hJTNd0c9//HFxYs95UIJSxSvuGTygoU27EVu2Ebrn8EC4/h48ECi87OZrBQ42 tLn1YOMj25yGPxhVW9YUF6QbBpND8dizdFZynuu2jx4+U2IWV5FdvVLQVG4tXameFCTH Q0R+VGAqH56iSePnTjlFWaqxUgW6GD5Lyj7vGOe0+Tdrtf/Xi5ptC9NM1p3q16PeduHI BXHEoj/kJ8Iv8K0+F7B5BDeCsTxlcfanPOetMt3K3mvo/AXnJgbySyheOrievvZeJxod VaOaBbtft+2EEaQKFwio7AuZA/FARgbmCXtWnct1q0vh4bJoQa4SQx4SsEqs4VSqTnha i9FQ== 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 :dkim-signature:delivered-to; bh=uN2/dBwDVB/TELT1jz/ig7UK7BRi/pt+JoJB3h3Qtmk=; b=HaOOugyQmDnejfAjMYmbrvGa4u6ZVvjEJv5JZCObWo5YrM4MDjBIAwzPn4KJjX/qVx FLft/P1kY63nGNffmvl1juexrb+xBE8RLpaqM5a9wRmXAL0rR+tQQg3+jKfcvc3tMegD NFpbBGxqRbD8mccBCL27v2bnDDg1R1INMju/4KVj/JG12CxsfU7uqTjtZASWzgpkSMwT yB2p7LCc9+6whawc/MzqcfpmDIPfswqsKd4mBlCd5sOCK2W9UjsQGzW2oCHWSTk60Fs6 qCgUFq/HjAaD+xsaildmQUllUjAfFFba9hOZG/w8Nqek23DNJP3eHtjOpuzF7sN0kP0m 5zKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=bfY3FuKF; 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 ar25si8173091ejc.770.2021.12.09.01.37.29; Thu, 09 Dec 2021 01:37:30 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=bfY3FuKF; 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 0B51568AE6F; Thu, 9 Dec 2021 11:37:14 +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 B574868AC87 for ; Thu, 9 Dec 2021 11:37:05 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639042631; x=1670578631; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nV+4DfTQH2aFYXukyd6L44Lw/GyCvYCSGe3SCPCtpEA=; b=bfY3FuKF2I8AQyE9EwxH5q7FT2QK+qOo8DGCzrSpdbPt/426e4P4IcIF k0uQb23rj0Cn9j/dX5wqeMPsZfSQcCG2/4hdCkxBooXjG8UdalPD+RAjo qNz6lctWNIKndBaKUTo4ZZOMvi6pirg/WuQJeFByMDFhqrepcfwandD+s M6eJZr8X8VDtOnfebyAYzVK+tRKUJvBqR2tV7Ny7rCTWdu1swH7O5gj4P hAfVzLeIMHxxmMS+XXXN21aLBV+2toO1qEXt7TmOMBqyikF7WdYZaHJ0K b1WviT2jf7jm6D4q+IYntnb/2K49zEAUEqKnsOdq08LkpVpYJFZBUgG9A g==; X-IronPort-AV: E=McAfee;i="6200,9189,10192"; a="237864442" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="237864442" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 01:37:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="462064106" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga003.jf.intel.com with ESMTP; 09 Dec 2021 01:37:00 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Dec 2021 17:36:51 +0800 Message-Id: <20211209093654.3149267-1-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/4] avfilter: add a transpose_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: oLaVfP66wOrX The following command is on how to apply transpose_vulkan filter: ffmpeg -init_hw_device vulkan -i input.264 -vf \ hwupload=extra_hw_frames=16,transpose_vulkan,hwdownload,format=yuv420p output.264 Signed-off-by: Wu Jianhua --- configure | 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_transpose_vulkan.c | 316 ++++++++++++++++++++++++++++++ 4 files changed, 319 insertions(+) create mode 100644 libavfilter/vf_transpose_vulkan.c diff --git a/configure b/configure index a98a18abaa..12cb49e877 100755 --- a/configure +++ b/configure @@ -3718,6 +3718,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" +transpose_vulkan_filter_deps="vulkan spirv_compiler" unsharp_opencl_filter_deps="opencl" uspp_filter_deps="gpl avcodec" vaguedenoiser_filter_deps="gpl" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index c8082c4a2f..8744cc3c63 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -483,6 +483,7 @@ OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER) += vf_transpose_npp.o OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER) += vf_transpose_opencl.o opencl.o opencl/transpose.o OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER) += vf_transpose_vaapi.o vaapi_vpp.o +OBJS-$(CONFIG_TRANSPOSE_VULKAN_FILTER) += vf_transpose_vulkan.o vulkan.o vulkan_filter.o OBJS-$(CONFIG_TRIM_FILTER) += trim.o OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync.o OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index b1af2cbcc8..9e16b4e71e 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -462,6 +462,7 @@ extern const AVFilter ff_vf_transpose; extern const AVFilter ff_vf_transpose_npp; extern const AVFilter ff_vf_transpose_opencl; extern const AVFilter ff_vf_transpose_vaapi; +extern const AVFilter ff_vf_transpose_vulkan; extern const AVFilter ff_vf_trim; extern const AVFilter ff_vf_unpremultiply; extern const AVFilter ff_vf_unsharp; diff --git a/libavfilter/vf_transpose_vulkan.c b/libavfilter/vf_transpose_vulkan.c new file mode 100644 index 0000000000..c9bae413c3 --- /dev/null +++ b/libavfilter/vf_transpose_vulkan.c @@ -0,0 +1,316 @@ +/* + * copyright (c) 2021 Wu Jianhua + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/random_seed.h" +#include "libavutil/opt.h" +#include "vulkan_filter.h" +#include "internal.h" + +#define CGS 32 + +typedef struct TransposeVulkanContext { + FFVulkanContext vkctx; + FFVkQueueFamilyCtx qf; + FFVkExecContext *exec; + FFVulkanPipeline *pl; + + VkDescriptorImageInfo input_images[3]; + VkDescriptorImageInfo output_images[3]; + + int initialized; +} TransposeVulkanContext; + +static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) +{ + int err = 0; + FFVkSPIRVShader *shd; + TransposeVulkanContext *s = ctx->priv; + FFVulkanContext *vkctx = &s->vkctx; + const int planes = av_pix_fmt_count_planes(s->vkctx.output_format); + + FFVulkanDescriptorSetBinding image_descs[] = { + { + .name = "input_images", + .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + .dimensions = 2, + .elems = planes, + .stages = VK_SHADER_STAGE_COMPUTE_BIT, + .updater = s->input_images, + }, + { + .name = "output_images", + .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, + .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format), + .mem_quali = "writeonly", + .dimensions = 2, + .elems = planes, + .stages = VK_SHADER_STAGE_COMPUTE_BIT, + .updater = s->output_images, + }, + }; + + image_descs[0].sampler = ff_vk_init_sampler(vkctx, 1, VK_FILTER_LINEAR); + if (!image_descs[0].sampler) + return AVERROR_EXTERNAL; + + ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT, 0); + + { + s->pl = ff_vk_create_pipeline(vkctx, &s->qf); + if (!s->pl) + return AVERROR(ENOMEM); + + shd = ff_vk_init_shader(s->pl, "transpose_compute", image_descs[0].stages); + if (!shd) + return AVERROR(ENOMEM); + + ff_vk_set_compute_shader_sizes(shd, (int [3]){ CGS, 1, 1 }); + RET(ff_vk_add_descriptor_set(vkctx, s->pl, shd, image_descs, FF_ARRAY_ELEMS(image_descs), 0)); + + GLSLC(0, void main() ); + GLSLC(0, { ); + GLSLC(1, ivec2 size; ); + GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); + for (int i = 0; i < planes; i++) { + GLSLC(0, ); + GLSLF(1, size = imageSize(output_images[%i]); ,i); + GLSLC(1, if (IS_WITHIN(pos, size)) { ); + GLSLF(2, vec4 res = texture(input_images[%i], pos.yx); ,i); + GLSLF(2, imageStore(output_images[%i], pos, res); ,i); + GLSLC(1, } ); + } + GLSLC(0, } ); + + RET(ff_vk_compile_shader(vkctx, shd, "main")); + RET(ff_vk_init_pipeline_layout(vkctx, s->pl)); + RET(ff_vk_init_compute_pipeline(vkctx, s->pl)); + } + + RET(ff_vk_create_exec_ctx(vkctx, &s->exec, &s->qf)); + s->initialized = 1; + +fail: + return err; +} + +static int process_frames(AVFilterContext *avctx, AVFrame *outframe, AVFrame *inframe) +{ + int err = 0; + VkCommandBuffer cmd_buf; + TransposeVulkanContext *s = avctx->priv; + FFVulkanContext *vkctx = &s->vkctx; + FFVulkanFunctions *vk = &s->vkctx.vkfn; + const int planes = av_pix_fmt_count_planes(s->vkctx.output_format); + + AVVkFrame *in = (AVVkFrame *)inframe->data[0]; + AVVkFrame *out = (AVVkFrame *)outframe->data[0]; + + const VkFormat *input_formats = av_vkfmt_from_pixfmt(s->vkctx.input_format); + const VkFormat *output_formats = av_vkfmt_from_pixfmt(s->vkctx.output_format); + + ff_vk_start_exec_recording(vkctx, s->exec); + cmd_buf = ff_vk_get_exec_buf(s->exec); + + for (int i = 0; i < planes; i++) { + RET(ff_vk_create_imageview(vkctx, s->exec, + &s->input_images[i].imageView, in->img[i], + input_formats[i], + ff_comp_identity_map)); + + RET(ff_vk_create_imageview(vkctx, s->exec, + &s->output_images[i].imageView, out->img[i], + output_formats[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 < planes; i++) { + VkImageMemoryBarrier barriers[] = { + { + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .srcAccessMask = 0, + .dstAccessMask = VK_ACCESS_SHADER_READ_BIT, + .oldLayout = in->layout[i], + .newLayout = s->input_images[i].imageLayout, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = in->img[i], + .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .subresourceRange.levelCount = 1, + .subresourceRange.layerCount = 1, + }, + { + .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .srcAccessMask = 0, + .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT, + .oldLayout = out->layout[i], + .newLayout = s->output_images[i].imageLayout, + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .image = out->img[i], + .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, + .subresourceRange.levelCount = 1, + .subresourceRange.layerCount = 1, + }, + }; + + vk->CmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, + 0, NULL, 0, NULL, FF_ARRAY_ELEMS(barriers), barriers); + + in->layout[i] = barriers[0].newLayout; + in->access[i] = barriers[0].dstAccessMask; + + out->layout[i] = barriers[1].newLayout; + out->access[i] = barriers[1].dstAccessMask; + } + + ff_vk_bind_pipeline_exec(vkctx, s->exec, s->pl); + vk->CmdDispatch(cmd_buf, FFALIGN(s->vkctx.output_width, CGS)/CGS, + s->vkctx.output_height, 1); + + ff_vk_add_exec_dep(vkctx, s->exec, inframe, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); + ff_vk_add_exec_dep(vkctx, s->exec, outframe, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); + + err = ff_vk_submit_exec_queue(vkctx, s->exec); + if (err) + return err; + + ff_vk_qf_rotate(&s->qf); + + return 0; + +fail: + ff_vk_discard_exec_deps(s->exec); + return err; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + int err; + AVFrame *out = NULL; + AVFilterContext *ctx = inlink->dst; + TransposeVulkanContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + err = AVERROR(ENOMEM); + goto fail; + } + + if (!s->initialized) + RET(init_filter(ctx, in)); + + RET(process_frames(ctx, out, in)); + + RET(av_frame_copy_props(out, in)); + + if (in->sample_aspect_ratio.num) + out->sample_aspect_ratio = in->sample_aspect_ratio; + else { + out->sample_aspect_ratio.num = in->sample_aspect_ratio.den; + out->sample_aspect_ratio.den = in->sample_aspect_ratio.num; + } + + av_frame_free(&in); + + return ff_filter_frame(outlink, out); + +fail: + av_frame_free(&in); + av_frame_free(&out); + return err; +} + +static av_cold void transpose_vulkan_uninit(AVFilterContext *avctx) +{ + TransposeVulkanContext *s = avctx->priv; + ff_vk_uninit(&s->vkctx); + + s->initialized = 0; +} + +static int config_props_output(AVFilterLink *outlink) +{ + int err = 0; + AVFilterContext *avctx = outlink->src; + TransposeVulkanContext *s = avctx->priv; + FFVulkanContext *vkctx = &s->vkctx; + AVFilterLink *inlink = avctx->inputs[0]; + + vkctx->output_width = inlink->h; + vkctx->output_height = inlink->w; + + RET(ff_vk_filter_config_output(outlink)); + + outlink->w = inlink->h; + outlink->h = inlink->w; + + if (inlink->sample_aspect_ratio.num) + outlink->sample_aspect_ratio = av_div_q((AVRational) { 1, 1 }, + inlink->sample_aspect_ratio); + else + outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; + + err = 0; + +fail: + return err; +} + +static const AVOption transpose_vulkan_options[] = { + { NULL } +}; + +AVFILTER_DEFINE_CLASS(transpose_vulkan); + +static const AVFilterPad transpose_vulkan_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = &filter_frame, + .config_props = &ff_vk_filter_config_input, + } +}; + +static const AVFilterPad transpose_vulkan_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = &config_props_output, + } +}; + +const AVFilter ff_vf_transpose_vulkan = { + .name = "transpose_vulkan", + .description = NULL_IF_CONFIG_SMALL("Transpose Vulkan Filter"), + .priv_size = sizeof(TransposeVulkanContext), + .init = &ff_vk_filter_init, + .uninit = &transpose_vulkan_uninit, + FILTER_INPUTS(transpose_vulkan_inputs), + FILTER_OUTPUTS(transpose_vulkan_outputs), + FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN), + .priv_class = &transpose_vulkan_class, + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, +}; From patchwork Thu Dec 9 09:36:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 32217 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp105953iog; Thu, 9 Dec 2021 01:37:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXfNI++/baF71UHTfsVhlL4Gq2fiNuQRc6ixbD06KWFPd2IExu/+IarusS9cDuhzHM2i9l X-Received: by 2002:a05:6402:2805:: with SMTP id h5mr26905985ede.267.1639042638188; Thu, 09 Dec 2021 01:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639042638; cv=none; d=google.com; s=arc-20160816; b=RfR8GNwyKMNtAQssYLvx4LFyTYDRKtfdlAX6Y8WjvYL2hTA1z2yriIo1aKmBPiCrg1 CKx7CVvfqjLyvnNc+Y7jryGSncaTQxUgZCL4GlRiEaFFmrajtxkLf9yD6EXW1XMDjxaH RhVhpAUr0ktUoNW8hR/q1YuFMiAaGP8CzKftKKhf3vOyvgk3rG91XRm1eWRiu+IubAyO MF8z7hDk/z+8EljFlOfPFYCs3V0KDXis57koIwN/AjTJo7MdyVEKvsmXn3QLgzRrT4gS eTDEAA/eVzEXkQ9HUIX0AtW+v+pWfGMfG+EuvuWc6sCTBipcYSClX47Dtj+fOmYO8BGL WEew== 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:dkim-signature:delivered-to; bh=hF/sGQ6IDJ0Jpqx0d57nLqMcUZB7lwU3BEF9vXqUyFE=; b=mr0HRqSZWezHG+M7B3rmjLCCHVRy+CUFvyv0fbM2T0w4zJXrol1gm8MUo97Nnqd7KZ GKRkqp380ydY8DdvKu4lpHWTQgR6B6ls+Yl3lRZtAN57WdwPH3VD1vbd7PtOYGQgVnXk SuTgw79Mm9iURIDH3tP3U+PkFjftWGQtixf5nWyytATs2JBcJP/yeiV+2q74KqDxfKQW 2u8QKCTw7U4EDgoP3ey2zP+a2gw/1uVuVjLwVkHqnkzWwiSzn9ctJ9ve5YDz6JNuImF/ pklQvRSWJlrAMLdYN0cmyohcx88bpUhpdodqyl3cb96OE36xzj9MIw+azJ8yzhEXhw6q T7vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=S7Kbv52f; 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 dz21si11896429edb.49.2021.12.09.01.37.17; Thu, 09 Dec 2021 01:37:18 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=S7Kbv52f; 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 E324968AC87; Thu, 9 Dec 2021 11:37:12 +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 B2C1B68AB96 for ; Thu, 9 Dec 2021 11:37:05 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639042630; x=1670578630; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jfNnXH77PBV82Ez8p0Bl/HO0VKWyyQLNZyFOHBlthiM=; b=S7Kbv52fLFRfV+aZKwH0xUzW1WQYshi6n+aM1RsR0emg94lKh4r1uRgW M1ibgzAgnB3hP/CvPL46f34INjxdvNU8Obn4FaOpXRulP6MyY4/mtzbQM TtTaco7A/bBvHwHvuizLBnImvGEkTLghcN4kXX39Xdre4vtKgkPMFYbRu KG8nDb3rxBp2G6ovBSp71RDCoEjN994FBMIQGUkQUoQca1W6Zx5fmFxcg 74g0wasxC9cGygUed6I/9eImk1feXuBkbd2oWRXEsiDxzhTsRcJAFl9xy iFRQ6USL5Sv2D0o3eD/qoKCuo80VNiOZ57X38VQH1iiKjWrODjFEEo6On Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10192"; a="237864449" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="237864449" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 01:37:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="462064116" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga003.jf.intel.com with ESMTP; 09 Dec 2021 01:37:02 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Dec 2021 17:36:52 +0800 Message-Id: <20211209093654.3149267-2-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209093654.3149267-1-jianhua.wu@intel.com> References: <20211209093654.3149267-1-jianhua.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avfilter/vf_transpose: fix un-checked potential memory allocation failure 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: R3k2o5ABfTZX Signed-off-by: Wu Jianhua --- libavfilter/vf_transpose.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index f9f0d70cd5..b964daeee3 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -328,6 +328,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, static int filter_frame(AVFilterLink *inlink, AVFrame *in) { + int err = 0; AVFilterContext *ctx = inlink->dst; TransContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -339,10 +340,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { - av_frame_free(&in); - return AVERROR(ENOMEM); + err = AVERROR(ENOMEM); + goto fail; } - av_frame_copy_props(out, in); + + err = av_frame_copy_props(out, in); + if (err < 0) + goto fail; if (in->sample_aspect_ratio.num == 0) { out->sample_aspect_ratio = in->sample_aspect_ratio; @@ -356,6 +360,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) FFMIN(outlink->h, ff_filter_get_nb_threads(ctx))); av_frame_free(&in); return ff_filter_frame(outlink, out); + +fail: + av_frame_free(&in); + av_frame_free(&out); + return err; } #define OFFSET(x) offsetof(TransContext, x) From patchwork Thu Dec 9 09:36:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 32215 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp106290iog; Thu, 9 Dec 2021 01:37:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdaMXdy1UixtLowq1DJeE6+G9hOhx9RCRNUjRP7zHiVS6+nW1R3t7y35QXYKXrsuY8bG1D X-Received: by 2002:a17:906:52cf:: with SMTP id w15mr14503870ejn.122.1639042662381; Thu, 09 Dec 2021 01:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639042662; cv=none; d=google.com; s=arc-20160816; b=No+Z6rwEVUCg3f5AQPn3aYZFXBs5eW4Nnijc7qOnQouZGweUUQfd3UVT7TNvnSoV/a 0k0lFPU7QKelvrQErWBsHWmy3uC/XQf/mfm7NJrPil+X7lKVFDoV6IRm2PPgPiFY/6BP Btt5c/ciEDy8YnOHBU7CGSSH+ANuj0hP1nVwhMwpFrylI+0Itd7VrOQwwcfHcAEeLbCN hhagDk63naxNoemA7Hvfn8Jrg4czJ8oFH7F2PXUwTg4lXuMGa/HMHWz0cr8KGLdYtUZd 7xlDdIG3+lw0UjiDTw5o44969i4qAEULBXg4hIgAnf+4QCDNHoZkO8Bc92UCZVESC+je m/Jg== 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:dkim-signature:delivered-to; bh=oBSh9i4vc2H1BMruL/0WY0BG/txLYbf3DhQNy7pmp+I=; b=oJxdyenlO7RqtBzgqOMeFCyR14U3m1Xtlq7SH0IrdIVYlqqx5sowTJzhtODokpbie0 b/mJz7tgy5zXlts7QEGtKa11FRxTOxgP2EIcQQlN0nb8B6TSuJsynxfJm6lemFfhsYHX ONnqnVM4GIdUamMBkkHwwhA+/q6mARbQJ73Vmr9qxSNQiq3yCHVAvJPZOOObGpKO7hS8 6A3ietkaExq/p800V++Pqtg2jV7Mt2iz/sHPOpJlzJ82oZy3KSr6WHJAaCXuUcbwCo5R hka9kpDPLcvMUKzZOuKixN2tlx0QvgU7cUfsoNwVm4gO6dFrg/1lsvExdgY+TJjPvTwh RO/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=TKK3ref6; 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 e26si9869520edr.306.2021.12.09.01.37.42; Thu, 09 Dec 2021 01:37:42 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=TKK3ref6; 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 1553568AEE4; Thu, 9 Dec 2021 11:37:15 +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 2195768AE6F for ; Thu, 9 Dec 2021 11:37:07 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639042633; x=1670578633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lhPtuWWJJkPhR18CqV+1nhgz7M1f5hdgOqIjrKzuI/A=; b=TKK3ref6t66DoEdIOdsF4oR/eNgtxyrGTFeRt7tseLJvn2ql/xrNHSzo HTA6pU1vQbjwtBjbYXJMtg8m9gNIB+KDfTFWJaTXiTfK+iBN3vTIi5rrJ FdFTNheLjbe+9HUg8ep0eH/5+Qp6w18EbswuP2yebU4QiUpUKu/fFzP2p g0dqZV4AO4OZtln4HyHat4YZGsd9brPAZ1tsRs3FEwfmhsKzk79PJDBlw KE7kJ899dlxPiMQkCdK7sg6j8ViHK9HCbTQ2np0BV/Hxh5LYzHH5tJnZp H0PM+A/QoYL0EoscJsb/mXGk4iU219V/ID95oRloEwrOQAlexMOkrvZY9 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10192"; a="237864454" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="237864454" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 01:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="462064123" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga003.jf.intel.com with ESMTP; 09 Dec 2021 01:37:04 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Dec 2021 17:36:53 +0800 Message-Id: <20211209093654.3149267-3-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209093654.3149267-1-jianhua.wu@intel.com> References: <20211209093654.3149267-1-jianhua.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/4] avfilter/gblur_vulkan: fix incorrect semantics 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: pCegApEPnB0L The input and output are arrays of images, so it's better to use the plural to align them to the variable name of VkDescriptorImageInfo. Signed-off-by: Wu Jianhua --- libavfilter/vf_gblur_vulkan.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c index a2e33d1c90..2dbbbd0965 100644 --- a/libavfilter/vf_gblur_vulkan.c +++ b/libavfilter/vf_gblur_vulkan.c @@ -50,31 +50,31 @@ typedef struct GBlurVulkanContext { } GBlurVulkanContext; static const char gblur_horizontal[] = { - C(0, void gblur(const ivec2 pos, const int index) ) - C(0, { ) - C(1, vec4 sum = texture(input_image[index], pos) * kernel[0]; ) - C(0, ) - C(1, for(int i = 1; i < kernel.length(); i++) { ) - C(2, sum += texture(input_image[index], pos + vec2(i, 0.0)) * kernel[i]; ) - C(2, sum += texture(input_image[index], pos - vec2(i, 0.0)) * kernel[i]; ) - C(1, } ) - C(0, ) - C(1, imageStore(output_image[index], pos, sum); ) - C(0, } ) + C(0, void gblur(const ivec2 pos, const int index) ) + C(0, { ) + C(1, vec4 sum = texture(input_images[index], pos) * kernel[0]; ) + C(0, ) + C(1, for (int i = 1; i < kernel.length(); i++) { ) + C(2, sum += texture(input_images[index], pos + vec2(i, 0.0)) * kernel[i]; ) + C(2, sum += texture(input_images[index], pos - vec2(i, 0.0)) * kernel[i]; ) + C(1, } ) + C(0, ) + C(1, imageStore(output_images[index], pos, sum); ) + C(0, } ) }; static const char gblur_vertical[] = { - C(0, void gblur(const ivec2 pos, const int index) ) - C(0, { ) - C(1, vec4 sum = texture(input_image[index], pos) * kernel[0]; ) - C(0, ) - C(1, for(int i = 1; i < kernel.length(); i++) { ) - C(2, sum += texture(input_image[index], pos + vec2(0.0, i)) * kernel[i]; ) - C(2, sum += texture(input_image[index], pos - vec2(0.0, i)) * kernel[i]; ) - C(1, } ) - C(0, ) - C(1, imageStore(output_image[index], pos, sum); ) - C(0, } ) + C(0, void gblur(const ivec2 pos, const int index) ) + C(0, { ) + C(1, vec4 sum = texture(input_images[index], pos) * kernel[0]; ) + C(0, ) + C(1, for (int i = 1; i < kernel.length(); i++) { ) + C(2, sum += texture(input_images[index], pos + vec2(0.0, i)) * kernel[i]; ) + C(2, sum += texture(input_images[index], pos - vec2(0.0, i)) * kernel[i]; ) + C(1, } ) + C(0, ) + C(1, imageStore(output_images[index], pos, sum); ) + C(0, } ) }; static inline float gaussian(float sigma, float x) @@ -133,14 +133,14 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) FFVulkanDescriptorSetBinding image_descs[] = { { - .name = "input_image", + .name = "input_images", .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .dimensions = 2, .elems = planes, .stages = VK_SHADER_STAGE_COMPUTE_BIT, }, { - .name = "output_image", + .name = "output_images", .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format), .mem_quali = "writeonly", @@ -202,13 +202,13 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); for (int i = 0; i < planes; i++) { GLSLC(0, ); - GLSLF(1, size = imageSize(output_image[%i]); ,i); + GLSLF(1, size = imageSize(output_images[%i]); ,i); GLSLC(1, if (IS_WITHIN(pos, size)) { ); if (s->planes & (1 << i)) { GLSLF(2, gblur(pos, %i); ,i); } else { - GLSLF(2, vec4 res = texture(input_image[%i], pos); ,i); - GLSLF(2, imageStore(output_image[%i], pos, res); ,i); + GLSLF(2, vec4 res = texture(input_images[%i], pos); ,i); + GLSLF(2, imageStore(output_images[%i], pos, res); ,i); } GLSLC(1, } ); } @@ -261,13 +261,13 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); for (int i = 0; i < planes; i++) { GLSLC(0, ); - GLSLF(1, size = imageSize(output_image[%i]); ,i); + GLSLF(1, size = imageSize(output_images[%i]); ,i); GLSLC(1, if (IS_WITHIN(pos, size)) { ); if (s->planes & (1 << i)) { GLSLF(2, gblur(pos, %i); ,i); } else { - GLSLF(2, vec4 res = texture(input_image[%i], pos); ,i); - GLSLF(2, imageStore(output_image[%i], pos, res); ,i); + GLSLF(2, vec4 res = texture(input_images[%i], pos); ,i); + GLSLF(2, imageStore(output_images[%i], pos, res); ,i); } GLSLC(1, } ); } From patchwork Thu Dec 9 09:36:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Jianhua X-Patchwork-Id: 32218 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp106467iog; Thu, 9 Dec 2021 01:37:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5iheb95SueM4f6DZCMErpCvJzxN/AiH9P/A4HDeNtFKD32Li+mD3Z0xffiRP0UYi0p2li X-Received: by 2002:a17:907:60cf:: with SMTP id hv15mr13731192ejc.561.1639042674579; Thu, 09 Dec 2021 01:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639042674; cv=none; d=google.com; s=arc-20160816; b=D7nJiFVZz0N429CiePa+qbgM+/1mDX30nJIKki7ZyhbaUsdr6JdGHh1hircbDLpYTq CUwbOP5rQy1lqS+16hORAEVzpwz86XzCTcbrEuPk2fsD6fDKpoCohhuHnU0apQZu0BDr tf6SNVFno+PSIOCIh9qMdOFn1WSAL8CocmHUO3yxliKOtCq0b3LF8ueg/nGRT9PQvWgm 7qUx22Z3LZq6MrwgDBJPl/sEPqO0GAWVCxG/IWwiMslIqWEUOA6z7xWtqd+HTMysYL7S vLgR7W9Bhh6QYpOw7y56mrxBAlh+KFk/LWXsJCFIGDfmJ2tNLM+Zv9c90YxBIRTaSHt0 spMA== 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:dkim-signature:delivered-to; bh=vJxA5xCJpyH4X5rHAoeSF7+lfmZnEh7NStELpDBzV/w=; b=mGiBa1aGh1f1un0oWBrSfblf0FVtDvskPDIXgNRWPX7JeQQBgN5mTUi85nwpmnRwjt wpwiBYCSVUKYLA1DNwhDGkQdyFse2OybcjLnZ+J0dkaK3+4cnDfuSKdo3nqucgtxoC0f IoSq5RuFRunPxEyiKCaK0DZ3wpiVTzTPzkza6rUPjOpPVLm/7+JYfTCR20XhYRr6QqFK GFKw0KdoW0P/bC73IIMgf2Xgil2LCceU74HR+VWB9wXjgIifdOBZpC8b1/6+27I3xPZ6 whmVI5sU7eG0owHAaUtqiM5EPbbtyFQISLXb8ic3wusN3o5YzsgKUROOVBaMBzEa3nS9 mqbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=cLlfJNzg; 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 u24si7996281edr.523.2021.12.09.01.37.54; Thu, 09 Dec 2021 01:37:54 -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; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=cLlfJNzg; 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 34B8F68AB42; Thu, 9 Dec 2021 11:37:18 +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 9E1E668AB42 for ; Thu, 9 Dec 2021 11:37:11 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639042636; x=1670578636; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lel0yFzdJxT3BaaNFaxoeV6Wu87lmqfqzUENwX3XWAk=; b=cLlfJNzg8blVO4KMjuhiZTmXabb4tbFSCAquTNboIh/VitptLFDwJ6cc eP0XQNR5jXD1mGhjBYK2gynNf/+ZCmqw371c2KVRshzSResZ37A8LHHt2 nBR74s3u73IxvQJBmYJl3xZASDu9xMzlEDigVnx3HVN6AxWKX1odc/j78 gtHmL/W0j0vmrhFxg6P6LWZIq7cFS/D5dB6vFXO55LNDmgXxeYG0+wqUg qCtkmW1/F7IG51BFqzWLhPD+lsN1bC+x6Temr1Ro+vghJ3WM+HZ4xBtki TG+uOQseK/Y5brK7QCmc1V8fFr5fyDM8XcaXItxu7cO5oj4afo3E+wtYD g==; X-IronPort-AV: E=McAfee;i="6200,9189,10192"; a="237864460" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="237864460" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 01:37:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="462064137" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.110]) by orsmga003.jf.intel.com with ESMTP; 09 Dec 2021 01:37:05 -0800 From: Wu Jianhua To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Dec 2021 17:36:54 +0800 Message-Id: <20211209093654.3149267-4-jianhua.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209093654.3149267-1-jianhua.wu@intel.com> References: <20211209093654.3149267-1-jianhua.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/4] avfilter/flip_vulkan: fix incorrect semantics 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: PkoXZj0vuOcj The input and output are arrays of images, so it's better to use the plural to align them to the variable name of VkDescriptorImageInfo. Signed-off-by: Wu Jianhua --- libavfilter/vf_flip_vulkan.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c index 0223786ef1..6a6709e79b 100644 --- a/libavfilter/vf_flip_vulkan.c +++ b/libavfilter/vf_flip_vulkan.c @@ -52,7 +52,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType FFVulkanDescriptorSetBinding image_descs[] = { { - .name = "input_image", + .name = "input_images", .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .dimensions = 2, .elems = planes, @@ -60,7 +60,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType .updater = s->input_images, }, { - .name = "output_image", + .name = "output_images", .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format), .mem_quali = "writeonly", @@ -89,33 +89,33 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in, enum FlipType ff_vk_set_compute_shader_sizes(shd, (int [3]){ CGS, 1, 1 }); RET(ff_vk_add_descriptor_set(vkctx, s->pl, shd, image_descs, FF_ARRAY_ELEMS(image_descs), 0)); - GLSLC(0, void main() ); - GLSLC(0, { ); - GLSLC(1, ivec2 size; ); - GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); + GLSLC(0, void main() ); + GLSLC(0, { ); + GLSLC(1, ivec2 size; ); + GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); ); for (int i = 0; i < planes; i++) { - GLSLC(0, ); - GLSLF(1, size = imageSize(output_image[%i]); ,i); - GLSLC(1, if (IS_WITHIN(pos, size)) { ); + GLSLC(0, ); + GLSLF(1, size = imageSize(output_images[%i]); ,i); + GLSLC(1, if (IS_WITHIN(pos, size)) { ); switch (type) { case FLIP_HORIZONTAL: - GLSLF(2, vec4 res = texture(input_image[%i], ivec2(size.x - pos.x, pos.y)); ,i); + GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.x - pos.x, pos.y)); ,i); break; case FLIP_VERTICAL: - GLSLF(2, vec4 res = texture(input_image[%i], ivec2(pos.x, size.y - pos.y)); ,i); + GLSLF(2, vec4 res = texture(input_images[%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); + GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.xy - pos.xy));, i); break; default: - GLSLF(2, vec4 res = texture(input_image[%i], pos); ,i); + GLSLF(2, vec4 res = texture(input_images[%i], pos); ,i); break; } - GLSLF(2, imageStore(output_image[%i], pos, res); ,i); - GLSLC(1, } ); + GLSLF(2, imageStore(output_images[%i], pos, res); ,i); + GLSLC(1, } ); } - GLSLC(0, } ); + GLSLC(0, } ); RET(ff_vk_compile_shader(vkctx, shd, "main")); RET(ff_vk_init_pipeline_layout(vkctx, s->pl));