[FFmpeg-cvslog] r18378 - in trunk: libavcodec/avcodec.h libavcodec/avpacket.c libavformat/utils.c

reimar subversion
Wed Apr 8 22:19:13 CEST 2009


Author: reimar
Date: Wed Apr  8 22:19:12 2009
New Revision: 18378

Log:
Add av_shrink_packet function for use in av_get_packet that reduces pkt->size
and ensures the following padding is correctly initialized to 0.

Modified:
   trunk/libavcodec/avcodec.h
   trunk/libavcodec/avpacket.c
   trunk/libavformat/utils.c

Modified: trunk/libavcodec/avcodec.h
==============================================================================
--- trunk/libavcodec/avcodec.h	Wed Apr  8 18:01:10 2009	(r18377)
+++ trunk/libavcodec/avcodec.h	Wed Apr  8 22:19:12 2009	(r18378)
@@ -2655,6 +2655,14 @@ void av_init_packet(AVPacket *pkt);
 int av_new_packet(AVPacket *pkt, int size);
 
 /**
+ * Reduce packet size, correctly zeroing padding
+ *
+ * @param pkt packet
+ * @param size new size
+ */
+void av_shrink_packet(AVPacket *pkt, int size);
+
+/**
  * @warning This is a hack - the packet memory allocation stuff is broken. The
  * packet is allocated if it was not really allocated.
  */

Modified: trunk/libavcodec/avpacket.c
==============================================================================
--- trunk/libavcodec/avpacket.c	Wed Apr  8 18:01:10 2009	(r18377)
+++ trunk/libavcodec/avpacket.c	Wed Apr  8 22:19:12 2009	(r18378)
@@ -62,6 +62,13 @@ int av_new_packet(AVPacket *pkt, int siz
     return 0;
 }
 
+void av_shrink_packet(AVPacket *pkt, int size)
+{
+    if (pkt->size <= size) return;
+    pkt->size = size;
+    memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+}
+
 int av_dup_packet(AVPacket *pkt)
 {
     if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Wed Apr  8 18:01:10 2009	(r18377)
+++ trunk/libavformat/utils.c	Wed Apr  8 22:19:12 2009	(r18378)
@@ -272,7 +272,7 @@ int av_get_packet(ByteIOContext *s, AVPa
     if(ret<=0)
         av_free_packet(pkt);
     else
-        pkt->size= ret;
+        av_shrink_packet(pkt, ret);
 
     return ret;
 }



More information about the ffmpeg-cvslog mailing list