summaryrefslogtreecommitdiffstats
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-02-09 20:13:13 +0000
committerThomas Martitz <kugel@rockbox.org>2011-02-09 20:13:13 +0000
commitf577a6a22c646669e56c5436859d2f5ec8b421e8 (patch)
tree04673c08ff7fc1e12ad4eb4147b705e0bd0fd926 /apps/buffering.c
parent0d902c8c54bbc36f24b40c49eb9872aa75b779e4 (diff)
downloadrockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.tar.gz
rockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.tar.bz2
rockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.zip
Embedded album art support in MP3/ID3v2 tags.
- Support is limited to non-desync jpeg in id3v2 tags. Other formats (hopefully) follow in the future. - Embedded album art takes precedence over files in album art files. - No additional buffers are used, the jpeg is read directly from the audio file. Flyspray: FS#11216 Author: Yoshihisa Uchida and I git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29259 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 123c7bc85f..9c0ad138f7 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -52,6 +52,7 @@
#include "albumart.h"
#include "jpeg_load.h"
#include "bmp.h"
+#include "playback.h"
#endif
#define GUARD_BUFSIZE (32*1024)
@@ -908,10 +909,12 @@ static bool fill_buffer(void)
/* Given a file descriptor to a bitmap file, write the bitmap data to the
buffer, with a struct bitmap and the actual data immediately following.
Return value is the total size (struct + data). */
-static int load_image(int fd, const char *path, struct dim *dim)
+static int load_image(int fd, const char *path, struct bufopen_bitmap_data *data)
{
int rc;
struct bitmap *bmp = (struct bitmap *)&buffer[buf_widx];
+ struct dim *dim = data->dim;
+ struct mp3_albumart *aa = data->embedded_albumart;
/* get the desired image size */
bmp->width = dim->width, bmp->height = dim->height;
@@ -928,8 +931,13 @@ static int load_image(int fd, const char *path, struct dim *dim)
- sizeof(struct bitmap);
#ifdef HAVE_JPEG
- int pathlen = strlen(path);
- if (strcmp(path + pathlen - 4, ".bmp"))
+ if (aa != NULL)
+ {
+ lseek(fd, aa->pos, SEEK_SET);
+ rc = clip_jpeg_fd(fd, aa->size, bmp, free, FORMAT_NATIVE|FORMAT_DITHER|
+ FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL);
+ }
+ else if (strcmp(path + strlen(path) - 4, ".bmp"))
rc = read_jpeg_fd(fd, bmp, free, FORMAT_NATIVE|FORMAT_DITHER|
FORMAT_RESIZE|FORMAT_KEEP_ASPECT, NULL);
else
@@ -1010,7 +1018,18 @@ int bufopen(const char *file, size_t offset, enum data_type type,
if (fd < 0)
return ERR_FILE_ERROR;
- size_t size = filesize(fd);
+ size_t size = 0;
+#ifdef HAVE_ALBUMART
+ if (type == TYPE_BITMAP)
+ { /* if albumart is embedded, the complete file is not buffered,
+ * but only the jpeg part; filesize() would be wrong */
+ struct bufopen_bitmap_data *aa = (struct bufopen_bitmap_data*)user_data;
+ if (aa->embedded_albumart)
+ size = aa->embedded_albumart->size;
+ }
+#endif
+ if (size == 0)
+ size = filesize(fd);
bool can_wrap = type==TYPE_PACKET_AUDIO || type==TYPE_CODEC;
size_t adjusted_offset = offset;
@@ -1058,7 +1077,7 @@ int bufopen(const char *file, size_t offset, enum data_type type,
/* Bitmap file: we load the data instead of the file */
int rc;
mutex_lock(&llist_mod_mutex); /* Lock because load_bitmap yields */
- rc = load_image(fd, file, (struct dim*)user_data);
+ rc = load_image(fd, file, (struct bufopen_bitmap_data*)user_data);
mutex_unlock(&llist_mod_mutex);
if (rc <= 0)
{