gst/mxf/: Rewrite parsing of descriptors to go top-down instead of bottom-up which makes it possible to have the buff...

Original commit message from CVS:
* gst/mxf/mxfaes-bwf.c:
(mxf_metadata_wave_audio_essence_descriptor_handle_tag):
* gst/mxf/mxfaes-bwf.h:
* gst/mxf/mxfdemux.c:
(gst_mxf_demux_handle_metadata_generic_descriptor),
(gst_mxf_demux_handle_metadata_file_descriptor),
(gst_mxf_demux_handle_metadata_multiple_descriptor),
(gst_mxf_demux_handle_metadata_generic_picture_essence_descriptor),
(gst_mxf_demux_handle_metadata_cdci_picture_essence_descriptor),
(gst_mxf_demux_handle_metadata_mpeg_video_descriptor),
(gst_mxf_demux_handle_metadata_generic_sound_essence_descriptor),
(gst_mxf_demux_handle_metadata_wave_audio_essence_descriptor),
(gst_mxf_demux_handle_header_metadata_resolve_references),
(gst_mxf_demux_handle_metadata):
* gst/mxf/mxfmpeg.c:
(mxf_metadata_mpeg_video_descriptor_handle_tag):
* gst/mxf/mxfmpeg.h:
* gst/mxf/mxfparse.c: (mxf_partition_pack_parse),
(mxf_primer_pack_parse), (mxf_metadata_preface_parse),
(mxf_metadata_identification_parse),
(mxf_metadata_content_storage_parse),
(mxf_metadata_essence_container_data_parse),
(mxf_metadata_generic_package_parse), (mxf_metadata_track_parse),
(mxf_metadata_sequence_parse),
(mxf_metadata_structural_component_parse),
(mxf_metadata_descriptor_parse),
(mxf_metadata_generic_descriptor_handle_tag),
(mxf_metadata_generic_descriptor_reset),
(mxf_metadata_file_descriptor_handle_tag),
(mxf_metadata_generic_sound_essence_descriptor_handle_tag),
(mxf_metadata_generic_picture_essence_descriptor_handle_tag),
(mxf_metadata_cdci_picture_essence_descriptor_handle_tag),
(mxf_metadata_multiple_descriptor_handle_tag),
(mxf_metadata_locator_parse):
* gst/mxf/mxfparse.h:
Rewrite parsing of descriptors to go top-down instead of bottom-up
which makes it possible to have the buffer data non-writable.
Improve debugging a bit.
This commit is contained in:
Sebastian Dröge 2008-11-25 09:38:26 +00:00
parent a485e4c252
commit fb8d2b901d
8 changed files with 1105 additions and 1211 deletions

View file

@ -1,3 +1,45 @@
2008-11-25 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/mxf/mxfaes-bwf.c:
(mxf_metadata_wave_audio_essence_descriptor_handle_tag):
* gst/mxf/mxfaes-bwf.h:
* gst/mxf/mxfdemux.c:
(gst_mxf_demux_handle_metadata_generic_descriptor),
(gst_mxf_demux_handle_metadata_file_descriptor),
(gst_mxf_demux_handle_metadata_multiple_descriptor),
(gst_mxf_demux_handle_metadata_generic_picture_essence_descriptor),
(gst_mxf_demux_handle_metadata_cdci_picture_essence_descriptor),
(gst_mxf_demux_handle_metadata_mpeg_video_descriptor),
(gst_mxf_demux_handle_metadata_generic_sound_essence_descriptor),
(gst_mxf_demux_handle_metadata_wave_audio_essence_descriptor),
(gst_mxf_demux_handle_header_metadata_resolve_references),
(gst_mxf_demux_handle_metadata):
* gst/mxf/mxfmpeg.c:
(mxf_metadata_mpeg_video_descriptor_handle_tag):
* gst/mxf/mxfmpeg.h:
* gst/mxf/mxfparse.c: (mxf_partition_pack_parse),
(mxf_primer_pack_parse), (mxf_metadata_preface_parse),
(mxf_metadata_identification_parse),
(mxf_metadata_content_storage_parse),
(mxf_metadata_essence_container_data_parse),
(mxf_metadata_generic_package_parse), (mxf_metadata_track_parse),
(mxf_metadata_sequence_parse),
(mxf_metadata_structural_component_parse),
(mxf_metadata_descriptor_parse),
(mxf_metadata_generic_descriptor_handle_tag),
(mxf_metadata_generic_descriptor_reset),
(mxf_metadata_file_descriptor_handle_tag),
(mxf_metadata_generic_sound_essence_descriptor_handle_tag),
(mxf_metadata_generic_picture_essence_descriptor_handle_tag),
(mxf_metadata_cdci_picture_essence_descriptor_handle_tag),
(mxf_metadata_multiple_descriptor_handle_tag),
(mxf_metadata_locator_parse):
* gst/mxf/mxfparse.h:
Rewrite parsing of descriptors to go top-down instead of bottom-up
which makes it possible to have the buffer data non-writable.
Improve debugging a bit.
2008-11-24 Michael Smith <msmith@songbirdnest.com>
* configure.ac:

