aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2011-12-08 11:06:23 +0100
committerTomas Härdin <tomas.hardin@codemill.se>2011-12-08 11:06:23 +0100
commit289bc14449bba2ba62d8ede4b22925055670055c (patch)
treef731e70e11485e13b0f8a83a7cb83e066434fea3
parente5f9c8927bcb5ad1477082386645350f5892c8ce (diff)
downloadffmpeg-289bc14449bba2ba62d8ede4b22925055670055c.tar.gz
mxfdec: Make mxf->partitions sorted by offset
This also zeroes new entries for good measure (used by future patches).
-rw-r--r--libavformat/mxfdec.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 003796558d..26024ae90a 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 {
@@ -446,7 +447,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: