lavc: shrink encoded video packet size after encoding.
authorAnton Khirnov <anton@khirnov.net>
Thu, 1 Mar 2012 11:15:45 +0000 (12:15 +0100)
committerAnton Khirnov <anton@khirnov.net>
Thu, 1 Mar 2012 21:21:35 +0000 (22:21 +0100)
Based on a patch by Nicolas George <nicolas.george <at> normalesup.org>

libavcodec/utils.c

index 2d79f66..d797c8a 100644 (file)
@@ -1113,6 +1113,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
         else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
             avpkt->pts = avpkt->dts = frame->pts;
 
+        if (!user_packet && avpkt->data) {
+            uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
+            if (new_data)
+                avpkt->data = new_data;
+        }
+
         avctx->frame_number++;
     }