From a926db34ad8b983c95ef72ed9a5cb884c55430d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 27 Nov 2008 16:26:39 +0000 Subject: gst/mxf/: Implement parsing of the random index pack, which provides a seek table (including body sid) to the start o... Original commit message from CVS: * gst/mxf/mxfdemux.c: (gst_mxf_demux_reset), (gst_mxf_demux_handle_random_index_pack), (gst_mxf_demux_pull_random_index_pack), (gst_mxf_demux_loop): * gst/mxf/mxfdemux.h: * gst/mxf/mxfparse.c: (mxf_random_index_pack_parse): * gst/mxf/mxfparse.h: * gst/mxf/mxftypes.h: Implement parsing of the random index pack, which provides a seek table (including body sid) to the start of partition packs. Later this will be used for reading all index table segments of the complete file efficiently. --- gst/mxf/mxfparse.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gst/mxf/mxfparse.c') diff --git a/gst/mxf/mxfparse.c b/gst/mxf/mxfparse.c index 90fa6348..aceebc97 100644 --- a/gst/mxf/mxfparse.c +++ b/gst/mxf/mxfparse.c @@ -556,6 +556,46 @@ mxf_partition_pack_reset (MXFPartitionPack * pack) memset (pack, 0, sizeof (MXFPartitionPack)); } +/* SMPTE 377M 11.1 */ +gboolean +mxf_random_index_pack_parse (const MXFUL * key, const guint8 * data, guint size, + GArray ** array) +{ + guint len, i; + MXFRandomIndexPackEntry entry; + + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (array != NULL, FALSE); + + if (size < 4) + return FALSE; + + if ((size - 4) % 12 != 0) + return FALSE; + + GST_DEBUG ("Parsing random index pack:"); + + len = (size - 4) / 12; + + GST_DEBUG (" number of entries = %u", len); + + *array = + g_array_sized_new (FALSE, FALSE, sizeof (MXFRandomIndexPackEntry), len); + + for (i = 0; i < len; i++) { + entry.body_sid = GST_READ_UINT32_BE (data); + entry.offset = GST_READ_UINT64_BE (data + 4); + data += 12; + + GST_DEBUG (" entry %u = body sid %u at offset %" G_GUINT64_FORMAT, i, + entry.body_sid, entry.offset); + + g_array_append_val (*array, entry); + } + + return TRUE; +} + /* SMPTE 377M 8.2 Table 1 and 2 */ static void -- cgit v1.2.1