From 1c56afad5d7647eb737491a41a4e63472bd3881d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 29 Jun 2005 13:46:51 +0000 Subject: removed old codec leftovers git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6919 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/SOURCES | 9 -- apps/plugins/a52towav.c | 217 ------------------------------------- apps/plugins/flac2wav.c | 237 ---------------------------------------- apps/plugins/lib/SOURCES | 5 - apps/plugins/midi2wav.c | 232 --------------------------------------- apps/plugins/mpa2wav.c | 269 ---------------------------------------------- apps/plugins/mpc2wav.c | 208 ----------------------------------- apps/plugins/vorbis2wav.c | 180 ------------------------------- apps/plugins/wv2wav.c | 217 ------------------------------------- 9 files changed, 1574 deletions(-) delete mode 100644 apps/plugins/a52towav.c delete mode 100644 apps/plugins/flac2wav.c delete mode 100644 apps/plugins/midi2wav.c delete mode 100644 apps/plugins/mpa2wav.c delete mode 100644 apps/plugins/mpc2wav.c delete mode 100644 apps/plugins/vorbis2wav.c delete mode 100644 apps/plugins/wv2wav.c diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 933625aac2..76d26e7e59 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -67,15 +67,6 @@ alpine_cdc.c #endif #if CONFIG_HWCODEC == MASNONE /* software codec platforms */ -#if 0 -mpa2wav.c -a52towav.c -flac2wav.c -vorbis2wav.c -wv2wav.c -mpc2wav.c -midi2wav.c -#endif iriverify.c #else splitedit.c diff --git a/apps/plugins/a52towav.c b/apps/plugins/a52towav.c deleted file mode 100644 index f6769abd2b..0000000000 --- a/apps/plugins/a52towav.c +++ /dev/null @@ -1,217 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * 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. - * - ****************************************************************************/ - -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include /* Needed by a52.h */ - -#include -#include - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ - -static struct plugin_api* rb; - -#ifdef WORDS_BIGENDIAN -#define LE_S16(x) ( (uint16_t) ( ((uint16_t)(x) >> 8) | ((uint16_t)(x) << 8) ) ) -#else -#define LE_S16(x) (x) -#endif - - -static float gain = 1; -static a52_state_t * state; - -static inline int16_t convert (int32_t i) -{ - i >>= 15; - return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i); -} - -void ao_play(file_info_struct* file_info,sample_t* samples,int flags) { - int i; - static int16_t int16_samples[256*2]; - - flags &= A52_CHANNEL_MASK | A52_LFE; - - if (flags==A52_STEREO) { - for (i = 0; i < 256; i++) { - int16_samples[2*i] = LE_S16(convert (samples[i])); - int16_samples[2*i+1] = LE_S16(convert (samples[i+256])); - } - } else { - DEBUGF("ERROR: unsupported format: %d\n",flags); - } - - /* FIX: Buffer the disk write to write larger amounts at one */ - i=rb->write(file_info->outfile,int16_samples,256*2*2); -} - - -void a52_decode_data (file_info_struct* file_info, uint8_t * start, uint8_t * end) -{ - static uint8_t buf[3840]; - static uint8_t * bufptr = buf; - static uint8_t * bufpos = buf + 7; - - /* - * sample_rate and flags are static because this routine could - * exit between the a52_syncinfo() and the ao_setup(), and we want - * to have the same values when we get back ! - */ - - static int sample_rate; - static int flags; - int bit_rate; - int len; - - while (1) { - len = end - start; - if (!len) - break; - if (len > bufpos - bufptr) - len = bufpos - bufptr; - memcpy (bufptr, start, len); - bufptr += len; - start += len; - if (bufptr == bufpos) { - if (bufpos == buf + 7) { - int length; - - length = a52_syncinfo (buf, &flags, &sample_rate, &bit_rate); - if (!length) { - DEBUGF("skip\n"); - for (bufptr = buf; bufptr < buf + 6; bufptr++) - bufptr[0] = bufptr[1]; - continue; - } - bufpos = buf + length; - } else { - // The following two defaults are taken from audio_out_oss.c: - level_t level; - sample_t bias; - int i; - - /* This is the configuration for the downmixing: */ - flags=A52_STEREO|A52_ADJUST_LEVEL|A52_LFE; - level=(1 << 26); - bias=0; - - level = (level_t) (level * gain); - - if (a52_frame (state, buf, &flags, &level, bias)) - goto error; - file_info->frames_decoded++; - - /* We assume this never changes */ - file_info->samplerate=sample_rate; - - // An A52 frame consists of 6 blocks of 256 samples - // So we decode and output them one block at a time - for (i = 0; i < 6; i++) { - if (a52_block (state)) { - goto error; - } - ao_play (file_info, a52_samples (state),flags); - file_info->current_sample+=256; - } - bufptr = buf; - bufpos = buf + 7; - continue; - error: - DEBUGF("error\n"); - bufptr = buf; - bufpos = buf + 7; - } - } - } -} - - -#define BUFFER_SIZE 4096 - -#ifdef USE_IRAM -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - file_info_struct file_info; - - /* Generic plugin initialisation */ - - TEST_PLUGIN_API(api); - rb = api; - -#ifdef USE_IRAM - rb->memcpy(iramstart, iramcopy, iramend-iramstart); -#endif - - /* This function sets up the buffers and reads the file into RAM */ - - if (local_init(file,"/ac3test.wav",&file_info,api)) { - return PLUGIN_ERROR; - } - - /* Intialise the A52 decoder and check for success */ - state = a52_init (0); // Parameter is "accel" - - if (state == NULL) { - rb->splash(HZ*2, true, "a52_init failed"); - return PLUGIN_ERROR; - } - - /* The main decoding loop */ - - file_info.start_tick=*(rb->current_tick); - rb->button_clear_queue(); - - while (file_info.curpos < file_info.filesize) { - - if ((file_info.curpos+BUFFER_SIZE) < file_info.filesize) { - a52_decode_data(&file_info,&filebuf[file_info.curpos],&filebuf[file_info.curpos+BUFFER_SIZE]); - file_info.curpos+=BUFFER_SIZE; - } else { - a52_decode_data(&file_info,&filebuf[file_info.curpos],&filebuf[file_info.filesize-1]); - file_info.curpos=file_info.filesize; - } - - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) { - close_wav(&file_info); - return PLUGIN_OK; - } - } - close_wav(&file_info); - - /* Cleanly close and exit */ - -//NOT NEEDED: a52_free (state); - - rb->splash(HZ*2, true, "FINISHED!"); - return PLUGIN_OK; -} -#endif /* CONFIG_HWCODEC == MASNONE */ diff --git a/apps/plugins/flac2wav.c b/apps/plugins/flac2wav.c deleted file mode 100644 index 84b5ed15b2..0000000000 --- a/apps/plugins/flac2wav.c +++ /dev/null @@ -1,237 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 Björn 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. - * - ****************************************************************************/ - -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ - -#define FLAC_MAX_SUPPORTED_BLOCKSIZE 4608 -#define FLAC_MAX_SUPPORTED_CHANNELS 2 - -static struct plugin_api* rb; - -/* Called when the FLAC decoder needs some FLAC data to decode */ -FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStreamDecoder *dec, - FLAC__byte buffer[], unsigned *bytes, void *data) -{ (void)dec; - - file_info_struct *p = (file_info_struct *) data; - - if (p->curpos >= p->filesize) { - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - - rb->memcpy(buffer,&filebuf[p->curpos],*bytes); - p->curpos+=*bytes; - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; -} - -/* Called when the FLAC decoder has some decoded PCM data to write */ -FLAC__StreamDecoderWriteStatus flac_write_handler(const FLAC__SeekableStreamDecoder *dec, - const FLAC__Frame *frame, - const FLAC__int32 * const buf[], - void *data) -{ - unsigned int c_samp, c_chan, d_samp; - file_info_struct *p = (file_info_struct *) data; - uint32_t data_size = frame->header.blocksize * frame->header.channels * (p->bitspersample / 8); - uint32_t samples = frame->header.blocksize; - - // FIXME: This should not be on the stack! - static unsigned char ldb[FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS*2]; - - if (samples*frame->header.channels > (FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS)) { - // ERROR!!! - DEBUGF("ERROR: samples*frame->header.channels=%d\n",samples*frame->header.channels); - return(FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE); - } - - (void)dec; - (void)data_size; - for(c_samp = d_samp = 0; c_samp < samples; c_samp++) { - for(c_chan = 0; c_chan < frame->header.channels; c_chan++, d_samp++) { - ldb[d_samp*2] = buf[c_chan][c_samp]&0xff; - ldb[(d_samp*2)+1] = (buf[c_chan][c_samp]&0xff00)>>8; - } - } - - rb->write(p->outfile,ldb,data_size); - - p->current_sample += samples; - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -void flac_metadata_handler(const FLAC__SeekableStreamDecoder *dec, - const FLAC__StreamMetadata *meta, void *data) -{ - file_info_struct *p = (file_info_struct *) data; - (void)dec; - - if(meta->type == FLAC__METADATA_TYPE_STREAMINFO) { - p->bitspersample = meta->data.stream_info.bits_per_sample; - p->samplerate = meta->data.stream_info.sample_rate; - p->channels = meta->data.stream_info.channels; -// FLAC__ASSERT(meta->data.stream_info.total_samples < 0x100000000); /* we can handle < 4 gigasamples */ - p->total_samples = (unsigned) - (meta->data.stream_info.total_samples & 0xffffffff); - p->current_sample = 0; - } -} - - -void flac_error_handler(const FLAC__SeekableStreamDecoder *dec, - FLAC__StreamDecoderErrorStatus status, void *data) -{ - (void)dec; - (void)status; - (void)data; -} - -FLAC__SeekableStreamDecoderSeekStatus flac_seek_handler (const FLAC__SeekableStreamDecoder *decoder, - FLAC__uint64 absolute_byte_offset, - void *client_data) -{ - (void)decoder; - file_info_struct *p = (file_info_struct *) client_data; - rb->lseek(p->infile,SEEK_SET,absolute_byte_offset); - return(FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK); -} - -FLAC__SeekableStreamDecoderTellStatus flac_tell_handler (const FLAC__SeekableStreamDecoder *decoder, - FLAC__uint64 *absolute_byte_offset, void *client_data) -{ - file_info_struct *p = (file_info_struct *) client_data; - - (void)decoder; - *absolute_byte_offset=rb->lseek(p->infile,SEEK_CUR,0); - return(FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK); -} - -FLAC__SeekableStreamDecoderLengthStatus flac_length_handler (const FLAC__SeekableStreamDecoder *decoder, - FLAC__uint64 *stream_length, void *client_data) -{ - file_info_struct *p = (file_info_struct *) client_data; - - (void)decoder; - *stream_length=p->filesize; - return(FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK); -} - -FLAC__bool flac_eof_handler (const FLAC__SeekableStreamDecoder *decoder, - void *client_data) -{ - file_info_struct *p = (file_info_struct *) client_data; - - (void)decoder; - if (p->curpos >= p->filesize) { - return(true); - } else { - return(false); - } -} - -#ifndef SIMULATOR -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - FLAC__SeekableStreamDecoder* flacDecoder; - file_info_struct file_info; - - TEST_PLUGIN_API(api); - - /* if you are using a global api pointer, don't forget to copy it! - otherwise you will get lovely "I04: IllInstr" errors... :-) */ - rb = api; - -#ifndef SIMULATOR - rb->memcpy(iramstart, iramcopy, iramend-iramstart); -#endif - - /* This function sets up the buffers and reads the file into RAM */ - - if (local_init(file,"/flactest.wav",&file_info,api)) { - return PLUGIN_ERROR; - } - - /* Create a decoder instance */ - - flacDecoder=FLAC__seekable_stream_decoder_new(); - - /* Set up the decoder and the callback functions - this must be done before init */ - - /* The following are required for stream_decoder and higher */ - FLAC__seekable_stream_decoder_set_client_data(flacDecoder,&file_info); - FLAC__seekable_stream_decoder_set_write_callback(flacDecoder, flac_write_handler); - FLAC__seekable_stream_decoder_set_read_callback(flacDecoder, flac_read_handler); - FLAC__seekable_stream_decoder_set_metadata_callback(flacDecoder, flac_metadata_handler); - FLAC__seekable_stream_decoder_set_error_callback(flacDecoder, flac_error_handler); - FLAC__seekable_stream_decoder_set_metadata_respond(flacDecoder, FLAC__METADATA_TYPE_STREAMINFO); - - /* The following are only for the seekable_stream_decoder */ - FLAC__seekable_stream_decoder_set_seek_callback(flacDecoder, flac_seek_handler); - FLAC__seekable_stream_decoder_set_tell_callback(flacDecoder, flac_tell_handler); - FLAC__seekable_stream_decoder_set_length_callback(flacDecoder, flac_length_handler); - FLAC__seekable_stream_decoder_set_eof_callback(flacDecoder, flac_eof_handler); - - if (FLAC__seekable_stream_decoder_init(flacDecoder)) { - return PLUGIN_ERROR; - } - - /* The first thing to do is to parse the metadata */ - FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDecoder); - - file_info.frames_decoded=0; - file_info.start_tick=*(rb->current_tick); - rb->button_clear_queue(); - - while (FLAC__seekable_stream_decoder_get_state(flacDecoder)!=2) { - FLAC__seekable_stream_decoder_process_single(flacDecoder); - file_info.frames_decoded++; - - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) { - close_wav(&file_info); - return PLUGIN_OK; - } - } - - close_wav(&file_info); - rb->splash(HZ*2, true, "FINISHED!"); - - /* Flush internal buffers etc */ -//No need for this. flacResult=FLAC__seekable_stream_decoder_reset(flacDecoder); - - // audio_close(); - - return PLUGIN_OK; -} -#endif /* CONFIG_HWCODEC == MASNONE */ diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 396ed062ac..49abf854da 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -34,8 +34,3 @@ gray_verline.c #ifdef HAVE_LCD_CHARCELLS playergfx.c #endif -#if 0 -#if CONFIG_HWCODEC == MASNONE /* software codec platforms */ -xxx2wav.c -#endif -#endif diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c deleted file mode 100644 index 241d56defb..0000000000 --- a/apps/plugins/midi2wav.c +++ /dev/null @@ -1,232 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2005 Stepan Moskovchenko - * - * 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. - * - ****************************************************************************/ - -#define SAMPLE_RATE 22050 -#define MAX_VOICES 100 - - -/* Only define LOCAL_DSP on Simulator or else we're asking for trouble */ -#if defined(SIMULATOR) - /*Enable this to write to the soundcard via a /dsv/dsp symlink in */ -// #define LOCAL_DSP -#endif - - -#if defined(LOCAL_DSP) -/* This is for writing to the DSP directly from the Simulator */ -#include -#include -#include -#include -#endif - -#include "../../firmware/export/system.h" - -#include "../../plugin.h" - -#include "lib/xxx2wav.h" - -int numberOfSamples IDATA_ATTR; -long bpm; - -#include "midi/midiutil.c" -#include "midi/guspat.h" -#include "midi/guspat.c" -#include "midi/sequencer.c" -#include "midi/midifile.c" -#include "midi/synth.c" - - - - -int fd=-1; /* File descriptor where the output is written */ - -extern long tempo; /* The sequencer keeps track of this */ - - -struct plugin_api * rb; - - - - - -enum plugin_status plugin_start(struct plugin_api* api, void* parameter) -{ - TEST_PLUGIN_API(api); - rb = api; - TEST_PLUGIN_API(api); - (void)parameter; - rb = api; - - if(parameter == NULL) - { - rb->splash(HZ*2, true, " Play .MID file "); - return PLUGIN_OK; - } - - rb->splash(HZ, true, parameter); - if(midimain(parameter) == -1) - { - return PLUGIN_ERROR; - } - rb->splash(HZ*3, true, "FINISHED PLAYING"); - return PLUGIN_OK; -} - -signed char outputBuffer[3000] IDATA_ATTR; /* signed char.. gonna run out of iram ... ! */ - - -int currentSample IDATA_ATTR; -int outputBufferPosition IDATA_ATTR; -int outputSampleOne IDATA_ATTR; -int outputSampleTwo IDATA_ATTR; - - -int midimain(void * filename) -{ - - printf("\nHello.\n"); - - rb->splash(HZ/5, true, "LOADING MIDI"); - - struct MIDIfile * mf = loadFile(filename); - - rb->splash(HZ/5, true, "LOADING PATCHES"); - if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) - { - return -1; - } - -/* - * This lets you hear the music through the sound card if you are on Simulator - * Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever - * your sound device is. - */ - -#if defined(LOCAL_DSP) - fd=rb->open("/dsp.raw", O_WRONLY); - int arg, status; - int bit, samp, ch; - - arg = 16; /* sample size */ - status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg); - status = ioctl(fd, SOUND_PCM_READ_BITS, &arg); - bit=arg; - - - arg = 2; /* Number of channels, 1=mono */ - status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg); - status = ioctl(fd, SOUND_PCM_READ_CHANNELS, &arg); - ch=arg; - - arg = SAMPLE_RATE; /* Yeah. sampling rate */ - status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); - status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); - samp=arg; -#else - file_info_struct file_info; - file_info.samplerate = SAMPLE_RATE; - file_info.infile = fd; - file_info.channels = 2; - file_info.bitspersample = 16; - local_init("/miditest.tmp", "/miditest.wav", &file_info, rb); - fd = file_info.outfile; -#endif - - - rb->splash(HZ/5, true, " I hope this works... "); - - - - - /* - * tick() will do one MIDI clock tick. Then, there's a loop here that - * will generate the right number of samples per MIDI tick. The whole - * MIDI playback is timed in terms of this value.. there are no forced - * delays or anything. It just produces enough samples for each tick, and - * the playback of these samples is what makes the timings right. - * - * This seems to work quite well. - */ - - printf("\nOkay, starting sequencing"); - - - currentSample=0; /* Sample counting variable */ - outputBufferPosition = 0; - - - bpm=mf->div*1000000/tempo; - numberOfSamples=SAMPLE_RATE/bpm; - - - - /* Tick() will return 0 if there are no more events left to play */ - while(tick(mf)) - { - /* - * Tempo recalculation moved to sequencer.c to be done on a tempo event only - * - */ - for(currentSample=0; currentSample>8; //High byte second - outputBufferPosition++; - - outputBuffer[outputBufferPosition]=outputSampleTwo&0XFF; // Low byte first - outputBufferPosition++; - outputBuffer[outputBufferPosition]=outputSampleTwo>>8; //High byte second - outputBufferPosition++; - - - /* - * As soon as we produce 2000 bytes of sound, - * write it to the sound card. Why 2000? I have - * no idea. It's 1 AM and I am dead tired. - */ - if(outputBufferPosition>=2000) - { - rb->write(fd, outputBuffer, 2000); - outputBufferPosition=0; - } - } - } - - printf("\n"); - -#if !defined(LOCAL_DSP) - - close_wav(&file_info); -#else - rb->close(fd); -#endif - return 0; -} diff --git a/apps/plugins/mpa2wav.c b/apps/plugins/mpa2wav.c deleted file mode 100644 index bf40fa3b81..0000000000 --- a/apps/plugins/mpa2wav.c +++ /dev/null @@ -1,269 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Dave Chapman - * - * 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. - * - ****************************************************************************/ - -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ - -static struct plugin_api* rb; - -struct mad_stream Stream IDATA_ATTR; -struct mad_frame Frame IDATA_ATTR; -struct mad_synth Synth IDATA_ATTR; -mad_timer_t Timer; -struct dither d0, d1; - -/* The following function is used inside libmad - let's hope it's never - called. -*/ - -void abort(void) { -} - -/* The "dither" code to convert the 24-bit samples produced by libmad was - taken from the coolplayer project - coolplayer.sourceforge.net */ - -struct dither { - mad_fixed_t error[3]; - mad_fixed_t random; -}; - -# define SAMPLE_DEPTH 16 -# define scale(x, y) dither((x), (y)) - -/* - * NAME: prng() - * DESCRIPTION: 32-bit pseudo-random number generator - */ -static __inline -unsigned long prng(unsigned long state) -{ - return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL; -} - -/* - * NAME: dither() - * DESCRIPTION: dither and scale sample - */ -static __inline -signed int dither(mad_fixed_t sample, struct dither *dither) -{ - unsigned int scalebits; - mad_fixed_t output, mask, random; - - enum { - MIN = -MAD_F_ONE, - MAX = MAD_F_ONE - 1 - }; - - /* noise shape */ - sample += dither->error[0] - dither->error[1] + dither->error[2]; - - dither->error[2] = dither->error[1]; - dither->error[1] = dither->error[0] / 2; - - /* bias */ - output = sample + (1L << (MAD_F_FRACBITS + 1 - SAMPLE_DEPTH - 1)); - - scalebits = MAD_F_FRACBITS + 1 - SAMPLE_DEPTH; - mask = (1L << scalebits) - 1; - - /* dither */ - random = prng(dither->random); - output += (random & mask) - (dither->random & mask); - - dither->random = random; - - /* clip */ - if (output > MAX) { - output = MAX; - - if (sample > MAX) - sample = MAX; - } - else if (output < MIN) { - output = MIN; - - if (sample < MIN) - sample = MIN; - } - - /* quantize */ - output &= ~mask; - - /* error feedback */ - dither->error[0] = sample - output; - - /* scale */ - return output >> scalebits; -} - -#define SHRT_MAX 32767 - -#define INPUT_BUFFER_SIZE (10*8192) -#define OUTPUT_BUFFER_SIZE 65536 /* Must be an integer multiple of 4. */ - -unsigned char InputBuffer[INPUT_BUFFER_SIZE+MAD_BUFFER_GUARD]; -unsigned char OutputBuffer[OUTPUT_BUFFER_SIZE]; -unsigned char *OutputPtr=OutputBuffer; -unsigned char *GuardPtr=NULL; -const unsigned char *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE; - -mad_fixed_t mad_frame_overlap[2][32][18] IDATA_ATTR; -unsigned char mad_main_data[MAD_BUFFER_MDLEN] IDATA_ATTR; - -#ifdef USE_IRAM -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - file_info_struct file_info; - int Status=0; - unsigned short Sample; - int i; - - /* Generic plugin inititialisation */ - - TEST_PLUGIN_API(api); - rb = api; - -#ifdef USE_IRAM - rb->memcpy(iramstart, iramcopy, iramend-iramstart); -#endif - - /* This function sets up the buffers and reads the file into RAM */ - - if (local_init(file,"/libmadtest.wav",&file_info,api)) { - return PLUGIN_ERROR; - } - - /* Create a decoder instance */ - - mad_stream_init(&Stream); - mad_frame_init(&Frame); - mad_synth_init(&Synth); - mad_timer_reset(&Timer); - - /* We do this so libmad doesn't try to call codec_calloc() */ - memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap)); - Frame.overlap = &mad_frame_overlap; - Stream.main_data = &mad_main_data; - - GuardPtr = &filebuf[file_info.filesize]; - memset(GuardPtr,0,MAD_BUFFER_GUARD); - mad_stream_buffer(&Stream, filebuf,file_info.filesize); - - file_info.curpos=0; - file_info.start_tick=*(rb->current_tick); - - rb->button_clear_queue(); - - /* This is the decoding loop. */ - while (file_info.curpos < file_info.filesize && - Stream.this_frame != GuardPtr && - Stream.error != MAD_ERROR_BUFLEN) { - file_info.curpos += (int)Stream.next_frame - (int)Stream.this_frame; - - if(mad_frame_decode(&Frame,&Stream)) - { - if(MAD_RECOVERABLE(Stream.error)) - { - if(Stream.error!=MAD_ERROR_LOSTSYNC || Stream.this_frame!=GuardPtr) - { - rb->splash(HZ*1, true, "Recoverable...!"); - } - continue; - } - else - if(Stream.error==MAD_ERROR_BUFLEN) - continue; - else - { - rb->splash(HZ*1, true, "Recoverable...!"); - //fprintf(stderr,"%s: unrecoverable frame level error.\n",ProgName); - Status=1; - break; - } - } - - /* We assume all frames have same samplerate as the first */ - if(file_info.frames_decoded==0) { - file_info.samplerate=Frame.header.samplerate; - } - - file_info.frames_decoded++; - - /* ?? Do we need the timer module? */ - mad_timer_add(&Timer,Frame.header.duration); - -/* DAVE: This can be used to attenuate the audio */ -// if(DoFilter) -// ApplyFilter(&Frame); - - mad_synth_frame(&Synth,&Frame); - - /* Convert MAD's numbers to an array of 16-bit LE signed integers */ - for(i=0;i>8; - - /* Right channel. If the decoded stream is monophonic then - * the right output channel is the same as the left one. - */ - if(MAD_NCHANNELS(&Frame.header)==2) - Sample=scale(Synth.pcm.samples[1][i],&d1); - *(OutputPtr++)=Sample&0xff; - *(OutputPtr++)=Sample>>8; - - /* Flush the buffer if it is full. */ - if(OutputPtr==OutputBufferEnd) - { - rb->write(file_info.outfile,OutputBuffer,OUTPUT_BUFFER_SIZE); - OutputPtr=OutputBuffer; - } - } - - file_info.current_sample+=Synth.pcm.length; - - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) { - close_wav(&file_info); - return PLUGIN_OK; - } - } - - close_wav(&file_info); - rb->splash(HZ*2, true, "FINISHED!"); - - return PLUGIN_OK; -} -#endif /* CONFIG_HWCODEC == MASNONE */ diff --git a/apps/plugins/mpc2wav.c b/apps/plugins/mpc2wav.c deleted file mode 100644 index b1478bac31..0000000000 --- a/apps/plugins/mpc2wav.c +++ /dev/null @@ -1,208 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Thom Johansen - * - * 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. - * - ****************************************************************************/ - -/* This is a lovely mishmash of sample.c from libmusepack and mpa2wav.c, - * but happens to work, so no whining! - */ - -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ - -static struct plugin_api* rb; -mpc_decoder decoder; - -/* - Our implementations of the mpc_reader callback functions. -*/ -mpc_int32_t -read_impl(void *data, void *ptr, mpc_int32_t size) -{ - file_info_struct *f = (file_info_struct *)data; - mpc_int32_t num = f->filesize - f->curpos; - if (num > size) - num = size; - rb->memcpy(ptr, filebuf + f->curpos, num); - f->curpos += num; - return num; -} - -bool -seek_impl(void *data, mpc_int32_t offset) -{ - file_info_struct *f = (file_info_struct *)data; - if (offset > f->filesize) { - return 0; - } else { - f->curpos = offset; - return 1; - } -} - -mpc_int32_t -tell_impl(void *data) -{ - file_info_struct *f = (file_info_struct *)data; - return f->curpos; -} - -mpc_int32_t -get_size_impl(void *data) -{ - file_info_struct *f = (file_info_struct *)data; - return f->filesize; -} - -bool -canseek_impl(void *data) -{ - (void)data; - return true; -} - -static int -shift_signed(MPC_SAMPLE_FORMAT val, int shift) -{ - if (shift > 0) - val <<= shift; - else if (shift < 0) - val >>= -shift; - return (int)val; -} - -#define OUTPUT_BUFFER_SIZE 65536 /* Must be an integer multiple of 4. */ - -unsigned char OutputBuffer[OUTPUT_BUFFER_SIZE]; -MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; -unsigned char *OutputPtr=OutputBuffer; -const unsigned char *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE; - -#ifdef USE_IRAM -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - file_info_struct file_info; - unsigned short Sample; - unsigned status = 1; - unsigned int i; - mpc_reader reader; - - /* Generic plugin inititialisation */ - - TEST_PLUGIN_API(api); - rb = api; - -#ifdef USE_IRAM - rb->memcpy(iramstart, iramcopy, iramend-iramstart); -#endif - - reader.read = read_impl; - reader.seek = seek_impl; - reader.tell = tell_impl; - reader.get_size = get_size_impl; - reader.canseek = canseek_impl; - reader.data = &file_info; - - /* This function sets up the buffers and reads the file into RAM */ - - if (local_init(file, "/libmusepacktest.wav", &file_info, api)) { - return PLUGIN_ERROR; - } - - /* read file's streaminfo data */ - mpc_streaminfo info; - mpc_streaminfo_init(&info); - if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { - rb->splash(HZ, true, "Not an MPC file."); - return PLUGIN_ERROR; - } - file_info.samplerate=info.sample_freq; - /* instantiate a decoder with our file reader */ - mpc_decoder_setup(&decoder, &reader); - if (!mpc_decoder_initialize(&decoder, &info)) { - rb->splash(HZ, true, "Error in init."); - return PLUGIN_ERROR; - } - file_info.frames_decoded = 0; - file_info.start_tick = *(rb->current_tick); - - rb->button_clear_queue(); - - /* This is the decoding loop. */ - while (status != 0) { - status = mpc_decoder_decode(&decoder, sample_buffer, 0, 0); - if (status == (unsigned)(-1)) { - //decode error - rb->splash(HZ, true, "Error decoding file."); - break; - } - else //status>0 - { - file_info.current_sample += status; - file_info.frames_decoded++; - /* Convert musepack's numbers to an array of 16-bit LE signed integers */ -#if 1 /* uncomment to time without byte swapping and disk writing */ - for(i = 0; i < status*info.channels; i += info.channels) - { - /* Left channel */ - Sample=shift_signed(sample_buffer[i], 16 - MPC_FIXED_POINT_SCALE_SHIFT); - *(OutputPtr++)=Sample&0xff; - *(OutputPtr++)=Sample>>8; - - /* Right channel. If the decoded stream is monophonic then - * the right output channel is the same as the left one. - */ - if(info.channels==2) - Sample=shift_signed(sample_buffer[i + 1], 16 - MPC_FIXED_POINT_SCALE_SHIFT); - *(OutputPtr++)=Sample&0xff; - *(OutputPtr++)=Sample>>8; - - /* Flush the buffer if it is full. */ - if(OutputPtr==OutputBufferEnd) - { - rb->write(file_info.outfile,OutputBuffer,OUTPUT_BUFFER_SIZE); - OutputPtr=OutputBuffer; - } - } -#endif - - } - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) { - close_wav(&file_info); - return PLUGIN_OK; - } - } - close_wav(&file_info); - rb->splash(HZ*2, true, "FINISHED!"); - - return PLUGIN_OK; -} -#endif /* CONFIG_HWCODEC == MASNONE */ diff --git a/apps/plugins/vorbis2wav.c b/apps/plugins/vorbis2wav.c deleted file mode 100644 index 01815ab1ca..0000000000 --- a/apps/plugins/vorbis2wav.c +++ /dev/null @@ -1,180 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 Björn 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. - * - ****************************************************************************/ -#include "kernel.h" -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ - -static struct plugin_api* rb; - -/* Some standard functions and variables needed by Tremor */ - - -int errno; - -size_t strlen(const char *s) { - return(rb->strlen(s)); -} - -char *strcpy(char *dest, const char *src) { - return(rb->strcpy(dest,src)); -} - -char *strcat(char *dest, const char *src) { - return(rb->strcat(dest,src)); -} - -size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) { - size_t len; - file_info_struct *p = (file_info_struct *) datasource; - - if (p->curpos >= p->filesize) { - return 0; /* EOF */ - } - - len=nmemb*size; - if ((long)(p->curpos+len) > (long)p->filesize) { len=p->filesize-p->curpos; } - - rb->memcpy(ptr,&filebuf[p->curpos],len); - p->curpos+=len; - - return(len); -} - -int seek_handler(void *datasource, ogg_int64_t offset, int whence) { - /* We are not seekable at the moment */ - (void)datasource; - (void)offset; - (void)whence; - return -1; -} - -int close_handler(void *datasource) { - (void)datasource; - return 0; -} - -long tell_handler(void *datasource) { - file_info_struct *p = (file_info_struct *) datasource; - return p->curpos; -} - -#ifdef USE_IRAM -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - - -/* reserve the PCM buffer in the IRAM area */ -static char pcmbuf[4096] IDATA_ATTR; - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - ov_callbacks callbacks; - OggVorbis_File vf; - vorbis_info* vi; - - int error; - long n; - int current_section; - int eof; -#if BYTE_ORDER == BIG_ENDIAN - int i; - char x; -#endif - - file_info_struct file_info; - - TEST_PLUGIN_API(api); - - /* if you are using a global api pointer, don't forget to copy it! - otherwise you will get lovely "I04: IllInstr" errors... :-) */ - rb = api; - - #ifdef USE_IRAM - rb->memcpy(iramstart, iramcopy, iramend-iramstart); - #endif - - /* This function sets up the buffers and reads the file into RAM */ - - if (local_init(file,"/vorbistest.wav",&file_info,api)) { - return PLUGIN_ERROR; - } - - - /* Create a decoder instance */ - - callbacks.read_func=read_handler; - callbacks.seek_func=seek_handler; - callbacks.tell_func=tell_handler; - callbacks.close_func=close_handler; - - file_info.frames_decoded=0; - file_info.start_tick=*(rb->current_tick); - rb->button_clear_queue(); - - error=ov_open_callbacks(&file_info,&vf,NULL,0,callbacks); - - vi=ov_info(&vf,-1); - - if (vi==NULL) { - rb->splash(HZ*2, true, "Error"); - } - file_info.samplerate=vi->rate; - - eof=0; - while (!eof) { - /* Read host-endian signed 16 bit PCM samples */ - n=ov_read(&vf,pcmbuf,sizeof(pcmbuf),¤t_section); - - if (n==0) { - eof=1; - } else if (n < 0) { - DEBUGF("Error decoding frame\n"); - } else { - file_info.frames_decoded++; -#if BYTE_ORDER == BIG_ENDIAN - for (i=0;iwrite(file_info.outfile,pcmbuf,n); - file_info.current_sample+=(n/4); - } - - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) { - close_wav(&file_info); - return PLUGIN_OK; - } - } - - close_wav(&file_info); - rb->splash(HZ*2, true, "FINISHED!"); - return PLUGIN_OK; -} -#endif /* CONFIG_HWCODEC == MASNONE */ diff --git a/apps/plugins/wv2wav.c b/apps/plugins/wv2wav.c deleted file mode 100644 index 909a0c3c63..0000000000 --- a/apps/plugins/wv2wav.c +++ /dev/null @@ -1,217 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Christian Gmeiner - * - * 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. - * - ****************************************************************************/ - -#include "plugin.h" - -#if (CONFIG_HWCODEC == MASNONE) -/* software codec platforms */ - -#include "lib/xxx2wav.h" /* Helper functions common to test decoders */ -#include - -#define BUFFER_SIZE 4096 - -static struct plugin_api* rb; -static file_info_struct file_info; -static long temp_buffer [BUFFER_SIZE] IDATA_ATTR; - -/* Reformat samples from longs in processor's native endian mode to - little-endian data with 2 bytes / sample. */ -uchar* format_samples (int bps, uchar *dst, long *src, ulong samcnt) -{ - long temp; - - switch (bps) - { - case 1: - while (samcnt--) - { - *dst++ = (uchar)(temp = (*src++ << 8)); - *dst++ = (uchar)(temp >> 8); - } - - break; - - case 2: - while (samcnt--) - { - *dst++ = (uchar)(temp = *src++); - *dst++ = (uchar)(temp >> 8); - } - - break; - - case 3: - while (samcnt--) - { - *dst++ = (uchar)(temp = (*src++ >> 8)); - *dst++ = (uchar)(temp >> 8); - } - - break; - - case 4: - while (samcnt--) - { - *dst++ = (uchar)(temp = (*src++ >> 16)); - *dst++ = (uchar)(temp >> 8); - } - - break; - } - - return dst; -} - -/* this is our function to decode a memory block from a file */ -void wvpack_decode_data(file_info_struct* file_info, int samples_to_decode, WavpackContext **wpc) -{ - int bps = WavpackGetBytesPerSample(*wpc); - /* nothing to decode */ - if (!samples_to_decode) - { - return; - } - - /* decode now */ - ulong samples_unpacked = WavpackUnpackSamples(*wpc, temp_buffer, samples_to_decode); - - if (samples_unpacked) - { - /* update some infos */ - file_info->current_sample += samples_unpacked; - - /* for now, convert mono to stereo here, in place */ - if (WavpackGetReducedChannels (*wpc) == 1) { - long *dst = temp_buffer + (samples_unpacked * 2); - long *src = temp_buffer + samples_unpacked; - long count = samples_unpacked; - - while (count--) { - *--dst = *--src; - *--dst = *src; - } - } - - format_samples (bps, (uchar *) temp_buffer, temp_buffer, samples_unpacked * file_info->channels); - rb->write(file_info->outfile, temp_buffer, samples_unpacked * 4); - } -} - -/* callback function for wavpack -Maybe we do this at a lower level, but the -first thing is to get all working */ -long Read(void* buffer, long size) -{ - long oldpos = file_info.curpos; - - if ((file_info.curpos + size) < file_info.filesize) - { - memcpy(buffer, &filebuf[file_info.curpos], size); - file_info.curpos += size; - } - else - { - memcpy(buffer, &filebuf[file_info.curpos], file_info.filesize-file_info.curpos); - file_info.curpos = file_info.filesize; - } - - return (file_info.curpos - oldpos); -} - -#ifdef USE_IRAM -extern char iramcopy[]; -extern char iramstart[]; -extern char iramend[]; -#endif - -/* this is the plugin entry point */ -enum plugin_status plugin_start(struct plugin_api* api, void* file) -{ - WavpackContext *wpc; - char error[80]; - - /* generic plugin initialisation */ - TEST_PLUGIN_API(api); - rb = api; - - #ifdef USE_IRAM - rb->memcpy(iramstart, iramcopy, iramend-iramstart); - #endif - - /* this function sets up the buffers and reads the file into RAM */ - if (local_init(file,"/wvtest.wav",&file_info,api)) - { - return PLUGIN_ERROR; - } - - /* setup wavpack */ - wpc = WavpackOpenFileInput(Read, error); - - /* was there an error? */ - if (!wpc) - { - rb->splash(HZ*2, true, error); - return PLUGIN_ERROR; - } - - /* grap/set some infos (forcing some to temp values) */ - file_info.channels = 2; - file_info.total_samples = WavpackGetNumSamples(wpc); - file_info.bitspersample = 16; - file_info.samplerate = WavpackGetSampleRate(wpc); - file_info.current_sample = 0; - - /* deciding loop */ - file_info.start_tick=*(rb->current_tick); - rb->button_clear_queue(); - - while (file_info.current_sample < file_info.total_samples) - { - wvpack_decode_data(&file_info, BUFFER_SIZE / file_info.channels, &wpc); - - display_status(&file_info); - - if (rb->button_get(false)!=BUTTON_NONE) - { - close_wav(&file_info); - return PLUGIN_OK; - } - } - - close_wav(&file_info); - - /* do some last checks */ - if ((WavpackGetNumSamples (wpc) != (ulong) -1) && (file_info.current_sample != WavpackGetNumSamples (wpc))) - { - rb->splash(HZ*2, true, "incorrect number of samples!"); - return PLUGIN_ERROR; - } - - if (WavpackGetNumErrors (wpc)) { - rb->splash(HZ*2, true, "crc errors detected!"); - return PLUGIN_ERROR; - } - - rb->splash(HZ*2, true, "FINISHED!"); - - return PLUGIN_OK; -} - -#endif /* CONFIG_HWCODEC == MASNONE */ -- cgit v1.2.3