]> git.sesse.net Git - ffmpeg/commitdiff
avutil/buffer: add av_buffer_pool_buffer_get_opaque
authorMarton Balint <cus@passwd.hu>
Sat, 7 Dec 2019 00:56:56 +0000 (01:56 +0100)
committerMarton Balint <cus@passwd.hu>
Wed, 25 Dec 2019 23:47:24 +0000 (00:47 +0100)
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 <cus@passwd.hu>
doc/APIchanges
libavutil/buffer.c
libavutil/buffer.h
libavutil/version.h

index 401c65a753459b8bd6d64309e90ce804fe27e626..5b8d801f06acf93bc0b1d90f02e9fa0d995a335d 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2019-12-xx - xxxxxxxxxx - lavu 56.37.100 - buffer.h
+  Add av_buffer_pool_buffer_get_opaque().
+
 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
   Add av_expr_count_vars().
 
index f0034b026a497edea978b610be0a112fc868a152..6d9cb7428e35cf8bf441a485b16278618a6d61ec 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <string.h>
 
+#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;
+}
index 73b6bd0b148e6e6018845a0df928d8d20cef115a..e0f94314f4566251a9b12199744adbab4fba2a3c 100644 (file)
@@ -284,6 +284,19 @@ void av_buffer_pool_uninit(AVBufferPool **pool);
  */
 AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
 
+/**
+ * Query the original opaque parameter of an allocated buffer in the pool.
+ *
+ * @param ref a buffer reference to a buffer returned by av_buffer_pool_get.
+ * @return the opaque parameter set by the buffer allocator function of the
+ *         buffer pool.
+ *
+ * @note the opaque parameter of ref is used by the buffer pool implementation,
+ * therefore you have to use this function to access the original opaque
+ * parameter of an allocated buffer.
+ */
+void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref);
+
 /**
  * @}
  */
index e18163388deab4c9329082cd91d8c108cc96a637..4de0fa1fc37b4079b283720811fc16e21b02beb1 100644 (file)
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  36
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  37
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \