[FFmpeg-cvslog] mxfdec: Use MaterialPackage - Track - TrackID instead of the system_item hack

Tomas Härdin git at videolan.org
Thu Dec 8 21:36:28 CET 2011


ffmpeg | branch: master | Tomas Härdin <tomas.hardin at codemill.se> | Thu Dec  8 11:53:57 2011 +0100| [5fb800f49a72fe1de2d85774218c1855015fbd7d] | committer: Tomas Härdin

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

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

 libavformat/mxfdec.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 0d34d64..e6e6aa1 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;
 



More information about the ffmpeg-cvslog mailing list