mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-15 11:30:08 +01:00
swscale/ops_chain: add type removed ff_sws_op_chain_free_cb
to avoid pointer casting and UB of calling function with different pointer type. Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
@@ -98,7 +98,7 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
|
|||||||
.block_size = SWS_BLOCK_SIZE,
|
.block_size = SWS_BLOCK_SIZE,
|
||||||
.cpu_flags = chain->cpu_flags,
|
.cpu_flags = chain->cpu_flags,
|
||||||
.priv = chain,
|
.priv = chain,
|
||||||
.free = (void (*)(void *)) ff_sws_op_chain_free,
|
.free = ff_sws_op_chain_free_cb,
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,11 +31,12 @@ SwsOpChain *ff_sws_op_chain_alloc(void)
|
|||||||
return av_mallocz(sizeof(SwsOpChain));
|
return av_mallocz(sizeof(SwsOpChain));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ff_sws_op_chain_free(SwsOpChain *chain)
|
void ff_sws_op_chain_free_cb(void *ptr)
|
||||||
{
|
{
|
||||||
if (!chain)
|
if (!ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
SwsOpChain *chain = ptr;
|
||||||
for (int i = 0; i < chain->num_impl + 1; i++) {
|
for (int i = 0; i < chain->num_impl + 1; i++) {
|
||||||
if (chain->free[i])
|
if (chain->free[i])
|
||||||
chain->free[i](chain->impl[i].priv.ptr);
|
chain->free[i](chain->impl[i].priv.ptr);
|
||||||
|
|||||||
@@ -86,7 +86,11 @@ typedef struct SwsOpChain {
|
|||||||
} SwsOpChain;
|
} SwsOpChain;
|
||||||
|
|
||||||
SwsOpChain *ff_sws_op_chain_alloc(void);
|
SwsOpChain *ff_sws_op_chain_alloc(void);
|
||||||
void ff_sws_op_chain_free(SwsOpChain *chain);
|
void ff_sws_op_chain_free_cb(void *chain);
|
||||||
|
static inline void ff_sws_op_chain_free(SwsOpChain *chain)
|
||||||
|
{
|
||||||
|
ff_sws_op_chain_free_cb(chain);
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns 0 on success, or a negative error code. */
|
/* Returns 0 on success, or a negative error code. */
|
||||||
int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
|
int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func,
|
||||||
|
|||||||
@@ -649,7 +649,7 @@ static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
|
|||||||
|
|
||||||
*out = (SwsCompiledOp) {
|
*out = (SwsCompiledOp) {
|
||||||
.priv = chain,
|
.priv = chain,
|
||||||
.free = (void (*)(void *)) ff_sws_op_chain_free,
|
.free = ff_sws_op_chain_free_cb,
|
||||||
|
|
||||||
/* Use at most two full YMM regs during the widest precision section */
|
/* Use at most two full YMM regs during the widest precision section */
|
||||||
.block_size = 2 * FFMIN(mmsize, 32) / ff_sws_op_list_max_size(ops),
|
.block_size = 2 * FFMIN(mmsize, 32) / ff_sws_op_list_max_size(ops),
|
||||||
|
|||||||
Reference in New Issue
Block a user