diff mbox series

[FFmpeg-devel,08/10] avfilter/scale_vulkan: call av_pix_fmt_count_planes only one time

Message ID 20211118042449.8038-8-jianhua.wu@intel.com
State New
Headers show
Series [FFmpeg-devel,01/10] avfilter/avgblur_vulkan: check if shader is created with success
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wu Jianhua Nov. 18, 2021, 4:24 a.m. UTC
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
---
 libavfilter/vf_scale_vulkan.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

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,