aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2011-12-08 11:53:57 +0100
committerTomas Härdin <tomas.hardin@codemill.se>2011-12-08 19:11:57 +0100
commit5fb800f49a72fe1de2d85774218c1855015fbd7d (patch)
tree70dee9fbe7041849992009f2223ae8699c4e6e36 /libavformat/mxfdec.c
parentfd34dbea58e097609ff09cf7dcc59f74930195d3 (diff)
downloadffmpeg-5fb800f49a72fe1de2d85774218c1855015fbd7d.tar.gz
mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 0d34d64f0c..e6e6aa1fb2 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -190,7 +190,6 @@ typedef struct {
uint8_t *local_tags;
int local_tags_count;
uint64_t footer_partition;
- int system_item;
int64_t essence_offset;
int first_essence_kl_length;
int64_t first_essence_length;
@@ -986,17 +985,22 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment
return 0;
}
-static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
+static int mxf_parse_index(MXFContext *mxf, int track_id, AVStream *st)
{
int64_t accumulated_offset = 0;
int j, k, ret, nb_sorted_segments;
MXFIndexTableSegment **sorted_segments;
+ int n_delta = track_id - 1; /* TrackID = 1-based stream index */
+
+ if (track_id < 1) {
+ av_log(mxf->fc, AV_LOG_ERROR, "TrackID not positive: %i\n", track_id);
+ return AVERROR_INVALIDDATA;
+ }
if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, &sorted_segments)))
return ret;
for (j = 0; j < nb_sorted_segments; j++) {
- int n_delta = i;
int duration, sample_duration = 1, last_sample_size = 0;
int64_t segment_size;
MXFIndexTableSegment *tableseg = sorted_segments[j];
@@ -1005,9 +1009,6 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
if (j > 0 && tableseg->body_sid != sorted_segments[j-1]->body_sid)
accumulated_offset = 0;
- /* HACK: How to correctly link between streams and slices? */
- if (i < mxf->system_item + st->index)
- n_delta++;
if (n_delta >= tableseg->nb_delta_entries && st->index != 0)
continue;
duration = tableseg->index_duration > 0 ? tableseg->index_duration :
@@ -1075,8 +1076,8 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
pos += mxf->essence_offset;
- av_dlog(mxf->fc, "Stream %d IndexEntry %d n_Delta %d Offset %"PRIx64" Timestamp %"PRId64"\n",
- st->index, st->nb_index_entries, n_delta, pos, sample_duration * st->nb_index_entries);
+ av_dlog(mxf->fc, "Stream %d IndexEntry %d TrackID %d Offset %"PRIx64" Timestamp %"PRId64"\n",
+ st->index, st->nb_index_entries, track_id, pos, sample_duration * st->nb_index_entries);
if ((ret = av_add_index_entry(st, pos, sample_duration * st->nb_index_entries, size, 0, flags)) < 0)
return ret;
@@ -1275,7 +1276,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
- if ((ret = mxf_parse_index(mxf, i, st)))
+ if ((ret = mxf_parse_index(mxf, material_track->track_id, st)))
return ret;
}
return 0;
@@ -1524,10 +1525,6 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
}
- if (IS_KLV_KEY(klv.key, mxf_system_item_key)) {
- mxf->system_item = 1;
- }
-
if (!mxf->essence_offset)
mxf->essence_offset = klv.offset;