From 243976fe55a0ea6e4be90d5470cf1d775a7e921e Mon Sep 17 00:00:00 2001 From: buschel Date: Sun, 7 Aug 2011 15:23:57 +0000 Subject: [PATCH] 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 --- apps/metadata/asf.c | 47 ++++++++++++++++++++++++++++++++++++++++ manual/appendix/file_formats.tex | 4 +++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/apps/metadata/asf.c b/apps/metadata/asf.c index bcba3f0f7..f5532fa62 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); } diff --git a/manual/appendix/file_formats.tex b/manual/appendix/file_formats.tex index 696c0d62d..4e5d96aed 100644 --- a/manual/appendix/file_formats.tex +++ b/manual/appendix/file_formats.tex @@ -295,7 +295,7 @@ {\textbf{Feature} & \textbf{ID3} & \textbf{APE} & \textbf{Vorbis} & \textbf{MP4} & \textbf{ASF}}{}{} Embedded albumart \fname{.bmp} & & & & & \\ - Embedded albumart \fname{.jpg} & x & x & & x & \\ + Embedded albumart \fname{.jpg} & x & x & & x & x \\ Embedded albumart \fname{.png} & & & & & \\ Replaygain information & x & x & x & x & x \\ Title (string) & x & x & x & x & x \\ @@ -311,6 +311,8 @@ Grouping (string) & & x & x & x & \\ \end{rbtabular} + \note{Embedded album art for ASF is limited to pictures of maximum 64 KB size.} + \subsection{Featureset for codec specific metadata} \begin{rbtabular}{\textwidth}{lX}% {\textbf{Feature} & \textbf{Codec specific metadata (file extension)}}{}{} -- 2.11.4.GIT