diff mbox series

[FFmpeg-devel,3/9,v2] avcodec/packet: change side data related public function and struct size types to size_t

Message ID 20210306194243.14931-3-jamrial@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/9,v3] avutil/buffer: change public function and struct size parameter types to size_t | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer March 6, 2021, 7:42 p.m. UTC
av_packet_add_side_data() already defines size as a size_t, so this makes it
consistent across all side data functions.

Signed-off-by: James Almer <jamrial@gmail.com>
---
Changes since v1 is using the buffer_size_t typedef.

 doc/APIchanges        |  4 ++++
 libavcodec/avpacket.c | 10 +++++++---
 libavcodec/packet.h   | 16 ++++++++++++++++
 libavcodec/version.h  |  2 +-
 4 files changed, 28 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index d2d107de78..34b15605e6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@  libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2021-03-xx - xxxxxxxxxx - lavc 58.130.100 - packet.h
+  Change AVBufferRef related AVPacket function and struct size
+  parameter and fields type to size_t at next major bump.
+
 2021-03-xx - xxxxxxxxxx - lavu 56.68.100 - buffer.h frame.h
   Change AVBufferRef and relevant AVFrame function and struct size
   parameter and fields type to size_t at next major bump.
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e4ba403cf6..291c778d95 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -330,12 +330,16 @@  int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
 
 
 uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                                 int size)
+                                 buffer_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)
@@ -351,7 +355,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,
-                                 int *size)
+                                 buffer_size_t *size)
 {
     int i;
 
@@ -554,7 +558,7 @@  int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di
 }
 
 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
-                               int size)
+                               buffer_size_t size)
 {
     int i;
 
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index b9d4c9c2c8..3d9013d783 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -305,7 +305,11 @@  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;
 
@@ -559,7 +563,11 @@  void av_free_packet(AVPacket *pkt);
  * @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.
@@ -586,7 +594,11 @@  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.
@@ -598,7 +610,11 @@  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
 
 #if FF_API_MERGE_SD_API
 attribute_deprecated
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 169c763e8a..3124ec8061 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@ 
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR 129
+#define LIBAVCODEC_VERSION_MINOR 130
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \