summaryrefslogtreecommitdiff
path: root/apps/recorder/jpeg_load.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/recorder/jpeg_load.c
parent0d902c8c54bbc36f24b40c49eb9872aa75b779e4 (diff)
downloadrockbox-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.c43
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
75{ 75{
76#ifdef JPEG_FROM_MEM 76#ifdef JPEG_FROM_MEM
77 unsigned char *data; 77 unsigned char *data;
78 unsigned long len;
79#else 78#else
80 int fd; 79 int fd;
81 int buf_left; 80 int buf_left;
82 int buf_index; 81 int buf_index;
83#endif 82#endif
83 unsigned long len;
84 unsigned long int bitbuf; 84 unsigned long int bitbuf;
85 int bitbuf_bits; 85 int bitbuf_bits;
86 int marker_ind; 86 int marker_ind;
@@ -888,8 +888,12 @@ INLINE void jpeg_putc(struct jpeg* p_jpeg)
888#else 888#else
889INLINE void fill_buf(struct jpeg* p_jpeg) 889INLINE void fill_buf(struct jpeg* p_jpeg)
890{ 890{
891 p_jpeg->buf_left = read(p_jpeg->fd, p_jpeg->buf, JPEG_READ_BUF_SIZE); 891 p_jpeg->buf_left = read(p_jpeg->fd, p_jpeg->buf,
892 (p_jpeg->len >= JPEG_READ_BUF_SIZE)?
893 JPEG_READ_BUF_SIZE : p_jpeg->len);
892 p_jpeg->buf_index = 0; 894 p_jpeg->buf_index = 0;
895 if (p_jpeg->buf_left > 0)
896 p_jpeg->len -= p_jpeg->buf_left;
893} 897}
894 898
895static unsigned char *jpeg_getc(struct jpeg* p_jpeg) 899static unsigned char *jpeg_getc(struct jpeg* p_jpeg)
@@ -1960,7 +1964,9 @@ block_end:
1960 * 1964 *
1961 *****************************************************************************/ 1965 *****************************************************************************/
1962#ifndef JPEG_FROM_MEM 1966#ifndef JPEG_FROM_MEM
1963int read_jpeg_file(const char* filename, 1967int clip_jpeg_file(const char* filename,
1968 int offset,
1969 unsigned long jpeg_size,
1964 struct bitmap *bm, 1970 struct bitmap *bm,
1965 int maxsize, 1971 int maxsize,
1966 int format, 1972 int format,
@@ -1975,11 +1981,20 @@ int read_jpeg_file(const char* filename,
1975 DEBUGF("read_jpeg_file: can't open '%s', rc: %d\n", filename, fd); 1981 DEBUGF("read_jpeg_file: can't open '%s', rc: %d\n", filename, fd);
1976 return fd * 10 - 1; 1982 return fd * 10 - 1;
1977 } 1983 }
1978 1984 lseek(fd, offset, SEEK_SET);
1979 ret = read_jpeg_fd(fd, bm, maxsize, format, cformat); 1985 ret = clip_jpeg_fd(fd, jpeg_size, bm, maxsize, format, cformat);
1980 close(fd); 1986 close(fd);
1981 return ret; 1987 return ret;
1982} 1988}
1989
1990int read_jpeg_file(const char* filename,
1991 struct bitmap *bm,
1992 int maxsize,
1993 int format,
1994 const struct custom_format *cformat)
1995{
1996 return clip_jpeg_file(filename, 0, 0, bm, maxsize, format, cformat);
1997}
1983#endif 1998#endif
1984 1999
1985static int calc_scale(int in_size, int out_size) 2000static int calc_scale(int in_size, int out_size)
@@ -2014,10 +2029,11 @@ int get_jpeg_dim_mem(unsigned char *data, unsigned long len,
2014 return 0; 2029 return 0;
2015} 2030}
2016 2031
2017int decode_jpeg_mem(unsigned char *data, unsigned long len, 2032int decode_jpeg_mem(unsigned char *data,
2018#else 2033#else
2019int read_jpeg_fd(int fd, 2034int clip_jpeg_fd(int fd,
2020#endif 2035#endif
2036 unsigned long len,
2021 struct bitmap *bm, 2037 struct bitmap *bm,
2022 int maxsize, 2038 int maxsize,
2023 int format, 2039 int format,
@@ -2039,11 +2055,13 @@ int read_jpeg_fd(int fd,
2039 return -1; 2055 return -1;
2040#endif 2056#endif
2041 memset(p_jpeg, 0, sizeof(struct jpeg)); 2057 memset(p_jpeg, 0, sizeof(struct jpeg));
2058 p_jpeg->len = len;
2042#ifdef JPEG_FROM_MEM 2059#ifdef JPEG_FROM_MEM
2043 p_jpeg->data = data; 2060 p_jpeg->data = data;
2044 p_jpeg->len = len;
2045#else 2061#else
2046 p_jpeg->fd = fd; 2062 p_jpeg->fd = fd;
2063 if (p_jpeg->len == 0)
2064 p_jpeg->len = filesize(p_jpeg->fd);
2047#endif 2065#endif
2048 status = process_markers(p_jpeg); 2066 status = process_markers(p_jpeg);
2049#ifndef JPEG_FROM_MEM 2067#ifndef JPEG_FROM_MEM
@@ -2212,4 +2230,13 @@ int read_jpeg_fd(int fd,
2212 return 0; 2230 return 0;
2213} 2231}
2214 2232
2233int read_jpeg_fd(int fd,
2234 struct bitmap *bm,
2235 int maxsize,
2236 int format,
2237 const struct custom_format *cformat)
2238{
2239 return clip_jpeg_fd(fd, 0, bm, maxsize, format, cformat);
2240}
2241
2215/**************** end JPEG code ********************/ 2242/**************** end JPEG code ********************/