summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/metadata/asf.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/metadata/asf.c b/apps/metadata/asf.c
index bcba3f0f79..f5532fa628 100644
--- a/apps/metadata/asf.c
+++ b/apps/metadata/asf.c
@@ -462,6 +462,53 @@ static int asf_parse_header(int fd, struct mp3entry* id3,
} else if (!strcmp("MusicBrainz/Track Id", utf8buf)) {
id3->mb_track_id = id3buf;
asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining);
+#ifdef HAVE_ALBUMART
+ } else if (!strcmp("WM/Picture", utf8buf)) {
+ uint32_t datalength, strlength;
+ /* Expected is either "01 00 xx xx 03 yy yy yy yy" or
+ * "03 yy yy yy yy". xx is the size of the WM/Picture
+ * container in bytes. yy equals the raw data length of
+ * the embedded image. */
+ lseek(fd, -4, SEEK_CUR);
+ read(fd, &type, 1);
+ if (type == 1) {
+ lseek(fd, 3, SEEK_CUR);
+ read(fd, &type, 1);
+ /* In case the parsing will fail in the next step we
+ * might at least be able to skip the whole section. */
+ datalength = length - 1;
+ }
+ if (type == 3) {
+ /* Read the raw data length of the embedded image. */
+ read_uint32le(fd, &datalength);
+
+ /* Reset utf8 buffer */
+ utf8 = utf8buf;
+ utf8length = 512;
+
+ /* Gather the album art format, this string has a
+ * double zero-termination. */
+ asf_utf16LEdecode(fd, 32, &utf8, &utf8length);
+ strlength = (strlen(utf8buf) + 2) * 2;
+ lseek(fd, strlength-32, SEEK_CUR);
+ if (!strcmp("image/jpeg", utf8buf)) {
+ id3->albumart.type = AA_TYPE_JPG;
+ } else if (!strcmp("image/png", utf8buf)) {
+ id3->albumart.type = AA_TYPE_PNG;
+ } else {
+ id3->albumart.type = AA_TYPE_UNKNOWN;
+ }
+
+ /* Set the album art size and position. */
+ if (id3->albumart.type != AA_TYPE_UNKNOWN) {
+ id3->albumart.pos = lseek(fd, 0, SEEK_CUR);
+ id3->albumart.size = datalength;
+ id3->embed_albumart = true;
+ }
+ }
+
+ lseek(fd, datalength, SEEK_CUR);
+#endif
} else {
lseek(fd, length, SEEK_CUR);
}