From 61b284de0d44247316fd185134c293d026e4131c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 11 Feb 2009 18:40:55 +0100 Subject: mxfdemux: Parse MXFTimestamp's milliseconds and add _to_string() function --- gst/mxf/mxfaes-bwf.c | 10 ++-------- gst/mxf/mxfdms1.c | 44 ++++++++++++++------------------------------ gst/mxf/mxfmetadata.c | 38 ++++++++------------------------------ gst/mxf/mxfparse.c | 13 +++++++++++-- gst/mxf/mxfparse.h | 1 + gst/mxf/mxftypes.h | 2 +- 6 files changed, 37 insertions(+), 71 deletions(-) diff --git a/gst/mxf/mxfaes-bwf.c b/gst/mxf/mxfaes-bwf.c index ca9234f3e..d2be9a260 100644 --- a/gst/mxf/mxfaes-bwf.c +++ b/gst/mxf/mxfaes-bwf.c @@ -203,14 +203,8 @@ mxf_metadata_wave_audio_essence_descriptor_handle_tag (MXFMetadataBase * if (!mxf_timestamp_parse (&self->peak_envelope_timestamp, tag_data, tag_size)) goto error; - GST_DEBUG (" peak envelope timestamp = %d/%u/%u %u:%u:%u.%u", - self->peak_envelope_timestamp.year, - self->peak_envelope_timestamp.month, - self->peak_envelope_timestamp.day, - self->peak_envelope_timestamp.hour, - self->peak_envelope_timestamp.minute, - self->peak_envelope_timestamp.second, - (self->peak_envelope_timestamp.quarter_msecond * 1000) / 256); + GST_DEBUG (" peak envelope timestamp = %s", + mxf_timestamp_to_string (&self->peak_envelope_timestamp, str)); break; case 0x3d31: self->peak_envelope_data = g_memdup (tag_data, tag_size); diff --git a/gst/mxf/mxfdms1.c b/gst/mxf/mxfdms1.c index e4105b8f5..1433262f8 100644 --- a/gst/mxf/mxfdms1.c +++ b/gst/mxf/mxfdms1.c @@ -1237,14 +1237,8 @@ mxf_dms1_clip_framework_handle_tag (MXFMetadataBase * metadata, if (!mxf_timestamp_parse (&self->clip_creation_date_and_time, tag_data, tag_size)) goto error; - GST_DEBUG (" clip creation date and time = %d/%u/%u %u:%u:%u.%u", - self->clip_creation_date_and_time.year, - self->clip_creation_date_and_time.month, - self->clip_creation_date_and_time.day, - self->clip_creation_date_and_time.hour, - self->clip_creation_date_and_time.minute, - self->clip_creation_date_and_time.second, - (self->clip_creation_date_and_time.quarter_msecond * 1000) / 256); + GST_DEBUG (" clip creation date and time = %s", + mxf_timestamp_to_string (&self->clip_creation_date_and_time, str)); } else if (memcmp (tag_ul, &take_number_ul, 16) == 0) { if (tag_size != 2) goto error; @@ -2666,6 +2660,9 @@ mxf_dms1_setting_period_handle_tag (MXFMetadataBase * metadata, { MXFDMS1SettingPeriod *self = MXF_DMS1_SETTING_PERIOD (metadata); gboolean ret = TRUE; +#ifndef GST_DISABLE_GST_DEBUG + gchar str[32]; +#endif MXFUL *tag_ul = NULL; static const guint8 setting_date_and_time_ul[] = { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x04, 0x07, @@ -2689,12 +2686,8 @@ mxf_dms1_setting_period_handle_tag (MXFMetadataBase * metadata, if (!mxf_timestamp_parse (&self->setting_date_and_time, tag_data, tag_size)) goto error; - GST_DEBUG (" last modified date = %d/%u/%u %u:%u:%u.%u", - self->setting_date_and_time.year, self->setting_date_and_time.month, - self->setting_date_and_time.day, self->setting_date_and_time.hour, - self->setting_date_and_time.minute, - self->setting_date_and_time.second, - (self->setting_date_and_time.quarter_msecond * 1000) / 256); + GST_DEBUG (" last modified date = %s", + mxf_timestamp_to_string (&self->setting_date_and_time, str)); } else if (memcmp (tag_ul, &time_period_keyword_ul, 16) == 0) { self->time_period_keyword = mxf_utf16_to_utf8 (tag_data, tag_size); GST_DEBUG (" time period keyword = %s", @@ -4586,6 +4579,9 @@ mxf_dms1_rights_handle_tag (MXFMetadataBase * metadata, MXFPrimerPack * primer, MXFDMS1Rights *self = MXF_DMS1_RIGHTS (metadata); gboolean ret = TRUE; MXFUL *tag_ul = NULL; +#ifndef GST_DISABLE_GST_DEBUG + gchar str[32]; +#endif static const guint8 copyright_owner_ul[] = { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x03, 0x02, 0x05, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00 @@ -4669,27 +4665,15 @@ mxf_dms1_rights_handle_tag (MXFMetadataBase * metadata, MXFPrimerPack * primer, tag_size)) goto error; - GST_DEBUG (" rights start date and time = %d/%u/%u %u:%u:%u.%u", - self->rights_start_date_and_time.year, - self->rights_start_date_and_time.month, - self->rights_start_date_and_time.day, - self->rights_start_date_and_time.hour, - self->rights_start_date_and_time.minute, - self->rights_start_date_and_time.second, - (self->rights_start_date_and_time.quarter_msecond * 1000) / 256); + GST_DEBUG (" rights start date and time = %s", + mxf_timestamp_to_string (&self->rights_start_date_and_time, str)); } else if (memcmp (tag_ul, &rights_stop_date_and_time_ul, 16) == 0) { if (!mxf_timestamp_parse (&self->rights_start_date_and_time, tag_data, tag_size)) goto error; - GST_DEBUG (" rights stop date and time = %d/%u/%u %u:%u:%u.%u", - self->rights_stop_date_and_time.year, - self->rights_stop_date_and_time.month, - self->rights_stop_date_and_time.day, - self->rights_stop_date_and_time.hour, - self->rights_stop_date_and_time.minute, - self->rights_stop_date_and_time.second, - (self->rights_stop_date_and_time.quarter_msecond * 1000) / 256); + GST_DEBUG (" rights stop date and time = %s", + mxf_timestamp_to_string (&self->rights_stop_date_and_time, str)); } else if (memcmp (tag_ul, &maximum_number_of_usages_ul, 16) == 0) { if (tag_size != 2) goto error; diff --git a/gst/mxf/mxfmetadata.c b/gst/mxf/mxfmetadata.c index 1c9a169d6..84324d54b 100644 --- a/gst/mxf/mxfmetadata.c +++ b/gst/mxf/mxfmetadata.c @@ -342,12 +342,8 @@ mxf_metadata_preface_handle_tag (MXFMetadataBase * metadata, case 0x3b02: if (!mxf_timestamp_parse (&self->last_modified_date, tag_data, tag_size)) goto error; - GST_DEBUG (" last modified date = %d/%u/%u %u:%u:%u.%u", - self->last_modified_date.year, self->last_modified_date.month, - self->last_modified_date.day, self->last_modified_date.hour, - self->last_modified_date.minute, - self->last_modified_date.second, - (self->last_modified_date.quarter_msecond * 1000) / 256); + GST_DEBUG (" last modified date = %s", + mxf_timestamp_to_string (&self->last_modified_date, str)); break; case 0x3b05: if (tag_size != 2) @@ -594,14 +590,8 @@ mxf_metadata_identification_handle_tag (MXFMetadataBase * metadata, case 0x3c06: if (!mxf_timestamp_parse (&self->modification_date, tag_data, tag_size)) goto error; - GST_DEBUG (" modification date = %d/%u/%u %u:%u:%u.%u", - self->modification_date.year, - self->modification_date.month, - self->modification_date.day, - self->modification_date.hour, - self->modification_date.minute, - self->modification_date.second, - (self->modification_date.quarter_msecond * 1000) / 256); + GST_DEBUG (" modification date = %s", + mxf_timestamp_to_string (&self->modification_date, str)); break; case 0x3c07: if (!mxf_product_version_parse (&self->toolkit_version, @@ -982,27 +972,15 @@ mxf_metadata_generic_package_handle_tag (MXFMetadataBase * metadata, if (!mxf_timestamp_parse (&self->package_creation_date, tag_data, tag_size)) goto error; - GST_DEBUG (" creation date = %d/%u/%u %u:%u:%u.%u", - self->package_creation_date.year, - self->package_creation_date.month, - self->package_creation_date.day, - self->package_creation_date.hour, - self->package_creation_date.minute, - self->package_creation_date.second, - (self->package_creation_date.quarter_msecond * 1000) / 256); + GST_DEBUG (" creation date = %s", + mxf_timestamp_to_string (&self->package_creation_date, str)); break; case 0x4404: if (!mxf_timestamp_parse (&self->package_modified_date, tag_data, tag_size)) goto error; - GST_DEBUG (" modification date = %d/%u/%u %u:%u:%u.%u", - self->package_modified_date.year, - self->package_modified_date.month, - self->package_modified_date.day, - self->package_modified_date.hour, - self->package_modified_date.minute, - self->package_modified_date.second, - (self->package_modified_date.quarter_msecond * 1000) / 256); + GST_DEBUG (" modification date = %s", + mxf_timestamp_to_string (&self->package_modified_date, str)); break; case 0x4403: if (!mxf_ul_array_parse (&self->tracks_uids, &self->n_tracks, tag_data, diff --git a/gst/mxf/mxfparse.c b/gst/mxf/mxfparse.c index c5c81fdb7..2611e817f 100644 --- a/gst/mxf/mxfparse.c +++ b/gst/mxf/mxfparse.c @@ -357,7 +357,7 @@ mxf_timestamp_parse (MXFTimestamp * timestamp, const guint8 * data, guint size) timestamp->hour = GST_READ_UINT8 (data + 4); timestamp->minute = GST_READ_UINT8 (data + 5); timestamp->second = GST_READ_UINT8 (data + 6); - timestamp->quarter_msecond = GST_READ_UINT8 (data + 7); + timestamp->msecond = (GST_READ_UINT8 (data + 7) * 1000) / 256; return TRUE; } @@ -385,12 +385,21 @@ mxf_timestamp_compare (const MXFTimestamp * a, const MXFTimestamp * b) return diff; else if ((diff = a->second - b->second) != 0) return diff; - else if ((diff = a->quarter_msecond - b->quarter_msecond) != 0) + else if ((diff = a->msecond - b->msecond) != 0) return diff; else return 0; } +gchar * +mxf_timestamp_to_string (const MXFTimestamp * t, gchar str[32]) +{ + g_snprintf (str, 32, + "%04d-%02u-%02u %02u:%02u:%02u.%03u", t->year, t->month, + t->day, t->hour, t->minute, t->second, t->msecond); + return str; +} + gboolean mxf_fraction_parse (MXFFraction * fraction, const guint8 * data, guint size) { diff --git a/gst/mxf/mxfparse.h b/gst/mxf/mxfparse.h index eb29d205f..08e8af89f 100644 --- a/gst/mxf/mxfparse.h +++ b/gst/mxf/mxfparse.h @@ -78,6 +78,7 @@ gboolean mxf_fraction_parse (MXFFraction *fraction, const guint8 *data, guint si gboolean mxf_timestamp_parse (MXFTimestamp * timestamp, const guint8 * data, guint size); gboolean mxf_timestamp_is_unknown (const MXFTimestamp *a); gint mxf_timestamp_compare (const MXFTimestamp *a, const MXFTimestamp *b); +gchar *mxf_timestamp_to_string (const MXFTimestamp *t, gchar str[32]); gboolean mxf_ul_array_parse (MXFUL **array, guint32 *count, const guint8 *data, guint size); diff --git a/gst/mxf/mxftypes.h b/gst/mxf/mxftypes.h index a59ac7422..d56499adc 100644 --- a/gst/mxf/mxftypes.h +++ b/gst/mxf/mxftypes.h @@ -42,7 +42,7 @@ typedef struct { guint8 hour; guint8 minute; guint8 second; - guint8 quarter_msecond; + guint16 msecond; } MXFTimestamp; /* SMPTE 377M 3.3 */ -- cgit v1.2.1