aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-02-28 01:08:31 +0200
committerMartin Storsjö <martin@martin.st>2012-03-01 16:08:30 +0200
commit442c1320e72a13d02c9c477aab7100ef910c33c7 (patch)
treed4627a94a9854a651c5821a66bc4e48a204546f2
parent5cd1337f5db49b4537d83ae2a8115a90d77e3a28 (diff)
downloadffmpeg-442c1320e72a13d02c9c477aab7100ef910c33c7.tar.gz
avpacket: Add a function for shrinking already allocated side data
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--doc/APIchanges3
-rw-r--r--libavcodec/avcodec.h11
-rw-r--r--libavcodec/avpacket.c16
-rw-r--r--libavcodec/version.h2
4 files changed, 31 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index de57b2e69c..00cee5ad90 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -12,6 +12,9 @@ libavutil: 2011-04-18
API changes, most recent first:
+2012-xx-xx - xxxxxxx - lavc 54.3.0 - avcodec.h
+ Add av_packet_shrink_side_data.
+
2012-xx-xx - xxxxxxx - lavf 54.2.0 - avformat.h
Add AVStream.attached_pic and AV_DISPOSITION_ATTACHED_PIC,
used for dealing with attached pictures/cover art.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f4db08335a..af2a5ca3f2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3079,6 +3079,17 @@ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
int size);
/**
+ * Shrink the already allocated side data buffer
+ *
+ * @param pkt packet
+ * @param type side information type
+ * @param size new side information size
+ * @return 0 on success, < 0 on failure
+ */
+int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+ int size);
+
+/**
* Get side information from packet.
*
* @param pkt packet
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index e0e4df46f2..9b549e7190 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -196,3 +196,19 @@ uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
}
return NULL;
}
+
+int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
+ int size)
+{
+ int i;
+
+ for (i = 0; i < pkt->side_data_elems; i++) {
+ if (pkt->side_data[i].type == type) {
+ if (size > pkt->side_data[i].size)
+ return AVERROR(ENOMEM);
+ pkt->side_data[i].size = size;
+ return 0;
+ }
+ }
+ return AVERROR(ENOENT);
+}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 2f11a29d92..157f3cbaba 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 2
+#define LIBAVCODEC_VERSION_MINOR 3
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \