From d1ed7c37b130500cc3c5b5ed4390192f623abd5d Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 8 Mar 2008 23:34:43 +0000 Subject: No need to have \n here. panicf() won't output it anyway. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16570 a1c6a512-1295-4272-9138-f99709370657 --- apps/SOURCES | 2 + apps/codecs/Makefile | 1 + apps/codecs/SOURCES | 1 + apps/filetypes.c | 1 + apps/main.c | 4 +- apps/metadata.c | 8 ++ apps/metadata/metadata_parsers.h | 1 + apps/playback.c | 2 +- apps/player/bmp.c | 199 +++++++++++++++++++++++++++++++++++++++ apps/player/bmp.h | 35 +++++++ apps/plugins/CATEGORIES | 1 + apps/plugins/SOURCES | 11 ++- 12 files changed, 262 insertions(+), 4 deletions(-) create mode 100644 apps/player/bmp.c create mode 100644 apps/player/bmp.h (limited to 'apps') 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 #endif #ifdef HAVE_LCD_CHARCELLS +player/bmp.c player/icons.c player/keyboard.c #endif @@ -129,6 +130,7 @@ metadata/mp4.c metadata/mpc.c metadata/ogg.c metadata/sid.c +metadata/mod.c metadata/spc.c metadata/vorbis.c metadata/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) ifndef SIMVER $(BUILDDIR)/%.a : % $(CODECDEPS) +$(OBJDIR)/mod.elf : $(OBJDIR)/mod.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/wav.elf : $(OBJDIR)/wav.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/sid.elf : $(OBJDIR)/sid.o $(OBJDIR)/codec_crt0.o $(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 aac.c #endif ape.c +mod.c shorten.c aiff.c speex.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[] = { { "m4a", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "m4b", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "mp4", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mod", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "shn", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "aif", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "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) if (preinit) dircache_init(); - + if (!global_settings.dircache) return 0; - + # ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized && firmware_settings.disk_clean && 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) break; + case AFMT_MOD: + if (!get_mod_metadata(fd, id3)) + { + return false; + } + + break; + case AFMT_SHN: id3->vbr = true; 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); bool get_monkeys_metadata(int fd, struct mp3entry* id3); bool get_musepack_metadata(int fd, struct mp3entry *id3); bool get_sid_metadata(int fd, struct mp3entry* id3); +bool get_mod_metadata(int fd, struct mp3entry* id3); bool get_spc_metadata(int fd, struct mp3entry* id3); bool get_ogg_metadata(int fd, struct mp3entry* id3); bool 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) } long audio_filebufused(void) -{ +{ return (long) buf_used(); } 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* +2008-02-24 Jens Arnold: minimalistic version for charcell displays +*/ + +#include +#include +#include +#include "inttypes.h" +#include "debug.h" +#include "lcd.h" +#include "file.h" +#include "config.h" +#include "system.h" +#include "bmp.h" +#include "lcd.h" + +#ifdef __GNUC__ +#define STRUCT_PACKED __attribute__((packed)) +#else +#define STRUCT_PACKED +#pragma pack (push, 2) +#endif + +/* BMP header structure */ +struct bmp_header { + uint16_t type; /* signature - 'BM' */ + uint32_t size; /* file size in bytes */ + uint16_t reserved1; /* 0 */ + uint16_t reserved2; /* 0 */ + uint32_t off_bits; /* offset to bitmap */ + uint32_t struct_size; /* size of this struct (40) */ + int32_t width; /* bmap width in pixels */ + int32_t height; /* bmap height in pixels */ + uint16_t planes; /* num planes - always 1 */ + uint16_t bit_count; /* bits per pixel */ + uint32_t compression; /* compression flag */ + uint32_t size_image; /* image size in bytes */ + int32_t x_pels_per_meter; /* horz resolution */ + int32_t y_pels_per_meter; /* vert resolution */ + uint32_t clr_used; /* 0 -> color table size */ + uint32_t clr_important; /* important color count */ +} STRUCT_PACKED; + +union rgb_union { + struct { /* Little endian */ + unsigned char blue; + unsigned char green; + unsigned char red; + unsigned char reserved; + }; + uint32_t raw; +}; + + +/* little endian functions */ +static inline unsigned readshort(uint16_t *value) +{ + unsigned char* bytes = (unsigned char*) value; + return (unsigned)bytes[0] | ((unsigned)bytes[1] << 8); +} + +static inline uint32_t readlong(uint32_t *value) +{ + unsigned char* bytes = (unsigned char*) value; + return (uint32_t)bytes[0] | ((uint32_t)bytes[1] << 8) | + ((uint32_t)bytes[2] << 16) | ((uint32_t)bytes[3] << 24); +} + +static inline unsigned brightness(union rgb_union color) +{ + return (3 * (unsigned)color.red + 6 * (unsigned)color.green + + (unsigned)color.blue) / 10; +} + +/****************************************************************************** + * read_bmp_file() + * + * Reads a BMP file and puts the data in rockbox format in *data. + * + *****************************************************************************/ +int read_bmp_file(const char* filename, + unsigned char *bitmap, + int maxsize) +{ + struct bmp_header bmph; + int fd, ret; + int width, height, depth; + int row, rowstart, rowstop, rowstep; + unsigned char invert; + unsigned char bmpbuf[4]; /* Buffer for one line */ + uint32_t palette[2]; + + fd = open(filename, O_RDONLY); + + /* Exit if file opening failed */ + if (fd < 0) + { + DEBUGF("read_bmp_file: can't open '%s', rc: %d\n", filename, fd); + return fd * 10 - 1; + } + + /* read fileheader */ + ret = read(fd, &bmph, sizeof(struct bmp_header)); + if (ret < 0) + return ret * 10 - 2; + + if (ret != sizeof(struct bmp_header)) { + DEBUGF("read_bmp_file: can't read BMP header."); + return -3; + } + + width = readlong(&bmph.width); + if (width > 8) + { + DEBUGF("read_bmp_file: Bitmap too wide (%d pixels, max is 8)\n", width); + return -4; + } + + depth = readshort(&bmph.bit_count); + if (depth != 1) + { + DEBUGF("read_bmp_fd: Wrong depth (%d, must be 1)\n", depth); + return -5; + } + + height = readlong(&bmph.height); + if (height < 0) + { /* Top-down BMP file */ + height = -height; + rowstart = 0; + rowstop = height; + rowstep = 1; + } + else + { /* normal BMP */ + rowstart = height - 1; + rowstop = -1; + rowstep = -1; + } + + /* Check if this fits the buffer */ + if (height > maxsize) + { + DEBUGF("read_bmp_fd: Bitmap too high for buffer: %d bytes.\n", height); + return -6; + } + + if (read(fd, palette, 2 * sizeof(uint32_t)) + != 2 * (int)sizeof(uint32_t)) + { + DEBUGF("read_bmp_fd: Can't read color palette\n"); + return -7; + } + invert = (brightness((union rgb_union)palette[1]) + > brightness((union rgb_union)palette[0])) + ? 0xff : 0x00; + + /* Search to the beginning of the image data */ + lseek(fd, (off_t)readlong(&bmph.off_bits), SEEK_SET); + memset(bitmap, 0, height); + + /* loop to read rows and put them to buffer */ + for (row = rowstart; row != rowstop; row += rowstep) + { + /* read one row */ + ret = read(fd, bmpbuf, 4); + if (ret != 4) + { + DEBUGF("read_bmp_fd: error reading image, read returned: %d " + "expected: 4\n", ret); + return -9; + } + bitmap[row] = bmpbuf[0] ^ invert; + } + + DEBUGF("totalsize: %d\n", totalsize); + + close(fd); + return height; /* return the used buffer size. */ +} 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Daniel Stenberg + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _BMP_H_ +#define _BMP_H_ + +/********************************************************************* + * read_bmp_file(), minimalistic version for charcell displays + * + * Reads a 1 bit BMP file and puts the data in a horizontal packed + * 1 bit-per-pixel char array. Width must be <= 8 pixels. + * Returns < 0 for error, or number of bytes used from the bitmap + * buffer, which equals bitmap height. + * + **********************************************/ +int read_bmp_file(const char* filename, + unsigned char *bitmap, + int maxsize); + +#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 test_codec,viewers test_disk,apps test_fps,apps +test_grey,apps test_sampr,apps test_scanrate,apps test_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 stopwatch.c vbrfix.c viewer.c +test_disk.c #ifdef OLYMPUS_MROBE_500 /* remove these once the plugins before it are compileable */ @@ -48,7 +49,10 @@ flipit.c #ifdef HAVE_LCD_BITMAP /* Not for the Player */ brickmania.c maze.c -mazezam.c +mazezam.c +greyscale.c +test_fps.c +test_scanrate.c text_editor.c wavview.c robotfindskitten.c @@ -59,6 +63,10 @@ jpeg.c mandelbrot.c plasma.c +#if LCD_DEPTH < 4 +test_grey.c +#endif + blackjack.c bounce.c bubbles.c @@ -118,6 +126,7 @@ nim.c #if CONFIG_CODEC == SWCODEC /* software codec platforms */ mp3_encoder.c +test_codec.c wav2wv.c #else /* hardware codec platforms */ #ifndef HAVE_MMC /* not for Ondio, has no remote control pin */ -- cgit v1.2.3