diff options
author | Daniel Stenberg <daniel@haxx.se> | 2005-06-29 13:46:51 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2005-06-29 13:46:51 +0000 |
commit | 1c56afad5d7647eb737491a41a4e63472bd3881d (patch) | |
tree | d46349d6e953906f085ac763c0d0cb9a42b60c7f /apps/plugins | |
parent | fa9cea64b12d21c4b2fc1e91f051bd51142d87ed (diff) | |
download | rockbox-1c56afad5d7647eb737491a41a4e63472bd3881d.tar.gz rockbox-1c56afad5d7647eb737491a41a4e63472bd3881d.zip |
removed old codec leftovers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6919 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/SOURCES | 9 | ||||
-rw-r--r-- | apps/plugins/a52towav.c | 217 | ||||
-rw-r--r-- | apps/plugins/flac2wav.c | 237 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 5 | ||||
-rw-r--r-- | apps/plugins/midi2wav.c | 232 | ||||
-rw-r--r-- | apps/plugins/mpa2wav.c | 269 | ||||
-rw-r--r-- | apps/plugins/mpc2wav.c | 208 | ||||
-rw-r--r-- | apps/plugins/vorbis2wav.c | 180 | ||||
-rw-r--r-- | apps/plugins/wv2wav.c | 217 |
9 files changed, 0 insertions, 1574 deletions
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 | |||
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #if CONFIG_HWCODEC == MASNONE /* software codec platforms */ | 69 | #if CONFIG_HWCODEC == MASNONE /* software codec platforms */ |
70 | #if 0 | ||
71 | mpa2wav.c | ||
72 | a52towav.c | ||
73 | flac2wav.c | ||
74 | vorbis2wav.c | ||
75 | wv2wav.c | ||
76 | mpc2wav.c | ||
77 | midi2wav.c | ||
78 | #endif | ||
79 | iriverify.c | 70 | iriverify.c |
80 | #else | 71 | #else |
81 | splitedit.c | 72 | 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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Dave Chapman | ||
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 | #include "plugin.h" | ||
21 | |||
22 | #if (CONFIG_HWCODEC == MASNONE) | ||
23 | /* software codec platforms */ | ||
24 | |||
25 | #include <inttypes.h> /* Needed by a52.h */ | ||
26 | |||
27 | #include <codecs/liba52/config-a52.h> | ||
28 | #include <codecs/liba52/a52.h> | ||
29 | |||
30 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
31 | |||
32 | static struct plugin_api* rb; | ||
33 | |||
34 | #ifdef WORDS_BIGENDIAN | ||
35 | #define LE_S16(x) ( (uint16_t) ( ((uint16_t)(x) >> 8) | ((uint16_t)(x) << 8) ) ) | ||
36 | #else | ||
37 | #define LE_S16(x) (x) | ||
38 | #endif | ||
39 | |||
40 | |||
41 | static float gain = 1; | ||
42 | static a52_state_t * state; | ||
43 | |||
44 | static inline int16_t convert (int32_t i) | ||
45 | { | ||
46 | i >>= 15; | ||
47 | return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i); | ||
48 | } | ||
49 | |||
50 | void ao_play(file_info_struct* file_info,sample_t* samples,int flags) { | ||
51 | int i; | ||
52 | static int16_t int16_samples[256*2]; | ||
53 | |||
54 | flags &= A52_CHANNEL_MASK | A52_LFE; | ||
55 | |||
56 | if (flags==A52_STEREO) { | ||
57 | for (i = 0; i < 256; i++) { | ||
58 | int16_samples[2*i] = LE_S16(convert (samples[i])); | ||
59 | int16_samples[2*i+1] = LE_S16(convert (samples[i+256])); | ||
60 | } | ||
61 | } else { | ||
62 | DEBUGF("ERROR: unsupported format: %d\n",flags); | ||
63 | } | ||
64 | |||
65 | /* FIX: Buffer the disk write to write larger amounts at one */ | ||
66 | i=rb->write(file_info->outfile,int16_samples,256*2*2); | ||
67 | } | ||
68 | |||
69 | |||
70 | void a52_decode_data (file_info_struct* file_info, uint8_t * start, uint8_t * end) | ||
71 | { | ||
72 | static uint8_t buf[3840]; | ||
73 | static uint8_t * bufptr = buf; | ||
74 | static uint8_t * bufpos = buf + 7; | ||
75 | |||
76 | /* | ||
77 | * sample_rate and flags are static because this routine could | ||
78 | * exit between the a52_syncinfo() and the ao_setup(), and we want | ||
79 | * to have the same values when we get back ! | ||
80 | */ | ||
81 | |||
82 | static int sample_rate; | ||
83 | static int flags; | ||
84 | int bit_rate; | ||
85 | int len; | ||
86 | |||
87 | while (1) { | ||
88 | len = end - start; | ||
89 | if (!len) | ||
90 | break; | ||
91 | if (len > bufpos - bufptr) | ||
92 | len = bufpos - bufptr; | ||
93 | memcpy (bufptr, start, len); | ||
94 | bufptr += len; | ||
95 | start += len; | ||
96 | if (bufptr == bufpos) { | ||
97 | if (bufpos == buf + 7) { | ||
98 | int length; | ||
99 | |||
100 | length = a52_syncinfo (buf, &flags, &sample_rate, &bit_rate); | ||
101 | if (!length) { | ||
102 | DEBUGF("skip\n"); | ||
103 | for (bufptr = buf; bufptr < buf + 6; bufptr++) | ||
104 | bufptr[0] = bufptr[1]; | ||
105 | continue; | ||
106 | } | ||
107 | bufpos = buf + length; | ||
108 | } else { | ||
109 | // The following two defaults are taken from audio_out_oss.c: | ||
110 | level_t level; | ||
111 | sample_t bias; | ||
112 | int i; | ||
113 | |||
114 | /* This is the configuration for the downmixing: */ | ||
115 | flags=A52_STEREO|A52_ADJUST_LEVEL|A52_LFE; | ||
116 | level=(1 << 26); | ||
117 | bias=0; | ||
118 | |||
119 | level = (level_t) (level * gain); | ||
120 | |||
121 | if (a52_frame (state, buf, &flags, &level, bias)) | ||
122 | goto error; | ||
123 | file_info->frames_decoded++; | ||
124 | |||
125 | /* We assume this never changes */ | ||
126 | file_info->samplerate=sample_rate; | ||
127 | |||
128 | // An A52 frame consists of 6 blocks of 256 samples | ||
129 | // So we decode and output them one block at a time | ||
130 | for (i = 0; i < 6; i++) { | ||
131 | if (a52_block (state)) { | ||
132 | goto error; | ||
133 | } | ||
134 | ao_play (file_info, a52_samples (state),flags); | ||
135 | file_info->current_sample+=256; | ||
136 | } | ||
137 | bufptr = buf; | ||
138 | bufpos = buf + 7; | ||
139 | continue; | ||
140 | error: | ||
141 | DEBUGF("error\n"); | ||
142 | bufptr = buf; | ||
143 | bufpos = buf + 7; | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | |||
149 | |||
150 | #define BUFFER_SIZE 4096 | ||
151 | |||
152 | #ifdef USE_IRAM | ||
153 | extern char iramcopy[]; | ||
154 | extern char iramstart[]; | ||
155 | extern char iramend[]; | ||
156 | #endif | ||
157 | |||
158 | /* this is the plugin entry point */ | ||
159 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
160 | { | ||
161 | file_info_struct file_info; | ||
162 | |||
163 | /* Generic plugin initialisation */ | ||
164 | |||
165 | TEST_PLUGIN_API(api); | ||
166 | rb = api; | ||
167 | |||
168 | #ifdef USE_IRAM | ||
169 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
170 | #endif | ||
171 | |||
172 | /* This function sets up the buffers and reads the file into RAM */ | ||
173 | |||
174 | if (local_init(file,"/ac3test.wav",&file_info,api)) { | ||
175 | return PLUGIN_ERROR; | ||
176 | } | ||
177 | |||
178 | /* Intialise the A52 decoder and check for success */ | ||
179 | state = a52_init (0); // Parameter is "accel" | ||
180 | |||
181 | if (state == NULL) { | ||
182 | rb->splash(HZ*2, true, "a52_init failed"); | ||
183 | return PLUGIN_ERROR; | ||
184 | } | ||
185 | |||
186 | /* The main decoding loop */ | ||
187 | |||
188 | file_info.start_tick=*(rb->current_tick); | ||
189 | rb->button_clear_queue(); | ||
190 | |||
191 | while (file_info.curpos < file_info.filesize) { | ||
192 | |||
193 | if ((file_info.curpos+BUFFER_SIZE) < file_info.filesize) { | ||
194 | a52_decode_data(&file_info,&filebuf[file_info.curpos],&filebuf[file_info.curpos+BUFFER_SIZE]); | ||
195 | file_info.curpos+=BUFFER_SIZE; | ||
196 | } else { | ||
197 | a52_decode_data(&file_info,&filebuf[file_info.curpos],&filebuf[file_info.filesize-1]); | ||
198 | file_info.curpos=file_info.filesize; | ||
199 | } | ||
200 | |||
201 | display_status(&file_info); | ||
202 | |||
203 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
204 | close_wav(&file_info); | ||
205 | return PLUGIN_OK; | ||
206 | } | ||
207 | } | ||
208 | close_wav(&file_info); | ||
209 | |||
210 | /* Cleanly close and exit */ | ||
211 | |||
212 | //NOT NEEDED: a52_free (state); | ||
213 | |||
214 | rb->splash(HZ*2, true, "FINISHED!"); | ||
215 | return PLUGIN_OK; | ||
216 | } | ||
217 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn 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 | |||
20 | #include "plugin.h" | ||
21 | |||
22 | #if (CONFIG_HWCODEC == MASNONE) | ||
23 | /* software codec platforms */ | ||
24 | |||
25 | #include <codecs/libFLAC/include/FLAC/seekable_stream_decoder.h> | ||
26 | |||
27 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
28 | |||
29 | #define FLAC_MAX_SUPPORTED_BLOCKSIZE 4608 | ||
30 | #define FLAC_MAX_SUPPORTED_CHANNELS 2 | ||
31 | |||
32 | static struct plugin_api* rb; | ||
33 | |||
34 | /* Called when the FLAC decoder needs some FLAC data to decode */ | ||
35 | FLAC__SeekableStreamDecoderReadStatus flac_read_handler(const FLAC__SeekableStreamDecoder *dec, | ||
36 | FLAC__byte buffer[], unsigned *bytes, void *data) | ||
37 | { (void)dec; | ||
38 | |||
39 | file_info_struct *p = (file_info_struct *) data; | ||
40 | |||
41 | if (p->curpos >= p->filesize) { | ||
42 | return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; | ||
43 | } | ||
44 | |||
45 | rb->memcpy(buffer,&filebuf[p->curpos],*bytes); | ||
46 | p->curpos+=*bytes; | ||
47 | |||
48 | return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; | ||
49 | } | ||
50 | |||
51 | /* Called when the FLAC decoder has some decoded PCM data to write */ | ||
52 | FLAC__StreamDecoderWriteStatus flac_write_handler(const FLAC__SeekableStreamDecoder *dec, | ||
53 | const FLAC__Frame *frame, | ||
54 | const FLAC__int32 * const buf[], | ||
55 | void *data) | ||
56 | { | ||
57 | unsigned int c_samp, c_chan, d_samp; | ||
58 | file_info_struct *p = (file_info_struct *) data; | ||
59 | uint32_t data_size = frame->header.blocksize * frame->header.channels * (p->bitspersample / 8); | ||
60 | uint32_t samples = frame->header.blocksize; | ||
61 | |||
62 | // FIXME: This should not be on the stack! | ||
63 | static unsigned char ldb[FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS*2]; | ||
64 | |||
65 | if (samples*frame->header.channels > (FLAC_MAX_SUPPORTED_BLOCKSIZE*FLAC_MAX_SUPPORTED_CHANNELS)) { | ||
66 | // ERROR!!! | ||
67 | DEBUGF("ERROR: samples*frame->header.channels=%d\n",samples*frame->header.channels); | ||
68 | return(FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE); | ||
69 | } | ||
70 | |||
71 | (void)dec; | ||
72 | (void)data_size; | ||
73 | for(c_samp = d_samp = 0; c_samp < samples; c_samp++) { | ||
74 | for(c_chan = 0; c_chan < frame->header.channels; c_chan++, d_samp++) { | ||
75 | ldb[d_samp*2] = buf[c_chan][c_samp]&0xff; | ||
76 | ldb[(d_samp*2)+1] = (buf[c_chan][c_samp]&0xff00)>>8; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | rb->write(p->outfile,ldb,data_size); | ||
81 | |||
82 | p->current_sample += samples; | ||
83 | |||
84 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; | ||
85 | } | ||
86 | |||
87 | void flac_metadata_handler(const FLAC__SeekableStreamDecoder *dec, | ||
88 | const FLAC__StreamMetadata *meta, void *data) | ||
89 | { | ||
90 | file_info_struct *p = (file_info_struct *) data; | ||
91 | (void)dec; | ||
92 | |||
93 | if(meta->type == FLAC__METADATA_TYPE_STREAMINFO) { | ||
94 | p->bitspersample = meta->data.stream_info.bits_per_sample; | ||
95 | p->samplerate = meta->data.stream_info.sample_rate; | ||
96 | p->channels = meta->data.stream_info.channels; | ||
97 | // FLAC__ASSERT(meta->data.stream_info.total_samples < 0x100000000); /* we can handle < 4 gigasamples */ | ||
98 | p->total_samples = (unsigned) | ||
99 | (meta->data.stream_info.total_samples & 0xffffffff); | ||
100 | p->current_sample = 0; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | |||
105 | void flac_error_handler(const FLAC__SeekableStreamDecoder *dec, | ||
106 | FLAC__StreamDecoderErrorStatus status, void *data) | ||
107 | { | ||
108 | (void)dec; | ||
109 | (void)status; | ||
110 | (void)data; | ||
111 | } | ||
112 | |||
113 | FLAC__SeekableStreamDecoderSeekStatus flac_seek_handler (const FLAC__SeekableStreamDecoder *decoder, | ||
114 | FLAC__uint64 absolute_byte_offset, | ||
115 | void *client_data) | ||
116 | { | ||
117 | (void)decoder; | ||
118 | file_info_struct *p = (file_info_struct *) client_data; | ||
119 | rb->lseek(p->infile,SEEK_SET,absolute_byte_offset); | ||
120 | return(FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK); | ||
121 | } | ||
122 | |||
123 | FLAC__SeekableStreamDecoderTellStatus flac_tell_handler (const FLAC__SeekableStreamDecoder *decoder, | ||
124 | FLAC__uint64 *absolute_byte_offset, void *client_data) | ||
125 | { | ||
126 | file_info_struct *p = (file_info_struct *) client_data; | ||
127 | |||
128 | (void)decoder; | ||
129 | *absolute_byte_offset=rb->lseek(p->infile,SEEK_CUR,0); | ||
130 | return(FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK); | ||
131 | } | ||
132 | |||
133 | FLAC__SeekableStreamDecoderLengthStatus flac_length_handler (const FLAC__SeekableStreamDecoder *decoder, | ||
134 | FLAC__uint64 *stream_length, void *client_data) | ||
135 | { | ||
136 | file_info_struct *p = (file_info_struct *) client_data; | ||
137 | |||
138 | (void)decoder; | ||
139 | *stream_length=p->filesize; | ||
140 | return(FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK); | ||
141 | } | ||
142 | |||
143 | FLAC__bool flac_eof_handler (const FLAC__SeekableStreamDecoder *decoder, | ||
144 | void *client_data) | ||
145 | { | ||
146 | file_info_struct *p = (file_info_struct *) client_data; | ||
147 | |||
148 | (void)decoder; | ||
149 | if (p->curpos >= p->filesize) { | ||
150 | return(true); | ||
151 | } else { | ||
152 | return(false); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | #ifndef SIMULATOR | ||
157 | extern char iramcopy[]; | ||
158 | extern char iramstart[]; | ||
159 | extern char iramend[]; | ||
160 | #endif | ||
161 | |||
162 | /* this is the plugin entry point */ | ||
163 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
164 | { | ||
165 | FLAC__SeekableStreamDecoder* flacDecoder; | ||
166 | file_info_struct file_info; | ||
167 | |||
168 | TEST_PLUGIN_API(api); | ||
169 | |||
170 | /* if you are using a global api pointer, don't forget to copy it! | ||
171 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
172 | rb = api; | ||
173 | |||
174 | #ifndef SIMULATOR | ||
175 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
176 | #endif | ||
177 | |||
178 | /* This function sets up the buffers and reads the file into RAM */ | ||
179 | |||
180 | if (local_init(file,"/flactest.wav",&file_info,api)) { | ||
181 | return PLUGIN_ERROR; | ||
182 | } | ||
183 | |||
184 | /* Create a decoder instance */ | ||
185 | |||
186 | flacDecoder=FLAC__seekable_stream_decoder_new(); | ||
187 | |||
188 | /* Set up the decoder and the callback functions - this must be done before init */ | ||
189 | |||
190 | /* The following are required for stream_decoder and higher */ | ||
191 | FLAC__seekable_stream_decoder_set_client_data(flacDecoder,&file_info); | ||
192 | FLAC__seekable_stream_decoder_set_write_callback(flacDecoder, flac_write_handler); | ||
193 | FLAC__seekable_stream_decoder_set_read_callback(flacDecoder, flac_read_handler); | ||
194 | FLAC__seekable_stream_decoder_set_metadata_callback(flacDecoder, flac_metadata_handler); | ||
195 | FLAC__seekable_stream_decoder_set_error_callback(flacDecoder, flac_error_handler); | ||
196 | FLAC__seekable_stream_decoder_set_metadata_respond(flacDecoder, FLAC__METADATA_TYPE_STREAMINFO); | ||
197 | |||
198 | /* The following are only for the seekable_stream_decoder */ | ||
199 | FLAC__seekable_stream_decoder_set_seek_callback(flacDecoder, flac_seek_handler); | ||
200 | FLAC__seekable_stream_decoder_set_tell_callback(flacDecoder, flac_tell_handler); | ||
201 | FLAC__seekable_stream_decoder_set_length_callback(flacDecoder, flac_length_handler); | ||
202 | FLAC__seekable_stream_decoder_set_eof_callback(flacDecoder, flac_eof_handler); | ||
203 | |||
204 | if (FLAC__seekable_stream_decoder_init(flacDecoder)) { | ||
205 | return PLUGIN_ERROR; | ||
206 | } | ||
207 | |||
208 | /* The first thing to do is to parse the metadata */ | ||
209 | FLAC__seekable_stream_decoder_process_until_end_of_metadata(flacDecoder); | ||
210 | |||
211 | file_info.frames_decoded=0; | ||
212 | file_info.start_tick=*(rb->current_tick); | ||
213 | rb->button_clear_queue(); | ||
214 | |||
215 | while (FLAC__seekable_stream_decoder_get_state(flacDecoder)!=2) { | ||
216 | FLAC__seekable_stream_decoder_process_single(flacDecoder); | ||
217 | file_info.frames_decoded++; | ||
218 | |||
219 | display_status(&file_info); | ||
220 | |||
221 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
222 | close_wav(&file_info); | ||
223 | return PLUGIN_OK; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | close_wav(&file_info); | ||
228 | rb->splash(HZ*2, true, "FINISHED!"); | ||
229 | |||
230 | /* Flush internal buffers etc */ | ||
231 | //No need for this. flacResult=FLAC__seekable_stream_decoder_reset(flacDecoder); | ||
232 | |||
233 | // audio_close(); | ||
234 | |||
235 | return PLUGIN_OK; | ||
236 | } | ||
237 | #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 | |||
34 | #ifdef HAVE_LCD_CHARCELLS | 34 | #ifdef HAVE_LCD_CHARCELLS |
35 | playergfx.c | 35 | playergfx.c |
36 | #endif | 36 | #endif |
37 | #if 0 | ||
38 | #if CONFIG_HWCODEC == MASNONE /* software codec platforms */ | ||
39 | xxx2wav.c | ||
40 | #endif | ||
41 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2005 Stepan Moskovchenko | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #define SAMPLE_RATE 22050 | ||
20 | #define MAX_VOICES 100 | ||
21 | |||
22 | |||
23 | /* Only define LOCAL_DSP on Simulator or else we're asking for trouble */ | ||
24 | #if defined(SIMULATOR) | ||
25 | /*Enable this to write to the soundcard via a /dsv/dsp symlink in */ | ||
26 | // #define LOCAL_DSP | ||
27 | #endif | ||
28 | |||
29 | |||
30 | #if defined(LOCAL_DSP) | ||
31 | /* This is for writing to the DSP directly from the Simulator */ | ||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <linux/soundcard.h> | ||
35 | #include <sys/ioctl.h> | ||
36 | #endif | ||
37 | |||
38 | #include "../../firmware/export/system.h" | ||
39 | |||
40 | #include "../../plugin.h" | ||
41 | |||
42 | #include "lib/xxx2wav.h" | ||
43 | |||
44 | int numberOfSamples IDATA_ATTR; | ||
45 | long bpm; | ||
46 | |||
47 | #include "midi/midiutil.c" | ||
48 | #include "midi/guspat.h" | ||
49 | #include "midi/guspat.c" | ||
50 | #include "midi/sequencer.c" | ||
51 | #include "midi/midifile.c" | ||
52 | #include "midi/synth.c" | ||
53 | |||
54 | |||
55 | |||
56 | |||
57 | int fd=-1; /* File descriptor where the output is written */ | ||
58 | |||
59 | extern long tempo; /* The sequencer keeps track of this */ | ||
60 | |||
61 | |||
62 | struct plugin_api * rb; | ||
63 | |||
64 | |||
65 | |||
66 | |||
67 | |||
68 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
69 | { | ||
70 | TEST_PLUGIN_API(api); | ||
71 | rb = api; | ||
72 | TEST_PLUGIN_API(api); | ||
73 | (void)parameter; | ||
74 | rb = api; | ||
75 | |||
76 | if(parameter == NULL) | ||
77 | { | ||
78 | rb->splash(HZ*2, true, " Play .MID file "); | ||
79 | return PLUGIN_OK; | ||
80 | } | ||
81 | |||
82 | rb->splash(HZ, true, parameter); | ||
83 | if(midimain(parameter) == -1) | ||
84 | { | ||
85 | return PLUGIN_ERROR; | ||
86 | } | ||
87 | rb->splash(HZ*3, true, "FINISHED PLAYING"); | ||
88 | return PLUGIN_OK; | ||
89 | } | ||
90 | |||
91 | signed char outputBuffer[3000] IDATA_ATTR; /* signed char.. gonna run out of iram ... ! */ | ||
92 | |||
93 | |||
94 | int currentSample IDATA_ATTR; | ||
95 | int outputBufferPosition IDATA_ATTR; | ||
96 | int outputSampleOne IDATA_ATTR; | ||
97 | int outputSampleTwo IDATA_ATTR; | ||
98 | |||
99 | |||
100 | int midimain(void * filename) | ||
101 | { | ||
102 | |||
103 | printf("\nHello.\n"); | ||
104 | |||
105 | rb->splash(HZ/5, true, "LOADING MIDI"); | ||
106 | |||
107 | struct MIDIfile * mf = loadFile(filename); | ||
108 | |||
109 | rb->splash(HZ/5, true, "LOADING PATCHES"); | ||
110 | if (initSynth(mf, "/.rockbox/patchset/patchset.cfg", "/.rockbox/patchset/drums.cfg") == -1) | ||
111 | { | ||
112 | return -1; | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * This lets you hear the music through the sound card if you are on Simulator | ||
117 | * Make a symlink, archos/dsp.raw and make it point to /dev/dsp or whatever | ||
118 | * your sound device is. | ||
119 | */ | ||
120 | |||
121 | #if defined(LOCAL_DSP) | ||
122 | fd=rb->open("/dsp.raw", O_WRONLY); | ||
123 | int arg, status; | ||
124 | int bit, samp, ch; | ||
125 | |||
126 | arg = 16; /* sample size */ | ||
127 | status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg); | ||
128 | status = ioctl(fd, SOUND_PCM_READ_BITS, &arg); | ||
129 | bit=arg; | ||
130 | |||
131 | |||
132 | arg = 2; /* Number of channels, 1=mono */ | ||
133 | status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg); | ||
134 | status = ioctl(fd, SOUND_PCM_READ_CHANNELS, &arg); | ||
135 | ch=arg; | ||
136 | |||
137 | arg = SAMPLE_RATE; /* Yeah. sampling rate */ | ||
138 | status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg); | ||
139 | status = ioctl(fd, SOUND_PCM_READ_RATE, &arg); | ||
140 | samp=arg; | ||
141 | #else | ||
142 | file_info_struct file_info; | ||
143 | file_info.samplerate = SAMPLE_RATE; | ||
144 | file_info.infile = fd; | ||
145 | file_info.channels = 2; | ||
146 | file_info.bitspersample = 16; | ||
147 | local_init("/miditest.tmp", "/miditest.wav", &file_info, rb); | ||
148 | fd = file_info.outfile; | ||
149 | #endif | ||
150 | |||
151 | |||
152 | rb->splash(HZ/5, true, " I hope this works... "); | ||
153 | |||
154 | |||
155 | |||
156 | |||
157 | /* | ||
158 | * tick() will do one MIDI clock tick. Then, there's a loop here that | ||
159 | * will generate the right number of samples per MIDI tick. The whole | ||
160 | * MIDI playback is timed in terms of this value.. there are no forced | ||
161 | * delays or anything. It just produces enough samples for each tick, and | ||
162 | * the playback of these samples is what makes the timings right. | ||
163 | * | ||
164 | * This seems to work quite well. | ||
165 | */ | ||
166 | |||
167 | printf("\nOkay, starting sequencing"); | ||
168 | |||
169 | |||
170 | currentSample=0; /* Sample counting variable */ | ||
171 | outputBufferPosition = 0; | ||
172 | |||
173 | |||
174 | bpm=mf->div*1000000/tempo; | ||
175 | numberOfSamples=SAMPLE_RATE/bpm; | ||
176 | |||
177 | |||
178 | |||
179 | /* Tick() will return 0 if there are no more events left to play */ | ||
180 | while(tick(mf)) | ||
181 | { | ||
182 | /* | ||
183 | * Tempo recalculation moved to sequencer.c to be done on a tempo event only | ||
184 | * | ||
185 | */ | ||
186 | for(currentSample=0; currentSample<numberOfSamples; currentSample++) | ||
187 | { | ||
188 | |||
189 | synthSample(&outputSampleOne, &outputSampleTwo); | ||
190 | |||
191 | |||
192 | /* | ||
193 | * 16-bit audio because, well, it's better | ||
194 | * But really because ALSA's OSS emulation sounds extremely | ||
195 | * noisy and distorted when in 8-bit mode. I still do not know | ||
196 | * why this happens. | ||
197 | */ | ||
198 | |||
199 | outputBuffer[outputBufferPosition]=outputSampleOne&0XFF; // Low byte first | ||
200 | outputBufferPosition++; | ||
201 | outputBuffer[outputBufferPosition]=outputSampleOne>>8; //High byte second | ||
202 | outputBufferPosition++; | ||
203 | |||
204 | outputBuffer[outputBufferPosition]=outputSampleTwo&0XFF; // Low byte first | ||
205 | outputBufferPosition++; | ||
206 | outputBuffer[outputBufferPosition]=outputSampleTwo>>8; //High byte second | ||
207 | outputBufferPosition++; | ||
208 | |||
209 | |||
210 | /* | ||
211 | * As soon as we produce 2000 bytes of sound, | ||
212 | * write it to the sound card. Why 2000? I have | ||
213 | * no idea. It's 1 AM and I am dead tired. | ||
214 | */ | ||
215 | if(outputBufferPosition>=2000) | ||
216 | { | ||
217 | rb->write(fd, outputBuffer, 2000); | ||
218 | outputBufferPosition=0; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | printf("\n"); | ||
224 | |||
225 | #if !defined(LOCAL_DSP) | ||
226 | |||
227 | close_wav(&file_info); | ||
228 | #else | ||
229 | rb->close(fd); | ||
230 | #endif | ||
231 | return 0; | ||
232 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Dave Chapman | ||
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 | #include "plugin.h" | ||
21 | |||
22 | #if (CONFIG_HWCODEC == MASNONE) | ||
23 | /* software codec platforms */ | ||
24 | |||
25 | #include <codecs/libmad/mad.h> | ||
26 | |||
27 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
28 | |||
29 | static struct plugin_api* rb; | ||
30 | |||
31 | struct mad_stream Stream IDATA_ATTR; | ||
32 | struct mad_frame Frame IDATA_ATTR; | ||
33 | struct mad_synth Synth IDATA_ATTR; | ||
34 | mad_timer_t Timer; | ||
35 | struct dither d0, d1; | ||
36 | |||
37 | /* The following function is used inside libmad - let's hope it's never | ||
38 | called. | ||
39 | */ | ||
40 | |||
41 | void abort(void) { | ||
42 | } | ||
43 | |||
44 | /* The "dither" code to convert the 24-bit samples produced by libmad was | ||
45 | taken from the coolplayer project - coolplayer.sourceforge.net */ | ||
46 | |||
47 | struct dither { | ||
48 | mad_fixed_t error[3]; | ||
49 | mad_fixed_t random; | ||
50 | }; | ||
51 | |||
52 | # define SAMPLE_DEPTH 16 | ||
53 | # define scale(x, y) dither((x), (y)) | ||
54 | |||
55 | /* | ||
56 | * NAME: prng() | ||
57 | * DESCRIPTION: 32-bit pseudo-random number generator | ||
58 | */ | ||
59 | static __inline | ||
60 | unsigned long prng(unsigned long state) | ||
61 | { | ||
62 | return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL; | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | * NAME: dither() | ||
67 | * DESCRIPTION: dither and scale sample | ||
68 | */ | ||
69 | static __inline | ||
70 | signed int dither(mad_fixed_t sample, struct dither *dither) | ||
71 | { | ||
72 | unsigned int scalebits; | ||
73 | mad_fixed_t output, mask, random; | ||
74 | |||
75 | enum { | ||
76 | MIN = -MAD_F_ONE, | ||
77 | MAX = MAD_F_ONE - 1 | ||
78 | }; | ||
79 | |||
80 | /* noise shape */ | ||
81 | sample += dither->error[0] - dither->error[1] + dither->error[2]; | ||
82 | |||
83 | dither->error[2] = dither->error[1]; | ||
84 | dither->error[1] = dither->error[0] / 2; | ||
85 | |||
86 | /* bias */ | ||
87 | output = sample + (1L << (MAD_F_FRACBITS + 1 - SAMPLE_DEPTH - 1)); | ||
88 | |||
89 | scalebits = MAD_F_FRACBITS + 1 - SAMPLE_DEPTH; | ||
90 | mask = (1L << scalebits) - 1; | ||
91 | |||
92 | /* dither */ | ||
93 | random = prng(dither->random); | ||
94 | output += (random & mask) - (dither->random & mask); | ||
95 | |||
96 | dither->random = random; | ||
97 | |||
98 | /* clip */ | ||
99 | if (output > MAX) { | ||
100 | output = MAX; | ||
101 | |||
102 | if (sample > MAX) | ||
103 | sample = MAX; | ||
104 | } | ||
105 | else if (output < MIN) { | ||
106 | output = MIN; | ||
107 | |||
108 | if (sample < MIN) | ||
109 | sample = MIN; | ||
110 | } | ||
111 | |||
112 | /* quantize */ | ||
113 | output &= ~mask; | ||
114 | |||
115 | /* error feedback */ | ||
116 | dither->error[0] = sample - output; | ||
117 | |||
118 | /* scale */ | ||
119 | return output >> scalebits; | ||
120 | } | ||
121 | |||
122 | #define SHRT_MAX 32767 | ||
123 | |||
124 | #define INPUT_BUFFER_SIZE (10*8192) | ||
125 | #define OUTPUT_BUFFER_SIZE 65536 /* Must be an integer multiple of 4. */ | ||
126 | |||
127 | unsigned char InputBuffer[INPUT_BUFFER_SIZE+MAD_BUFFER_GUARD]; | ||
128 | unsigned char OutputBuffer[OUTPUT_BUFFER_SIZE]; | ||
129 | unsigned char *OutputPtr=OutputBuffer; | ||
130 | unsigned char *GuardPtr=NULL; | ||
131 | const unsigned char *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE; | ||
132 | |||
133 | mad_fixed_t mad_frame_overlap[2][32][18] IDATA_ATTR; | ||
134 | unsigned char mad_main_data[MAD_BUFFER_MDLEN] IDATA_ATTR; | ||
135 | |||
136 | #ifdef USE_IRAM | ||
137 | extern char iramcopy[]; | ||
138 | extern char iramstart[]; | ||
139 | extern char iramend[]; | ||
140 | #endif | ||
141 | |||
142 | /* this is the plugin entry point */ | ||
143 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
144 | { | ||
145 | file_info_struct file_info; | ||
146 | int Status=0; | ||
147 | unsigned short Sample; | ||
148 | int i; | ||
149 | |||
150 | /* Generic plugin inititialisation */ | ||
151 | |||
152 | TEST_PLUGIN_API(api); | ||
153 | rb = api; | ||
154 | |||
155 | #ifdef USE_IRAM | ||
156 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
157 | #endif | ||
158 | |||
159 | /* This function sets up the buffers and reads the file into RAM */ | ||
160 | |||
161 | if (local_init(file,"/libmadtest.wav",&file_info,api)) { | ||
162 | return PLUGIN_ERROR; | ||
163 | } | ||
164 | |||
165 | /* Create a decoder instance */ | ||
166 | |||
167 | mad_stream_init(&Stream); | ||
168 | mad_frame_init(&Frame); | ||
169 | mad_synth_init(&Synth); | ||
170 | mad_timer_reset(&Timer); | ||
171 | |||
172 | /* We do this so libmad doesn't try to call codec_calloc() */ | ||
173 | memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap)); | ||
174 | Frame.overlap = &mad_frame_overlap; | ||
175 | Stream.main_data = &mad_main_data; | ||
176 | |||
177 | GuardPtr = &filebuf[file_info.filesize]; | ||
178 | memset(GuardPtr,0,MAD_BUFFER_GUARD); | ||
179 | mad_stream_buffer(&Stream, filebuf,file_info.filesize); | ||
180 | |||
181 | file_info.curpos=0; | ||
182 | file_info.start_tick=*(rb->current_tick); | ||
183 | |||
184 | rb->button_clear_queue(); | ||
185 | |||
186 | /* This is the decoding loop. */ | ||
187 | while (file_info.curpos < file_info.filesize && | ||
188 | Stream.this_frame != GuardPtr && | ||
189 | Stream.error != MAD_ERROR_BUFLEN) { | ||
190 | file_info.curpos += (int)Stream.next_frame - (int)Stream.this_frame; | ||
191 | |||
192 | if(mad_frame_decode(&Frame,&Stream)) | ||
193 | { | ||
194 | if(MAD_RECOVERABLE(Stream.error)) | ||
195 | { | ||
196 | if(Stream.error!=MAD_ERROR_LOSTSYNC || Stream.this_frame!=GuardPtr) | ||
197 | { | ||
198 | rb->splash(HZ*1, true, "Recoverable...!"); | ||
199 | } | ||
200 | continue; | ||
201 | } | ||
202 | else | ||
203 | if(Stream.error==MAD_ERROR_BUFLEN) | ||
204 | continue; | ||
205 | else | ||
206 | { | ||
207 | rb->splash(HZ*1, true, "Recoverable...!"); | ||
208 | //fprintf(stderr,"%s: unrecoverable frame level error.\n",ProgName); | ||
209 | Status=1; | ||
210 | break; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | /* We assume all frames have same samplerate as the first */ | ||
215 | if(file_info.frames_decoded==0) { | ||
216 | file_info.samplerate=Frame.header.samplerate; | ||
217 | } | ||
218 | |||
219 | file_info.frames_decoded++; | ||
220 | |||
221 | /* ?? Do we need the timer module? */ | ||
222 | mad_timer_add(&Timer,Frame.header.duration); | ||
223 | |||
224 | /* DAVE: This can be used to attenuate the audio */ | ||
225 | // if(DoFilter) | ||
226 | // ApplyFilter(&Frame); | ||
227 | |||
228 | mad_synth_frame(&Synth,&Frame); | ||
229 | |||
230 | /* Convert MAD's numbers to an array of 16-bit LE signed integers */ | ||
231 | for(i=0;i<Synth.pcm.length;i++) | ||
232 | { | ||
233 | /* Left channel */ | ||
234 | Sample=scale(Synth.pcm.samples[0][i],&d0); | ||
235 | *(OutputPtr++)=Sample&0xff; | ||
236 | *(OutputPtr++)=Sample>>8; | ||
237 | |||
238 | /* Right channel. If the decoded stream is monophonic then | ||
239 | * the right output channel is the same as the left one. | ||
240 | */ | ||
241 | if(MAD_NCHANNELS(&Frame.header)==2) | ||
242 | Sample=scale(Synth.pcm.samples[1][i],&d1); | ||
243 | *(OutputPtr++)=Sample&0xff; | ||
244 | *(OutputPtr++)=Sample>>8; | ||
245 | |||
246 | /* Flush the buffer if it is full. */ | ||
247 | if(OutputPtr==OutputBufferEnd) | ||
248 | { | ||
249 | rb->write(file_info.outfile,OutputBuffer,OUTPUT_BUFFER_SIZE); | ||
250 | OutputPtr=OutputBuffer; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | file_info.current_sample+=Synth.pcm.length; | ||
255 | |||
256 | display_status(&file_info); | ||
257 | |||
258 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
259 | close_wav(&file_info); | ||
260 | return PLUGIN_OK; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | close_wav(&file_info); | ||
265 | rb->splash(HZ*2, true, "FINISHED!"); | ||
266 | |||
267 | return PLUGIN_OK; | ||
268 | } | ||
269 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Thom Johansen | ||
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 | /* This is a lovely mishmash of sample.c from libmusepack and mpa2wav.c, | ||
21 | * but happens to work, so no whining! | ||
22 | */ | ||
23 | |||
24 | #include "plugin.h" | ||
25 | |||
26 | #if (CONFIG_HWCODEC == MASNONE) | ||
27 | /* software codec platforms */ | ||
28 | |||
29 | #include <codecs/libmusepack/musepack.h> | ||
30 | |||
31 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
32 | |||
33 | static struct plugin_api* rb; | ||
34 | mpc_decoder decoder; | ||
35 | |||
36 | /* | ||
37 | Our implementations of the mpc_reader callback functions. | ||
38 | */ | ||
39 | mpc_int32_t | ||
40 | read_impl(void *data, void *ptr, mpc_int32_t size) | ||
41 | { | ||
42 | file_info_struct *f = (file_info_struct *)data; | ||
43 | mpc_int32_t num = f->filesize - f->curpos; | ||
44 | if (num > size) | ||
45 | num = size; | ||
46 | rb->memcpy(ptr, filebuf + f->curpos, num); | ||
47 | f->curpos += num; | ||
48 | return num; | ||
49 | } | ||
50 | |||
51 | bool | ||
52 | seek_impl(void *data, mpc_int32_t offset) | ||
53 | { | ||
54 | file_info_struct *f = (file_info_struct *)data; | ||
55 | if (offset > f->filesize) { | ||
56 | return 0; | ||
57 | } else { | ||
58 | f->curpos = offset; | ||
59 | return 1; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | mpc_int32_t | ||
64 | tell_impl(void *data) | ||
65 | { | ||
66 | file_info_struct *f = (file_info_struct *)data; | ||
67 | return f->curpos; | ||
68 | } | ||
69 | |||
70 | mpc_int32_t | ||
71 | get_size_impl(void *data) | ||
72 | { | ||
73 | file_info_struct *f = (file_info_struct *)data; | ||
74 | return f->filesize; | ||
75 | } | ||
76 | |||
77 | bool | ||
78 | canseek_impl(void *data) | ||
79 | { | ||
80 | (void)data; | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | static int | ||
85 | shift_signed(MPC_SAMPLE_FORMAT val, int shift) | ||
86 | { | ||
87 | if (shift > 0) | ||
88 | val <<= shift; | ||
89 | else if (shift < 0) | ||
90 | val >>= -shift; | ||
91 | return (int)val; | ||
92 | } | ||
93 | |||
94 | #define OUTPUT_BUFFER_SIZE 65536 /* Must be an integer multiple of 4. */ | ||
95 | |||
96 | unsigned char OutputBuffer[OUTPUT_BUFFER_SIZE]; | ||
97 | MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; | ||
98 | unsigned char *OutputPtr=OutputBuffer; | ||
99 | const unsigned char *OutputBufferEnd=OutputBuffer+OUTPUT_BUFFER_SIZE; | ||
100 | |||
101 | #ifdef USE_IRAM | ||
102 | extern char iramcopy[]; | ||
103 | extern char iramstart[]; | ||
104 | extern char iramend[]; | ||
105 | #endif | ||
106 | |||
107 | /* this is the plugin entry point */ | ||
108 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
109 | { | ||
110 | file_info_struct file_info; | ||
111 | unsigned short Sample; | ||
112 | unsigned status = 1; | ||
113 | unsigned int i; | ||
114 | mpc_reader reader; | ||
115 | |||
116 | /* Generic plugin inititialisation */ | ||
117 | |||
118 | TEST_PLUGIN_API(api); | ||
119 | rb = api; | ||
120 | |||
121 | #ifdef USE_IRAM | ||
122 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
123 | #endif | ||
124 | |||
125 | reader.read = read_impl; | ||
126 | reader.seek = seek_impl; | ||
127 | reader.tell = tell_impl; | ||
128 | reader.get_size = get_size_impl; | ||
129 | reader.canseek = canseek_impl; | ||
130 | reader.data = &file_info; | ||
131 | |||
132 | /* This function sets up the buffers and reads the file into RAM */ | ||
133 | |||
134 | if (local_init(file, "/libmusepacktest.wav", &file_info, api)) { | ||
135 | return PLUGIN_ERROR; | ||
136 | } | ||
137 | |||
138 | /* read file's streaminfo data */ | ||
139 | mpc_streaminfo info; | ||
140 | mpc_streaminfo_init(&info); | ||
141 | if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { | ||
142 | rb->splash(HZ, true, "Not an MPC file."); | ||
143 | return PLUGIN_ERROR; | ||
144 | } | ||
145 | file_info.samplerate=info.sample_freq; | ||
146 | /* instantiate a decoder with our file reader */ | ||
147 | mpc_decoder_setup(&decoder, &reader); | ||
148 | if (!mpc_decoder_initialize(&decoder, &info)) { | ||
149 | rb->splash(HZ, true, "Error in init."); | ||
150 | return PLUGIN_ERROR; | ||
151 | } | ||
152 | file_info.frames_decoded = 0; | ||
153 | file_info.start_tick = *(rb->current_tick); | ||
154 | |||
155 | rb->button_clear_queue(); | ||
156 | |||
157 | /* This is the decoding loop. */ | ||
158 | while (status != 0) { | ||
159 | status = mpc_decoder_decode(&decoder, sample_buffer, 0, 0); | ||
160 | if (status == (unsigned)(-1)) { | ||
161 | //decode error | ||
162 | rb->splash(HZ, true, "Error decoding file."); | ||
163 | break; | ||
164 | } | ||
165 | else //status>0 | ||
166 | { | ||
167 | file_info.current_sample += status; | ||
168 | file_info.frames_decoded++; | ||
169 | /* Convert musepack's numbers to an array of 16-bit LE signed integers */ | ||
170 | #if 1 /* uncomment to time without byte swapping and disk writing */ | ||
171 | for(i = 0; i < status*info.channels; i += info.channels) | ||
172 | { | ||
173 | /* Left channel */ | ||
174 | Sample=shift_signed(sample_buffer[i], 16 - MPC_FIXED_POINT_SCALE_SHIFT); | ||
175 | *(OutputPtr++)=Sample&0xff; | ||
176 | *(OutputPtr++)=Sample>>8; | ||
177 | |||
178 | /* Right channel. If the decoded stream is monophonic then | ||
179 | * the right output channel is the same as the left one. | ||
180 | */ | ||
181 | if(info.channels==2) | ||
182 | Sample=shift_signed(sample_buffer[i + 1], 16 - MPC_FIXED_POINT_SCALE_SHIFT); | ||
183 | *(OutputPtr++)=Sample&0xff; | ||
184 | *(OutputPtr++)=Sample>>8; | ||
185 | |||
186 | /* Flush the buffer if it is full. */ | ||
187 | if(OutputPtr==OutputBufferEnd) | ||
188 | { | ||
189 | rb->write(file_info.outfile,OutputBuffer,OUTPUT_BUFFER_SIZE); | ||
190 | OutputPtr=OutputBuffer; | ||
191 | } | ||
192 | } | ||
193 | #endif | ||
194 | |||
195 | } | ||
196 | display_status(&file_info); | ||
197 | |||
198 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
199 | close_wav(&file_info); | ||
200 | return PLUGIN_OK; | ||
201 | } | ||
202 | } | ||
203 | close_wav(&file_info); | ||
204 | rb->splash(HZ*2, true, "FINISHED!"); | ||
205 | |||
206 | return PLUGIN_OK; | ||
207 | } | ||
208 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn 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 | #include "kernel.h" | ||
20 | #include "plugin.h" | ||
21 | |||
22 | #if (CONFIG_HWCODEC == MASNONE) | ||
23 | /* software codec platforms */ | ||
24 | |||
25 | #include <codecs/Tremor/ivorbisfile.h> | ||
26 | |||
27 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
28 | |||
29 | static struct plugin_api* rb; | ||
30 | |||
31 | /* Some standard functions and variables needed by Tremor */ | ||
32 | |||
33 | |||
34 | int errno; | ||
35 | |||
36 | size_t strlen(const char *s) { | ||
37 | return(rb->strlen(s)); | ||
38 | } | ||
39 | |||
40 | char *strcpy(char *dest, const char *src) { | ||
41 | return(rb->strcpy(dest,src)); | ||
42 | } | ||
43 | |||
44 | char *strcat(char *dest, const char *src) { | ||
45 | return(rb->strcat(dest,src)); | ||
46 | } | ||
47 | |||
48 | size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) { | ||
49 | size_t len; | ||
50 | file_info_struct *p = (file_info_struct *) datasource; | ||
51 | |||
52 | if (p->curpos >= p->filesize) { | ||
53 | return 0; /* EOF */ | ||
54 | } | ||
55 | |||
56 | len=nmemb*size; | ||
57 | if ((long)(p->curpos+len) > (long)p->filesize) { len=p->filesize-p->curpos; } | ||
58 | |||
59 | rb->memcpy(ptr,&filebuf[p->curpos],len); | ||
60 | p->curpos+=len; | ||
61 | |||
62 | return(len); | ||
63 | } | ||
64 | |||
65 | int seek_handler(void *datasource, ogg_int64_t offset, int whence) { | ||
66 | /* We are not seekable at the moment */ | ||
67 | (void)datasource; | ||
68 | (void)offset; | ||
69 | (void)whence; | ||
70 | return -1; | ||
71 | } | ||
72 | |||
73 | int close_handler(void *datasource) { | ||
74 | (void)datasource; | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | long tell_handler(void *datasource) { | ||
79 | file_info_struct *p = (file_info_struct *) datasource; | ||
80 | return p->curpos; | ||
81 | } | ||
82 | |||
83 | #ifdef USE_IRAM | ||
84 | extern char iramcopy[]; | ||
85 | extern char iramstart[]; | ||
86 | extern char iramend[]; | ||
87 | #endif | ||
88 | |||
89 | |||
90 | /* reserve the PCM buffer in the IRAM area */ | ||
91 | static char pcmbuf[4096] IDATA_ATTR; | ||
92 | |||
93 | /* this is the plugin entry point */ | ||
94 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
95 | { | ||
96 | ov_callbacks callbacks; | ||
97 | OggVorbis_File vf; | ||
98 | vorbis_info* vi; | ||
99 | |||
100 | int error; | ||
101 | long n; | ||
102 | int current_section; | ||
103 | int eof; | ||
104 | #if BYTE_ORDER == BIG_ENDIAN | ||
105 | int i; | ||
106 | char x; | ||
107 | #endif | ||
108 | |||
109 | file_info_struct file_info; | ||
110 | |||
111 | TEST_PLUGIN_API(api); | ||
112 | |||
113 | /* if you are using a global api pointer, don't forget to copy it! | ||
114 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
115 | rb = api; | ||
116 | |||
117 | #ifdef USE_IRAM | ||
118 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
119 | #endif | ||
120 | |||
121 | /* This function sets up the buffers and reads the file into RAM */ | ||
122 | |||
123 | if (local_init(file,"/vorbistest.wav",&file_info,api)) { | ||
124 | return PLUGIN_ERROR; | ||
125 | } | ||
126 | |||
127 | |||
128 | /* Create a decoder instance */ | ||
129 | |||
130 | callbacks.read_func=read_handler; | ||
131 | callbacks.seek_func=seek_handler; | ||
132 | callbacks.tell_func=tell_handler; | ||
133 | callbacks.close_func=close_handler; | ||
134 | |||
135 | file_info.frames_decoded=0; | ||
136 | file_info.start_tick=*(rb->current_tick); | ||
137 | rb->button_clear_queue(); | ||
138 | |||
139 | error=ov_open_callbacks(&file_info,&vf,NULL,0,callbacks); | ||
140 | |||
141 | vi=ov_info(&vf,-1); | ||
142 | |||
143 | if (vi==NULL) { | ||
144 | rb->splash(HZ*2, true, "Error"); | ||
145 | } | ||
146 | file_info.samplerate=vi->rate; | ||
147 | |||
148 | eof=0; | ||
149 | while (!eof) { | ||
150 | /* Read host-endian signed 16 bit PCM samples */ | ||
151 | n=ov_read(&vf,pcmbuf,sizeof(pcmbuf),¤t_section); | ||
152 | |||
153 | if (n==0) { | ||
154 | eof=1; | ||
155 | } else if (n < 0) { | ||
156 | DEBUGF("Error decoding frame\n"); | ||
157 | } else { | ||
158 | file_info.frames_decoded++; | ||
159 | #if BYTE_ORDER == BIG_ENDIAN | ||
160 | for (i=0;i<n;i+=2) { | ||
161 | x=pcmbuf[i]; pcmbuf[i]=pcmbuf[i+1]; pcmbuf[i+1]=x; | ||
162 | } | ||
163 | #endif | ||
164 | rb->write(file_info.outfile,pcmbuf,n); | ||
165 | file_info.current_sample+=(n/4); | ||
166 | } | ||
167 | |||
168 | display_status(&file_info); | ||
169 | |||
170 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
171 | close_wav(&file_info); | ||
172 | return PLUGIN_OK; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | close_wav(&file_info); | ||
177 | rb->splash(HZ*2, true, "FINISHED!"); | ||
178 | return PLUGIN_OK; | ||
179 | } | ||
180 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Christian Gmeiner | ||
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 | #include "plugin.h" | ||
21 | |||
22 | #if (CONFIG_HWCODEC == MASNONE) | ||
23 | /* software codec platforms */ | ||
24 | |||
25 | #include "lib/xxx2wav.h" /* Helper functions common to test decoders */ | ||
26 | #include <codecs/libwavpack/wavpack.h> | ||
27 | |||
28 | #define BUFFER_SIZE 4096 | ||
29 | |||
30 | static struct plugin_api* rb; | ||
31 | static file_info_struct file_info; | ||
32 | static long temp_buffer [BUFFER_SIZE] IDATA_ATTR; | ||
33 | |||
34 | /* Reformat samples from longs in processor's native endian mode to | ||
35 | little-endian data with 2 bytes / sample. */ | ||
36 | uchar* format_samples (int bps, uchar *dst, long *src, ulong samcnt) | ||
37 | { | ||
38 | long temp; | ||
39 | |||
40 | switch (bps) | ||
41 | { | ||
42 | case 1: | ||
43 | while (samcnt--) | ||
44 | { | ||
45 | *dst++ = (uchar)(temp = (*src++ << 8)); | ||
46 | *dst++ = (uchar)(temp >> 8); | ||
47 | } | ||
48 | |||
49 | break; | ||
50 | |||
51 | case 2: | ||
52 | while (samcnt--) | ||
53 | { | ||
54 | *dst++ = (uchar)(temp = *src++); | ||
55 | *dst++ = (uchar)(temp >> 8); | ||
56 | } | ||
57 | |||
58 | break; | ||
59 | |||
60 | case 3: | ||
61 | while (samcnt--) | ||
62 | { | ||
63 | *dst++ = (uchar)(temp = (*src++ >> 8)); | ||
64 | *dst++ = (uchar)(temp >> 8); | ||
65 | } | ||
66 | |||
67 | break; | ||
68 | |||
69 | case 4: | ||
70 | while (samcnt--) | ||
71 | { | ||
72 | *dst++ = (uchar)(temp = (*src++ >> 16)); | ||
73 | *dst++ = (uchar)(temp >> 8); | ||
74 | } | ||
75 | |||
76 | break; | ||
77 | } | ||
78 | |||
79 | return dst; | ||
80 | } | ||
81 | |||
82 | /* this is our function to decode a memory block from a file */ | ||
83 | void wvpack_decode_data(file_info_struct* file_info, int samples_to_decode, WavpackContext **wpc) | ||
84 | { | ||
85 | int bps = WavpackGetBytesPerSample(*wpc); | ||
86 | /* nothing to decode */ | ||
87 | if (!samples_to_decode) | ||
88 | { | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | /* decode now */ | ||
93 | ulong samples_unpacked = WavpackUnpackSamples(*wpc, temp_buffer, samples_to_decode); | ||
94 | |||
95 | if (samples_unpacked) | ||
96 | { | ||
97 | /* update some infos */ | ||
98 | file_info->current_sample += samples_unpacked; | ||
99 | |||
100 | /* for now, convert mono to stereo here, in place */ | ||
101 | if (WavpackGetReducedChannels (*wpc) == 1) { | ||
102 | long *dst = temp_buffer + (samples_unpacked * 2); | ||
103 | long *src = temp_buffer + samples_unpacked; | ||
104 | long count = samples_unpacked; | ||
105 | |||
106 | while (count--) { | ||
107 | *--dst = *--src; | ||
108 | *--dst = *src; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | format_samples (bps, (uchar *) temp_buffer, temp_buffer, samples_unpacked * file_info->channels); | ||
113 | rb->write(file_info->outfile, temp_buffer, samples_unpacked * 4); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | /* callback function for wavpack | ||
118 | Maybe we do this at a lower level, but the | ||
119 | first thing is to get all working */ | ||
120 | long Read(void* buffer, long size) | ||
121 | { | ||
122 | long oldpos = file_info.curpos; | ||
123 | |||
124 | if ((file_info.curpos + size) < file_info.filesize) | ||
125 | { | ||
126 | memcpy(buffer, &filebuf[file_info.curpos], size); | ||
127 | file_info.curpos += size; | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | memcpy(buffer, &filebuf[file_info.curpos], file_info.filesize-file_info.curpos); | ||
132 | file_info.curpos = file_info.filesize; | ||
133 | } | ||
134 | |||
135 | return (file_info.curpos - oldpos); | ||
136 | } | ||
137 | |||
138 | #ifdef USE_IRAM | ||
139 | extern char iramcopy[]; | ||
140 | extern char iramstart[]; | ||
141 | extern char iramend[]; | ||
142 | #endif | ||
143 | |||
144 | /* this is the plugin entry point */ | ||
145 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
146 | { | ||
147 | WavpackContext *wpc; | ||
148 | char error[80]; | ||
149 | |||
150 | /* generic plugin initialisation */ | ||
151 | TEST_PLUGIN_API(api); | ||
152 | rb = api; | ||
153 | |||
154 | #ifdef USE_IRAM | ||
155 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
156 | #endif | ||
157 | |||
158 | /* this function sets up the buffers and reads the file into RAM */ | ||
159 | if (local_init(file,"/wvtest.wav",&file_info,api)) | ||
160 | { | ||
161 | return PLUGIN_ERROR; | ||
162 | } | ||
163 | |||
164 | /* setup wavpack */ | ||
165 | wpc = WavpackOpenFileInput(Read, error); | ||
166 | |||
167 | /* was there an error? */ | ||
168 | if (!wpc) | ||
169 | { | ||
170 | rb->splash(HZ*2, true, error); | ||
171 | return PLUGIN_ERROR; | ||
172 | } | ||
173 | |||
174 | /* grap/set some infos (forcing some to temp values) */ | ||
175 | file_info.channels = 2; | ||
176 | file_info.total_samples = WavpackGetNumSamples(wpc); | ||
177 | file_info.bitspersample = 16; | ||
178 | file_info.samplerate = WavpackGetSampleRate(wpc); | ||
179 | file_info.current_sample = 0; | ||
180 | |||
181 | /* deciding loop */ | ||
182 | file_info.start_tick=*(rb->current_tick); | ||
183 | rb->button_clear_queue(); | ||
184 | |||
185 | while (file_info.current_sample < file_info.total_samples) | ||
186 | { | ||
187 | wvpack_decode_data(&file_info, BUFFER_SIZE / file_info.channels, &wpc); | ||
188 | |||
189 | display_status(&file_info); | ||
190 | |||
191 | if (rb->button_get(false)!=BUTTON_NONE) | ||
192 | { | ||
193 | close_wav(&file_info); | ||
194 | return PLUGIN_OK; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | close_wav(&file_info); | ||
199 | |||
200 | /* do some last checks */ | ||
201 | if ((WavpackGetNumSamples (wpc) != (ulong) -1) && (file_info.current_sample != WavpackGetNumSamples (wpc))) | ||
202 | { | ||
203 | rb->splash(HZ*2, true, "incorrect number of samples!"); | ||
204 | return PLUGIN_ERROR; | ||
205 | } | ||
206 | |||
207 | if (WavpackGetNumErrors (wpc)) { | ||
208 | rb->splash(HZ*2, true, "crc errors detected!"); | ||
209 | return PLUGIN_ERROR; | ||
210 | } | ||
211 | |||
212 | rb->splash(HZ*2, true, "FINISHED!"); | ||
213 | |||
214 | return PLUGIN_OK; | ||
215 | } | ||
216 | |||
217 | #endif /* CONFIG_HWCODEC == MASNONE */ | ||