summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-14 14:59:32 +0200
committerJames Almer <jamrial@gmail.com>2021-04-27 10:43:13 -0300
commitef6a9e5e311f09fa8032974fa4d0c1e166a959bb (patch)
treeb9b1893c45771cde9f36853685a5bc8a6b5cf27c /libavcodec
parent985c0dac674846721ec8ff23344c16ac7d1c9a1e (diff)
downloadffmpeg-ef6a9e5e311f09fa8032974fa4d0c1e166a959bb.tar.gz
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 'libavcodec')
-rw-r--r--libavcodec/aacdec_template.c4
-rw-r--r--libavcodec/adxdec.c2
-rw-r--r--libavcodec/audiotoolboxdec.c2
-rw-r--r--libavcodec/avpacket.c28
-rw-r--r--libavcodec/cbs_bsf.c2
-rw-r--r--libavcodec/decode.c13
-rw-r--r--libavcodec/h264_metadata_bsf.c2
-rw-r--r--libavcodec/h264dec.c2
-rw-r--r--libavcodec/hevcdec.c2
-rw-r--r--libavcodec/libvpxdec.c2
-rw-r--r--libavcodec/mpeg12enc.c4
-rw-r--r--libavcodec/mscc.c5
-rw-r--r--libavcodec/nvdec.c4
-rw-r--r--libavcodec/packet.h24
-rw-r--r--libavcodec/srtdec.c2
-rw-r--r--libavcodec/vaapi_encode.c2
16 files changed, 31 insertions, 69 deletions
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 98f77a3ad7..d78e60ec2e 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -3437,11 +3437,11 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
int buf_consumed;
int buf_offset;
int err;
- buffer_size_t new_extradata_size;
+ size_t new_extradata_size;
const uint8_t *new_extradata = av_packet_get_side_data(avpkt,
AV_PKT_DATA_NEW_EXTRADATA,
&new_extradata_size);
- buffer_size_t jp_dualmono_size;
+ size_t jp_dualmono_size;
const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt,
AV_PKT_DATA_JP_DUALMONO,
&jp_dualmono_size);
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 94de3eee19..eb05145da9 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -103,7 +103,7 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *buf = avpkt->data;
const uint8_t *buf_end = buf + avpkt->size;
int num_blocks, ch, ret;
- buffer_size_t new_extradata_size;
+ size_t new_extradata_size;
uint8_t *new_extradata;
new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index fa55f58988..a4fb8c9120 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -484,7 +484,7 @@ static int ffat_decode(AVCodecContext *avctx, void *data,
if (avctx->codec_id == AV_CODEC_ID_AAC) {
if (!at->extradata_size) {
uint8_t *side_data;
- buffer_size_t side_data_size;
+ size_t side_data_size;
side_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
&side_data_size);
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 622b50d5eb..e32c467586 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -218,16 +218,12 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- buffer_size_t size)
+ size_t size)
{
int ret;
uint8_t *data;
-#if FF_API_BUFFER_SIZE_T
- if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
-#else
if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
-#endif
return NULL;
data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!data)
@@ -243,7 +239,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
}
uint8_t *av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
- buffer_size_t *size)
+ size_t *size)
{
int i;
@@ -297,11 +293,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type)
return NULL;
}
-#if FF_API_BUFFER_SIZE_T
-uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size)
-#else
uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
-#endif
{
uint8_t *data = NULL;
*size = 0;
@@ -320,11 +312,7 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
if (pass)
memcpy(data + total_length, str, len);
-#if FF_API_BUFFER_SIZE_T
- else if (len > INT_MAX - total_length)
-#else
else if (len > SIZE_MAX - total_length)
-#endif
return NULL;
total_length += len;
}
@@ -340,12 +328,8 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
return data;
}
-#if FF_API_BUFFER_SIZE_T
-int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
-#else
int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
AVDictionary **dict)
-#endif
{
const uint8_t *end;
int ret;
@@ -372,7 +356,7 @@ int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
}
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- buffer_size_t size)
+ size_t size)
{
int i;
@@ -402,7 +386,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
dst->side_data_elems = 0;
for (i = 0; i < src->side_data_elems; i++) {
enum AVPacketSideDataType type = src->side_data[i].type;
- buffer_size_t size = src->side_data[i].size;
+ size_t size = src->side_data[i].size;
uint8_t *src_data = src->side_data[i].data;
uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
@@ -599,7 +583,7 @@ void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
{
uint8_t *side_data;
- buffer_size_t side_data_size;
+ size_t side_data_size;
int i;
side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
@@ -625,7 +609,7 @@ int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp)
{
AVProducerReferenceTime *prft;
uint8_t *side_data;
- buffer_size_t side_data_size;
+ size_t side_data_size;
side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size);
if (!side_data) {
diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c
index f0f7dd79b5..0977d431f7 100644
--- a/libavcodec/cbs_bsf.c
+++ b/libavcodec/cbs_bsf.c
@@ -24,7 +24,7 @@ static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
CBSBSFContext *ctx = bsf->priv_data;
CodedBitstreamFragment *frag = &ctx->fragment;
uint8_t *side_data;
- buffer_size_t side_data_size;
+ size_t side_data_size;
int err;
side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9e5230ae1d..cd98c98a97 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -67,7 +67,7 @@ typedef struct FramePool {
static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
{
int ret;
- buffer_size_t size;
+ size_t size;
const uint8_t *data;
uint32_t flags;
int64_t val;
@@ -344,7 +344,7 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
got_frame = 0;
} else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
uint8_t *side;
- buffer_size_t side_size;
+ size_t side_size;
uint32_t discard_padding = 0;
uint8_t skip_reason = 0;
uint8_t discard_reason = 0;
@@ -1463,7 +1463,7 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
{
- buffer_size_t size;
+ size_t size;
const uint8_t *side_metadata;
AVDictionary **frame_md = &frame->metadata;
@@ -1502,7 +1502,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
frame->pkt_size = pkt->size;
for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
- buffer_size_t size;
+ size_t size;
uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size);
if (packet_sd) {
AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
@@ -1841,14 +1841,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
{
- buffer_size_t size;
+ size_t size;
const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
memcpy(dst, pal, AVPALETTE_SIZE);
return 1;
} else if (pal) {
- av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
+ av_log(logctx, AV_LOG_ERROR,
+ "Palette size %"SIZE_SPECIFIER" is wrong\n", size);
}
return 0;
}
diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 06d23e3142..ef74cba560 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -371,7 +371,7 @@ static int h264_metadata_handle_display_orientation(AVBSFContext *bsf,
H264RawSEIDisplayOrientation *disp =
&ctx->display_orientation_payload;
uint8_t *data;
- buffer_size_t size;
+ size_t size;
int write = 0;
data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size);
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index e5b77abc6a..536020095c 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -975,7 +975,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
return send_next_delayed_frame(h, pict, got_frame, 0);
if (av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
- buffer_size_t side_size;
+ size_t side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
ff_h264_decode_extradata(side, side_size,
&h->ps, &h->is_avc, &h->nal_length_size,
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 2231aed259..ad38f37187 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3303,7 +3303,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
AVPacket *avpkt)
{
int ret;
- buffer_size_t new_extradata_size;
+ size_t new_extradata_size;
uint8_t *new_extradata;
HEVCContext *s = avctx->priv_data;
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 9b5728fba4..67d56fb05e 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -221,7 +221,7 @@ static int vpx_decode(AVCodecContext *avctx,
struct vpx_image *img, *img_alpha;
int ret;
uint8_t *side_data = NULL;
- buffer_size_t side_data_size;
+ size_t side_data_size;
ret = decode_frame(avctx, &ctx->decoder, avpkt->data, avpkt->size);
if (ret)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index fd3e7de94a..432d27e1f6 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -575,8 +575,8 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
put_bits(&s->pb, 8, 0xff); // marker_bits
} else {
av_log(s->avctx, AV_LOG_WARNING,
- "Warning Closed Caption size (%d) can not exceed 93 bytes "
- "and must be a multiple of 3\n", side_data->size);
+ "Closed Caption size (%"SIZE_SPECIFIER") can not exceed "
+ "93 bytes and must be a multiple of 3\n", side_data->size);
}
}
}
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
index fe02649623..e685b2a32b 100644
--- a/libavcodec/mscc.c
+++ b/libavcodec/mscc.c
@@ -152,7 +152,7 @@ static int decode_frame(AVCodecContext *avctx,
}
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
- buffer_size_t size;
+ size_t size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
@@ -160,7 +160,8 @@ static int decode_frame(AVCodecContext *avctx,
for (j = 0; j < 256; j++)
s->pal[j] = 0xFF000000 | AV_RL32(pal + j * 4);
} else if (pal) {
- av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
+ av_log(avctx, AV_LOG_ERROR,
+ "Palette size %"SIZE_SPECIFIER" is wrong\n", size);
}
memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);
}
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index d6b6608866..251be039a8 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -242,7 +242,7 @@ fail:
return ret;
}
-static AVBufferRef *nvdec_decoder_frame_alloc(void *opaque, buffer_size_t size)
+static AVBufferRef *nvdec_decoder_frame_alloc(void *opaque, size_t size)
{
NVDECFramePool *pool = opaque;
AVBufferRef *ret;
@@ -283,7 +283,7 @@ static void nvdec_free_dummy(struct AVHWFramesContext *ctx)
av_buffer_pool_uninit(&ctx->pool);
}
-static AVBufferRef *nvdec_alloc_dummy(buffer_size_t size)
+static AVBufferRef *nvdec_alloc_dummy(size_t size)
{
return av_buffer_create(NULL, 0, NULL, NULL, 0);
}
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 6e6d9c58c9..fad8341c12 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -305,11 +305,7 @@ enum AVPacketSideDataType {
typedef struct AVPacketSideData {
uint8_t *data;
-#if FF_API_BUFFER_SIZE_T
- int size;
-#else
size_t size;
-#endif
enum AVPacketSideDataType type;
} AVPacketSideData;
@@ -528,11 +524,7 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
* @return pointer to fresh allocated data or NULL otherwise
*/
uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
- int size);
-#else
size_t size);
-#endif
/**
* Wrap an existing array as a packet side data.
@@ -559,11 +551,7 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
* @return 0 on success, < 0 on failure
*/
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
- int size);
-#else
size_t size);
-#endif
/**
* Get side information from packet.
@@ -575,11 +563,7 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
* @return pointer to data if present or NULL otherwise
*/
uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
-#if FF_API_BUFFER_SIZE_T
- int *size);
-#else
size_t *size);
-#endif
const char *av_packet_side_data_name(enum AVPacketSideDataType type);
@@ -590,11 +574,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type);
* @param size pointer to store the size of the returned data
* @return pointer to data if successful, NULL otherwise
*/
-#if FF_API_BUFFER_SIZE_T
-uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size);
-#else
uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size);
-#endif
/**
* Unpack a dictionary from side_data.
*
@@ -603,12 +583,8 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size);
* @param dict the metadata storage dictionary
* @return 0 on success, < 0 on failure
*/
-#if FF_API_BUFFER_SIZE_T
-int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict);
-#else
int av_packet_unpack_dictionary(const uint8_t *data, size_t size,
AVDictionary **dict);
-#endif
/**
* Convenience function to free all the side data stored.
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index 98f84ac673..e77b94f74e 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -59,7 +59,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
AVBPrint buffer;
int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
int ret;
- buffer_size_t size;
+ size_t size;
const uint8_t *p = av_packet_get_side_data(avpkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);
FFASSDecoderContext *s = avctx->priv_data;
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 607858435f..7510816ec1 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -2235,7 +2235,7 @@ static void vaapi_encode_free_output_buffer(void *opaque,
}
static AVBufferRef *vaapi_encode_alloc_output_buffer(void *opaque,
- buffer_size_t size)
+ size_t size)
{
AVCodecContext *avctx = opaque;
VAAPIEncodeContext *ctx = avctx->priv_data;