[FFmpeg-cvslog] movenc: Increase the cluster array allocation by doubling

Andrey Semashev git at videolan.org
Wed Jun 5 11:31:49 CEST 2013


ffmpeg | branch: master | Andrey Semashev <andysem at mail.ru> | Mon Jun  3 13:32:48 2013 +0300| [ab1189766a82a95f108005463cde75f73fcc0ae5] | committer: Martin Storsjö

movenc: Increase the cluster array allocation by doubling

The previous allocation increment of 16384 meant that the cluster
array was allocated for 0.6 MB initially, which is a bit excessive
for cases with fragmentation where only a fraction of that ever
actually is used.

Therefore, start off at a much smaller value, and increase by
doubling (to avoid reallocating too often when writing long
non-fragmented mp4 files).

Bug-Id: 525
Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab1189766a82a95f108005463cde75f73fcc0ae5
---

 libavformat/movenc.c |    2 +-
 libavformat/movenc.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e259168..e819d75 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2870,7 +2870,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (trk->entry >= trk->cluster_capacity) {
-        unsigned new_capacity = trk->entry + MOV_INDEX_CLUSTER_SIZE;
+        unsigned new_capacity = 2*(trk->entry + MOV_INDEX_CLUSTER_SIZE);
         if (av_reallocp_array(&trk->cluster, new_capacity,
                               sizeof(*trk->cluster)))
             return AVERROR(ENOMEM);
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 2aa8ffb..103b918 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -26,7 +26,7 @@
 
 #include "avformat.h"
 
-#define MOV_INDEX_CLUSTER_SIZE 16384
+#define MOV_INDEX_CLUSTER_SIZE 1024
 #define MOV_TIMESCALE 1000
 
 #define RTP_MAX_PACKET_SIZE 1450



More information about the ffmpeg-cvslog mailing list