[FFmpeg-cvslog] mxfdec: Make mxf->partitions sorted by offset.

Tomas Härdin git at videolan.org
Mon Jan 23 01:18:11 CET 2012


ffmpeg | branch: master | Tomas Härdin <tomas.hardin at codemill.se> | Thu Dec  8 11:06:23 2011 +0100| [c77a5460b19e6f93470132af020e3fe813293bd3] | committer: Janne Grunau

mxfdec: Make mxf->partitions sorted by offset.

This also zeroes new entries for good measure (used by future patches).

Signed-off-by: Janne Grunau <janne-libav at jannau.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c77a5460b19e6f93470132af020e3fe813293bd3
---

 libavformat/mxfdec.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 5ce9a24..e451fe1 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -192,6 +192,7 @@ typedef struct {
     MXFPartition *current_partition;
     int parsing_backward;
     int64_t last_forward_tell;
+    int last_forward_partition;
 } MXFContext;
 
 enum MXFWrappingScheme {
@@ -448,7 +449,20 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
     if (!mxf->partitions)
         return AVERROR(ENOMEM);
 
-    partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count++];
+    if (mxf->parsing_backward) {
+        /* insert the new partition pack in the middle
+         * this makes the entries in mxf->partitions sorted by offset */
+        memmove(&mxf->partitions[mxf->last_forward_partition+1],
+                &mxf->partitions[mxf->last_forward_partition],
+                (mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
+        partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
+    } else {
+        mxf->last_forward_partition++;
+        partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
+    }
+
+    memset(partition, 0, sizeof(*partition));
+    mxf->partitions_count++;
 
     switch(uid[13]) {
     case 2:



More information about the ffmpeg-cvslog mailing list