CVS Root: /cvs/gstreamer
Module: gst-plugins-bad
Changes by: slomo
Date: Thu Nov 27 2008 16:26:53 UTC
Log message:
* 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.
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.3752&r2=1.3753
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c.diff?r1=1.11&r2=1.12
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h.diff?r1=1.3&r2=1.4
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.c.diff?r1=1.10&r2=1.11
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.h.diff?r1=1.7&r2=1.8
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxftypes.h.diff?r1=1.2&r2=1.3
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3752
retrieving revision 1.3753
diff -u -d -r1.3752 -r1.3753
--- ChangeLog 27 Nov 2008 10:09:51 -0000 1.3752
+++ ChangeLog 27 Nov 2008 16:26:32 -0000 1.3753
@@ -1,5 +1,19 @@
2008-11-27 Sebastian Dröge <[email protected]>
+ * 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.
+
+2008-11-27 Sebastian Dröge <[email protected]>
* gst/mxf/Makefile.am:
* gst/mxf/mxfdemux.c:
(gst_mxf_demux_handle_header_metadata_update_streams),
Index: mxfdemux.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mxfdemux.c 27 Nov 2008 10:09:52 -0000 1.11
+++ mxfdemux.c 27 Nov 2008 16:26:38 -0000 1.12
@@ -389,6 +389,11 @@
demux->src = NULL;
}
+ if (demux->partition_index) {
+ g_array_free (demux->partition_index, TRUE);
+ demux->partition_index = NULL;
+ }
gst_mxf_demux_reset_mxf_state (demux);
gst_mxf_demux_reset_metadata (demux);
}
@@ -1275,8 +1280,9 @@
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;
}
@@ -2136,7 +2142,17 @@
"Handling random index pack of size %u at offset %"
G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), demux->offset);
- /* TODO: Parse this */
+ GST_DEBUG_OBJECT (demux, "Already parsed random index pack");
+ return GST_FLOW_OK;
+ if (!mxf_random_index_pack_parse (key, GST_BUFFER_DATA (buffer),
+ GST_BUFFER_SIZE (buffer), &demux->partition_index)) {
+ GST_ERROR_OBJECT (demux, "Parsing random index pack failed");
+ return GST_FLOW_ERROR;
return GST_FLOW_OK;
@@ -2235,6 +2251,74 @@
return ret;
+void
+gst_mxf_demux_pull_random_index_pack (GstMXFDemux * demux)
+{
+ GstBuffer *buffer;
+ GstFlowReturn ret;
+ gint64 filesize = -1;
+ GstFormat fmt = GST_FORMAT_BYTES;
+ guint32 pack_size;
+ MXFUL key;
+ if (!gst_pad_query_peer_duration (demux->sinkpad, &fmt, &filesize) ||
+ fmt != GST_FORMAT_BYTES || filesize == -1) {
+ GST_DEBUG_OBJECT (demux, "Can't query upstream size");
+ return;
+ g_assert (filesize > 4);
+ if ((ret =
+ gst_mxf_demux_pull_range (demux, filesize - 4, 4,
+ &buffer)) != GST_FLOW_OK) {
+ GST_DEBUG_OBJECT (demux, "Failed pulling last 4 bytes");
+ pack_size = GST_READ_UINT32_BE (GST_BUFFER_DATA (buffer));
+ gst_buffer_unref (buffer);
+ if (pack_size < 20) {
+ GST_DEBUG_OBJECT (demux, "Too small pack size");
+ } else if (pack_size > filesize - 20) {
+ GST_DEBUG_OBJECT (demux, "Too large pack size");
+ gst_mxf_demux_pull_range (demux, filesize - pack_size, 16,
+ GST_DEBUG_OBJECT (demux, "Failed pulling random index pack key");
+ memcpy (&key, GST_BUFFER_DATA (buffer), 16);
+ if (!mxf_is_random_index_pack (&key)) {
+ GST_DEBUG_OBJECT (demux, "No random index pack");
+ gst_mxf_demux_pull_klv_packet (demux, filesize - pack_size, &key,
+ &buffer, NULL)) != GST_FLOW_OK) {
+ GST_DEBUG_OBJECT (demux, "Failed pulling random index pack");
+ gst_mxf_demux_handle_random_index_pack (demux, &key, buffer);
+ if (!demux->partition_index)
+ demux->partition_index =
+ g_array_new (FALSE, FALSE, sizeof (MXFRandomIndexPackEntry));
+}
static void
gst_mxf_demux_parse_footer_metadata (GstMXFDemux * demux)
{
@@ -2521,6 +2605,11 @@
goto pause;
+ /* First of all pull&parse the random index pack at EOF */
+ if (!demux->partition_index) {
+ gst_mxf_demux_pull_random_index_pack (demux);
/* Now actually do something */
ret = gst_mxf_demux_pull_and_handle_klv_packet (demux);
Index: mxfdemux.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mxfdemux.h 27 Nov 2008 08:49:08 -0000 1.3
+++ mxfdemux.h 27 Nov 2008 16:26:38 -0000 1.4
@@ -67,6 +67,8 @@
MXFPartitionPack partition;
MXFPrimerPack primer;
+ GArray *partition_index;
/* Structural metadata */
gboolean update_metadata;
gboolean final_metadata;
Index: mxfparse.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.c,v
retrieving revision 1.10
diff -u -d -r1.10 -r1.11
--- mxfparse.c 27 Nov 2008 10:09:53 -0000 1.10
+++ mxfparse.c 27 Nov 2008 16:26:38 -0000 1.11
@@ -556,6 +556,46 @@
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)
+ 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 */
Index: mxfparse.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfparse.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mxfparse.h 27 Nov 2008 10:09:53 -0000 1.7
+++ mxfparse.h 27 Nov 2008 16:26:39 -0000 1.8
@@ -77,6 +77,8 @@
gboolean mxf_primer_pack_parse (const MXFUL *key, MXFPrimerPack *pack, const guint8 *data, guint size);
void mxf_primer_pack_reset (MXFPrimerPack *pack);
+gboolean mxf_random_index_pack_parse (const MXFUL *key, const guint8 *data, guint size, GArray **array);
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.2
diff -u -d -r1.2 -r1.3
--- mxftypes.h 25 Nov 2008 10:26:11 -0000 1.2
+++ mxftypes.h 27 Nov 2008 16:26:39 -0000 1.3
@@ -63,6 +63,12 @@
guint8 *data;
} MXFLocalTag;
+typedef struct {
+ guint32 body_sid;
+ guint64 offset;
+} MXFRandomIndexPackEntry;
typedef enum {
MXF_PARTITION_PACK_HEADER,
MXF_PARTITION_PACK_BODY,
-------------------------------------------------------------------------
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.