mxfdemux: Add support for non-standard Avid MXF files containing DNxHD essence

Avid uses a custom essence container UL and custom essence element keys
that are fortunately compatible with the generic container essence
elements. Partially fixes bug #561922.
This commit is contained in:
Sebastian Dröge 2009-02-07 10:38:26 +01:00
parent 3c3dff6869
commit 8dc9f2ea4d
4 changed files with 36 additions and 4 deletions

View file

@ -2133,7 +2133,8 @@ next_try:
gst_buffer_unref (buffer);
buffer = NULL;
} else if (mxf_is_generic_container_system_item (&key) ||
mxf_is_generic_container_essence_element (&key)) {
mxf_is_generic_container_essence_element (&key) ||
mxf_is_avid_essence_container_essence_element (&key)) {
demux->offset += read;
gst_buffer_unref (buffer);
buffer = NULL;
@ -2183,7 +2184,8 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
demux->run_in + demux->current_partition->primer.offset +
demux->current_partition->partition.header_byte_count ||
mxf_is_generic_container_system_item (key) ||
mxf_is_generic_container_essence_element (key))) {
mxf_is_generic_container_essence_element (key) ||
mxf_is_avid_essence_container_essence_element (key))) {
demux->current_partition->parsed_metadata = TRUE;
if ((ret = gst_mxf_demux_resolve_references (demux)) != GST_FLOW_OK ||
(ret = gst_mxf_demux_update_tracks (demux)) != GST_FLOW_OK) {
@ -2234,7 +2236,8 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
} else if (mxf_is_generic_container_system_item (key)) {
ret =
gst_mxf_demux_handle_generic_container_system_item (demux, key, buffer);
} else if (mxf_is_generic_container_essence_element (key)) {
} else if (mxf_is_generic_container_essence_element (key) ||
mxf_is_avid_essence_container_essence_element (key)) {
ret =
gst_mxf_demux_handle_generic_container_essence_element (demux, key,
buffer, peek);

View file

@ -215,6 +215,18 @@ mxf_is_avid_essence_container_label (const MXFUL * key)
return (memcmp (&key->u, avid_essence_container_label, 16) == 0);
}
/* Essence element key found in files generated by Avid */
static const guint8 avid_essence_element_ul[] = {
0x06, 0x0e, 0x2b, 0x34, 0x01, 0x02, 0x01, 0x01, 0x0e, 0x04, 0x03, 0x01, 0x00,
0x00, 0x00, 0x00
};
gboolean
mxf_is_avid_essence_container_essence_element (const MXFUL * key)
{
return (memcmp (&key->u, avid_essence_element_ul, 12) == 0);
}
gboolean
mxf_ul_is_equal (const MXFUL * a, const MXFUL * b)
{

View file

@ -61,6 +61,7 @@ gboolean mxf_is_index_table_segment (const MXFUL *key);
gboolean mxf_is_generic_container_system_item (const MXFUL *key);
gboolean mxf_is_generic_container_essence_element (const MXFUL *key);
gboolean mxf_is_avid_essence_container_essence_element (const MXFUL * key);
gboolean mxf_is_generic_container_essence_container_label (const MXFUL *key);
gboolean mxf_is_avid_essence_container_label (const MXFUL *key);

View file

@ -33,6 +33,11 @@
GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
#define GST_CAT_DEFAULT mxf_debug
static const guint8 picture_essence_coding_vc3_avid[] = {
0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, 0x0e, 0x04, 0x02, 0x01, 0x02,
0x04, 0x01, 0x00
};
static gboolean
mxf_is_vc3_essence_track (const MXFMetadataTimelineTrack * track)
{
@ -54,8 +59,19 @@ mxf_is_vc3_essence_track (const MXFMetadataTimelineTrack * track)
/* SMPTE S2019-4 7 */
if (mxf_is_generic_container_essence_container_label (key) &&
key->u[12] == 0x02 && key->u[13] == 0x11 &&
(key->u[14] == 0x01 || key->u[14] == 0x02))
(key->u[14] == 0x01 || key->u[14] == 0x02)) {
return TRUE;
} else if (mxf_is_avid_essence_container_label (key)) {
MXFMetadataGenericPictureEssenceDescriptor *p;
if (!MXF_IS_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (d))
return FALSE;
p = MXF_METADATA_GENERIC_PICTURE_ESSENCE_DESCRIPTOR (d);
key = &p->picture_essence_coding;
if (memcmp (key, picture_essence_coding_vc3_avid, 16) == 0)
return TRUE;
}
}
return FALSE;