Commit ab118976 authored by Andrey Semashev's avatar Andrey Semashev Committed by 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: 's avatarMartin Storsjö <martin@martin.st>
parent 3b4feac1
...@@ -2870,7 +2870,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -2870,7 +2870,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
} }
if (trk->entry >= trk->cluster_capacity) { 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, if (av_reallocp_array(&trk->cluster, new_capacity,
sizeof(*trk->cluster))) sizeof(*trk->cluster)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "avformat.h" #include "avformat.h"
#define MOV_INDEX_CLUSTER_SIZE 16384 #define MOV_INDEX_CLUSTER_SIZE 1024
#define MOV_TIMESCALE 1000 #define MOV_TIMESCALE 1000
#define RTP_MAX_PACKET_SIZE 1450 #define RTP_MAX_PACKET_SIZE 1450
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment