1
0
Fork 0
forked from len0rd/rockbox

Submit FS#12218. Add support for embedded album art for ASF tags. For now the support is limited to embedded pictures of max 64 KB size.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30263 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-08-07 15:23:57 +00:00
parent 0bba82bf94
commit 93c6f1329a
2 changed files with 50 additions and 1 deletions

View file

@ -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);
}