slomo gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/gst/mxf/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-bad
Changes by:     slomo
Date:           Fri Nov 28 2008  11:24:38 UTC

Log message:
* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset),
(gst_mxf_demux_handle_index_table_segment):
* gst/mxf/mxfdemux.h:
* gst/mxf/mxfparse.c: (mxf_index_table_segment_parse),
(mxf_index_table_segment_reset):
* gst/mxf/mxfparse.h:
* gst/mxf/mxftypes.h:
Implement parsing of index table segments, which will later be
used for seeking.

Modified files:
    .               : ChangeLog
    gst/mxf         : mxfdemux.c mxfdemux.h mxfparse.c mxfparse.h
                      mxftypes.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3760&r2=1.3761
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c.diff?r1=1.12&r2=1.13
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h.diff?r1=1.4&r2=1.5
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.c.diff?r1=1.11&r2=1.12
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.h.diff?r1=1.8&r2=1.9
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxftypes.h.diff?r1=1.3&r2=1.4

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3760
retrieving revision 1.3761
diff -u -d -r1.3760 -r1.3761
--- ChangeLog	28 Nov 2008 09:49:53 -0000	1.3760
+++ ChangeLog	28 Nov 2008 11:24:22 -0000	1.3761
@@ -1,5 +1,17 @@
 2008-11-28  Sebastian Dröge  <[email protected]>
 
+	* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset),
+	(gst_mxf_demux_handle_index_table_segment):
+	* gst/mxf/mxfdemux.h:
+	* gst/mxf/mxfparse.c: (mxf_index_table_segment_parse),
+	(mxf_index_table_segment_reset):
+	* gst/mxf/mxfparse.h:
+	* gst/mxf/mxftypes.h:
+	Implement parsing of index table segments, which will later be
+	used for seeking.
+
+2008-11-28  Sebastian Dröge  <[email protected]>
 	* docs/plugins/gst-plugins-bad-plugins.args:
 	* docs/plugins/gst-plugins-bad-plugins.hierarchy:
 	* docs/plugins/gst-plugins-bad-plugins.interfaces:
Index: mxfdemux.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mxfdemux.c	27 Nov 2008 16:26:38 -0000	1.12
+++ mxfdemux.c	28 Nov 2008 11:24:23 -0000	1.13
@@ -394,6 +394,17 @@
     demux->partition_index = NULL;
   }
+  if (demux->index_table) {
+    guint i;
+    for (i = 0; i < demux->index_table->len; i++)
+      mxf_index_table_segment_reset (&g_array_index (demux->index_table,
+              MXFIndexTableSegment, i));
+    g_array_free (demux->index_table, TRUE);
+    demux->index_table = NULL;
+  }
   gst_mxf_demux_reset_mxf_state (demux);
   gst_mxf_demux_reset_metadata (demux);
 }
