mxfdec: Do not parse slices or DeltaEntryArrays.
authorTomas Härdin <tomas.hardin@codemill.se>
Fri, 16 Dec 2011 10:02:04 +0000 (11:02 +0100)
committerJanne Grunau <janne-libav@jannau.net>
Sun, 22 Jan 2012 13:40:54 +0000 (14:40 +0100)
The most recent demuxing/seeking code does not need them.

libavformat/mxfdec.c

index f192d80..a81eec0 100644 (file)
@@ -148,17 +148,12 @@ typedef struct {
     int edit_unit_byte_count;
     int index_sid;
     int body_sid;
     int edit_unit_byte_count;
     int index_sid;
     int body_sid;
-    int slice_count;
     AVRational index_edit_rate;
     uint64_t index_start_position;
     uint64_t index_duration;
     AVRational index_edit_rate;
     uint64_t index_start_position;
     uint64_t index_duration;
-    int *slice;
-    int *element_delta;
-    int nb_delta_entries;
     int8_t *temporal_offset_entries;
     int *flag_entries;
     uint64_t *stream_offset_entries;
     int8_t *temporal_offset_entries;
     int *flag_entries;
     uint64_t *stream_offset_entries;
-    uint32_t **slice_offset_entries;
     int nb_index_entries;
 } MXFIndexTableSegment;
 
     int nb_index_entries;
 } MXFIndexTableSegment;
 
@@ -666,39 +661,9 @@ static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size
     return 0;
 }
 
     return 0;
 }
 
-static int mxf_read_delta_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
-{
-    int i, length;
-
-    segment->nb_delta_entries = avio_rb32(pb);
-    if (segment->nb_delta_entries < 1 ||
-        segment->nb_delta_entries > INT_MAX >> av_log2(sizeof(*segment->slice)))
-        return AVERROR(ENOMEM);
-
-    length = avio_rb32(pb);
-
-    segment->slice = av_mallocz(segment->nb_delta_entries *
-                                sizeof(*segment->slice));
-    if (!segment->slice)
-        return AVERROR(ENOMEM);
-    segment->element_delta = av_mallocz(segment->nb_delta_entries *
-                                        sizeof(*segment->element_delta));
-    if (!segment->element_delta) {
-        av_freep(&segment->slice);
-        return AVERROR(ENOMEM);
-    }
-
-    for (i = 0; i < segment->nb_delta_entries; i++) {
-        avio_r8(pb);    /* PosTableIndex */
-        segment->slice[i] = avio_r8(pb);
-        segment->element_delta[i] = avio_rb32(pb);
-    }
-    return 0;
-}
-
 static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
 {
 static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
 {
-    int i, j, length;
+    int i, length;
 
     segment->nb_index_entries = avio_rb32(pb);
     if (!segment->nb_index_entries)
 
     segment->nb_index_entries = avio_rb32(pb);
     if (!segment->nb_index_entries)
@@ -716,41 +681,23 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
                                  sizeof(*segment->flag_entries));
     segment->stream_offset_entries   = av_mallocz(segment->nb_index_entries *
                                  sizeof(*segment->stream_offset_entries));
                                  sizeof(*segment->flag_entries));
     segment->stream_offset_entries   = av_mallocz(segment->nb_index_entries *
                                  sizeof(*segment->stream_offset_entries));
