From aa7a44190ee2be06e032034e312d37f6838c7b31 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 4 Aug 2008 07:05:33 +0000 Subject: gst/qtdemux/qtdemux.c: Add support for tmpo tag (BPM). Original commit message from CVS: * gst/qtdemux/qtdemux.c: Add support for tmpo tag (BPM). --- gst/qtdemux/qtdemux.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'gst/qtdemux/qtdemux.c') diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 2c99d55e..e940bafd 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -3815,6 +3815,32 @@ qtdemux_tag_add_num (GstQTDemux * qtdemux, const char *tag1, } } +static void +qtdemux_tag_add_tmpo (GstQTDemux * qtdemux, const char *tag1, GNode * node) +{ + GNode *data; + int len; + int type; + int n1; + + data = qtdemux_tree_get_child_by_type (node, FOURCC_data); + if (data) { + len = QT_UINT32 (data->data); + type = QT_UINT32 ((guint8 *) data->data + 8); + GST_DEBUG_OBJECT (qtdemux, "have tempo tag, type=%d,len=%d", type, len); + /* some files wrongly have a type 0x0f=15, but it should be 0x15 */ + if ((type == 0x00000015 || type == 0x0000000f) && len >= 16) { + n1 = QT_UINT16 ((guint8 *) data->data + 16); + if (n1) { + /* do not add bpm=0 */ + GST_DEBUG_OBJECT (qtdemux, "adding tag %d", n1); + gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_REPLACE, + tag1, (gdouble) n1, NULL); + } + } + } +} + static void qtdemux_tag_add_date (GstQTDemux * qtdemux, const char *tag, GNode * node) { @@ -4002,6 +4028,11 @@ qtdemux_parse_udta (GstQTDemux * qtdemux, GNode * udta) qtdemux_tag_add_str (qtdemux, GST_TAG_GENRE, node); } } + + node = qtdemux_tree_get_child_by_type (ilst, FOURCC_tmpo); + if (node) { + qtdemux_tag_add_tmpo (qtdemux, GST_TAG_BEATS_PER_MINUTE, node); + } } typedef struct -- cgit