diff options
| author | Dominik Wenger <domonoky@googlemail.com> | 2008-07-26 15:16:10 +0000 |
|---|---|---|
| committer | Dominik Wenger <domonoky@googlemail.com> | 2008-07-26 15:16:10 +0000 |
| commit | 25bb37bb6851c85e21fb0cecfd9617eebe6c7a56 (patch) | |
| tree | 14800e46724f8fa90c2ea1cb7100ac89423cde4e /apps/codecs | |
| parent | 4e4bf82fb756f36dca6af333357a54e09b9f4cca (diff) | |
| download | rockbox-25bb37bb6851c85e21fb0cecfd9617eebe6c7a56.zip rockbox-25bb37bb6851c85e21fb0cecfd9617eebe6c7a56.tar.gz rockbox-25bb37bb6851c85e21fb0cecfd9617eebe6c7a56.tar.bz2 rockbox-25bb37bb6851c85e21fb0cecfd9617eebe6c7a56.tar.xz | |
commit asap codec. plays .sap files. At the moment it only plays the default song. So subSongs are ignored.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18121 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
| -rw-r--r-- | apps/codecs/Makefile | 12 | ||||
| -rw-r--r-- | apps/codecs/SOURCES | 1 | ||||
| -rw-r--r-- | apps/codecs/asap.c | 131 | ||||
| -rw-r--r-- | apps/codecs/asap/README.rockbox | 25 | ||||
| -rw-r--r-- | apps/codecs/asap/SOURCES | 3 | ||||
| -rw-r--r-- | apps/codecs/asap/apokeysnd.c | 3 | ||||
| -rw-r--r-- | apps/codecs/asap/asap.c | 14 | ||||
| -rw-r--r-- | apps/codecs/asap/asap.h | 2 |
8 files changed, 184 insertions, 7 deletions
diff --git a/apps/codecs/Makefile b/apps/codecs/Makefile index 7c066d2..9dd88e5 100644 --- a/apps/codecs/Makefile +++ b/apps/codecs/Makefile @@ -17,8 +17,8 @@ ifdef APPEXTRA endif ifdef SOFTWARECODECS - CODECLIBS = -lspc -lmad -la52 -lffmpegFLAC -lTremor -lwavpack -lmusepack -lalac -lfaad -lm4a -lspeex -ldemac -lwma - OUTPUT = libspc libmad liba52 libffmpegFLAC libwma libTremor libwavpack libmusepack libalac libfaad libm4a libspeex libdemac + CODECLIBS = -lspc -lmad -la52 -lffmpegFLAC -lTremor -lwavpack -lmusepack -lalac -lfaad -lm4a -lspeex -ldemac -lwma -lasap + OUTPUT = libspc libmad liba52 libffmpegFLAC libwma libTremor libwavpack libmusepack libalac libfaad libm4a libspeex libdemac libasap endif # we "borrow" the plugin LDS file @@ -40,7 +40,7 @@ DIRS = . CODECDEPS = $(LINKCODEC) $(BUILDDIR)/libcodec.a -.PHONY: libspc libmad liba52 libffmpegFLAC libTremor libspeex libwavpack libmusepack libalac libfaad libm4a libdemac libwma +.PHONY: libspc libmad liba52 libffmpegFLAC libTremor libspeex libwavpack libmusepack libalac libfaad libm4a libdemac libwma libasap all: $(LINKCODEC) $(ROCKS) @@ -70,6 +70,7 @@ $(OBJDIR)/aiff_enc.elf: $(OBJDIR)/aiff_enc.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/mp3_enc.elf: $(OBJDIR)/mp3_enc.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/wav_enc.elf: $(OBJDIR)/wav_enc.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/wavpack_enc.elf: $(OBJDIR)/wavpack_enc.o $(BUILDDIR)/libwavpack.a $(OBJDIR)/codec_crt0.o +$(OBJDIR)/asap.elf : $(OBJDIR)/asap.o $(BUILDDIR)/libasap.a $(OBJDIR)/codec_crt0.o $(OBJDIR)/%.elf: $(OBJDIR)/codec_crt0.o $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) -o $@ $^ -L$(BUILDDIR) -lcodec -lgcc \ @@ -218,6 +219,11 @@ libdemac: $(SILENT)mkdir -p $(OBJDIR)/libdemac $(call PRINTS,MAKE in libdemac)$(MAKE) -C demac/libdemac OBJDIR=$(OBJDIR)/libdemac OUTPUT=$(BUILDDIR)/libdemac.a +$(BUILDDIR)/libasap.a: libasap + +libasap: + $(SILENT)mkdir -p $(OBJDIR)/asap + $(call PRINTS,MAKE in asap)$(MAKE) -C asap OBJDIR=$(OBJDIR)/asap OUTPUT=$(BUILDDIR)/libasap.a clean: $(call PRINTS,cleaning codecs)rm -fr $(OBJDIR)/spc $(BUILDDIR)/libspc.a $(OBJDIR)/libmad $(BUILDDIR)/libmad.a $(OBJDIR)/liba52 $(BUILDDIR)/liba52.a $(OBJDIR)/libffmpegFLAC $(BUILDDIR)/libffmpegFLAC.a $(OBJDIR)/Tremor $(BUILDDIR)/libTremor.a $(OBJDIR)/libspeex $(BUILDDIR)/libSpeex.a $(OBJDIR)/libwavpack $(BUILDDIR)/libwavpack.a $(OBJDIR)/libmusepack $(BUILDDIR)/libmusepack.a $(OBJDIR)/libalac $(BUILDDIR)/libalac.a $(OBJDIR)/libfaad $(BUILDDIR)/libfaad.a $(OBJDIR)/libm4a $(BUILDDIR)/libm4a.a $(OBJDIR)/libdemac $(BUILDDIR)/libdemac.a $(OBJDIR)/libwma $(BUILDDIR)/libwma.a $(SILENT)$(MAKE) -C spc clean OBJDIR=$(OBJDIR)/spc diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES index 3c0118c..25ca549 100644 --- a/apps/codecs/SOURCES +++ b/apps/codecs/SOURCES @@ -21,6 +21,7 @@ sid.c adx.c nsf.c spc.c +asap.c #if defined(HAVE_RECORDING) && !defined(SIMULATOR) /* encoders */ aiff_enc.c diff --git a/apps/codecs/asap.c b/apps/codecs/asap.c new file mode 100644 index 0000000..f6fa68f --- /dev/null +++ b/apps/codecs/asap.c @@ -0,0 +1,131 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: asap.c 17847 2008-06-28 18:10:04Z domonoky $ + * + * Copyright (C) 2008 Dominik Wenger + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "codeclib.h" +#include "asap/asap.h" + +CODEC_HEADER + +#define CHUNK_SIZE (1024*8) + +static byte samples[CHUNK_SIZE]; /* The sample buffer */ +static ASAP_State asap; /* asap codec state */ + +/* this is the codec entry point */ +enum codec_status codec_main(void) +{ + int n_bytes; + int song; + int duration; + char* module; + + /* Generic codec initialisation */ + ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); + +next_track: + if (codec_init()) { + DEBUGF("codec init failed\n"); + return CODEC_ERROR; + } + + while (!*ci->taginfo_ready && !ci->stop_codec) + ci->sleep(1); + + codec_set_replaygain(ci->id3); + + int bytes_done =0; + int filesize; + ci->seek_buffer(0); + module = ci->request_buffer(&filesize, ci->filesize); + if (!module || (size_t)filesize < (size_t)ci->filesize) + { + DEBUGF("loading error\n"); + return CODEC_ERROR; + } + + /*Init ASAP */ + if (!ASAP_Load(&asap, ci->id3->path, module, filesize)) + { + DEBUGF("%s: format not supported",ci->id3->path); + return CODEC_ERROR; + } + + /* Make use of 44.1khz */ + ci->configure(DSP_SET_FREQUENCY, 44100); + /* Sample depth is 16 bit little endian */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + /* Stereo or Mono output ? */ + if(asap.module_info.channels ==1) + ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + else + ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); + + /* reset eleapsed */ + ci->set_elapsed(0); + + song = asap.module_info.default_song; + duration = asap.module_info.durations[song]; + if (duration < 0) + duration = 180 * 1000; + + ASAP_PlaySong(&asap, song, duration); + ASAP_MutePokeyChannels(&asap, 0); + + /* The main decoder loop */ + while (1) { + ci->yield(); + if (ci->stop_codec || ci->new_track) + break; + + if (ci->seek_time) { + /* New time is ready in ci->seek_time */ + + /* seek to pos */ + ASAP_Seek(&asap,ci->seek_time); + /* update elapsed */ + ci->set_elapsed(ci->seek_time); + /* update bytes_done */ + bytes_done = ci->seek_time*44.1*2; + /* seek ready */ + ci->seek_complete(); + } + + /* Generate a buffer full of Audio */ + #ifdef ROCKBOX_LITTLE_ENDIAN + n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_LE); + #else + n_bytes = ASAP_Generate(&asap, samples, sizeof(samples), ASAP_FORMAT_S16_BE); + #endif + + ci->pcmbuf_insert(samples, NULL, n_bytes /2); + + bytes_done += n_bytes; + ci->set_elapsed((bytes_done / 2) / 44.1); + + if(n_bytes != sizeof(samples)) + break; + } + + if (ci->request_next_track()) + goto next_track; + + return CODEC_OK; +} diff --git a/apps/codecs/asap/README.rockbox b/apps/codecs/asap/README.rockbox new file mode 100644 index 0000000..322c130 --- /dev/null +++ b/apps/codecs/asap/README.rockbox @@ -0,0 +1,25 @@ +Library: asap-1.2.0 +Imported: 2008-26-07 by Dominik Wenger + +This directory contains a local version of asap (http://asap.sourceforge.net/) for decoding Atari 8bit .sap +audio streams. + +LICENSING INFORMATION + +Asap is available under the terms of the GPL v2 or later +license, which is both an open source and free software license. +The Licence is the same as the rest of Rockbox. + + +IMPORT DETAILS + +The .[ch] files in apps/codec/asap are copied from ASAP. +Some #defines were added, so it uses the ci-> Pointer. + +A small modification was needed in asap.h Line 120. +(changed the delta buffer to signed char) + +Also players.h (contains binarys of players) was generated and copied +into Rockbox. + + diff --git a/apps/codecs/asap/SOURCES b/apps/codecs/asap/SOURCES new file mode 100644 index 0000000..0d1f1f4 --- /dev/null +++ b/apps/codecs/asap/SOURCES @@ -0,0 +1,3 @@ +acpu.c +asap.c +apokeysnd.c diff --git a/apps/codecs/asap/apokeysnd.c b/apps/codecs/asap/apokeysnd.c index d0a4b1b..1d48bc2 100644 --- a/apps/codecs/asap/apokeysnd.c +++ b/apps/codecs/asap/apokeysnd.c @@ -20,13 +20,14 @@ * along with ASAP; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "codeclib.h" #if !defined(JAVA) && !defined(CSHARP) #include <string.h> #endif #include "asap_internal.h" +#define memset ci->memset #define ULTRASOUND_CYCLES 112 #define MUTE_FREQUENCY 1 diff --git a/apps/codecs/asap/asap.c b/apps/codecs/asap/asap.c index 084708a..31de730 100644 --- a/apps/codecs/asap/asap.c +++ b/apps/codecs/asap/asap.c @@ -20,7 +20,7 @@ * along with ASAP; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "codeclib.h" #if !defined(JAVA) && !defined(CSHARP) #include <string.h> #endif @@ -30,6 +30,14 @@ #include "players.h" #endif +#define memcpy ci->memcpy +#define memcmp ci->memcmp +#define memset ci->memset +#define strcpy ci->strcpy +#define strcmp ci->strcmp +#define strstr ci->strcasestr + + #define CMR_BASS_TABLE_OFFSET 0x70f CONST_LOOKUP(byte, cmr_bass_table) = { @@ -1012,7 +1020,7 @@ FILE_FUNC abool parse_sap_header(ASAP_ModuleInfo PTR module_info, i = 0; while (module[module_index] != 0x0d) { line[i++] = (char) module[module_index++]; - if (module_index >= module_len || i >= sizeof(line) - 1) + if (module_index >= module_len || (unsigned)i >= sizeof(line) - 1) return FALSE; } if (++module_index >= module_len || module[module_index++] != 0x0a) @@ -1719,6 +1727,7 @@ int ASAP_SetModuleInfo(const ASAP_ModuleInfo *module_info, const byte ARRAY modu const char *ASAP_CanConvert(const char *filename, const ASAP_ModuleInfo *module_info, const byte ARRAY module, int module_len) { + (void)filename; switch (module_info->type) { case 'B': if (module_info->init == 0x4f3 || module_info->init == 0xf4f3 || module_info->init == 0x4ef) @@ -1755,6 +1764,7 @@ const char *ASAP_CanConvert(const char *filename, const ASAP_ModuleInfo *module_ int ASAP_Convert(const char *filename, const ASAP_ModuleInfo *module_info, const byte ARRAY module, int module_len, byte ARRAY out_module) { + (void) filename; int out_len; byte *dest; int addr; diff --git a/apps/codecs/asap/asap.h b/apps/codecs/asap/asap.h index 194d416..783d628 100644 --- a/apps/codecs/asap/asap.h +++ b/apps/codecs/asap/asap.h @@ -117,7 +117,7 @@ typedef struct { int delta3; int delta4; int skctl; - char delta_buffer[888]; + signed char delta_buffer[888]; } PokeyState; /* Player state. |