You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-25 14:23:15 +02:00
avcodec/refstruct: Allow to always return zeroed pool entries
This is in preparation for the following commit. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -285,6 +285,10 @@ static int refstruct_pool_get_ext(void *datap, FFRefStructPool *pool)
|
||||
}
|
||||
}
|
||||
atomic_fetch_add_explicit(&pool->refcount, 1, memory_order_relaxed);
|
||||
|
||||
if (pool->pool_flags & FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME)
|
||||
memset(ret, 0, pool->size);
|
||||
|
||||
memcpy(datap, &ret, sizeof(ret));
|
||||
|
||||
return 0;
|
||||
@ -357,6 +361,12 @@ FFRefStructPool *ff_refstruct_pool_alloc_ext_c(size_t size, unsigned flags,
|
||||
flags &= ~FF_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR;
|
||||
pool->pool_flags = flags;
|
||||
|
||||
if (flags & FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME) {
|
||||
// We will zero the buffer before every use, so zeroing
|
||||
// upon allocating the buffer is unnecessary.
|
||||
pool->entry_flags |= FF_REFSTRUCT_FLAG_NO_ZEROING;
|
||||
}
|
||||
|
||||
atomic_init(&pool->refcount, 1);
|
||||
|
||||
err = ff_mutex_init(&pool->mutex, NULL);
|
||||
|
Reference in New Issue
Block a user