diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-02-09 20:13:13 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-02-09 20:13:13 +0000 |
commit | f577a6a22c646669e56c5436859d2f5ec8b421e8 (patch) | |
tree | 04673c08ff7fc1e12ad4eb4147b705e0bd0fd926 /apps/recorder/jpeg_load.c | |
parent | 0d902c8c54bbc36f24b40c49eb9872aa75b779e4 (diff) | |
download | rockbox-f577a6a22c646669e56c5436859d2f5ec8b421e8.tar.gz 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/jpeg_load.c')
-rw-r--r-- | apps/recorder/jpeg_load.c | 43 |
1 files changed, 35 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 ********************/ |