Increase it in a linear way instead.
Helps reduce memory usage, especially on long, non fragmented output.

Signed-off-by: James Almer <jamr...@gmail.com>
---
An alternative is using av_fast_realloc(), in a similar fashion as
ff_add_index_entry(), which will keep the memory usage more closely tied to the
amount of entries needed, but the amount of reallocations will be much higher,
so i don't know if the tradeof is beneficial.

 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 85df5d1374..ce82acf914 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -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);
-- 
2.25.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to