[FFmpeg-devel] [PATCH 10/11] libavformat/mxfdec.c: Parse index table segment DeltaEntryArray.

Alexis Ballier aballier at gentoo.org
Wed Oct 21 18:01:04 CEST 2015


---
 libavformat/mxfdec.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 75858fc..020294d 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -192,6 +192,12 @@ typedef struct MXFDescriptor {
     enum AVPixelFormat pix_fmt;
 } MXFDescriptor;
 
+typedef struct MXFDeltaEntry {
+    int8_t pos_table_index;
+    uint8_t slice;
+    uint32_t element_delta;
+} MXFDeltaEntry;
+
 typedef struct MXFIndexTableSegment {
     UID uid;
     enum MXFMetadataSetType type;
@@ -206,6 +212,8 @@ typedef struct MXFIndexTableSegment {
     int *flag_entries;
     uint64_t *stream_offset_entries;
     int nb_index_entries;
+    uint32_t nb_delta_entries;
+    MXFDeltaEntry* delta_entry_array;
 } MXFIndexTableSegment;
 
 typedef struct MXFPackage {
@@ -333,6 +341,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
         av_freep(&seg->temporal_offset_entries);
         av_freep(&seg->flag_entries);
         av_freep(&seg->stream_offset_entries);
+        av_freep(&seg->delta_entry_array);
     default:
         break;
     }
@@ -924,6 +933,28 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg
     return 0;
 }
 
+static int mxf_read_delta_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
+{
+    uint32_t length;
+    unsigned int i;
+
+    segment->nb_delta_entries = avio_rb32(pb);
+
+    length = avio_rb32(pb);
+
+    if (!(segment->delta_entry_array = av_calloc(segment->nb_delta_entries, sizeof(*segment->delta_entry_array))))
+        return AVERROR(ENOMEM);
+
+    for (i = 0; i < segment->nb_delta_entries; i++) {
+        segment->delta_entry_array[i].pos_table_index = avio_r8(pb);
+        segment->delta_entry_array[i].slice           = avio_r8(pb);
+        segment->delta_entry_array[i].element_delta   = avio_rb32(pb);
+        avio_skip(pb, length - 6);
+    }
+
+    return 0;
+}
+
 static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 {
     MXFIndexTableSegment *segment = arg;
@@ -944,6 +975,9 @@ static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int
         segment->slice_count = avio_r8(pb);
         av_log(NULL, AV_LOG_TRACE, "Slice Count %u\n", segment->slice_count);
         break;
+    case 0x3F09:
+        av_log(NULL, AV_LOG_TRACE, "DeltaEntryArray found\n");
+        return mxf_read_delta_entry_array(pb, segment);
     case 0x3F0A:
         av_log(NULL, AV_LOG_TRACE, "IndexEntryArray found\n");
         return mxf_read_index_entry_array(pb, segment);
-- 
2.6.2



More information about the ffmpeg-devel mailing list