diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-05 11:19:16 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-05 11:19:16 +0200 |
commit | 30b491f1c99aa7992157791a98d6cdae6ca2e895 (patch) | |
tree | 816c548897f653bb339ff22848c4b6bb5858b4ea /libavformat | |
parent | ea038b996d5662702b2247a6aa919dee1cebc0be (diff) | |
parent | 3b4feac1ec14f861bdd7f494f288f4d8dd7f449e (diff) | |
download | ffmpeg-30b491f1c99aa7992157791a98d6cdae6ca2e895.tar.gz |
Merge commit '3b4feac1ec14f861bdd7f494f288f4d8dd7f449e'
* commit '3b4feac1ec14f861bdd7f494f288f4d8dd7f449e':
movenc: Keep track of the allocated size for the cluster array
mem: Add av_realloc_array and av_reallocp_array
Conflicts:
doc/APIchanges
libavformat/movenc.c
libavutil/mem.c
libavutil/mem.h
libavutil/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/movenc.c | 10 | ||||
-rw-r--r-- | libavformat/movenc.h | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 2787e453b9..40465e80fc 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3208,10 +3208,12 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) memcpy(trk->vos_data, pkt->data, size); } - if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { - trk->cluster = av_realloc_f(trk->cluster, sizeof(*trk->cluster), (trk->entry + MOV_INDEX_CLUSTER_SIZE)); - 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; diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 2c57834d10..6b583d5577 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -102,6 +102,7 @@ typedef struct MOVTrack { 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; |