View file

@ -41,154 +41,134 @@ GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
/* SMPTE 382M Annex 1 */
gboolean
mxf_metadata_wave_audio_essence_descriptor_parse (const MXFUL * key,
MXFMetadataWaveAudioEssenceDescriptor * descriptor,
const MXFPrimerPack * primer, guint16 type, const guint8 * data, guint size)
mxf_metadata_wave_audio_essence_descriptor_handle_tag
(MXFMetadataGenericDescriptor * d, const MXFPrimerPack * primer,
guint16 tag, const guint8 * tag_data, guint16 tag_size)
{
guint16 tag, tag_size;
const guint8 *tag_data;
MXFMetadataWaveAudioEssenceDescriptor *descriptor =
(MXFMetadataWaveAudioEssenceDescriptor *) d;
gboolean ret = FALSE;
gchar str[48];
g_return_val_if_fail (data != NULL, FALSE);
memset (descriptor, 0, sizeof (MXFMetadataWaveAudioEssenceDescriptor));
if (!mxf_metadata_generic_sound_essence_descriptor_parse (key,
(MXFMetadataGenericSoundEssenceDescriptor *) descriptor, primer, type,
data, size))
goto error;
while (mxf_local_tag_parse (data, size, &tag, &tag_size, &tag_data)) {
if (tag_size == 0 || tag == 0x0000)
goto next;
switch (tag) {
case 0x3d0a:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 2)
goto error;
descriptor->block_align = GST_READ_UINT16_BE (tag_data);
break;
case 0x3d0b:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->sequence_offset = GST_READ_UINT8 (tag_data);
break;
case 0x3d09:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->avg_bps = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d32:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 16)
goto error;
memcpy (&descriptor->channel_assignment, tag_data, 16);
break;
case 0x3d29:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->peak_envelope_version = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2a:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->peak_envelope_format = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2b:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->points_per_peak_value = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2c:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->peak_envelope_block_size = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2d:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->peak_channels = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2e:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->peak_frames = GST_READ_UINT32_BE (tag_data);
break;
case 0x3d2f:
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 8)
goto error;
descriptor->peak_of_peaks_position = GST_READ_UINT64_BE (tag_data);
break;
case 0x3d30:
GST_WRITE_UINT16_BE (data, 0x0000);
if (!mxf_timestamp_parse (&descriptor->peak_envelope_timestamp,
tag_data, tag_size))
goto error;
break;
case 0x3d31:
GST_WRITE_UINT16_BE (data, 0x0000);
descriptor->peak_envelope_data = g_memdup (tag_data, tag_size);
descriptor->peak_envelope_data_length = tag_size;
break;
default:
if (type != MXF_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR)
goto next;
GST_WRITE_UINT16_BE (data, 0x0000);
if (!gst_metadata_add_custom_tag (primer, tag, tag_data, tag_size,
&((MXFMetadataGenericDescriptor *) descriptor)->other_tags))
goto error;
break;
}
next:
data += 4 + tag_size;
size -= 4 + tag_size;
switch (tag) {
case 0x3d0a:
if (tag_size != 2)
goto error;
descriptor->block_align = GST_READ_UINT16_BE (tag_data);
GST_DEBUG (" block align = %u", descriptor->block_align);
ret = TRUE;
break;
case 0x3d0b:
if (tag_size != 1)
goto error;
descriptor->sequence_offset = GST_READ_UINT8 (tag_data);
GST_DEBUG (" sequence offset = %u", descriptor->sequence_offset);
ret = TRUE;
break;
case 0x3d09:
if (tag_size != 4)
goto error;
descriptor->avg_bps = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" average bps = %u", descriptor->avg_bps);
ret = TRUE;
break;
case 0x3d32:
if (tag_size != 16)
goto error;
memcpy (&descriptor->channel_assignment, tag_data, 16);
GST_DEBUG (" channel assignment = %s",
mxf_ul_to_string (&descriptor->channel_assignment, str));
ret = TRUE;
break;
case 0x3d29:
if (tag_size != 4)
goto error;
descriptor->peak_envelope_version = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" peak envelope version = %u",
descriptor->peak_envelope_version);
ret = TRUE;
break;
case 0x3d2a:
if (tag_size != 4)
goto error;
descriptor->peak_envelope_format = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" peak envelope format = %u",
descriptor->peak_envelope_format);
ret = TRUE;
break;
case 0x3d2b:
if (tag_size != 4)
goto error;
descriptor->points_per_peak_value = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" points per peak value = %u",
descriptor->points_per_peak_value);
ret = TRUE;
break;
case 0x3d2c:
if (tag_size != 4)
goto error;
descriptor->peak_envelope_block_size = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" peak envelope block size = %u",
descriptor->peak_envelope_block_size);
ret = TRUE;
break;
case 0x3d2d:
if (tag_size != 4)
goto error;
descriptor->peak_channels = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" peak channels = %u", descriptor->peak_channels);
ret = TRUE;
break;
case 0x3d2e:
if (tag_size != 4)
goto error;
descriptor->peak_frames = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" peak frames = %u", descriptor->peak_frames);
ret = TRUE;
break;
case 0x3d2f:
if (tag_size != 8)
goto error;
descriptor->peak_of_peaks_position = GST_READ_UINT64_BE (tag_data);
GST_DEBUG (" peak of peaks position = %" G_GINT64_FORMAT,
descriptor->peak_of_peaks_position);
ret = TRUE;
break;
case 0x3d30:
if (!mxf_timestamp_parse (&descriptor->peak_envelope_timestamp,
tag_data, tag_size))
goto error;
GST_DEBUG (" peak envelope timestamp = %d/%u/%u %u:%u:%u.%u",
descriptor->peak_envelope_timestamp.year,
descriptor->peak_envelope_timestamp.month,
descriptor->peak_envelope_timestamp.day,
descriptor->peak_envelope_timestamp.hour,
descriptor->peak_envelope_timestamp.minute,
descriptor->peak_envelope_timestamp.second,
(descriptor->peak_envelope_timestamp.quarter_msecond * 1000) / 256);
ret = TRUE;
break;
case 0x3d31:
descriptor->peak_envelope_data = g_memdup (tag_data, tag_size);
descriptor->peak_envelope_data_length = tag_size;
GST_DEBUG (" peak evelope data size = %u",
descriptor->peak_envelope_data_length);
ret = TRUE;
break;
default:
ret =
mxf_metadata_generic_sound_essence_descriptor_handle_tag (d, primer,
tag, tag_data, tag_size);
break;
}
GST_DEBUG ("Parsed wave audio essence descriptor:");
GST_DEBUG (" block align = %u", descriptor->block_align);
GST_DEBUG (" sequence offset = %u", descriptor->sequence_offset);
GST_DEBUG (" average bps = %u", descriptor->avg_bps);
GST_DEBUG (" channel assignment = %s",
mxf_ul_to_string (&descriptor->channel_assignment, str));
GST_DEBUG (" peak envelope version = %u", descriptor->peak_envelope_version);
GST_DEBUG (" peak envelope format = %u", descriptor->peak_envelope_format);
GST_DEBUG (" points per peak value = %u", descriptor->points_per_peak_value);
GST_DEBUG (" peak envelope block size = %u",
descriptor->peak_envelope_block_size);
GST_DEBUG (" peak channels = %u", descriptor->peak_channels);
GST_DEBUG (" peak frames = %u", descriptor->peak_frames);
GST_DEBUG (" peak of peaks position = %" G_GINT64_FORMAT,
descriptor->peak_of_peaks_position);
GST_DEBUG (" peak envelope timestamp = %d/%u/%u %u:%u:%u.%u",
descriptor->peak_envelope_timestamp.year,
descriptor->peak_envelope_timestamp.month,
descriptor->peak_envelope_timestamp.day,
descriptor->peak_envelope_timestamp.hour,
descriptor->peak_envelope_timestamp.minute,
descriptor->peak_envelope_timestamp.second,
(descriptor->peak_envelope_timestamp.quarter_msecond * 1000) / 256);
GST_DEBUG (" peak evelope data size = %u",
descriptor->peak_envelope_data_length);
return TRUE;
return ret;
error:
GST_ERROR ("Invalid wave audio essence descriptor");
mxf_metadata_wave_audio_essence_descriptor_reset (descriptor);
GST_ERROR ("Invalid wave audio essence descriptor tag 0x%04x of size %u", tag,
tag_size);
return FALSE;
return TRUE;
}
void mxf_metadata_wave_audio_essence_descriptor_reset

