Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-14 15:59:32 +0300
committerJames Almer <jamrial@gmail.com>2021-04-27 16:43:13 +0300
commitef6a9e5e311f09fa8032974fa4d0c1e166a959bb (patch)
treeb9b1893c45771cde9f36853685a5bc8a6b5cf27c /libavutil
parent985c0dac674846721ec8ff23344c16ac7d1c9a1e (diff)
avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/buffer.c14
-rw-r--r--libavutil/buffer.h29
-rw-r--r--libavutil/buffer_internal.h8
-rw-r--r--libavutil/detection_bbox.c4
-rw-r--r--libavutil/frame.c2
-rw-r--r--libavutil/frame.h8
-rw-r--r--libavutil/hwcontext_cuda.c2
-rw-r--r--libavutil/hwcontext_d3d11va.c2
-rw-r--r--libavutil/hwcontext_dxva2.c2
-rw-r--r--libavutil/hwcontext_opencl.c2
-rw-r--r--libavutil/hwcontext_qsv.c2
-rw-r--r--libavutil/hwcontext_vaapi.c2
-rw-r--r--libavutil/hwcontext_vdpau.c2
-rw-r--r--libavutil/hwcontext_vulkan.c2
-rw-r--r--libavutil/internal.h7
-rw-r--r--libavutil/version.h3
-rw-r--r--libavutil/video_enc_params.c4
17 files changed, 20 insertions, 75 deletions
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 858633e8c7..b13eeadffb 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -26,7 +26,7 @@
#include "mem.h"
#include "thread.h"
-AVBufferRef *av_buffer_create(uint8_t *data, buffer_size_t size,
+AVBufferRef *av_buffer_create(uint8_t *data, size_t size,
void (*free)(void *opaque, uint8_t *data),
void *opaque, int flags)
{
@@ -64,7 +64,7 @@ void av_buffer_default_free(void *opaque, uint8_t *data)
av_free(data);
}
-AVBufferRef *av_buffer_alloc(buffer_size_t size)
+AVBufferRef *av_buffer_alloc(size_t size)
{
AVBufferRef *ret = NULL;
uint8_t *data = NULL;
@@ -80,7 +80,7 @@ AVBufferRef *av_buffer_alloc(buffer_size_t size)
return ret;
}
-AVBufferRef *av_buffer_allocz(buffer_size_t size)
+AVBufferRef *av_buffer_allocz(size_t size)
{
AVBufferRef *ret = av_buffer_alloc(size);
if (!ret)
@@ -166,7 +166,7 @@ int av_buffer_make_writable(AVBufferRef **pbuf)
return 0;
}
-int av_buffer_realloc(AVBufferRef **pbuf, buffer_size_t size)
+int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
{
AVBufferRef *buf = *pbuf;
uint8_t *tmp;
@@ -242,8 +242,8 @@ int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src)
return 0;
}
-AVBufferPool *av_buffer_pool_init2(buffer_size_t size, void *opaque,
- AVBufferRef* (*alloc)(void *opaque, buffer_size_t size),
+AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque,
+ AVBufferRef* (*alloc)(void *opaque, size_t size),
void (*pool_free)(void *opaque))
{
AVBufferPool *pool = av_mallocz(sizeof(*pool));
@@ -263,7 +263,7 @@ AVBufferPool *av_buffer_pool_init2(buffer_size_t size, void *opaque,
return pool;
}
-AVBufferPool *av_buffer_pool_init(buffer_size_t size, AVBufferRef* (*alloc)(buffer_size_t size))
+AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size))
{
AVBufferPool *pool = av_mallocz(sizeof(*pool));
if (!pool)
diff --git a/libavutil/buffer.h b/libavutil/buffer.h
index 241a80ed67..63ab87eb72 100644
--- a/libavutil/buffer.h
+++ b/libavutil/buffer.h
@@ -93,11 +93,7 @@ typedef struct AVBufferRef {
/**
* Size of data in bytes.
*/
-#if FF_API_BUFFER_SIZE_T
- int size;
-#else
size_t size;
-#endif
} AVBufferRef;
/**
@@ -105,21 +101,13 @@ 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_allocz(size_t size);
-#endif
/**
* Always treat the buffer as read-only, even when it has only one
@@ -142,11 +130,7 @@ AVBufferRef *av_buffer_allocz(size_t 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);
@@ -214,11 +198,7 @@ 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
/**
* Ensure dst refers to the same data as src.
@@ -285,11 +265,7 @@ 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.
@@ -306,13 +282,8 @@ AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size
* data. May be NULL.
* @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 d902772ed3..839dc05f8f 100644
--- a/libavutil/buffer_internal.h
+++ b/libavutil/buffer_internal.h
@@ -33,7 +33,7 @@
struct AVBuffer {
uint8_t *data; /**< data described by this buffer */
- buffer_size_t size; /**< size of data in bytes */
+ size_t size; /**< size of data in bytes */
/**
* number of existing AVBufferRef instances referring to this buffer
@@ -90,10 +90,10 @@ struct AVBufferPool {
*/
atomic_uint refcount;
- buffer_size_t size;
+ size_t size;
void *opaque;
- AVBufferRef* (*alloc)(buffer_size_t size);
- AVBufferRef* (*alloc2)(void *opaque, buffer_size_t size);
+ AVBufferRef* (*alloc)(size_t size);
+ AVBufferRef* (*alloc2)(void *opaque, size_t size);
void (*pool_free)(void *opaque);
};
diff --git a/libavutil/detection_bbox.c b/libavutil/detection_bbox.c
index 0750ffac6a..40711e6aa9 100644
--- a/libavutil/detection_bbox.c
+++ b/libavutil/detection_bbox.c
@@ -54,10 +54,6 @@ AVDetectionBBoxHeader *av_detection_bbox_create_side_data(AVFrame *frame, uint32
header = av_detection_bbox_alloc(nb_bboxes, &size);
if (!header)
return NULL;
- if (size > INT_MAX) {
- av_freep(&header);
- return NULL;
- }
buf = av_buffer_create((uint8_t *)header, size, NULL, NULL, 0);
if (!buf) {
av_freep(&header);
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5bc8ab36df..2ec59b44b1 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -603,7 +603,7 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
enum AVFrameSideDataType type,
- buffer_size_t size)
+ size_t size)
{
AVFrameSideData *ret;
AVBufferRef *buf = av_buffer_alloc(size);
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 853d4cabec..ff2540a20f 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -209,11 +209,7 @@ enum AVActiveFormatDescription {
typedef struct AVFrameSideData {
enum AVFrameSideDataType type;
uint8_t *data;
-#if FF_API_BUFFER_SIZE_T
- int size;
-#else
size_t size;
-#endif
AVDictionary *metadata;
AVBufferRef *buf;
} AVFrameSideData;
@@ -818,11 +814,7 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
*/
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
enum AVFrameSideDataType type,
-#if FF_API_BUFFER_SIZE_T
- int size);
-#else
size_t size);
-#endif
/**
* Add a new side data to a frame from an existing AVBufferRef
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 3773cd9eb8..cfdf2d7fd4 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -93,7 +93,7 @@ static void cuda_buffer_free(void *opaque, uint8_t *data)
CHECK_CU(cu->cuCtxPopCurrent(&dummy));
}
-static AVBufferRef *cuda_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *cuda_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = opaque;
AVHWDeviceContext *device_ctx = ctx->device_ctx;
diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 2a3549ebd8..27274ee3fa 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -202,7 +202,7 @@ static AVBufferRef *d3d11va_alloc_single(AVHWFramesContext *ctx)
return wrap_texture_buf(tex, 0);
}
-static AVBufferRef *d3d11va_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *d3d11va_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = (AVHWFramesContext*)opaque;
D3D11VAFramesContext *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 33b3dc80ff..63b037da4a 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -124,7 +124,7 @@ static void dxva2_pool_release_dummy(void *opaque, uint8_t *data)
// released in dxva2_frames_uninit()
}
-static AVBufferRef *dxva2_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *dxva2_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = (AVHWFramesContext*)opaque;
DXVA2FramesContext *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index ee814602b2..41fac43229 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1617,7 +1617,7 @@ static void opencl_pool_free(void *opaque, uint8_t *data)
av_free(desc);
}
-static AVBufferRef *opencl_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *opencl_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *hwfc = opaque;
AVOpenCLDeviceContext *hwctx = hwfc->device_ctx->hwctx;
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 30b0d81f84..08a6e0ee1c 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -194,7 +194,7 @@ static void qsv_pool_release_dummy(void *opaque, uint8_t *data)
{
}
-static AVBufferRef *qsv_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *qsv_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = (AVHWFramesContext*)opaque;
QSVFramesContext *s = ctx->internal->priv;
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 4b81bd1f67..83e542876d 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -464,7 +464,7 @@ static void vaapi_buffer_free(void *opaque, uint8_t *data)
}
}
-static AVBufferRef *vaapi_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vaapi_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *hwfc = opaque;
VAAPIFramesContext *ctx = hwfc->internal->priv;
diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c
index a6fd7126f3..5b78e95529 100644
--- a/libavutil/hwcontext_vdpau.c
+++ b/libavutil/hwcontext_vdpau.c
@@ -225,7 +225,7 @@ static void vdpau_buffer_free(void *opaque, uint8_t *data)
device_priv->surf_destroy(surf);
}
-static AVBufferRef *vdpau_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vdpau_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = opaque;
VDPAUFramesContext *priv = ctx->internal->priv;
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2e3faaaa1a..48327ad98f 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1693,7 +1693,7 @@ static void try_export_flags(AVHWFramesContext *hwfc,
}
}
-static AVBufferRef *vulkan_pool_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *vulkan_pool_alloc(void *opaque, size_t size)
{
int err;
AVVkFrame *f;
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 854e9cbed2..7cd36ff742 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -292,11 +292,4 @@ void ff_check_pixfmt_descriptors(void);
*/
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
-// Temporary typedef to simplify porting all AVBufferRef users to size_t
-#if FF_API_BUFFER_SIZE_T
-typedef int buffer_size_t;
-#else
-typedef size_t buffer_size_t;
-#endif
-
#endif /* AVUTIL_INTERNAL_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index b78ff1acec..f67b41c0cb 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -108,9 +108,6 @@
#ifndef FF_API_CHILD_CLASS_NEXT
#define FF_API_CHILD_CLASS_NEXT (LIBAVUTIL_VERSION_MAJOR < 57)
#endif
-#ifndef FF_API_BUFFER_SIZE_T
-#define FF_API_BUFFER_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57)
-#endif
#ifndef FF_API_CPU_FLAGS
#define FF_API_CPU_FLAGS (LIBAVUTIL_VERSION_MAJOR < 57)
#endif
diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
index 635176ab91..b9cdafddbb 100644
--- a/libavutil/video_enc_params.c
+++ b/libavutil/video_enc_params.c
@@ -63,10 +63,6 @@ av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType t
par = av_video_enc_params_alloc(type, nb_blocks, &size);
if (!par)
return NULL;
- if (size > INT_MAX) {
- av_free(par);
- return NULL;
- }
buf = av_buffer_create((uint8_t *)par, size, NULL, NULL, 0);
if (!buf) {
av_freep(&par);