@@ -1280,9 +1291,8 @@
           MXFMetadataEssenceContainerData, i);
       for (j = 0; j < demux->content_storage.n_essence_container_data; j++) {
-        if (mxf_ul_is_equal (&demux->
-                content_storage.essence_container_data_uids[j],
-                &data->instance_uid)) {
+        if (mxf_ul_is_equal (&demux->content_storage.
+                essence_container_data_uids[j], &data->instance_uid)) {
           demux->content_storage.essence_container_data[j] = data;
           break;
         }
@@ -2160,11 +2170,32 @@
 gst_mxf_demux_handle_index_table_segment (GstMXFDemux * demux,
     const MXFUL * key, GstBuffer * buffer)
 {
+  MXFIndexTableSegment segment;
+  memset (&segment, 0, sizeof (segment));
   GST_DEBUG_OBJECT (demux,
       "Handling index table segment of size %u at offset %"
       G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), demux->offset);
-  /* TODO: Parse this */
+  if (!demux->primer.valid) {
+    GST_WARNING_OBJECT (demux, "Invalid primer pack");
+    return GST_FLOW_OK;
+  if (!mxf_index_table_segment_parse (key, &segment, &demux->primer,
+          GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer))) {
+    GST_ERROR_OBJECT (demux, "Parsing index table segment failed");
+    return GST_FLOW_ERROR;
+  if (!demux->index_table)
+    demux->index_table =
+        g_array_new (FALSE, FALSE, sizeof (MXFIndexTableSegment));
+  g_array_append_val (demux->index_table, segment);
   return GST_FLOW_OK;
Index: mxfdemux.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mxfdemux.h	27 Nov 2008 16:26:38 -0000	1.4
+++ mxfdemux.h	28 Nov 2008 11:24:23 -0000	1.5
@@ -68,6 +68,7 @@
   MXFPrimerPack primer;
   GArray *partition_index;
+  GArray *index_table;
   /* Structural metadata */
   gboolean update_metadata;
Index: mxfparse.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.c,v
retrieving revision 1.11
diff -u -d -r1.11 -r1.12
--- mxfparse.c	27 Nov 2008 16:26:38 -0000	1.11
+++ mxfparse.c	28 Nov 2008 11:24:23 -0000	1.12
@@ -596,6 +596,246 @@
   return TRUE;
+/* SMPTE 377M 10.2.3 */
+gboolean
+mxf_index_table_segment_parse (const MXFUL * key,
+    MXFIndexTableSegment * segment, const MXFPrimerPack * primer,
+    const guint8 * data, guint size)
+{
+  gchar str[48];
+  guint16 tag, tag_size;
+  const guint8 *tag_data;
+  g_return_val_if_fail (key != NULL, FALSE);
+  g_return_val_if_fail (data != NULL, FALSE);
+  g_return_val_if_fail (primer != NULL, FALSE);
+  memset (segment, 0, sizeof (MXFIndexTableSegment));
+  if (size < 70)
+    return FALSE;
+  GST_DEBUG ("Parsing index table segment:");
+  while (mxf_local_tag_parse (data, size, &tag, &tag_size, &tag_data)) {
+    if (tag_size == 0 || tag == 0x0000)
+      goto next;
+    switch (tag) {
+      case 0x3c0a:
+        if (tag_size != 16)
+          goto error;
+        memcpy (&segment->instance_id, tag_data, 16);
+        GST_DEBUG ("  instance id = %s",
+            mxf_ul_to_string (&segment->instance_id, str));
+        break;
+      case 0x3f0b:
+        if (!mxf_fraction_parse (&segment->index_edit_rate, tag_data, tag_size))
+        GST_DEBUG ("  index edit rate = %d/%d", segment->index_edit_rate.n,
+            segment->index_edit_rate.d);
+      case 0x3f0c:
+        if (tag_size != 8)
+        segment->index_start_position = GST_READ_UINT64_BE (tag_data);
+        GST_DEBUG ("  index start position = %" G_GINT64_FORMAT,
+            segment->index_start_position);
+      case 0x3f0d:
+        segment->index_duration = GST_READ_UINT64_BE (tag_data);
+        GST_DEBUG ("  index duration = %" G_GINT64_FORMAT,
+            segment->index_duration);
+      case 0x3f05:
+        if (tag_size != 4)
+        segment->edit_unit_byte_count = GST_READ_UINT32_BE (tag_data);
+        GST_DEBUG ("  edit unit byte count = %u",
+            segment->edit_unit_byte_count);
+      case 0x3f06:
+        segment->index_sid = GST_READ_UINT32_BE (tag_data);
+        GST_DEBUG ("  index sid = %u", segment->index_sid);
+      case 0x3f07:
+        segment->body_sid = GST_READ_UINT32_BE (tag_data);
+        GST_DEBUG ("  body sid = %u", segment->body_sid);
+      case 0x3f08:
+        if (tag_size != 1)
+        segment->slice_count = GST_READ_UINT8 (tag_data);
+        GST_DEBUG ("  slice count = %u", segment->slice_count);
+      case 0x3f0e:
+        segment->pos_table_count = GST_READ_UINT8 (tag_data);
+        GST_DEBUG ("  pos table count = %u", segment->pos_table_count);
+      case 0x3f09:{
+        guint len, i;
+        if (tag_size < 8)
+        len = GST_READ_UINT32_BE (tag_data);
+        segment->n_delta_entries = len;
+        GST_DEBUG ("  number of delta entries = %u", segment->n_delta_entries);
+        if (len == 0)
+          goto next;
+        tag_data += 4;
+        tag_size -= 4;
+        if (GST_READ_UINT32_BE (tag_data) != 6)
+        if (tag_size < len * 6)
+        segment->delta_entries = g_new (MXFDeltaEntry, len);
+        for (i = 0; i < len; i++) {
+          GST_DEBUG ("    delta entry %u:", i);
+          segment->delta_entries[i].pos_table_index = GST_READ_UINT8 (tag_data);
+          tag_data += 1;
+          tag_size -= 1;
+          GST_DEBUG ("    pos table index = %d",
+              segment->delta_entries[i].pos_table_index);
+          segment->delta_entries[i].slice = GST_READ_UINT8 (tag_data);
+          GST_DEBUG ("    slice = %u", segment->delta_entries[i].slice);
+          segment->delta_entries[i].element_delta =
+              GST_READ_UINT32_BE (tag_data);
+          tag_data += 4;
+          tag_size -= 4;
+          GST_DEBUG ("    element delta = %u",
+              segment->delta_entries[i].element_delta);
+        }
+      }
+      case 0x3f0a:{
+        guint len, i, j;
+        segment->n_index_entries = len;
+        GST_DEBUG ("  number of index entries = %u", segment->n_index_entries);
+        if (GST_READ_UINT32_BE (tag_data) !=
+            (11 + 4 * segment->slice_count + 8 * segment->pos_table_count))
+        if (tag_size <
+            len * (11 + 4 * segment->slice_count +
+                8 * segment->pos_table_count))
+        segment->index_entries = g_new (MXFIndexEntry, len);
+          MXFIndexEntry *entry = &segment->index_entries[i];
+          GST_DEBUG ("    index entry %u:", i);
+          entry->temporal_offset = GST_READ_UINT8 (tag_data);
+          GST_DEBUG ("    temporal offset = %d", entry->temporal_offset);
+          entry->key_frame_offset = GST_READ_UINT8 (tag_data);
+          GST_DEBUG ("    keyframe offset = %d", entry->key_frame_offset);
+          entry->flags = GST_READ_UINT8 (tag_data);
+          GST_DEBUG ("    flags = 0x%02x", entry->flags);
+          entry->stream_offset = GST_READ_UINT64_BE (tag_data);
+          tag_data += 8;
+          tag_size -= 8;
+          GST_DEBUG ("    stream offset = %" G_GUINT64_FORMAT,
+              entry->stream_offset);
+          for (j = 0; j < segment->slice_count; j++) {
+            entry->slice_offset[j] = GST_READ_UINT32_BE (tag_data);
+            tag_data += 4;
+            tag_size -= 4;
+            GST_DEBUG ("    slice %u offset = %u", j, entry->slice_offset[j]);
+          }
+          for (j = 0; j < segment->pos_table_count; j++) {
+            mxf_fraction_parse (&entry->pos_table[j], tag_data, tag_size);
+            tag_data += 8;
+            tag_size -= 8;
+            GST_DEBUG ("    pos table %u = %d/%d", j, entry->pos_table[j].n,
+                entry->pos_table[j].d);
+      default:
+        if (!gst_metadata_add_custom_tag (primer, tag, tag_data, tag_size,
+                &segment->other_tags))
+    }
+  next:
+    data += 4 + tag_size;
+    size -= 4 + tag_size;
+  return TRUE;
+error:
+  GST_ERROR ("Invalid index table segment");
+  return FALSE;
+}
+void
+mxf_index_table_segment_reset (MXFIndexTableSegment * segment)
+  guint i;
+  g_return_if_fail (segment != NULL);
+  for (i = 0; i < segment->n_index_entries; i++) {
+    g_free (segment->index_entries[i].slice_offset);
+    g_free (segment->index_entries[i].pos_table);
+  g_free (segment->index_entries);
+  g_free (segment->delta_entries);
+  if (segment->other_tags)
+    g_hash_table_destroy (segment->other_tags);
 /* SMPTE 377M 8.2 Table 1 and 2 */
 static void
Index: mxfparse.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mxfparse.h	27 Nov 2008 16:26:39 -0000	1.8
+++ mxfparse.h	28 Nov 2008 11:24:24 -0000	1.9
@@ -79,6 +79,9 @@
 gboolean mxf_random_index_pack_parse (const MXFUL *key, const guint8 *data, guint size, GArray **array);
+gboolean mxf_index_table_segment_parse (const MXFUL *key, MXFIndexTableSegment *segment, const MXFPrimerPack *primer, const guint8 *data, guint size);
+void mxf_index_table_segment_reset (MXFIndexTableSegment *segment);
 gboolean mxf_local_tag_parse (const guint8 * data, guint size, guint16 * tag,
     guint16 * tag_size, const guint8 ** tag_data);
 void gst_mxf_local_tag_free (MXFLocalTag *tag);
Index: mxftypes.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxftypes.h,v
retrieving revision 1.3
diff -u -d -r1.3 -r1.4
--- mxftypes.h	27 Nov 2008 16:26:39 -0000	1.3
+++ mxftypes.h	28 Nov 2008 11:24:24 -0000	1.4
@@ -115,6 +115,44 @@
   GHashTable *mappings;
 } MXFPrimerPack;
+typedef struct {
+  gint8 pos_table_index;
+  guint8 slice;
+  guint32 element_delta;
+} MXFDeltaEntry;
+  gint8 temporal_offset;
+  gint8 key_frame_offset;
+  guint8 flags;
+  guint64 stream_offset;
+  
+  guint32 *slice_offset;
+  MXFFraction *pos_table;
+} MXFIndexEntry;
+  MXFUL instance_id;
+  MXFFraction index_edit_rate;
+  gint64 index_start_position;
+  gint64 index_duration;
+  guint32 edit_unit_byte_count;
+  guint32 index_sid;
+  guint32 body_sid;
+  guint8 slice_count;
+  guint8 pos_table_count;
+  guint32 n_delta_entries;
+  MXFDeltaEntry *delta_entries;
+  guint32 n_index_entries;
+  MXFIndexEntry *index_entries;
+  GHashTable *other_tags;
+} MXFIndexTableSegment;
 /* SMPTE 377M 8.6 table 14 */
 #define MXF_METADATA_PREFACE (0x012f)
 #define MXF_METADATA_IDENTIFICATION (0x0130)

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.