View file

@ -55,7 +55,8 @@ typedef struct {
guint16 peak_envelope_data_length;
} MXFMetadataWaveAudioEssenceDescriptor;
gboolean mxf_metadata_wave_audio_essence_descriptor_parse (const MXFUL *key, MXFMetadataWaveAudioEssenceDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_wave_audio_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_wave_audio_essence_descriptor_reset (MXFMetadataWaveAudioEssenceDescriptor *descriptor);
gboolean mxf_is_aes_bwf_essence_track (const MXFMetadataTrack *track);

View file

@ -703,21 +703,26 @@ gst_mxf_demux_handle_metadata_generic_descriptor (GstMXFDemux * demux,
{
MXFMetadataGenericDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata generic descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_generic_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_generic_descriptor_handle_tag,
(MXFMetadataDescriptorReset) mxf_metadata_generic_descriptor_reset)) {
GST_ERROR_OBJECT (demux, "Parsing metadata generic descriptor failed");
return GST_FLOW_ERROR;
}
if (!demux->generic_descriptor)
demux->generic_descriptor =
g_array_new (FALSE, FALSE, sizeof (MXFMetadataGenericDescriptor));
g_array_new (FALSE, TRUE, sizeof (MXFMetadataGenericDescriptor));
g_array_append_val (demux->generic_descriptor, descriptor);
@ -730,21 +735,26 @@ gst_mxf_demux_handle_metadata_file_descriptor (GstMXFDemux * demux,
{
MXFMetadataFileDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata file descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_file_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_file_descriptor_handle_tag,
(MXFMetadataDescriptorReset) mxf_metadata_file_descriptor_reset)) {
GST_ERROR_OBJECT (demux, "Parsing metadata file descriptor failed");
return GST_FLOW_ERROR;
}
if (!demux->file_descriptor)
demux->file_descriptor =
g_array_new (FALSE, FALSE, sizeof (MXFMetadataFileDescriptor));
g_array_new (FALSE, TRUE, sizeof (MXFMetadataFileDescriptor));
g_array_append_val (demux->file_descriptor, descriptor);
@ -757,21 +767,27 @@ gst_mxf_demux_handle_metadata_multiple_descriptor (GstMXFDemux * demux,
{
MXFMetadataMultipleDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata multiple descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_multiple_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_multiple_descriptor_handle_tag,
(MXFMetadataDescriptorReset) mxf_metadata_multiple_descriptor_reset))
{
GST_ERROR_OBJECT (demux, "Parsing metadata multiple descriptor failed");
return GST_FLOW_ERROR;
}
if (!demux->multiple_descriptor)
demux->multiple_descriptor =
g_array_new (FALSE, FALSE, sizeof (MXFMetadataMultipleDescriptor));
g_array_new (FALSE, TRUE, sizeof (MXFMetadataMultipleDescriptor));
g_array_append_val (demux->multiple_descriptor, descriptor);
@ -784,14 +800,20 @@ gst_mxf_demux_handle_metadata_generic_picture_essence_descriptor (GstMXFDemux *
{
MXFMetadataGenericPictureEssenceDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata generic picture essence descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_generic_picture_essence_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_generic_picture_essence_descriptor_handle_tag,
(MXFMetadataDescriptorReset)
mxf_metadata_generic_picture_essence_descriptor_reset)) {
GST_ERROR_OBJECT (demux,
"Parsing metadata generic picture essence descriptor failed");
return GST_FLOW_ERROR;
@ -799,7 +821,7 @@ gst_mxf_demux_handle_metadata_generic_picture_essence_descriptor (GstMXFDemux *
if (!demux->generic_picture_essence_descriptor)
demux->generic_picture_essence_descriptor =
g_array_new (FALSE, FALSE,
g_array_new (FALSE, TRUE,
sizeof (MXFMetadataGenericPictureEssenceDescriptor));
g_array_append_val (demux->generic_picture_essence_descriptor, descriptor);
@ -813,14 +835,20 @@ gst_mxf_demux_handle_metadata_cdci_picture_essence_descriptor (GstMXFDemux *
{
MXFMetadataCDCIPictureEssenceDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata CDCI picture essence descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_cdci_picture_essence_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_cdci_picture_essence_descriptor_handle_tag,
(MXFMetadataDescriptorReset)
mxf_metadata_cdci_picture_essence_descriptor_reset)) {
GST_ERROR_OBJECT (demux,
"Parsing metadata CDCI picture essence descriptor failed");
return GST_FLOW_ERROR;
@ -828,7 +856,7 @@ gst_mxf_demux_handle_metadata_cdci_picture_essence_descriptor (GstMXFDemux *
if (!demux->cdci_picture_essence_descriptor)
demux->cdci_picture_essence_descriptor =
g_array_new (FALSE, FALSE,
g_array_new (FALSE, TRUE,
sizeof (MXFMetadataCDCIPictureEssenceDescriptor));
g_array_append_val (demux->cdci_picture_essence_descriptor, descriptor);
@ -842,21 +870,27 @@ gst_mxf_demux_handle_metadata_mpeg_video_descriptor (GstMXFDemux * demux,
{
MXFMetadataMPEGVideoDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata MPEG video descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_mpeg_video_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_mpeg_video_descriptor_handle_tag,
(MXFMetadataDescriptorReset)
mxf_metadata_mpeg_video_descriptor_reset)) {
GST_ERROR_OBJECT (demux, "Parsing metadata MPEG video descriptor failed");
return GST_FLOW_ERROR;
}
if (!demux->mpeg_video_descriptor)
demux->mpeg_video_descriptor =
g_array_new (FALSE, FALSE, sizeof (MXFMetadataMPEGVideoDescriptor));
g_array_new (FALSE, TRUE, sizeof (MXFMetadataMPEGVideoDescriptor));
g_array_append_val (demux->mpeg_video_descriptor, descriptor);
@ -869,14 +903,20 @@ gst_mxf_demux_handle_metadata_generic_sound_essence_descriptor (GstMXFDemux *
{
MXFMetadataGenericSoundEssenceDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata generic sound essence descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_generic_sound_essence_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_generic_sound_essence_descriptor_handle_tag,
(MXFMetadataDescriptorReset)
mxf_metadata_generic_sound_essence_descriptor_reset)) {
GST_ERROR_OBJECT (demux,
"Parsing metadata generic sound essence descriptor failed");
return GST_FLOW_ERROR;
@ -884,7 +924,7 @@ gst_mxf_demux_handle_metadata_generic_sound_essence_descriptor (GstMXFDemux *
if (!demux->generic_sound_essence_descriptor)
demux->generic_sound_essence_descriptor =
g_array_new (FALSE, FALSE,
g_array_new (FALSE, TRUE,
sizeof (MXFMetadataGenericSoundEssenceDescriptor));
g_array_append_val (demux->generic_sound_essence_descriptor, descriptor);
@ -898,14 +938,20 @@ gst_mxf_demux_handle_metadata_wave_audio_essence_descriptor (GstMXFDemux *
{
MXFMetadataWaveAudioEssenceDescriptor descriptor;
memset (&descriptor, 0, sizeof (descriptor));
GST_DEBUG_OBJECT (demux,
"Handling metadata wave sound essence descriptor of size %u"
" at offset %" G_GUINT64_FORMAT " with type 0x%04d",
GST_BUFFER_SIZE (buffer), demux->offset, type);
if (!mxf_metadata_wave_audio_essence_descriptor_parse (key, &descriptor,
&demux->primer, type, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer))) {
if (!mxf_metadata_descriptor_parse (key,
(MXFMetadataGenericDescriptor *) & descriptor, &demux->primer,
type, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
(MXFMetadataDescriptorHandleTag)
mxf_metadata_wave_audio_essence_descriptor_handle_tag,
(MXFMetadataDescriptorReset)
mxf_metadata_wave_audio_essence_descriptor_reset)) {
GST_ERROR_OBJECT (demux,
"Parsing metadata wave sound essence descriptor failed");
return GST_FLOW_ERROR;
@ -913,7 +959,7 @@ gst_mxf_demux_handle_metadata_wave_audio_essence_descriptor (GstMXFDemux *
if (!demux->wave_audio_essence_descriptor)
demux->wave_audio_essence_descriptor =
g_array_new (FALSE, FALSE,
g_array_new (FALSE, TRUE,
sizeof (MXFMetadataWaveAudioEssenceDescriptor));
g_array_append_val (demux->wave_audio_essence_descriptor, descriptor);
@ -1748,12 +1794,6 @@ gst_mxf_demux_handle_metadata (GstMXFDemux * demux, const MXFUL * key,
return GST_FLOW_OK;
}
/* Make writable as the parsing of descriptors sets already read local tags to 0x0000 */
if (!gst_buffer_is_writable (buffer))
buffer = gst_buffer_copy (buffer);
else
buffer = gst_buffer_ref (buffer);
switch (type) {
case MXF_METADATA_PREFACE:
ret = gst_mxf_demux_handle_metadata_preface (demux, key, buffer);
@ -1838,8 +1878,6 @@ gst_mxf_demux_handle_metadata (GstMXFDemux * demux, const MXFUL * key,
break;
}
gst_buffer_unref (buffer);
return ret;
}

View file

@ -89,116 +89,94 @@ static const guint8 _profile_and_level_ul[] = {
};
gboolean
mxf_metadata_mpeg_video_descriptor_parse (const MXFUL * key,
MXFMetadataMPEGVideoDescriptor * descriptor,
const MXFPrimerPack * primer, guint16 type, const guint8 * data, guint size)
mxf_metadata_mpeg_video_descriptor_handle_tag (MXFMetadataGenericDescriptor * d,
const MXFPrimerPack * primer, guint16 tag, const guint8 * tag_data,
guint16 tag_size)
{
guint16 tag, tag_size;
const guint8 *tag_data;
MXFMetadataMPEGVideoDescriptor *descriptor =
(MXFMetadataMPEGVideoDescriptor *) d;
gboolean ret = FALSE;
MXFUL *tag_ul = NULL;
g_return_val_if_fail (data != NULL, FALSE);
if (!(tag_ul =
(MXFUL *) g_hash_table_lookup (primer->mappings,
GUINT_TO_POINTER (((guint) tag)))))
return FALSE;
memset (descriptor, 0, sizeof (MXFMetadataMPEGVideoDescriptor));
if (!mxf_metadata_cdci_picture_essence_descriptor_parse (key,
(MXFMetadataCDCIPictureEssenceDescriptor *) descriptor, primer, type,
data, size))
goto error;
while (mxf_local_tag_parse (data, size, &tag, &tag_size, &tag_data)) {
MXFUL *tag_ul = NULL;
if (tag_size == 0 || tag == 0x0000)
goto next;
if (!(tag_ul =
(MXFUL *) g_hash_table_lookup (primer->mappings,
GUINT_TO_POINTER (((guint) tag)))))
goto next;
if (memcmp (tag_ul, &_single_sequence_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->single_sequence = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_constant_b_frames_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->const_b_frames = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_coded_content_type_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->coded_content_type = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_low_delay_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->low_delay = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_closed_gop_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->closed_gop = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_identical_gop_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->identical_gop = GST_READ_UINT8 (tag_data);
} else if (memcmp (tag_ul, &_max_gop_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 2)
goto error;
descriptor->max_gop = GST_READ_UINT16_BE (tag_data);
} else if (memcmp (tag_ul, &_b_picture_count_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 2)
goto error;
descriptor->b_picture_count = GST_READ_UINT16_BE (tag_data);
} else if (memcmp (tag_ul, &_bitrate_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 4)
goto error;
descriptor->bitrate = GST_READ_UINT32_BE (tag_data);
} else if (memcmp (tag_ul, &_profile_and_level_ul, 16) == 0) {
GST_WRITE_UINT16_BE (data, 0x0000);
if (tag_size != 1)
goto error;
descriptor->profile_and_level = GST_READ_UINT8 (tag_data);
} else {
if (type != MXF_METADATA_MPEG_VIDEO_DESCRIPTOR)
goto next;
GST_WRITE_UINT16_BE (data, 0x0000);
if (!gst_metadata_add_custom_tag (primer, tag, tag_data, tag_size,
&((MXFMetadataGenericDescriptor *) descriptor)->other_tags))
goto error;
}
next:
data += 4 + tag_size;
size -= 4 + tag_size;
if (memcmp (tag_ul, &_single_sequence_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->single_sequence = GST_READ_UINT8 (tag_data);
GST_DEBUG (" single sequence = %s",
(descriptor->single_sequence) ? "yes" : "no");
ret = TRUE;
} else if (memcmp (tag_ul, &_constant_b_frames_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->const_b_frames = GST_READ_UINT8 (tag_data);
GST_DEBUG (" constant b frames = %s",
(descriptor->single_sequence) ? "yes" : "no");
ret = TRUE;
} else if (memcmp (tag_ul, &_coded_content_type_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->coded_content_type = GST_READ_UINT8 (tag_data);
GST_DEBUG (" coded content type = %u", descriptor->coded_content_type);
ret = TRUE;
} else if (memcmp (tag_ul, &_low_delay_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->low_delay = GST_READ_UINT8 (tag_data);
GST_DEBUG (" low delay = %s", (descriptor->low_delay) ? "yes" : "no");
ret = TRUE;
} else if (memcmp (tag_ul, &_closed_gop_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->closed_gop = GST_READ_UINT8 (tag_data);
GST_DEBUG (" closed gop = %s", (descriptor->closed_gop) ? "yes" : "no");
ret = TRUE;
} else if (memcmp (tag_ul, &_identical_gop_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->identical_gop = GST_READ_UINT8 (tag_data);
GST_DEBUG (" identical gop = %s",
(descriptor->identical_gop) ? "yes" : "no");
ret = TRUE;
} else if (memcmp (tag_ul, &_max_gop_ul, 16) == 0) {
if (tag_size != 2)
goto error;
descriptor->max_gop = GST_READ_UINT16_BE (tag_data);
GST_DEBUG (" max gop = %u", descriptor->max_gop);
ret = TRUE;
} else if (memcmp (tag_ul, &_b_picture_count_ul, 16) == 0) {
if (tag_size != 2)
goto error;
descriptor->b_picture_count = GST_READ_UINT16_BE (tag_data);
GST_DEBUG (" b picture count = %u", descriptor->b_picture_count);
ret = TRUE;
} else if (memcmp (tag_ul, &_bitrate_ul, 16) == 0) {
if (tag_size != 4)
goto error;
descriptor->bitrate = GST_READ_UINT32_BE (tag_data);
GST_DEBUG (" bitrate = %u", descriptor->bitrate);
ret = TRUE;
} else if (memcmp (tag_ul, &_profile_and_level_ul, 16) == 0) {
if (tag_size != 1)
goto error;
descriptor->profile_and_level = GST_READ_UINT8 (tag_data);
GST_DEBUG (" profile & level = %u", descriptor->profile_and_level);
ret = TRUE;
} else {
ret =
mxf_metadata_cdci_picture_essence_descriptor_handle_tag (d, primer, tag,
tag_data, tag_size);
}
GST_DEBUG ("Parsed mpeg video descriptors:");
GST_DEBUG (" single sequence = %s",
(descriptor->single_sequence) ? "yes" : "no");
GST_DEBUG (" constant b frames = %s",
(descriptor->single_sequence) ? "yes" : "no");
GST_DEBUG (" coded content type = %u", descriptor->coded_content_type);
GST_DEBUG (" low delay = %s", (descriptor->low_delay) ? "yes" : "no");
GST_DEBUG (" closed gop = %s", (descriptor->closed_gop) ? "yes" : "no");
GST_DEBUG (" identical gop = %s",
(descriptor->identical_gop) ? "yes" : "no");
GST_DEBUG (" max gop = %u", descriptor->max_gop);
GST_DEBUG (" b picture count = %u", descriptor->b_picture_count);
GST_DEBUG (" bitrate = %u", descriptor->bitrate);
GST_DEBUG (" profile & level = %u", descriptor->profile_and_level);
return TRUE;
return ret;
error:
GST_ERROR ("Invalid mpeg video descriptor");
mxf_metadata_mpeg_video_descriptor_reset (descriptor);
GST_ERROR ("Invalid mpeg video descriptor tag 0x%04x of size %u", tag,
tag_size);
return FALSE;
}

View file

@ -49,7 +49,7 @@ typedef struct {
guint8 profile_and_level;
} MXFMetadataMPEGVideoDescriptor;
gboolean mxf_metadata_mpeg_video_descriptor_parse (const MXFUL *key, MXFMetadataMPEGVideoDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_mpeg_video_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor, const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_mpeg_video_descriptor_reset (MXFMetadataMPEGVideoDescriptor *descriptor);
gboolean mxf_is_mpeg_video_essence_track (const MXFMetadataTrack *track);

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,10 @@
typedef GstFlowReturn (*MXFEssenceElementHandler) (const MXFUL *key, GstBuffer *buffer, GstCaps *caps, MXFMetadataGenericPackage *package, MXFMetadataTrack *track, MXFMetadataStructuralComponent *component, gpointer mapping_data, GstBuffer **outbuf);
typedef gboolean (*MXFMetadataDescriptorHandleTag) (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
typedef void (*MXFMetadataDescriptorReset) (MXFMetadataGenericDescriptor *descriptor);
gchar * mxf_ul_to_string (const MXFUL *ul, gchar str[48]);
gboolean mxf_ul_is_equal (const MXFUL *a, const MXFUL *b);
gboolean mxf_ul_is_zero (const MXFUL *ul);
@ -104,22 +108,31 @@ void mxf_metadata_sequence_reset (MXFMetadataSequence *sequence);
gboolean mxf_metadata_structural_component_parse (const MXFUL *key, MXFMetadataStructuralComponent *component, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
void mxf_metadata_structural_component_reset (MXFMetadataStructuralComponent *component);
gboolean mxf_metadata_generic_descriptor_parse (const MXFUL *key, MXFMetadataGenericDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean
mxf_metadata_descriptor_parse (const MXFUL * key, MXFMetadataGenericDescriptor * descriptor, const MXFPrimerPack * primer, guint16 type, const guint8 * data, guint size, MXFMetadataDescriptorHandleTag handle_tag, MXFMetadataDescriptorReset reset);
gboolean mxf_metadata_generic_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_generic_descriptor_reset (MXFMetadataGenericDescriptor *descriptor);
gboolean mxf_metadata_file_descriptor_parse (const MXFUL *key, MXFMetadataFileDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_file_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_file_descriptor_reset (MXFMetadataFileDescriptor *descriptor);
gboolean mxf_metadata_generic_sound_essence_descriptor_parse (const MXFUL *key, MXFMetadataGenericSoundEssenceDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_generic_sound_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_generic_sound_essence_descriptor_reset (MXFMetadataGenericSoundEssenceDescriptor *descriptor);
gboolean mxf_metadata_generic_picture_essence_descriptor_parse (const MXFUL *key, MXFMetadataGenericPictureEssenceDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_generic_picture_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_generic_picture_essence_descriptor_reset (MXFMetadataGenericPictureEssenceDescriptor *descriptor);
gboolean mxf_metadata_cdci_picture_essence_descriptor_parse (const MXFUL *key, MXFMetadataCDCIPictureEssenceDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_cdci_picture_essence_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_cdci_picture_essence_descriptor_reset (MXFMetadataCDCIPictureEssenceDescriptor *descriptor);
gboolean mxf_metadata_multiple_descriptor_parse (const MXFUL *key, MXFMetadataMultipleDescriptor *descriptor, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);
gboolean mxf_metadata_multiple_descriptor_handle_tag (MXFMetadataGenericDescriptor *descriptor,
const MXFPrimerPack *primer, guint16 tag, const guint8 *tag_data, guint16 tag_size);
void mxf_metadata_multiple_descriptor_reset (MXFMetadataMultipleDescriptor *descriptor);
gboolean mxf_metadata_locator_parse (const MXFUL *key, MXFMetadataLocator *locator, const MXFPrimerPack *primer, guint16 type, const guint8 *data, guint size);