From d9e85475c58b5450f4477c26430bc408489cf08c Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Tue, 15 Mar 2011 20:17:28 +0000 Subject: [PATCH] Submit FS#12009. Add embedded album art support for m4a. Thanks to Jason Yu. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29591 a1c6a512-1295-4272-9138-f99709370657 --- apps/metadata/mp4.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index a431231e12..4feb56cf98 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c @@ -33,6 +33,11 @@ #include "debug.h" #include "replaygain.h" +#ifdef DEBUGF +#undef DEBUGF +#define DEBUGF(...) +#endif + #define MP4_3gp6 FOURCC('3', 'g', 'p', '6') #define MP4_aART FOURCC('a', 'A', 'R', 'T') #define MP4_alac FOURCC('a', 'l', 'a', 'c') @@ -45,6 +50,7 @@ #define MP4_cwrt FOURCC(0xa9, 'w', 'r', 't') #define MP4_ccmt FOURCC(0xa9, 'c', 'm', 't') #define MP4_cday FOURCC(0xa9, 'd', 'a', 'y') +#define MP4_covr FOURCC('c', 'o', 'v', 'r') #define MP4_disk FOURCC('d', 'i', 's', 'k') #define MP4_esds FOURCC('e', 's', 'd', 's') #define MP4_ftyp FOURCC('f', 't', 'y', 'p') @@ -461,6 +467,32 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3, } break; +#ifdef HAVE_ALBUMART + case MP4_covr: + { + int pos = lseek(fd, 0, SEEK_CUR) + 16; + + read_mp4_tag(fd, size, buffer, 8); + id3->albumart.type = AA_TYPE_UNKNOWN; + if (memcmp(buffer, "\xff\xd8\xff\xe0", 4) == 0) + { + id3->albumart.type = AA_TYPE_JPG; + } + else if (memcmp(buffer, "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) + { + id3->albumart.type = AA_TYPE_PNG; + } + + if (id3->albumart.type != AA_TYPE_UNKNOWN) + { + id3->albumart.pos = pos; + id3->albumart.size = size - 16; + id3->embed_albumart = true; + } + } + break; +#endif + case MP4_extra: { char tag_name[TAG_NAME_LENGTH];