diff options
author | Albert Song <albb0920@gmail.com> | 2013-12-13 01:48:48 -0800 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-12-13 12:37:20 +0100 |
commit | f633d5ed482848826b6b081078be0414a5aaa78f (patch) | |
tree | d819ae26c3e653e881453227b6b856fb73804e6c /lib/rbcodec/metadata/flac.c | |
parent | 8666871cb378e68fb9b4c7c429aa3d4cb22a685b (diff) | |
download | rockbox-f633d5ed482848826b6b081078be0414a5aaa78f.tar.gz rockbox-f633d5ed482848826b6b081078be0414a5aaa78f.zip |
Add support for flac embeded album art.
Change-Id: I077768f7d80b57976f9a7278b640ef67cf4f2af2
Reviewed-on: http://gerrit.rockbox.org/694
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'lib/rbcodec/metadata/flac.c')
-rw-r--r-- | lib/rbcodec/metadata/flac.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/rbcodec/metadata/flac.c b/lib/rbcodec/metadata/flac.c index a8be4c6de4..df25bb9b4d 100644 --- a/lib/rbcodec/metadata/flac.c +++ b/lib/rbcodec/metadata/flac.c | |||
@@ -113,6 +113,56 @@ bool get_flac_metadata(int fd, struct mp3entry* id3) | |||
113 | return rc; | 113 | return rc; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | #ifdef HAVE_ALBUMART | ||
117 | else if (type == 6) /* 6 is the PICTURE block */ | ||
118 | { | ||
119 | if(!id3->has_embedded_albumart) /* only use the first PICTURE */ | ||
120 | { | ||
121 | unsigned int buf_size = MIN(sizeof(id3->path), i); | ||
122 | int picframe_pos = 4; /* skip picture type */ | ||
123 | int mime_length, description_length; | ||
124 | |||
125 | id3->albumart.pos = lseek(fd, 0, SEEK_CUR); | ||
126 | |||
127 | int bytes_read = read(fd, buf, buf_size); | ||
128 | i -= bytes_read; | ||
129 | |||
130 | mime_length = get_long_be(&buf[picframe_pos]); | ||
131 | |||
132 | char *mime = buf + picframe_pos + 4; | ||
133 | picframe_pos += 4 + mime_length; | ||
134 | |||
135 | id3->albumart.type = AA_TYPE_UNKNOWN; | ||
136 | if (memcmp(mime, "image/", 6) == 0) | ||
137 | { | ||
138 | mime += 6; | ||
139 | if (strcmp(mime, "jpeg") == 0 || strcmp(mime, "jpg") == 0){ | ||
140 | id3->albumart.type = AA_TYPE_JPG; | ||
141 | }else if (strcmp(mime, "png") == 0) | ||
142 | id3->albumart.type = AA_TYPE_PNG; | ||
143 | } | ||
144 | |||
145 | description_length = get_long_be(&buf[picframe_pos]); | ||
146 | |||
147 | /* 16 = skip picture width,height,color-depth,color-used */ | ||
148 | picframe_pos += 4 + description_length + 16; | ||
149 | |||
150 | /* if we support the format and image length is in the buffer */ | ||
151 | if(id3->albumart.type != AA_TYPE_UNKNOWN | ||
152 | && (picframe_pos + 4) - buf_size > 0) | ||
153 | { | ||
154 | id3->has_embedded_albumart = true; | ||
155 | id3->albumart.size = get_long_be(&buf[picframe_pos]); | ||
156 | id3->albumart.pos += picframe_pos + 4; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | if (lseek(fd, i, SEEK_CUR) < 0) | ||
161 | { | ||
162 | return rc; | ||
163 | } | ||
164 | } | ||
165 | #endif | ||
116 | else if (!last_metadata) | 166 | else if (!last_metadata) |
117 | { | 167 | { |
118 | /* Skip to next metadata block */ | 168 | /* Skip to next metadata block */ |