• Home
  • Raw
  • Download

Lines Matching full:pool

249     AVBufferPool *pool = av_mallocz(sizeof(*pool));  in av_buffer_pool_init2()  local
250 if (!pool) in av_buffer_pool_init2()
253 ff_mutex_init(&pool->mutex, NULL); in av_buffer_pool_init2()
255 pool->size = size; in av_buffer_pool_init2()
256 pool->opaque = opaque; in av_buffer_pool_init2()
257 pool->alloc2 = alloc; in av_buffer_pool_init2()
258 pool->alloc = av_buffer_alloc; // fallback in av_buffer_pool_init2()
259 pool->pool_free = pool_free; in av_buffer_pool_init2()
261 atomic_init(&pool->refcount, 1); in av_buffer_pool_init2()
263 return pool; in av_buffer_pool_init2()
268 AVBufferPool *pool = av_mallocz(sizeof(*pool)); in av_buffer_pool_init() local
269 if (!pool) in av_buffer_pool_init()
272 ff_mutex_init(&pool->mutex, NULL); in av_buffer_pool_init()
274 pool->size = size; in av_buffer_pool_init()
275 pool->alloc = alloc ? alloc : av_buffer_alloc; in av_buffer_pool_init()
277 atomic_init(&pool->refcount, 1); in av_buffer_pool_init()
279 return pool; in av_buffer_pool_init()
282 static void buffer_pool_flush(AVBufferPool *pool) in buffer_pool_flush() argument
284 while (pool->pool) { in buffer_pool_flush()
285 BufferPoolEntry *buf = pool->pool; in buffer_pool_flush()
286 pool->pool = buf->next; in buffer_pool_flush()
294 * This function gets called when the pool has been uninited and
297 static void buffer_pool_free(AVBufferPool *pool) in buffer_pool_free() argument
299 buffer_pool_flush(pool); in buffer_pool_free()
300 ff_mutex_destroy(&pool->mutex); in buffer_pool_free()
302 if (pool->pool_free) in buffer_pool_free()
303 pool->pool_free(pool->opaque); in buffer_pool_free()
305 av_freep(&pool); in buffer_pool_free()
310 AVBufferPool *pool; in av_buffer_pool_uninit() local
314 pool = *ppool; in av_buffer_pool_uninit()
317 ff_mutex_lock(&pool->mutex); in av_buffer_pool_uninit()
318 buffer_pool_flush(pool); in av_buffer_pool_uninit()
319 ff_mutex_unlock(&pool->mutex); in av_buffer_pool_uninit()
321 if (atomic_fetch_sub_explicit(&pool->refcount, 1, memory_order_acq_rel) == 1) in av_buffer_pool_uninit()
322 buffer_pool_free(pool); in av_buffer_pool_uninit()
328 AVBufferPool *pool = buf->pool; in pool_release_buffer() local
331 memset(buf->data, FF_MEMORY_POISON, pool->size); in pool_release_buffer()
333 ff_mutex_lock(&pool->mutex); in pool_release_buffer()
334 buf->next = pool->pool; in pool_release_buffer()
335 pool->pool = buf; in pool_release_buffer()
336 ff_mutex_unlock(&pool->mutex); in pool_release_buffer()
338 if (atomic_fetch_sub_explicit(&pool->refcount, 1, memory_order_acq_rel) == 1) in pool_release_buffer()
339 buffer_pool_free(pool); in pool_release_buffer()
343 * it is returned to the pool on free */
344 static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool) in pool_alloc_buffer() argument
349 av_assert0(pool->alloc || pool->alloc2); in pool_alloc_buffer()
351 ret = pool->alloc2 ? pool->alloc2(pool->opaque, pool->size) : in pool_alloc_buffer()
352 pool->alloc(pool->size); in pool_alloc_buffer()
365 buf->pool = pool; in pool_alloc_buffer()
373 AVBufferRef *av_buffer_pool_get(AVBufferPool *pool) in av_buffer_pool_get() argument
378 ff_mutex_lock(&pool->mutex); in av_buffer_pool_get()
379 buf = pool->pool; in av_buffer_pool_get()
381 ret = av_buffer_create(buf->data, pool->size, pool_release_buffer, in av_buffer_pool_get()
384 pool->pool = buf->next; in av_buffer_pool_get()
388 ret = pool_alloc_buffer(pool); in av_buffer_pool_get()
390 ff_mutex_unlock(&pool->mutex); in av_buffer_pool_get()
393 atomic_fetch_add_explicit(&pool->refcount, 1, memory_order_relaxed); in av_buffer_pool_get()