-    segment->slice_offset_entries    = av_mallocz(segment->nb_index_entries *
-                                 sizeof(*segment->slice_offset_entries));
 
 
-    if (!segment->flag_entries         || !segment->stream_offset_entries ||
-        !segment->slice_offset_entries || !segment->temporal_offset_entries)
-        goto errmem;
+    if (!segment->flag_entries || !segment->stream_offset_entries ||
+        !segment->temporal_offset_entries) {
+        av_freep(&segment->flag_entries);
+        av_freep(&segment->stream_offset_entries);
+        av_freep(&segment->temporal_offset_entries);
+        return AVERROR(ENOMEM);
+    }
 
     for (i = 0; i < segment->nb_index_entries; i++) {
         segment->temporal_offset_entries[i] = avio_r8(pb);
         avio_r8(pb);                                        /* KeyFrameOffset */
         segment->flag_entries[i] = avio_r8(pb);
         segment->stream_offset_entries[i] = avio_rb64(pb);
 
     for (i = 0; i < segment->nb_index_entries; i++) {
         segment->temporal_offset_entries[i] = avio_r8(pb);
         avio_r8(pb);                                        /* KeyFrameOffset */
         segment->flag_entries[i] = avio_r8(pb);
         segment->stream_offset_entries[i] = avio_rb64(pb);
-        if (segment->slice_count) {
-            segment->slice_offset_entries[i] = av_mallocz(segment->slice_count *
-                                      sizeof(**segment->slice_offset_entries));
-            if (!segment->slice_offset_entries[i])
-                goto errmem;
-
-            for (j = 0; j < segment->slice_count; j++)
-                segment->slice_offset_entries[i][j] = avio_rb32(pb);
-        }
-
-        avio_skip(pb, length - 11 - 4 * segment->slice_count);
+        avio_skip(pb, length - 11);
     }
     return 0;
     }
     return 0;
-errmem:
-    if (segment->slice_offset_entries && segment->slice_count) {
-        for (i = 0; i < segment->nb_index_entries; i++)
-            av_free(segment->slice_offset_entries[i]);
-    }
-    av_freep(&segment->flag_entries);
-    av_freep(&segment->stream_offset_entries);
-    av_freep(&segment->slice_offset_entries);
-    av_freep(&segment->temporal_offset_entries);
-    return AVERROR(ENOMEM);
 }
 
 static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 }
 
 static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
@@ -769,13 +716,6 @@ static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int
         segment->body_sid = avio_rb32(pb);
         av_dlog(NULL, "BodySID %d\n", segment->body_sid);
         break;
         segment->body_sid = avio_rb32(pb);
         av_dlog(NULL, "BodySID %d\n", segment->body_sid);
         break;
-    case 0x3F08:
-        segment->slice_count = avio_r8(pb);
-        av_dlog(NULL, "SliceCount %d\n", segment->slice_count);
-        break;
-    case 0x3F09:
-        av_dlog(NULL, "DeltaEntryArray found\n");
-        return mxf_read_delta_entry_array(pb, segment);
     case 0x3F0A:
         av_dlog(NULL, "IndexEntryArray found\n");
         return mxf_read_index_entry_array(pb, segment);
     case 0x3F0A:
         av_dlog(NULL, "IndexEntryArray found\n");
         return mxf_read_index_entry_array(pb, segment);
@@ -1935,7 +1875,7 @@ static int mxf_read_close(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
     MXFIndexTableSegment *seg;
 {
     MXFContext *mxf = s->priv_data;
     MXFIndexTableSegment *seg;
-    int i, j;
+    int i;
 
     av_freep(&mxf->packages_refs);
 
 
     av_freep(&mxf->packages_refs);
 
@@ -1956,15 +1896,9 @@ static int mxf_read_close(AVFormatContext *s)
             break;
         case IndexTableSegment:
             seg = (MXFIndexTableSegment *)mxf->metadata_sets[i];
             break;
         case IndexTableSegment:
             seg = (MXFIndexTableSegment *)mxf->metadata_sets[i];
-            if (seg->slice_count)
-                for (j = 0; j < seg->nb_index_entries; j++)
-                    av_freep(&seg->slice_offset_entries[j]);
-            av_freep(&seg->slice);
-            av_freep(&seg->element_delta);
             av_freep(&seg->temporal_offset_entries);
             av_freep(&seg->flag_entries);
             av_freep(&seg->stream_offset_entries);
             av_freep(&seg->temporal_offset_entries);
             av_freep(&seg->flag_entries);
             av_freep(&seg->stream_offset_entries);
-            av_freep(&seg->slice_offset_entries);
             break;
         default:
             break;
             break;
         default:
             break;