Use default size 1024. Benchmark: time ./ffmpeg -f s16le -ac 5 -ar 48000 -t 10000 -i /dev/zero \ -af "aformat=s16p, asetnsamples=256" -f null - old: 27.616s new: 22.079s
Signed-off-by: Muhammad Faiz <mfc...@gmail.com> --- libavutil/buffer.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavutil/buffer.c b/libavutil/buffer.c index 8d1aa5fa84..6dd3f0441b 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -24,6 +24,11 @@ #include "common.h" #include "mem.h" #include "thread.h" +#include "staticpool.h" + +FF_STATICPOOL_DECLARE(AVBufferRef, 1024) +FF_STATICPOOL_DECLARE(AVBuffer, 1024) +FF_STATICPOOL_DECLARE(BufferPoolEntry, 1024) AVBufferRef *av_buffer_create(uint8_t *data, int size, void (*free)(void *opaque, uint8_t *data), @@ -32,7 +37,7 @@ AVBufferRef *av_buffer_create(uint8_t *data, int size, AVBufferRef *ref = NULL; AVBuffer *buf = NULL; - buf = av_mallocz(sizeof(*buf)); + buf = FF_STATICPOOL_MALLOCZ(AVBuffer); if (!buf) return NULL; @@ -46,9 +51,9 @@ AVBufferRef *av_buffer_create(uint8_t *data, int size, if (flags & AV_BUFFER_FLAG_READONLY) buf->flags |= BUFFER_FLAG_READONLY; - ref = av_mallocz(sizeof(*ref)); + ref = FF_STATICPOOL_MALLOCZ(AVBufferRef); if (!ref) { - av_freep(&buf); + FF_STATICPOOL_FREEP(AVBuffer, &buf); return NULL; } @@ -92,7 +97,7 @@ AVBufferRef *av_buffer_allocz(int size) AVBufferRef *av_buffer_ref(AVBufferRef *buf) { - AVBufferRef *ret = av_mallocz(sizeof(*ret)); + AVBufferRef *ret = FF_STATICPOOL_MALLOCZ(AVBufferRef); if (!ret) return NULL; @@ -112,13 +117,13 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef **src) if (src) { **dst = **src; - av_freep(src); + FF_STATICPOOL_FREEP(AVBufferRef, src); } else - av_freep(dst); + FF_STATICPOOL_FREEP(AVBufferRef, dst); if (atomic_fetch_add_explicit(&b->refcount, -1, memory_order_acq_rel) == 1) { b->free(b->opaque, b->data); - av_freep(&b); + FF_STATICPOOL_FREEP(AVBuffer, &b); } } @@ -262,7 +267,7 @@ static void buffer_pool_free(AVBufferPool *pool) pool->pool = buf->next; buf->free(buf->opaque, buf->data); - av_freep(&buf); + FF_STATICPOOL_FREEP(BufferPoolEntry, &buf); } ff_mutex_destroy(&pool->mutex); @@ -314,7 +319,7 @@ static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool) if (!ret) return NULL; - buf = av_mallocz(sizeof(*buf)); + buf = FF_STATICPOOL_MALLOCZ(BufferPoolEntry); if (!buf) { av_buffer_unref(&ret); return NULL; -- 2.13.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel