From 16685114d5999a9b5ab3ea537d89fca3669d94c9 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 7 Dec 2019 01:56:56 +0100 Subject: avutil/buffer: add av_buffer_pool_buffer_get_opaque In order to access the original opaque parameter of a buffer in the buffer pool. (The buffer pool implementation overrides the normal opaque parameter but also saves it so it is accessible). v2: add assertion check before dereferencing the BufferPoolEntry. Signed-off-by: Marton Balint --- libavutil/buffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libavutil/buffer.c') diff --git a/libavutil/buffer.c b/libavutil/buffer.c index f0034b026a..6d9cb7428e 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -20,6 +20,7 @@ #include #include +#include "avassert.h" #include "buffer_internal.h" #include "common.h" #include "mem.h" @@ -355,3 +356,10 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool) return ret; } + +void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref) +{ + BufferPoolEntry *buf = ref->buffer->opaque; + av_assert0(buf); + return buf->opaque; +} -- cgit v1.2.3