PR #25526 opened by Ramiro Polla (ramiro)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25526
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25526.patch


>From fc620476ec7301591cd04a30859e4e2472c514a8 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <[email protected]>
Date: Tue, 27 Oct 2026 15:29:40 +0100
Subject: [PATCH 1/2] swscale/tests/swscale: factor plane count out of loop
 condition

---
 libswscale/tests/swscale.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 10533722c7e..869a24472b5 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -279,7 +279,8 @@ static int get_buffer(AVFrame *frame, int align)
     if (ret < 0 || align >= 0)
         return ret;
 
-    for (int p = 0; p < av_pix_fmt_count_planes(frame->format); p++) {
+    const int nb_planes = av_pix_fmt_count_planes(frame->format);
+    for (int p = 0; p < nb_planes; p++) {
         const int is_chroma = p == 1 || p == 2;
         const int h = is_chroma ? AV_CEIL_RSHIFT(frame->height, 
desc->log2_chroma_h)
                                 : frame->height;
-- 
2.54.0


>From e495c422e544804d01d0bee163ddc0ada3846b28 Mon Sep 17 00:00:00 2001
From: Ramiro Polla <[email protected]>
Date: Tue, 27 Oct 2026 15:30:46 +0100
Subject: [PATCH 2/2] swscale/vulkan/ops: factor plane count out of loop
 conditions

---
 libswscale/vulkan/ops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
index 5492a9390e5..18192e03426 100644
--- a/libswscale/vulkan/ops.c
+++ b/libswscale/vulkan/ops.c
@@ -773,7 +773,8 @@ static int get_view_fmts(VkFormat 
view_fmts[AV_NUM_DATA_POINTERS],
     if (!vk_fmts)
         return AVERROR(ENOTSUP);
 
-    for (int i = 0; i < av_pix_fmt_count_planes(fmt); i++) {
+    const int nb_planes = av_pix_fmt_count_planes(fmt);
+    for (int i = 0; i < nb_planes; i++) {
         view_fmts[i] = word_fmt ? word_fmt : ff_vk_map_fmt_to_rep(vk_fmts[i], 
rep);
         if (view_fmts[i] == VK_FORMAT_UNDEFINED)
             return AVERROR(ENOTSUP);
@@ -786,8 +787,9 @@ static int get_view_fmts(VkFormat 
view_fmts[AV_NUM_DATA_POINTERS],
  * have to cover the highest plane referenced, not just the plane count. */
 static int rw_op_img_count(const SwsOp *op, const uint8_t *planes)
 {
+    const int nb_planes = ff_sws_rw_op_planes(op);
     int count = 0;
-    for (int i = 0; i < ff_sws_rw_op_planes(op); i++)
+    for (int i = 0; i < nb_planes; i++)
         count = FFMAX(count, planes[i] + 1);
     return count;
 }
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to