When writing fragmented mp4, the cluster array is reset when a
fragment is written. Instead of starting off reallocating the
array only based on the number of current elements in it, keep
track of how many elements there were allocated earlier.
This avoids reallocating this array needlessly when writing
fragmented mp4 files.
Bug-Id: 525
Signed-off-by: Martin Storsjö <martin@martin.st>
memcpy(trk->vos_data, pkt->data, size);
}
- if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) {
- trk->cluster = av_realloc(trk->cluster, (trk->entry + MOV_INDEX_CLUSTER_SIZE) * sizeof(*trk->cluster));
- if (!trk->cluster)
- return -1;
+ if (trk->entry >= trk->cluster_capacity) {
+ unsigned new_capacity = trk->entry + MOV_INDEX_CLUSTER_SIZE;
+ if (av_reallocp_array(&trk->cluster, new_capacity,
+ sizeof(*trk->cluster)))
+ return AVERROR(ENOMEM);
+ trk->cluster_capacity = new_capacity;
}
trk->cluster[trk->entry].pos = avio_tell(pb) - size;
int vos_len;
uint8_t *vos_data;
MOVIentry *cluster;
+ unsigned cluster_capacity;
int audio_vbr;
int height; ///< active picture (w/o VBI) height for D-10/IMX
uint32_t tref_tag;