diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-05 11:33:19 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-05 11:33:25 +0200 |
commit | 606e8baf0fec23140f2a1baffb8752cb761039f5 (patch) | |
tree | 0f0dfda212ee815770451a52d4656ad1ebbfc05c /libavformat | |
parent | 28ce9c0b73c5c4aea4cdaa1f584e7c0839286a35 (diff) | |
parent | 7c020e1ad37d27c9d5db4d714401f09c80e3cc44 (diff) | |
download | ffmpeg-606e8baf0fec23140f2a1baffb8752cb761039f5.tar.gz |
Merge commit '7c020e1ad37d27c9d5db4d714401f09c80e3cc44'
* commit '7c020e1ad37d27c9d5db4d714401f09c80e3cc44':
movenc: Grow the frag_info array in chunks
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/movenc.c | 11 | ||||
-rw-r--r-- | libavformat/movenc.h | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 206c4be3dd..77fc1804b7 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3085,9 +3085,14 @@ static int mov_flush_fragment(AVFormatContext *s) MOVFragmentInfo *info; avio_flush(s->pb); track->nb_frag_info++; - track->frag_info = av_realloc(track->frag_info, - sizeof(*track->frag_info) * - track->nb_frag_info); + if (track->nb_frag_info >= track->frag_info_capacity) { + unsigned new_capacity = track->nb_frag_info + MOV_FRAG_INFO_ALLOC_INCREMENT; + if (av_reallocp_array(&track->frag_info, + new_capacity, + sizeof(*track->frag_info))) + return AVERROR(ENOMEM); + track->frag_info_capacity = new_capacity; + } info = &track->frag_info[track->nb_frag_info - 1]; info->offset = avio_tell(s->pb); info->time = mov->tracks[i].frag_start; diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 456ed0c4f7..a6571d5109 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -26,6 +26,7 @@ #include "avformat.h" +#define MOV_FRAG_INFO_ALLOC_INCREMENT 64 #define MOV_INDEX_CLUSTER_SIZE 1024 #define MOV_TIMESCALE 1000 @@ -130,6 +131,7 @@ typedef struct MOVTrack { int nb_frag_info; MOVFragmentInfo *frag_info; + unsigned frag_info_capacity; struct { int64_t struct_offset; |