summaryrefslogtreecommitdiff
path: root/community-testing/xmms2/vorbis-albumart.patch
blob: de4305f6f12d5e2ef5b889fdcbb64b6e8a62eb09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
From f38882beb1c9b4f3e3c63ac7d65603ad5917cd9d Mon Sep 17 00:00:00 2001
From: Brad Jorsch <anomie@users.sourceforge.net>
Date: Tue, 09 Mar 2010 15:41:33 +0000
Subject: OTHER: Add support for METADATA_BLOCK_PICTURE in Vorbis plugin

Bug-Debian: http://bugs.debian.org/565479
---
diff --git a/src/plugins/vorbis_common/common.c b/src/plugins/vorbis_common/common.c
index c1f4ef9..fc4ff1b 100644
--- a/src/plugins/vorbis_common/common.c
+++ b/src/plugins/vorbis_common/common.c
@@ -243,6 +243,74 @@ get_replaygain (xmms_xform_t *xform, vorbis_comment *vc)
 	}
 }
 
+static void
+handle_image_comment (xmms_xform_t *xform, const gchar *value, gsize len)
+{
+	guint32 typ, mime_len, desc_len, img_len;
+	guchar *pos, *end, *mime_data, *img_data;
+	gchar hash[33];
+
+	pos = value;
+	end = value + len;
+
+	if (pos + 4 > end) {
+		XMMS_DBG ("Malformed picture comment");
+		return;
+	}
+	typ = GUINT32_FROM_BE (*(guint32 *)pos);
+	if (typ != 0 && typ != 3) {
+		XMMS_DBG ("Picture type %d not handled", typ);
+		return;
+	}
+	pos += 4;
+
+	if (pos + 4 > end) {
+		XMMS_DBG ("Malformed picture comment");
+		return;
+	}
+	mime_len = GUINT32_FROM_BE (*(guint32 *)pos);
+	pos += 4;
+	mime_data = pos;
+	pos += mime_len;
+
+	if (pos + 4 > end) {
+		XMMS_DBG ("Malformed picture comment");
+		return;
+	}
+	desc_len = GUINT32_FROM_BE (*(guint32 *)pos);
+	pos += 4;
+	pos += desc_len;
+
+	pos += 4; /* width */
+	pos += 4; /* height */
+	pos += 4; /* depth */
+	pos += 4; /* indexed palette length */
+
+	if (pos + 4 > end) {
+		XMMS_DBG ("Malformed picture comment");
+		return;
+	}
+	img_len = GUINT32_FROM_BE (*(guint32 *)pos);
+	pos += 4;
+	img_data = pos;
+
+	if (img_data + img_len > end) {
+		XMMS_DBG ("Malformed picture comment");
+		return;
+	}
+
+	if (xmms_bindata_plugin_add ((const guchar *)img_data, img_len, hash)) {
+		const gchar *metakey;
+
+		metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_PICTURE_FRONT;
+		xmms_xform_metadata_set_str (xform, metakey, hash);
+
+		metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_PICTURE_FRONT_MIME;
+		mime_data[mime_len] = '\0';
+		xmms_xform_metadata_set_str (xform, metakey, mime_data);
+	}
+}
+
 /* note that "key" is NOT NUL-terminated here,
  * but "value" is.
  */
@@ -253,6 +321,14 @@ handle_comment (xmms_xform_t *xform,
 {
 	gint i;
 
+	if (!g_ascii_strncasecmp (key, "METADATA_BLOCK_PICTURE", key_len)) {
+		gsize dlen;
+		gchar *dvalue = g_base64_decode (value, &dlen);
+		handle_image_comment (xform, dvalue, dlen);
+		g_free (dvalue);
+		return;
+	}
+
 	for (i = 0; i < G_N_ELEMENTS (properties); i++) {
 		if (key_len != strlen (properties[i].vname))
 			continue;
--
cgit v0.8.3.4


From d8273630bd92ecea581240ae93c6795cc538d076 Mon Sep 17 00:00:00 2001
From: Erik Massop <e.massop@hccnet.nl>
Date: Tue, 09 Mar 2010 15:45:03 +0000
Subject: OTHER: Add Brad Jorsch to AUTHORS, disable Vorbis albumart for glib < 2.12

(Name found using e-mail address at http://sourceforge.net/users/anomie )
---
diff --git a/AUTHORS b/AUTHORS
index f2ef9af..7331d4b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -146,6 +146,10 @@ N: Johannes Jordan
 E: ypnos@lanrules.de
 D: Visualization
 
+N: Brad Jorsch
+E: anomie@users.sourceforge.net
+D: Support for front picture from Vorbis.
+
 N: Daniel Kamiński
 E: maniel.rulez@gmail.com
 D: mlib remove command in cli, Ruby fixes.
diff --git a/src/plugins/vorbis_common/common.c b/src/plugins/vorbis_common/common.c
index fc4ff1b..ab1dc75 100644
--- a/src/plugins/vorbis_common/common.c
+++ b/src/plugins/vorbis_common/common.c
@@ -27,6 +27,7 @@
 #include "xmms/xmms_sample.h"
 #include "xmms/xmms_log.h"
 #include "xmms/xmms_medialib.h"
+#include "xmms/xmms_bindata.h"
 
 #include <glib.h>
 
@@ -244,12 +245,22 @@ get_replaygain (xmms_xform_t *xform, vorbis_comment *vc)
 }
 
 static void
-handle_image_comment (xmms_xform_t *xform, const gchar *value, gsize len)
+handle_image_comment (xmms_xform_t *xform, const gchar *encoded_value)
 {
+	gsize len;
+	guchar *value;
+
 	guint32 typ, mime_len, desc_len, img_len;
 	guchar *pos, *end, *mime_data, *img_data;
 	gchar hash[33];
 
+#if GLIB_CHECK_VERSION(2,12,0)
+	value = g_base64_decode (encoded_value, &len);
+#else
+	/* TODO: Implement/backport base64 decoding */
+	return;
+#endif
+
 	pos = value;
 	end = value + len;
 
@@ -299,7 +310,7 @@ handle_image_comment (xmms_xform_t *xform, const gchar *value, gsize len)
 		return;
 	}
 
-	if (xmms_bindata_plugin_add ((const guchar *)img_data, img_len, hash)) {
+	if (xmms_bindata_plugin_add (img_data, img_len, hash)) {
 		const gchar *metakey;
 
 		metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_PICTURE_FRONT;
@@ -307,8 +318,10 @@ handle_image_comment (xmms_xform_t *xform, const gchar *value, gsize len)
 
 		metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_PICTURE_FRONT_MIME;
 		mime_data[mime_len] = '\0';
-		xmms_xform_metadata_set_str (xform, metakey, mime_data);
+		xmms_xform_metadata_set_str (xform, metakey, (gchar *)mime_data);
 	}
+
+	g_free (value);
 }
 
 /* note that "key" is NOT NUL-terminated here,
@@ -322,10 +335,7 @@ handle_comment (xmms_xform_t *xform,
 	gint i;
 
 	if (!g_ascii_strncasecmp (key, "METADATA_BLOCK_PICTURE", key_len)) {
-		gsize dlen;
-		gchar *dvalue = g_base64_decode (value, &dlen);
-		handle_image_comment (xform, dvalue, dlen);
-		g_free (dvalue);
+		handle_image_comment (xform, value);
 		return;
 	}
 
--
cgit v0.8.3.4