History

mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack

Tomas Härdin committed 14 years ago

Commit 5fb800f1 parent fd34dbe1 file · +10 −13Browse files

Unified · Split

libavformat/mxfdec.c+10−13
@@ -190,7 +190,6 @@ typedef struct { · 189 unmodified lines
190190 uint8_t *local_tags;
191191 int local_tags_count;
192192 uint64_t footer_partition;
193− int system_item;
194193 int64_t essence_offset;
195194 int first_essence_kl_length;
196195 int64_t first_essence_length;
@@ -986,17 +985,22 @@ static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segment · 789 unmodified lines
986985 return 0;
987986 }
988987
989−static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st)
988+static int mxf_parse_index(MXFContext *mxf, int track_id, AVStream *st)
990989 {
991990 int64_t accumulated_offset = 0;
992991 int j, k, ret, nb_sorted_segments;
993992 MXFIndexTableSegment **sorted_segments;
993+ int n_delta = track_id - 1; /* TrackID = 1-based stream index */
994+
995+ if (track_id < 1) {
996+ av_log(mxf->fc, AV_LOG_ERROR, "TrackID not positive: %i\n", track_id);
997+ return AVERROR_INVALIDDATA;
998+ }
994999
9951000 if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, &sorted_segments)))
9961001 return ret;
9971002
9981003 for (j = 0; j < nb_sorted_segments; j++) {
999− int n_delta = i;
10001004 int duration, sample_duration = 1, last_sample_size = 0;
10011005 int64_t segment_size;
10021006 MXFIndexTableSegment *tableseg = sorted_segments[j];
@@ -1005,9 +1009,6 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st) · 2 unmodified lines
10051009 if (j > 0 && tableseg->body_sid != sorted_segments[j-1]->body_sid)
10061010 accumulated_offset = 0;
10071011
1008− /* HACK: How to correctly link between streams and slices? */
1009− if (i < mxf->system_item + st->index)
1010− n_delta++;
10111012 if (n_delta >= tableseg->nb_delta_entries && st->index != 0)
10121013 continue;
10131014 duration = tableseg->index_duration > 0 ? tableseg->index_duration :
@@ -1075,8 +1076,8 @@ static int mxf_parse_index(MXFContext *mxf, int i, AVStream *st) · 61 unmodified lines
10751076
10761077 pos += mxf->essence_offset;
10771078
1078− av_dlog(mxf->fc, "Stream %d IndexEntry %d n_Delta %d Offset %"PRIx64" Timestamp %"PRId64"\n",
1079− st->index, st->nb_index_entries, n_delta, pos, sample_duration * st->nb_index_entries);
1079+ av_dlog(mxf->fc, "Stream %d IndexEntry %d TrackID %d Offset %"PRIx64" Timestamp %"PRId64"\n",
1080+ st->index, st->nb_index_entries, track_id, pos, sample_duration * st->nb_index_entries);
10801081
10811082 if ((ret = av_add_index_entry(st, pos, sample_duration * st->nb_index_entries, size, 0, flags)) < 0)
10821083 return ret;
@@ -1275,7 +1276,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) · 192 unmodified lines
12751276 st->need_parsing = AVSTREAM_PARSE_FULL;
12761277 }
12771278
1278− if ((ret = mxf_parse_index(mxf, i, st)))
1279+ if ((ret = mxf_parse_index(mxf, material_track->track_id, st)))
12791280 return ret;
12801281 }
12811282 return 0;
@@ -1524,10 +1525,6 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap) · 242 unmodified lines
15241525 }
15251526 }
15261527
1527− if (IS_KLV_KEY(klv.key, mxf_system_item_key)) {
1528− mxf->system_item = 1;
1529− }
1530−
15311528 if (!mxf->essence_offset)
15321529 mxf->essence_offset = klv.offset;
15331530

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t