[FFmpeg-cvslog] r25777 - in trunk/libavformat: avformat.h utils.c

reimar subversion
Sun Nov 21 11:24:48 CET 2010


Author: reimar
Date: Sun Nov 21 11:24:48 2010
New Revision: 25777

Log:
Add av_append_packet function, to be used in code that merges packets
to allow palette handling without using PaletteControl.

Modified:
   trunk/libavformat/avformat.h
   trunk/libavformat/utils.c

Modified: trunk/libavformat/avformat.h
==============================================================================
--- trunk/libavformat/avformat.h	Sun Nov 21 11:21:06 2010	(r25776)
+++ trunk/libavformat/avformat.h	Sun Nov 21 11:24:48 2010	(r25777)
@@ -22,7 +22,7 @@
 #define AVFORMAT_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 84
+#define LIBAVFORMAT_VERSION_MINOR 85
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -245,6 +245,21 @@ void av_metadata_free(AVMetadata **m);
 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
 
 
+/**
+ * Reads data and appends it to the current content of the AVPacket.
+ * If pkt->size is 0 it behaves like av_get_packet.
+ * Note that this uses av_grow_packet and thus involves a realloc
+ * which is inefficient. Thus this function should only be used
+ * when there is no reasonable way to know (an upper bound of)
+ * the final size.
+ *
+ * @param pkt packet
+ * @param size amount of data to read
+ * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
+ *         will not be lost even if an error occurs.
+ */
+int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size);
+
 /*************************************************/
 /* fractional numbers for exact pts handling */
 

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Sun Nov 21 11:21:06 2010	(r25776)
+++ trunk/libavformat/utils.c	Sun Nov 21 11:24:48 2010	(r25777)
@@ -339,6 +339,21 @@ int av_get_packet(ByteIOContext *s, AVPa
     return ret;
 }
 
+int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size)
+{
+    int ret;
+    int old_size;
+    if (!pkt->size)
+        return av_get_packet(s, pkt, size);
+    old_size = pkt->size;
+    ret = av_grow_packet(pkt, size);
+    if (ret < 0)
+        return ret;
+    ret = get_buffer(s, pkt->data + old_size, size);
+    av_shrink_packet(pkt, old_size + FFMAX(ret, 0));
+    return ret;
+}
+
 
 int av_filename_number_test(const char *filename)
 {



More information about the ffmpeg-cvslog mailing list