summaryrefslogtreecommitdiff
path: root/libavformat/asfenc.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2012-04-04 02:48:27 -0300
committerMichael Niedermayer <michaelni@gmx.at>2012-04-05 05:48:27 +0200
commit97d36a1898dabd6fd85d0f2295bdac911d607b8e (patch)
treee4c73187d70b1108fa5cd60cea440788a23efc95 /libavformat/asfenc.c
parent13cc3645b002f918272a7dfbc31294fded55943b (diff)
asfenc: realloc index_ptr fewer times
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/asfenc.c')
-rw-r--r--libavformat/asfenc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index a287ac55ad..136ddb325f 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -30,7 +30,7 @@
#define ASF_INDEXED_INTERVAL 10000000
-#define ASF_INDEX_BLOCK 600
+#define ASF_INDEX_BLOCK (1<<9)
#define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2
#define ASF_PACKET_ERROR_CORRECTION_FLAGS (\
@@ -810,11 +810,11 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {
start_sec = (int)(duration / INT64_C(10000000));
if (start_sec != (int)(asf->last_indexed_pts / INT64_C(10000000))) {
+ if (start_sec > asf->nb_index_memory_alloc) {
+ asf->nb_index_memory_alloc = (start_sec + ASF_INDEX_BLOCK) & ~(ASF_INDEX_BLOCK - 1);
+ asf->index_ptr = (ASFIndex*)av_realloc( asf->index_ptr, sizeof(ASFIndex) * asf->nb_index_memory_alloc );
+ }
for(i=asf->nb_index_count;i<start_sec;i++) {
- if (i>=asf->nb_index_memory_alloc) {
- asf->nb_index_memory_alloc += ASF_INDEX_BLOCK;
- asf->index_ptr = (ASFIndex*)av_realloc( asf->index_ptr, sizeof(ASFIndex) * asf->nb_index_memory_alloc );
- }
// store
asf->index_ptr[i].packet_number = (uint32_t)packet_st;
asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets-packet_st);