summaryrefslogtreecommitdiffstats
path: root/gst/id3demux
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2007-03-12 13:28:29 +0000
committerTim-Philipp Müller <tim@centricular.net>2007-03-12 13:28:29 +0000
commit2354b65a9e4dc93c4a2f2ccd4c64a650474f905d (patch)
tree0e7faaa20f6e4f51e646d8e2872e15f8abf87ca7 /gst/id3demux
parenta7368fc0c6505dd2be3bc605a780f981c277d8ea (diff)
gst/id3demux/id3v2frames.c: Fix parsing of ID3 v2.2.0 PIC frames. Only in version >= 2.3.0 is the image format a vari...
Original commit message from CVS: * gst/id3demux/id3v2frames.c: (parse_picture_frame): Fix parsing of ID3 v2.2.0 PIC frames. Only in version >= 2.3.0 is the image format a variable-length NUL-terminated string; in versions before that the image format is a fixed-length string of 3 characters (see #348644 for a sample tag). Also make supplied mime type lower-case and fix up 'jpg' to 'jpeg'.
Diffstat (limited to 'gst/id3demux')
-rw-r--r--gst/id3demux/id3v2frames.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c
index f02f1241..153d4943 100644
--- a/gst/id3demux/id3v2frames.c
+++ b/gst/id3demux/id3v2frames.c
@@ -433,10 +433,10 @@ parse_picture_frame (ID3TagsWorking * work)
GstCaps *image_caps = NULL;
gboolean is_pic_uri = FALSE;
guint8 txt_encoding, pic_type;
- gchar *mime_str = NULL;
+ gchar *c, *mime_str = NULL;
gint len, datalen;
- GST_LOG ("APIC frame");
+ GST_LOG ("APIC frame (ID3v2.%u)", ID3V2_VER_MAJOR (work->hdr.version));
if (work->parse_size < 1 + 1 + 1 + 1 + 1)
goto not_enough_data;
@@ -445,8 +445,32 @@ parse_picture_frame (ID3TagsWorking * work)
++work->parse_data;
--work->parse_size;
- if (!parse_id_string (work, &mime_str, &len, &datalen)) {
- return FALSE;
+ /* Read image format; in early ID3v2 versions this is a fixed-length
+ * 3-character string without terminator; in later versions (>= 2.3.0)
+ * this is a NUL-terminated string of variable length */
+ if (ID3V2_VER_MAJOR (work->hdr.version) < 3) {
+ if (work->parse_size < 3)
+ goto not_enough_data;
+
+ mime_str = g_strndup ((gchar *) work->parse_data, 3);
+ len = 3;
+ } else {
+ if (!parse_id_string (work, &mime_str, &len, &datalen))
+ return FALSE;
+ ++len; /* for string terminator */
+ }
+
+ /* Fix up 'jpg' => 'jpeg' in mime/media type */
+ if (mime_str != NULL &&
+ (g_ascii_strcasecmp (mime_str, "jpg") == 0 ||
+ g_ascii_strcasecmp (mime_str, "image/jpg") == 0)) {
+ g_free (mime_str);
+ mime_str = g_strdup ("jpeg");
+ }
+
+ /* Make lower-case */
+ for (c = mime_str; c != NULL && *c != '\0'; ++c) {
+ *c = g_ascii_tolower (*c);
}
is_pic_uri = (mime_str != NULL && strcmp (mime_str, "-->") == 0);
@@ -459,12 +483,13 @@ parse_picture_frame (ID3TagsWorking * work)
mime_str = tmp;
}
- if (work->parse_size < (len + 1) + 1 + 1 + 1)
+ if (work->parse_size < len + 1 + 1 + 1)
goto not_enough_data;
- work->parse_data += (len + 1);
- work->parse_size -= (len + 1);
+ work->parse_data += len;
+ work->parse_size -= len;
+ /* Read image type */
pic_type = work->parse_data[0];
++work->parse_data;
--work->parse_size;