From patchwork Mon Jun 1 17:25:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 20062 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 7150F44B694 for ; Mon, 1 Jun 2020 20:26:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C74D68A0C3; Mon, 1 Jun 2020 20:26:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7706B689E53 for ; Mon, 1 Jun 2020 20:26:29 +0300 (EEST) Received: by mail-qt1-f196.google.com with SMTP id c12so8275264qtq.11 for ; Mon, 01 Jun 2020 10:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=sJCFO7z9GLF8Z1pwBOZeYXU6wUEKOQ6b/ypDI83U2MA=; b=bph59dyCcdv/zKxYIqGI3wyMyMaztaM6OKbVWClyPVPUFUc9S0Hk/xals03mDWkdCv CVO7cjjpPWvDEnwuPBBZ6LwL7ZlyXRq/sdxeN3J+eKHVi4Q1mIzAPdmOKfjaqXsiwvN1 FnR9HLIEud3JqZGHNpGce+deNeVwoOEhB+vUEy9eY3NkdISJhMeyzymw2XNP/z6G5v4C g5qLa8Y+VZzLV952qwffxZJwJOzpHevM+kKbfS30UA+iIvdmeOooP1KBCUTQN3oLJRcT 3uMI4UUqLZoMU6TSZpAhBRyk/VQEMRTYeChheMMbj0DbU3+VVrQ1oprXracB5moGMKi0 7f8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=sJCFO7z9GLF8Z1pwBOZeYXU6wUEKOQ6b/ypDI83U2MA=; b=OQ5alBVJS3tMdCsU222NjRUFqeDczDHbd0FeM+AtRbK6NrLrON5FJ227aSfTHJH/rs iKF7lWT5cj7v8nlRWEe8EJDrlWd0LPMSHr60TyZk5V+X3I6dlogRz5KBpZRQRE/d+Osx E8y5ng2b/xyosloSyY3NOFnXRlKC9ifq8fpPTlwUFCSVP0B19vLtpJTJ0gsAJ/4Or5bz 3cVJ7TqrXfUoREoGbuZtqz2n4mDSWoUL8Y73rs0lTp+BRGtnYy8MiVM+wonNUGqh2ZF5 N8MPXfShe7cnJzw4//zX8l4KUUCEg4bB5oKZVtenBAJoJ7oKzO8w4HKLD5QBXjGxzasO 4kXw== X-Gm-Message-State: AOAM530946PKWMZYbbp2GaPVYcPR5BfAhXMawtIWwEuU+HypeLiS+n9r WkAOiKJXIDV2jHR/DUG4EjYIUs1O X-Google-Smtp-Source: ABdhPJxcFiMgE9Tf8Q/uu1v11LkZaWETBqluh/saXmwQCgzLFmJSE+oEvkIas01fLxx6B7zgIAEkAw== X-Received: by 2002:ac8:c8b:: with SMTP id n11mr23796861qti.49.1591032387555; Mon, 01 Jun 2020 10:26:27 -0700 (PDT) Received: from localhost.localdomain ([181.23.72.208]) by smtp.gmail.com with ESMTPSA id g132sm1839473qkb.78.2020.06.01.10.26.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 10:26:26 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 Jun 2020 14:25:36 -0300 Message-Id: <20200601172539.17081-1-jamrial@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4 v2] avutil/buffer: change public function and struct size parameter types to size_t 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- No changes since v1. doc/APIchanges | 4 ++++ libavutil/buffer.c | 25 +++++++++++++++++++++++++ libavutil/buffer.h | 31 +++++++++++++++++++++++++++++++ libavutil/buffer_internal.h | 13 +++++++++++++ libavutil/version.h | 3 +++ 5 files changed, 76 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index fb5534b5f5..9de23744c0 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-06-xx - xxxxxxxxxx + Change AVBufferRef related function and struct size parameter and fields + type to size_t at next major bump. + 2020-xx-xx - xxxxxxxxxx - lavc 58.88.100 - avcodec.h codec.h Move AVCodec-related public API to new header codec.h. diff --git a/libavutil/buffer.c b/libavutil/buffer.c index 6d9cb7428e..0a29430381 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -26,7 +26,11 @@ #include "mem.h" #include "thread.h" +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_create(uint8_t *data, int size, +#else +AVBufferRef *av_buffer_create(uint8_t *data, size_t size, +#endif void (*free)(void *opaque, uint8_t *data), void *opaque, int flags) { @@ -65,7 +69,11 @@ void av_buffer_default_free(void *opaque, uint8_t *data) av_free(data); } +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_alloc(int size) +#else +AVBufferRef *av_buffer_alloc(size_t size) +#endif { AVBufferRef *ret = NULL; uint8_t *data = NULL; @@ -81,7 +89,11 @@ AVBufferRef *av_buffer_alloc(int size) return ret; } +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_allocz(int size) +#else +AVBufferRef *av_buffer_allocz(size_t size) +#endif { AVBufferRef *ret = av_buffer_alloc(size); if (!ret) @@ -167,7 +179,11 @@ int av_buffer_make_writable(AVBufferRef **pbuf) return 0; } +#if FF_API_BUFFER_SIZE_T int av_buffer_realloc(AVBufferRef **pbuf, int size) +#else +int av_buffer_realloc(AVBufferRef **pbuf, size_t size) +#endif { AVBufferRef *buf = *pbuf; uint8_t *tmp; @@ -216,8 +232,13 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size) return 0; } +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init2(int size, void *opaque, AVBufferRef* (*alloc)(void *opaque, int size), +#else +AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, + AVBufferRef* (*alloc)(void *opaque, size_t size), +#endif void (*pool_free)(void *opaque)) { AVBufferPool *pool = av_mallocz(sizeof(*pool)); @@ -236,7 +257,11 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque, return pool; } +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)) +#else +AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size)) +#endif { AVBufferPool *pool = av_mallocz(sizeof(*pool)); if (!pool) diff --git a/libavutil/buffer.h b/libavutil/buffer.h index e0f94314f4..547c376439 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -27,6 +27,8 @@ #include +#include "version.h" + /** * @defgroup lavu_buffer AVBuffer * @ingroup lavu_data @@ -90,7 +92,11 @@ typedef struct AVBufferRef { /** * Size of data in bytes. */ +#if FF_API_BUFFER_SIZE_T int size; +#else + size_t size; +#endif } AVBufferRef; /** @@ -98,13 +104,21 @@ typedef struct AVBufferRef { * * @return an AVBufferRef of given size or NULL when out of memory */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_alloc(int size); +#else +AVBufferRef *av_buffer_alloc(size_t size); +#endif /** * Same as av_buffer_alloc(), except the returned buffer will be initialized * to zero. */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_allocz(int size); +#else +AVBufferRef *av_buffer_alloc(size_t size); +#endif /** * Always treat the buffer as read-only, even when it has only one @@ -127,7 +141,11 @@ AVBufferRef *av_buffer_allocz(int size); * * @return an AVBufferRef referring to data on success, NULL on failure. */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_create(uint8_t *data, int size, +#else +AVBufferRef *av_buffer_create(uint8_t *data, size_t size, +#endif void (*free)(void *opaque, uint8_t *data), void *opaque, int flags); @@ -195,7 +213,11 @@ int av_buffer_make_writable(AVBufferRef **buf); * reference to it (i.e. the one passed to this function). In all other cases * a new buffer is allocated and the data is copied. */ +#if FF_API_BUFFER_SIZE_T int av_buffer_realloc(AVBufferRef **buf, int size); +#else +int av_buffer_realloc(AVBufferRef **buf, size_t size); +#endif /** * @} @@ -246,7 +268,11 @@ typedef struct AVBufferPool AVBufferPool; * (av_buffer_alloc()). * @return newly created buffer pool on success, NULL on error. */ +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); +#else +AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size)); +#endif /** * Allocate and initialize a buffer pool with a more complex allocator. @@ -262,8 +288,13 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); * data. * @return newly created buffer pool on success, NULL on error. */ +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init2(int size, void *opaque, AVBufferRef* (*alloc)(void *opaque, int size), +#else +AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, + AVBufferRef* (*alloc)(void *opaque, size_t size), +#endif void (*pool_free)(void *opaque)); /** diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h index 54b67047e5..c2f9342422 100644 --- a/libavutil/buffer_internal.h +++ b/libavutil/buffer_internal.h @@ -36,7 +36,11 @@ struct AVBuffer { uint8_t *data; /**< data described by this buffer */ +#if FF_API_BUFFER_SIZE_T int size; /**< size of data in bytes */ +#else + size_t size; /**< size of data in bytes */ +#endif /** * number of existing AVBufferRef instances referring to this buffer @@ -88,10 +92,19 @@ struct AVBufferPool { */ atomic_uint refcount; +#if FF_API_BUFFER_SIZE_T int size; +#else + size_t size; +#endif void *opaque; +#if FF_API_BUFFER_SIZE_T AVBufferRef* (*alloc)(int size); AVBufferRef* (*alloc2)(void *opaque, int size); +#else + AVBufferRef* (*alloc)(size_t size); + AVBufferRef* (*alloc2)(void *opaque, size_t size); +#endif void (*pool_free)(void *opaque); }; diff --git a/libavutil/version.h b/libavutil/version.h index 7acecf5a97..431eb1d571 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -129,6 +129,9 @@ #ifndef FF_API_PSEUDOPAL #define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) #endif +#ifndef FF_API_BUFFER_SIZE_T +#define FF_API_BUFFER_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) +#endif /**