mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user