summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/SOURCES2
-rw-r--r--apps/codecs/Makefile1
-rw-r--r--apps/codecs/SOURCES1
-rw-r--r--apps/filetypes.c1
-rw-r--r--apps/main.c4
-rw-r--r--apps/metadata.c8
-rw-r--r--apps/metadata/metadata_parsers.h1
-rw-r--r--apps/playback.c2
-rw-r--r--apps/player/bmp.c199
-rw-r--r--apps/player/bmp.h35
-rw-r--r--apps/plugins/CATEGORIES1
-rw-r--r--apps/plugins/SOURCES11
12 files changed, 262 insertions, 4 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 0d23f42765..f3cb39fc1f 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -75,6 +75,7 @@ gui/backdrop.c
75#endif 75#endif
76 76
77#ifdef HAVE_LCD_CHARCELLS 77#ifdef HAVE_LCD_CHARCELLS
78player/bmp.c
78player/icons.c 79player/icons.c
79player/keyboard.c 80player/keyboard.c
80#endif 81#endif
@@ -129,6 +130,7 @@ metadata/mp4.c
129metadata/mpc.c 130metadata/mpc.c
130metadata/ogg.c 131metadata/ogg.c
131metadata/sid.c 132metadata/sid.c
133metadata/mod.c
132metadata/spc.c 134metadata/spc.c
133metadata/vorbis.c 135metadata/vorbis.c
134metadata/wave.c 136metadata/wave.c
diff --git a/apps/codecs/Makefile b/apps/codecs/Makefile
index 5a65341d02..7c066d284d 100644
--- a/apps/codecs/Makefile
+++ b/apps/codecs/Makefile
@@ -47,6 +47,7 @@ all: $(LINKCODEC) $(ROCKS)
47ifndef SIMVER 47ifndef SIMVER
48$(BUILDDIR)/%.a : % $(CODECDEPS) 48$(BUILDDIR)/%.a : % $(CODECDEPS)
49 49
50$(OBJDIR)/mod.elf : $(OBJDIR)/mod.o $(OBJDIR)/codec_crt0.o
50$(OBJDIR)/wav.elf : $(OBJDIR)/wav.o $(OBJDIR)/codec_crt0.o 51$(OBJDIR)/wav.elf : $(OBJDIR)/wav.o $(OBJDIR)/codec_crt0.o
51$(OBJDIR)/sid.elf : $(OBJDIR)/sid.o $(OBJDIR)/codec_crt0.o 52$(OBJDIR)/sid.elf : $(OBJDIR)/sid.o $(OBJDIR)/codec_crt0.o
52$(OBJDIR)/adx.elf : $(OBJDIR)/adx.o $(OBJDIR)/codec_crt0.o 53$(OBJDIR)/adx.elf : $(OBJDIR)/adx.o $(OBJDIR)/codec_crt0.o
diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES
index a93cb6c0cc..3c0118c1ce 100644
--- a/apps/codecs/SOURCES
+++ b/apps/codecs/SOURCES
@@ -13,6 +13,7 @@ wma.c
13aac.c 13aac.c
14#endif 14#endif
15ape.c 15ape.c
16mod.c
16shorten.c 17shorten.c
17aiff.c 18aiff.c
18speex.c 19speex.c
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 8427bc7450..7cf95553a3 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -69,6 +69,7 @@ const struct filetype inbuilt_filetypes[] = {
69 { "m4a", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 69 { "m4a", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
70 { "m4b", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 70 { "m4b", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
71 { "mp4", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 71 { "mp4", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
72 { "mod", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
72 { "shn", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 73 { "shn", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
73 { "aif", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 74 { "aif", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
74 { "aiff",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 75 { "aiff",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
diff --git a/apps/main.c b/apps/main.c
index 15dd1bcef9..b60b089b74 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -144,10 +144,10 @@ static int init_dircache(bool preinit)
144 144
145 if (preinit) 145 if (preinit)
146 dircache_init(); 146 dircache_init();
147 147
148 if (!global_settings.dircache) 148 if (!global_settings.dircache)
149 return 0; 149 return 0;
150 150
151# ifdef HAVE_EEPROM_SETTINGS 151# ifdef HAVE_EEPROM_SETTINGS
152 if (firmware_settings.initialized && firmware_settings.disk_clean 152 if (firmware_settings.initialized && firmware_settings.disk_clean
153 && preinit) 153 && preinit)
diff --git a/apps/metadata.c b/apps/metadata.c
index 3abbd74c35..303fafc070 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -183,6 +183,14 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
183 183
184 break; 184 break;
185 185
186 case AFMT_MOD:
187 if (!get_mod_metadata(fd, id3))
188 {
189 return false;
190 }
191
192 break;
193
186 case AFMT_SHN: 194 case AFMT_SHN:
187 id3->vbr = true; 195 id3->vbr = true;
188 id3->filesize = filesize(fd); 196 id3->filesize = filesize(fd);
diff --git a/apps/metadata/metadata_parsers.h b/apps/metadata/metadata_parsers.h
index c3265f8a43..b34d09fe4c 100644
--- a/apps/metadata/metadata_parsers.h
+++ b/apps/metadata/metadata_parsers.h
@@ -25,6 +25,7 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3);
25bool get_monkeys_metadata(int fd, struct mp3entry* id3); 25bool get_monkeys_metadata(int fd, struct mp3entry* id3);
26bool get_musepack_metadata(int fd, struct mp3entry *id3); 26bool get_musepack_metadata(int fd, struct mp3entry *id3);
27bool get_sid_metadata(int fd, struct mp3entry* id3); 27bool get_sid_metadata(int fd, struct mp3entry* id3);
28bool get_mod_metadata(int fd, struct mp3entry* id3);
28bool get_spc_metadata(int fd, struct mp3entry* id3); 29bool get_spc_metadata(int fd, struct mp3entry* id3);
29bool get_ogg_metadata(int fd, struct mp3entry* id3); 30bool get_ogg_metadata(int fd, struct mp3entry* id3);
30bool get_wave_metadata(int fd, struct mp3entry* id3); 31bool get_wave_metadata(int fd, struct mp3entry* id3);
diff --git a/apps/playback.c b/apps/playback.c
index cb9ed3e162..dbaf55fbdd 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1511,7 +1511,7 @@ int audio_track_count(void)
1511} 1511}
1512 1512
1513long audio_filebufused(void) 1513long audio_filebufused(void)
1514{ 1514{
1515 return (long) buf_used(); 1515 return (long) buf_used();
1516} 1516}
1517 1517
diff --git a/apps/player/bmp.c b/apps/player/bmp.c
new file mode 100644
index 0000000000..290880c0f7
--- /dev/null
+++ b/apps/player/bmp.c
@@ -0,0 +1,199 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/*
212008-02-24 Jens Arnold: minimalistic version for charcell displays
22*/
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include "inttypes.h"
28#include "debug.h"
29#include "lcd.h"
30#include "file.h"
31#include "config.h"
32#include "system.h"
33#include "bmp.h"
34#include "lcd.h"
35
36#ifdef __GNUC__
37#define STRUCT_PACKED __attribute__((packed))
38#else
39#define STRUCT_PACKED
40#pragma pack (push, 2)
41#endif
42
43/* BMP header structure */
44struct bmp_header {
45 uint16_t type; /* signature - 'BM' */
46 uint32_t size; /* file size in bytes */
47 uint16_t reserved1; /* 0 */
48 uint16_t reserved2; /* 0 */
49 uint32_t off_bits; /* offset to bitmap */
50 uint32_t struct_size; /* size of this struct (40) */
51 int32_t width; /* bmap width in pixels */
52 int32_t height; /* bmap height in pixels */
53 uint16_t planes; /* num planes - always 1 */
54 uint16_t bit_count; /* bits per pixel */
55 uint32_t compression; /* compression flag */
56 uint32_t size_image; /* image size in bytes */
57 int32_t x_pels_per_meter; /* horz resolution */
58 int32_t y_pels_per_meter; /* vert resolution */
59 uint32_t clr_used; /* 0 -> color table size */
60 uint32_t clr_important; /* important color count */
61} STRUCT_PACKED;
62
63union rgb_union {
64 struct { /* Little endian */
65 unsigned char blue;
66 unsigned char green;
67 unsigned char red;
68 unsigned char reserved;
69 };
70 uint32_t raw;
71};
72
73
74/* little endian functions */
75static inline unsigned readshort(uint16_t *value)
76{
77 unsigned char* bytes = (unsigned char*) value;
78 return (unsigned)bytes[0] | ((unsigned)bytes[1] << 8);
79}
80
81static inline uint32_t readlong(uint32_t *value)
82{
83 unsigned char* bytes = (unsigned char*) value;
84 return (uint32_t)bytes[0] | ((uint32_t)bytes[1] << 8) |
85 ((uint32_t)bytes[2] << 16) | ((uint32_t)bytes[3] << 24);
86}
87
88static inline unsigned brightness(union rgb_union color)
89{
90 return (3 * (unsigned)color.red + 6 * (unsigned)color.green
91 + (unsigned)color.blue) / 10;
92}
93
94/******************************************************************************
95 * read_bmp_file()
96 *
97 * Reads a BMP file and puts the data in rockbox format in *data.
98 *
99 *****************************************************************************/
100int read_bmp_file(const char* filename,
101 unsigned char *bitmap,
102 int maxsize)
103{
104 struct bmp_header bmph;
105 int fd, ret;
106 int width, height, depth;
107 int row, rowstart, rowstop, rowstep;
108 unsigned char invert;
109 unsigned char bmpbuf[4]; /* Buffer for one line */
110 uint32_t palette[2];
111
112 fd = open(filename, O_RDONLY);
113
114 /* Exit if file opening failed */
115 if (fd < 0)
116 {
117 DEBUGF("read_bmp_file: can't open '%s', rc: %d\n", filename, fd);
118 return fd * 10 - 1;
119 }
120
121 /* read fileheader */
122 ret = read(fd, &bmph, sizeof(struct bmp_header));
123 if (ret < 0)
124 return ret * 10 - 2;
125
126 if (ret != sizeof(struct bmp_header)) {
127 DEBUGF("read_bmp_file: can't read BMP header.");
128 return -3;
129 }
130
131 width = readlong(&bmph.width);
132 if (width > 8)
133 {
134 DEBUGF("read_bmp_file: Bitmap too wide (%d pixels, max is 8)\n", width);
135 return -4;
136 }
137
138 depth = readshort(&bmph.bit_count);
139 if (depth != 1)
140 {
141 DEBUGF("read_bmp_fd: Wrong depth (%d, must be 1)\n", depth);
142 return -5;
143 }
144
145 height = readlong(&bmph.height);
146 if (height < 0)
147 { /* Top-down BMP file */
148 height = -height;
149 rowstart = 0;
150 rowstop = height;
151 rowstep = 1;
152 }
153 else
154 { /* normal BMP */
155 rowstart = height - 1;
156 rowstop = -1;
157 rowstep = -1;
158 }
159
160 /* Check if this fits the buffer */
161 if (height > maxsize)
162 {
163 DEBUGF("read_bmp_fd: Bitmap too high for buffer: %d bytes.\n", height);
164 return -6;
165 }
166
167 if (read(fd, palette, 2 * sizeof(uint32_t))
168 != 2 * (int)sizeof(uint32_t))
169 {
170 DEBUGF("read_bmp_fd: Can't read color palette\n");
171 return -7;
172 }
173 invert = (brightness((union rgb_union)palette[1])
174 > brightness((union rgb_union)palette[0]))
175 ? 0xff : 0x00;
176
177 /* Search to the beginning of the image data */
178 lseek(fd, (off_t)readlong(&bmph.off_bits), SEEK_SET);
179 memset(bitmap, 0, height);
180
181 /* loop to read rows and put them to buffer */
182 for (row = rowstart; row != rowstop; row += rowstep)
183 {
184 /* read one row */
185 ret = read(fd, bmpbuf, 4);
186 if (ret != 4)
187 {
188 DEBUGF("read_bmp_fd: error reading image, read returned: %d "
189 "expected: 4\n", ret);
190 return -9;
191 }
192 bitmap[row] = bmpbuf[0] ^ invert;
193 }
194
195 DEBUGF("totalsize: %d\n", totalsize);
196
197 close(fd);
198 return height; /* return the used buffer size. */
199}
diff --git a/apps/player/bmp.h b/apps/player/bmp.h
new file mode 100644
index 0000000000..ddfa349d9d
--- /dev/null
+++ b/apps/player/bmp.h
@@ -0,0 +1,35 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _BMP_H_
20#define _BMP_H_
21
22/*********************************************************************
23 * read_bmp_file(), minimalistic version for charcell displays
24 *
25 * Reads a 1 bit BMP file and puts the data in a horizontal packed
26 * 1 bit-per-pixel char array. Width must be <= 8 pixels.
27 * Returns < 0 for error, or number of bytes used from the bitmap
28 * buffer, which equals bitmap height.
29 *
30 **********************************************/
31int read_bmp_file(const char* filename,
32 unsigned char *bitmap,
33 int maxsize);
34
35#endif
diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES
index 4b267c162b..c2ad75e0c7 100644
--- a/apps/plugins/CATEGORIES
+++ b/apps/plugins/CATEGORIES
@@ -80,6 +80,7 @@ stopwatch,apps
80test_codec,viewers 80test_codec,viewers
81test_disk,apps 81test_disk,apps
82test_fps,apps 82test_fps,apps
83test_grey,apps
83test_sampr,apps 84test_sampr,apps
84test_scanrate,apps 85test_scanrate,apps
85test_viewports,apps 86test_viewports,apps
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 4f782dc455..7b7edbf5c2 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -21,6 +21,7 @@ stats.c
21stopwatch.c 21stopwatch.c
22vbrfix.c 22vbrfix.c
23viewer.c 23viewer.c
24test_disk.c
24 25
25#ifdef OLYMPUS_MROBE_500 26#ifdef OLYMPUS_MROBE_500
26/* remove these once the plugins before it are compileable */ 27/* remove these once the plugins before it are compileable */
@@ -48,7 +49,10 @@ flipit.c
48#ifdef HAVE_LCD_BITMAP /* Not for the Player */ 49#ifdef HAVE_LCD_BITMAP /* Not for the Player */
49brickmania.c 50brickmania.c
50maze.c 51maze.c
51mazezam.c 52mazezam.c
53greyscale.c
54test_fps.c
55test_scanrate.c
52text_editor.c 56text_editor.c
53wavview.c 57wavview.c
54robotfindskitten.c 58robotfindskitten.c
@@ -59,6 +63,10 @@ jpeg.c
59mandelbrot.c 63mandelbrot.c
60plasma.c 64plasma.c
61 65
66#if LCD_DEPTH < 4
67test_grey.c
68#endif
69
62blackjack.c 70blackjack.c
63bounce.c 71bounce.c
64bubbles.c 72bubbles.c
@@ -118,6 +126,7 @@ nim.c
118 126
119#if CONFIG_CODEC == SWCODEC /* software codec platforms */ 127#if CONFIG_CODEC == SWCODEC /* software codec platforms */
120mp3_encoder.c 128mp3_encoder.c
129test_codec.c
121wav2wv.c 130wav2wv.c
122#else /* hardware codec platforms */ 131#else /* hardware codec platforms */
123#ifndef HAVE_MMC /* not for Ondio, has no remote control pin */ 132#ifndef HAVE_MMC /* not for Ondio, has no remote control pin */