gst/mxf/: Allow non-MXF KLV packets and just drop them instead of throwing an error and handle 9 byte product version...

Original commit message from CVS:
* gst/mxf/mxfdemux.c: (gst_mxf_demux_pull_klv_packet),
(gst_mxf_demux_handle_klv_packet), (gst_mxf_demux_chain):
* gst/mxf/mxfparse.c: (mxf_product_version_parse),
(mxf_metadata_identification_parse),
(mxf_metadata_content_storage_parse):
Allow non-MXF KLV packets and just drop them instead of throwing
an error and handle 9 byte product versions as written by Avid.
This doesn't add support for the non-standard Avid MXF files
but at least makes it possible to parse their header metadata.
Fix a copy&paste error in debug output.
This commit is contained in:
Sebastian Dröge 2008-11-24 10:41:13 +00:00
parent 25d2d8f48a
commit fa9ccc1eca
3 changed files with 31 additions and 28 deletions

View file

@ -1,3 +1,17 @@
2008-11-24 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/mxf/mxfdemux.c: (gst_mxf_demux_pull_klv_packet),
(gst_mxf_demux_handle_klv_packet), (gst_mxf_demux_chain):
* gst/mxf/mxfparse.c: (mxf_product_version_parse),
(mxf_metadata_identification_parse),
(mxf_metadata_content_storage_parse):
Allow non-MXF KLV packets and just drop them instead of throwing
an error and handle 9 byte product versions as written by Avid.
This doesn't add support for the non-standard Avid MXF files
but at least makes it possible to parse their header metadata.
Fix a copy&paste error in debug output.
2008-11-23 Stefan Kost <ensonic@users.sf.net>
* ext/jack/gstjackaudiosink.c:

View file

@ -1127,8 +1127,9 @@ gst_mxf_demux_handle_header_metadata_resolve_references (GstMXFDemux * demux)
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;
}
@ -1982,7 +1983,6 @@ gst_mxf_demux_pull_klv_packet (GstMXFDemux * demux, guint64 offset, MXFUL * key,
const guint8 *data;
guint64 data_offset = 0;
guint64 length;
gchar key_str[48];
GstFlowReturn ret = GST_FLOW_OK;
memset (key, 0, sizeof (MXFUL));
@ -1994,13 +1994,6 @@ gst_mxf_demux_pull_klv_packet (GstMXFDemux * demux, guint64 offset, MXFUL * key,
data = GST_BUFFER_DATA (buffer);
if (!mxf_is_mxf_packet ((const MXFUL *) data)) {
GST_ERROR_OBJECT (demux, "Not an MXF packet, skipping. Key: %s",
mxf_ul_to_string ((const MXFUL *) data, key_str));
ret = GST_FLOW_ERROR;
goto beach;
}
memcpy (key, GST_BUFFER_DATA (buffer), 16);
/* Decode BER encoded packet length */
@ -2243,7 +2236,12 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
goto beach;
}
if (mxf_is_partition_pack (key)) {
if (!mxf_is_mxf_packet (key)) {
GST_WARNING_OBJECT (demux,
"Skipping non-MXF packet of size %u at offset %"
G_GUINT64_FORMAT ", key: %s", GST_BUFFER_SIZE (buffer), demux->offset,
mxf_ul_to_string (key, key_str));
} else if (mxf_is_partition_pack (key)) {
ret = gst_mxf_demux_handle_partition_pack (demux, key, buffer);
} else if (mxf_is_primer_pack (key)) {
ret = gst_mxf_demux_handle_primer_pack (demux, key, buffer);
@ -2414,7 +2412,6 @@ gst_mxf_demux_chain (GstPad * pad, GstBuffer * inbuf)
guint64 length = 0;
guint64 offset = 0;
GstBuffer *buffer = NULL;
gchar key_str[48];
demux = GST_MXF_DEMUX (gst_pad_get_parent (pad));
@ -2488,13 +2485,6 @@ gst_mxf_demux_chain (GstPad * pad, GstBuffer * inbuf)
/* Pull 16 byte key and first byte of BER encoded length */
data = gst_adapter_peek (demux->adapter, 17);
if (!mxf_is_mxf_packet ((const MXFUL *) data)) {
GST_ERROR_OBJECT (demux, "Not an MXF packet, skipping. Key: %s",
mxf_ul_to_string ((const MXFUL *) data, key_str));
ret = GST_FLOW_ERROR;
break;
}
memcpy (&key, data, 16);
/* Decode BER encoded packet length */

View file

@ -376,13 +376,18 @@ mxf_product_version_parse (MXFProductVersion * product_version,
memset (product_version, 0, sizeof (MXFProductVersion));
if (size < 10)
if (size < 9)
return FALSE;
product_version->major = GST_READ_UINT16_BE (data);
product_version->minor = GST_READ_UINT16_BE (data + 2);
product_version->patch = GST_READ_UINT16_BE (data + 4);
product_version->build = GST_READ_UINT16_BE (data + 6);
/* Avid writes a 9 byte product version */
if (size == 9)
product_version->release = GST_READ_UINT8 (data + 8);
else
product_version->release = GST_READ_UINT16_BE (data + 8);
return TRUE;
@ -921,8 +926,6 @@ mxf_metadata_identification_parse (const MXFUL * key,
break;
case 0x3c03:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 10)
goto error;
if (!mxf_product_version_parse (&identification->product_version,
tag_data, tag_size))
goto error;
@ -939,16 +942,12 @@ mxf_metadata_identification_parse (const MXFUL * key,
break;
case 0x3c06:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 8)
goto error;
if (!mxf_timestamp_parse (&identification->modification_date, tag_data,
tag_size))
goto error;
break;
case 0x3c07:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 10)
goto error;
if (!mxf_product_version_parse (&identification->toolkit_version,
tag_data, tag_size))
goto error;
@ -1126,7 +1125,7 @@ mxf_metadata_content_storage_parse (const MXFUL * key,
for (i = 0; i < content_storage->n_packages; i++)
GST_DEBUG (" package %u = %s", i,
mxf_ul_to_string (&content_storage->packages_uids[i], str));
for (i = 0; i < content_storage->n_packages; i++)
for (i = 0; i < content_storage->n_essence_container_data; i++)
GST_DEBUG (" essence container data %u = %s", i,
mxf_ul_to_string (&content_storage->essence_container_data_uids[i],
str));