avformat/movenc: Reduce size of the allocated MOVIentry array
authorJames Almer <jamrial@gmail.com>
Wed, 25 Mar 2020 17:16:35 +0000 (14:16 -0300)
committerJames Almer <jamrial@gmail.com>
Thu, 26 Mar 2020 14:46:08 +0000 (11:46 -0300)
Increasing it by 2048 entries per realloc is exessive.
Reduces memory usage, especially on long, non fragmented output.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/movenc.c

index 85df5d1..ce82acf 100644 (file)
@@ -5559,7 +5559,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (trk->entry >= trk->cluster_capacity) {
-        unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
+        unsigned new_capacity = trk->entry + MOV_INDEX_CLUSTER_SIZE;
         if (av_reallocp_array(&trk->cluster, new_capacity,
                               sizeof(*trk->cluster))) {
             ret = AVERROR(ENOMEM);