PR #22511 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22511
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22511.patch
Passing a struct/union by value can generally be inefficient.
Additionally, when the struct/union is declared to be aligned,
whether it really stays aligned when passed as a parameter by
value is unclear.
This fixes build errors like this, with MSVC targeting 32 bit ARM:
libswscale/ops_chain.h(91): error C2719: 'unnamed-parameter': formal
parameter with requested alignment of 16 won't be aligned
From 3f000d6b5d2c73eec7db8edadcf0199a17a99c13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Sun, 15 Mar 2026 15:56:35 +0200
Subject: [PATCH] swscale/ops_chain: Don't pass an aligned union as parameter
by value
Passing a struct/union by value can generally be inefficient.
Additionally, when the struct/union is declared to be aligned,
whether it really stays aligned when passed as a parameter by
value is unclear.
This fixes build errors like this, with MSVC targeting 32 bit ARM:
libswscale/ops_chain.h(91): error C2719: 'unnamed-parameter': formal
parameter with requested alignment of 16 won't be aligned
---
libswscale/ops_chain.c | 6 +++---
libswscale/ops_chain.h | 10 +++++-----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libswscale/ops_chain.c b/libswscale/ops_chain.c
index 1a4ac539ba..c58cb9c8ea 100644
--- a/libswscale/ops_chain.c
+++ b/libswscale/ops_chain.c
@@ -39,14 +39,14 @@ void ff_sws_op_chain_free_cb(void *ptr)
SwsOpChain *chain = ptr;
for (int i = 0; i < chain->num_impl + 1; i++) {
if (chain->free[i])
- chain->free[i](chain->impl[i].priv);
+ chain->free[i](&chain->impl[i].priv);
}
av_free(chain);
}
int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
- void (*free)(SwsOpPriv), const SwsOpPriv *priv)
+ void (*free)(SwsOpPriv *), const SwsOpPriv *priv)
{
const int idx = chain->num_impl;
if (idx == SWS_MAX_OPS)
@@ -235,7 +235,7 @@ int ff_sws_op_compile_tables(const SwsOpTable *const
tables[], int num_tables,
ret = ff_sws_op_chain_append(chain, best->func, best->free, &priv);
if (ret < 0) {
if (best->free)
- best->free(priv);
+ best->free(&priv);
return ret;
}
diff --git a/libswscale/ops_chain.h b/libswscale/ops_chain.h
index 76ab5d964b..9009936f91 100644
--- a/libswscale/ops_chain.h
+++ b/libswscale/ops_chain.h
@@ -88,7 +88,7 @@ static_assert(offsetof(SwsOpImpl, priv) == 16, "SwsOpImpl
layout mismatch");
typedef struct SwsOpChain {
#define SWS_MAX_OPS 16
SwsOpImpl impl[SWS_MAX_OPS + 1]; /* reserve extra space for the entrypoint
*/
- void (*free[SWS_MAX_OPS + 1])(SwsOpPriv);
+ void (*free[SWS_MAX_OPS + 1])(SwsOpPriv *);
int num_impl;
int cpu_flags; /* set of all used CPU flags */
} SwsOpChain;
@@ -102,7 +102,7 @@ static inline 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)(SwsOpPriv), const SwsOpPriv *priv);
+ void (*free)(SwsOpPriv *), const SwsOpPriv *priv);
typedef struct SwsOpEntry {
/* Kernel metadata; reduced size subset of SwsOp */
@@ -125,12 +125,12 @@ typedef struct SwsOpEntry {
/* Kernel implementation */
SwsFuncPtr func;
int (*setup)(const SwsOp *op, SwsOpPriv *out); /* optional */
- void (*free)(SwsOpPriv priv);
+ void (*free)(SwsOpPriv *priv);
} SwsOpEntry;
-static inline void ff_op_priv_free(SwsOpPriv priv)
+static inline void ff_op_priv_free(SwsOpPriv *priv)
{
- av_free(priv.ptr);
+ av_free(priv->ptr);
}
typedef struct SwsOpTable {
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]