diff options
Diffstat (limited to 'apps/plugins/vorbis2wav.c')
-rw-r--r-- | apps/plugins/vorbis2wav.c | 180 |
1 files changed, 0 insertions, 180 deletions
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 */ | ||