changeset 2507:048f4f45a84c libavformat

Use num_entries directly rather than mixing it with a local copy
author conrad
date Wed, 05 Sep 2007 00:25:44 +0000
parents 623cb1c85104
children 9b96804b67c1
files matroskaenc.c
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/matroskaenc.c	Wed Sep 05 00:25:42 2007 +0000
+++ b/matroskaenc.c	Wed Sep 05 00:25:44 2007 +0000
@@ -262,7 +262,6 @@
 static int mkv_add_seekhead_entry(mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos)
 {
     mkv_seekhead_entry *entries = seekhead->entries;
-    int new_entry = seekhead->num_entries;
 
     // don't store more elements than we reserved space for
     if (seekhead->max_entries > 0 && seekhead->max_entries <= seekhead->num_entries)
@@ -272,11 +271,10 @@
     if (entries == NULL)
         return AVERROR(ENOMEM);
 
-    entries[new_entry].elementid = elementid;
-    entries[new_entry].segmentpos = filepos - seekhead->segment_offset;
+    entries[seekhead->num_entries  ].elementid = elementid;
+    entries[seekhead->num_entries++].segmentpos = filepos - seekhead->segment_offset;
 
     seekhead->entries = entries;
-    seekhead->num_entries++;
 
     return 0;
 }
@@ -341,18 +339,16 @@
 static int mkv_add_cuepoint(mkv_cues *cues, AVPacket *pkt, offset_t cluster_pos)
 {
     mkv_cuepoint *entries = cues->entries;
-    int new_entry = cues->num_entries;
 
     entries = av_realloc(entries, (cues->num_entries + 1) * sizeof(mkv_cuepoint));
     if (entries == NULL)
         return AVERROR(ENOMEM);
 
-    entries[new_entry].pts = pkt->pts;
-    entries[new_entry].tracknum = pkt->stream_index + 1;
-    entries[new_entry].cluster_pos = cluster_pos - cues->segment_offset;
+    entries[cues->num_entries  ].pts = pkt->pts;
+    entries[cues->num_entries  ].tracknum = pkt->stream_index + 1;
+    entries[cues->num_entries++].cluster_pos = cluster_pos - cues->segment_offset;
 
     cues->entries = entries;
-    cues->num_entries++;
     return 0;
 }