summaryrefslogtreecommitdiffstats
path: root/apps/recorder
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/recorder
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/recorder')
-rw-r--r--apps/recorder/jpeg_load.c43
-rw-r--r--apps/recorder/jpeg_load.h23
2 files changed, 58 insertions, 8 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index 1af65fab6c..cd13934921 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -75,12 +75,12 @@ struct jpeg
{
#ifdef JPEG_FROM_MEM
unsigned char *data;
- unsigned long len;
#else
int fd;
int buf_left;
int buf_index;
#endif
+ unsigned long len;
unsigned long int bitbuf;
int bitbuf_bits;
int marker_ind;
@@ -888,8 +888,12 @@ INLINE void jpeg_putc(struct jpeg* p_jpeg)
#else
INLINE void fill_buf(struct jpeg* p_jpeg)
{
- p_jpeg->buf_left = read(p_jpeg->fd, p_jpeg->buf, JPEG_READ_BUF_SIZE);
+ p_jpeg->buf_left = read(p_jpeg->fd, p_jpeg->buf,
+ (p_jpeg->len >= JPEG_READ_BUF_SIZE)?
+ JPEG_READ_BUF_SIZE : p_jpeg->len);
p_jpeg->buf_index = 0;
+ if (p_jpeg->buf_left > 0)
+ p_jpeg->len -= p_jpeg->buf_left;
}
static unsigned char *jpeg_getc(struct jpeg* p_jpeg)
@@ -1960,7 +1964,9 @@ block_end:
*
*****************************************************************************/
#ifndef JPEG_FROM_MEM
-int read_jpeg_file(const char* filename,
+int clip_jpeg_file(const char* filename,
+ int offset,
+ unsigned long jpeg_size,
struct bitmap *bm,
int maxsize,
int format,
@@ -1975,11 +1981,20 @@ int read_jpeg_file(const char* filename,
DEBUGF("read_jpeg_file: can't open '%s', rc: %d\n", filename, fd);
return fd * 10 - 1;
}
-
- ret = read_jpeg_fd(fd, bm, maxsize, format, cformat);
+ lseek(fd, offset, SEEK_SET);
+ ret = clip_jpeg_fd(fd, jpeg_size, bm, maxsize, format, cformat);
close(fd);
return ret;
}
+
+int read_jpeg_file(const char* filename,
+ struct bitmap *bm,
+ int maxsize,
+ int format,
+ const struct custom_format *cformat)
+{
+ return clip_jpeg_file(filename, 0, 0, bm, maxsize, format, cformat);
+}
#endif
static int calc_scale(int in_size, int out_size)
@@ -2014,10 +2029,11 @@ int get_jpeg_dim_mem(unsigned char *data, unsigned long len,
return 0;
}
-int decode_jpeg_mem(unsigned char *data, unsigned long len,
+int decode_jpeg_mem(unsigned char *data,
#else
-int read_jpeg_fd(int fd,
+int clip_jpeg_fd(int fd,
#endif
+ unsigned long len,
struct bitmap *bm,
int maxsize,
int format,
@@ -2039,11 +2055,13 @@ int read_jpeg_fd(int fd,
return -1;
#endif
memset(p_jpeg, 0, sizeof(struct jpeg));
+ p_jpeg->len = len;
#ifdef JPEG_FROM_MEM
p_jpeg->data = data;
- p_jpeg->len = len;
#else
p_jpeg->fd = fd;
+ if (p_jpeg->len == 0)
+ p_jpeg->len = filesize(p_jpeg->fd);
#endif
status = process_markers(p_jpeg);
#ifndef JPEG_FROM_MEM
@@ -2212,4 +2230,13 @@ int read_jpeg_fd(int fd,
return 0;
}
+int read_jpeg_fd(int fd,
+ struct bitmap *bm,
+ int maxsize,
+ int format,
+ const struct custom_format *cformat)
+{
+ return clip_jpeg_fd(fd, 0, bm, maxsize, format, cformat);
+}
+
/**************** end JPEG code ********************/
diff --git a/apps/recorder/jpeg_load.h b/apps/recorder/jpeg_load.h
index 73b6c51bf3..6ff96dabad 100644
--- a/apps/recorder/jpeg_load.h
+++ b/apps/recorder/jpeg_load.h
@@ -44,4 +44,27 @@ int read_jpeg_fd(int fd,
int format,
const struct custom_format *cformat);
+/**
+ * read embedded jpeg files as above. Needs an offset and length into
+ * the file
+ **/
+int clip_jpeg_file(const char* filename,
+ int offset,
+ unsigned long jpeg_size,
+ struct bitmap *bm,
+ int maxsize,
+ int format,
+ const struct custom_format *cformat);
+
+/**
+ * read embedded jpeg files as above. Needs an open file descripter, and
+ * assumes the caller has lseek()'d to the start of the jpeg blob
+ **/
+int clip_jpeg_fd(int fd,
+ unsigned long jpeg_size,
+ struct bitmap *bm,
+ int maxsize,
+ int format,
+ const struct custom_format *cformat);
+
#endif /* _JPEG_JPEG_DECODER_H */