PR #20413 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20413
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20413.patch

This fixes the following compiler error, if compiling with MSVC
for ARM (32 bit):

    src/libswscale/ops_chain.c(48): error C2719: 'priv': formal parameter with 
requested alignment of 16 won't be aligned

This change shouldn't affect the performance of this operation
(which in itself probably isn't relevant); instead of copying the
contents of the SwsOpPriv struct from the stack as parameter,
it gets copied straight from the caller function's stack frame
instead.

Separately from this issue, MSVC 17.8 and 17.9 end up in an
internal compiler error when compiling libswscale/ops.c, but
older and newer versions do compile it successfully.


From 04e504941d181d9f863ba487defd49080787c7a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Wed, 3 Sep 2025 14:03:28 +0300
Subject: [PATCH] swscale: Don't pass a concrete SwsOpPriv as parameter

This fixes the following compiler error, if compiling with MSVC
for ARM (32 bit):

    src/libswscale/ops_chain.c(48): error C2719: 'priv': formal parameter with 
requested alignment of 16 won't be aligned

This change shouldn't affect the performance of this operation
(which in itself probably isn't relevant); instead of copying the
contents of the SwsOpPriv struct from the stack as parameter,
it gets copied straight from the caller function's stack frame
instead.

Separately from this issue, MSVC 17.8 and 17.9 end up in an
internal compiler error when compiling libswscale/ops.c, but
older and newer versions do compile it successfully.
---
 libswscale/ops_chain.c | 6 +++---
 libswscale/ops_chain.h | 2 +-
 libswscale/x86/ops.c   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libswscale/ops_chain.c b/libswscale/ops_chain.c
index 5d138a9e46..80162507b0 100644
--- a/libswscale/ops_chain.c
+++ b/libswscale/ops_chain.c
@@ -45,7 +45,7 @@ void ff_sws_op_chain_free(SwsOpChain *chain)
 }
 
 int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
-                           void (*free)(void *), SwsOpPriv priv)
+                           void (*free)(void *), const SwsOpPriv *priv)
 {
     const int idx = chain->num_impl;
     if (idx == SWS_MAX_OPS)
@@ -53,7 +53,7 @@ int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
 
     av_assert1(func);
     chain->impl[idx].cont = func;
-    chain->impl[idx + 1].priv = priv;
+    chain->impl[idx + 1].priv = *priv;
     chain->free[idx + 1] = free;
     chain->num_impl++;
     return 0;
@@ -231,7 +231,7 @@ int ff_sws_op_compile_tables(const SwsOpTable *const 
tables[], int num_tables,
     }
 
     chain->cpu_flags |= best_cpu_flags;
-    ret = ff_sws_op_chain_append(chain, best->func, best->free, priv);
+    ret = ff_sws_op_chain_append(chain, best->func, best->free, &priv);
     if (ret < 0) {
         if (best->free)
             best->free(&priv);
diff --git a/libswscale/ops_chain.h b/libswscale/ops_chain.h
index 777d8e13c1..ceff7e4e7e 100644
--- a/libswscale/ops_chain.h
+++ b/libswscale/ops_chain.h
@@ -90,7 +90,7 @@ void ff_sws_op_chain_free(SwsOpChain *chain);
 
 /* Returns 0 on success, or a negative error code. */
 int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
-                           void (*free)(void *), SwsOpPriv priv);
+                           void (*free)(void *), const SwsOpPriv *priv);
 
 typedef struct SwsOpEntry {
     /* Kernel metadata; reduced size subset of SwsOp */
diff --git a/libswscale/x86/ops.c b/libswscale/x86/ops.c
index b3fe5fb014..8704f77227 100644
--- a/libswscale/x86/ops.c
+++ b/libswscale/x86/ops.c
@@ -695,7 +695,7 @@ static int compile(SwsContext *ctx, SwsOpList *ops, 
SwsCompiledOp *out)
         SWS_DECL_FUNC(NAME);                                    \
         void NAME##_return(void);                               \
         ret = ff_sws_op_chain_append(chain, NAME##_return,      \
-                                     NULL, (SwsOpPriv) {0});    \
+                                     NULL, &(SwsOpPriv) {0});   \
         out->func = NAME;                                       \
     } while (0)
 
-- 
2.49.1

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

Reply via email to