From patchwork Sun Dec 22 20:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 16926 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1F2CF4493DF for ; Sun, 22 Dec 2019 22:48:31 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED64368A78B; Sun, 22 Dec 2019 22:48:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0DEC568830E for ; Sun, 22 Dec 2019 22:48:25 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 190ECE3ACC; Sun, 22 Dec 2019 21:48:24 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 87GcqY6-fhUl; Sun, 22 Dec 2019 21:48:22 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id DD4DAE224B; Sun, 22 Dec 2019 21:48:21 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Dec 2019 21:48:11 +0100 Message-Id: <20191222204811.30709-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <13350f2c-776f-e4c8-333c-4774b202e401@gmail.com> References: <13350f2c-776f-e4c8-333c-4774b202e401@gmail.com> Subject: [FFmpeg-devel] [PATCHv2 1/2] avutil/buffer: add av_buffer_pool_buffer_get_opaque X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- doc/APIchanges | 3 +++ libavutil/buffer.c | 8 ++++++++ libavutil/buffer.h | 13 +++++++++++++ libavutil/version.h | 4 ++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 401c65a753..5b8d801f06 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -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(). 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; +} diff --git a/libavutil/buffer.h b/libavutil/buffer.h index 73b6bd0b14..e0f94314f4 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -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); + /** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index e18163388d..4de0fa1fc3 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -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, \