diff options
-rw-r--r-- | apps/plugins/Makefile | 2 | ||||
-rw-r--r-- | apps/plugins/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/xxx2wav.c | 14 | ||||
-rw-r--r-- | apps/plugins/lib/xxx2wav.h | 9 | ||||
-rw-r--r-- | apps/plugins/viewers.config | 1 | ||||
-rw-r--r-- | apps/plugins/vorbis2wav.c | 159 |
6 files changed, 185 insertions, 1 deletions
diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile index 1ecf3809fe..9549959bbd 100644 --- a/apps/plugins/Makefile +++ b/apps/plugins/Makefile | |||
@@ -17,7 +17,7 @@ ifdef APPEXTRA | |||
17 | endif | 17 | endif |
18 | 18 | ||
19 | ifdef SOFTWARECODECS | 19 | ifdef SOFTWARECODECS |
20 | CODECLIBS = -lmad -la52 -lFLAC | 20 | CODECLIBS = -lmad -la52 -lFLAC -lTremor |
21 | endif | 21 | endif |
22 | 22 | ||
23 | LDS := plugin.lds | 23 | LDS := plugin.lds |
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index abdc10453f..d29bd3cb32 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -67,4 +67,5 @@ alpine_cdc.c | |||
67 | mpa2wav.c | 67 | mpa2wav.c |
68 | a52towav.c | 68 | a52towav.c |
69 | flac2wav.c | 69 | flac2wav.c |
70 | vorbis2wav.c | ||
70 | #endif | 71 | #endif |
diff --git a/apps/plugins/lib/xxx2wav.c b/apps/plugins/lib/xxx2wav.c index cc8c31a11e..052de9ad37 100644 --- a/apps/plugins/lib/xxx2wav.c +++ b/apps/plugins/lib/xxx2wav.c | |||
@@ -53,6 +53,12 @@ void* calloc(size_t nmemb, size_t size) { | |||
53 | return(x); | 53 | return(x); |
54 | } | 54 | } |
55 | 55 | ||
56 | void* alloca(size_t size) { | ||
57 | void* x; | ||
58 | x=malloc(size); | ||
59 | return(x); | ||
60 | } | ||
61 | |||
56 | void free(void* ptr) { | 62 | void free(void* ptr) { |
57 | (void)ptr; | 63 | (void)ptr; |
58 | } | 64 | } |
@@ -76,6 +82,14 @@ int memcmp(const void *s1, const void *s2, size_t n) { | |||
76 | return(local_rb->memcmp(s1,s2,n)); | 82 | return(local_rb->memcmp(s1,s2,n)); |
77 | } | 83 | } |
78 | 84 | ||
85 | void* memchr(const void *s, int c, size_t n) { | ||
86 | /* TO DO: Implement for Tremor */ | ||
87 | (void)s; | ||
88 | (void)c; | ||
89 | (void)n; | ||
90 | return(NULL); | ||
91 | } | ||
92 | |||
79 | void* memmove(const void *s1, const void *s2, size_t n) { | 93 | void* memmove(const void *s1, const void *s2, size_t n) { |
80 | char* dest=(char*)s1; | 94 | char* dest=(char*)s1; |
81 | char* src=(char*)s2; | 95 | char* src=(char*)s2; |
diff --git a/apps/plugins/lib/xxx2wav.h b/apps/plugins/lib/xxx2wav.h index e89361c46a..501aaa3933 100644 --- a/apps/plugins/lib/xxx2wav.h +++ b/apps/plugins/lib/xxx2wav.h | |||
@@ -19,6 +19,15 @@ | |||
19 | 19 | ||
20 | /* Various "helper functions" common to all the xxx2wav decoder plugins */ | 20 | /* Various "helper functions" common to all the xxx2wav decoder plugins */ |
21 | 21 | ||
22 | |||
23 | /* A macro to enable printf for the simulator only */ | ||
24 | |||
25 | #ifdef SIMULATOR | ||
26 | #define dprintf(...) printf(__VA_ARGS__) | ||
27 | #else | ||
28 | #define dprintf(...) | ||
29 | #endif | ||
30 | |||
22 | /* the main data structure of the program */ | 31 | /* the main data structure of the program */ |
23 | typedef struct { | 32 | typedef struct { |
24 | int infile; | 33 | int infile; |
diff --git a/apps/plugins/viewers.config b/apps/plugins/viewers.config index d22e53dba0..aa25d6fe81 100644 --- a/apps/plugins/viewers.config +++ b/apps/plugins/viewers.config | |||
@@ -11,3 +11,4 @@ mp3,mpa2wav.rock, 00 00 00 00 00 00 | |||
11 | ac3,a52towav.rock, 00 00 00 00 00 00 | 11 | ac3,a52towav.rock, 00 00 00 00 00 00 |
12 | a52,a52towav.rock, 00 00 00 00 00 00 | 12 | a52,a52towav.rock, 00 00 00 00 00 00 |
13 | flac,flac2wav.rock, 00 00 00 00 00 00 | 13 | flac,flac2wav.rock, 00 00 00 00 00 00 |
14 | ogg,vorbis2wav.rock, 00 00 00 00 00 00 | ||
diff --git a/apps/plugins/vorbis2wav.c b/apps/plugins/vorbis2wav.c new file mode 100644 index 0000000000..3b5de72c74 --- /dev/null +++ b/apps/plugins/vorbis2wav.c | |||
@@ -0,0 +1,159 @@ | |||
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/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 | int errno; | ||
34 | |||
35 | size_t strlen(const char *s) { | ||
36 | return(rb->strlen(s)); | ||
37 | } | ||
38 | |||
39 | char *strcpy(char *dest, const char *src) { | ||
40 | return(rb->strcpy(dest,src)); | ||
41 | } | ||
42 | |||
43 | char *strcat(char *dest, const char *src) { | ||
44 | return(rb->strcat(dest,src)); | ||
45 | } | ||
46 | |||
47 | size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) { | ||
48 | size_t len; | ||
49 | file_info_struct *p = (file_info_struct *) datasource; | ||
50 | |||
51 | if (p->curpos >= p->filesize) { | ||
52 | return 0; /* EOF */ | ||
53 | } | ||
54 | |||
55 | len=nmemb*size; | ||
56 | if ((long)(p->curpos+len) > (long)p->filesize) { len=p->filesize-p->curpos; } | ||
57 | |||
58 | rb->memcpy(ptr,&filebuf[p->curpos],len); | ||
59 | p->curpos+=len; | ||
60 | |||
61 | return(len); | ||
62 | } | ||
63 | |||
64 | int seek_handler(void *datasource, ogg_int64_t offset, int whence) { | ||
65 | /* We are not seekable at the moment */ | ||
66 | (void)datasource; | ||
67 | (void)offset; | ||
68 | (void)whence; | ||
69 | return -1; | ||
70 | } | ||
71 | |||
72 | int close_handler(void *datasource) { | ||
73 | (void)datasource; | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | long tell_handler(void *datasource) { | ||
78 | file_info_struct *p = (file_info_struct *) datasource; | ||
79 | return p->curpos; | ||
80 | } | ||
81 | |||
82 | |||
83 | /* this is the plugin entry point */ | ||
84 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | ||
85 | { | ||
86 | ov_callbacks callbacks; | ||
87 | OggVorbis_File vf; | ||
88 | vorbis_info* vi; | ||
89 | |||
90 | int error; | ||
91 | long n; | ||
92 | int current_section; | ||
93 | int eof; | ||
94 | static char pcmbuf[4096]; | ||
95 | |||
96 | file_info_struct file_info; | ||
97 | |||
98 | TEST_PLUGIN_API(api); | ||
99 | |||
100 | /* if you are using a global api pointer, don't forget to copy it! | ||
101 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
102 | rb = api; | ||
103 | |||
104 | |||
105 | /* This function sets up the buffers and reads the file into RAM */ | ||
106 | |||
107 | if (local_init(file,"/vorbistest.wav",&file_info,api)) { | ||
108 | return PLUGIN_ERROR; | ||
109 | } | ||
110 | |||
111 | /* Create a decoder instance */ | ||
112 | |||
113 | callbacks.read_func=read_handler; | ||
114 | callbacks.seek_func=seek_handler; | ||
115 | callbacks.tell_func=tell_handler; | ||
116 | callbacks.close_func=close_handler; | ||
117 | |||
118 | file_info.frames_decoded=0; | ||
119 | file_info.start_tick=*(rb->current_tick); | ||
120 | rb->button_clear_queue(); | ||
121 | |||
122 | error=ov_open_callbacks(&file_info,&vf,NULL,0,callbacks); | ||
123 | |||
124 | vi=ov_info(&vf,-1); | ||
125 | |||
126 | if (vi==NULL) { | ||
127 | rb->splash(HZ*2, true, "Error"); | ||
128 | } | ||
129 | file_info.samplerate=vi->rate; | ||
130 | |||
131 | eof=0; | ||
132 | while (!eof) { | ||
133 | /* Read host-endian signed 16 bit PCM samples */ | ||
134 | n=ov_read(&vf,pcmbuf,sizeof(pcmbuf),¤t_section); | ||
135 | |||
136 | if (n==0) { | ||
137 | eof=1; | ||
138 | } else if (n < 0) { | ||
139 | dprintf("Error decoding frame\n"); | ||
140 | } else { | ||
141 | file_info.frames_decoded++; | ||
142 | rb->write(file_info.outfile,pcmbuf,n); | ||
143 | file_info.current_sample+=(n/4); | ||
144 | } | ||
145 | |||
146 | display_status(&file_info); | ||
147 | |||
148 | if (rb->button_get(false)!=BUTTON_NONE) { | ||
149 | close_wav(&file_info); | ||
150 | return PLUGIN_OK; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | close_wav(&file_info); | ||
155 | rb->splash(HZ*2, true, "FINISHED!"); | ||
156 | |||
157 | return PLUGIN_OK; | ||
158 | } | ||
159 | #endif /* CONFIG_HWCODEC == MASNONE */ | ||