diff options
-rw-r--r-- | apps/plugins/mp3_encoder.c | 89 |
1 files changed, 10 insertions, 79 deletions
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 453c755f10..4558fdd56b 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c | |||
@@ -24,8 +24,6 @@ MEM_FUNCTION_WRAPPERS(rb); | |||
24 | #define SAMPL2 576 | 24 | #define SAMPL2 576 |
25 | #define SBLIMIT 32 | 25 | #define SBLIMIT 32 |
26 | #define HTN 16 | 26 | #define HTN 16 |
27 | #define memcpy rb->memcpy | ||
28 | #define memset rb->memset | ||
29 | #define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ | 27 | #define putlong(c, s) if(s+sz <= 32) { cc = (cc << s) | c; sz+= s; } \ |
30 | else { putbits(cc, sz); cc = c; sz = s; } | 28 | else { putbits(cc, sz); cc = c; sz = s; } |
31 | 29 | ||
@@ -2278,43 +2276,8 @@ void compress(void) | |||
2278 | 2276 | ||
2279 | 2277 | ||
2280 | int num_file; | 2278 | int num_file; |
2281 | char filename[12][80]; | ||
2282 | char mp3_name[80]; | 2279 | char mp3_name[80]; |
2283 | 2280 | ||
2284 | void read_wav_files(char *dirname) | ||
2285 | { | ||
2286 | DIR *dir = rb->opendir(dirname); | ||
2287 | |||
2288 | if(!dir) | ||
2289 | return; | ||
2290 | |||
2291 | while(true) | ||
2292 | { | ||
2293 | struct dirent *entry; | ||
2294 | |||
2295 | entry = rb->readdir(dir); | ||
2296 | if(!entry) | ||
2297 | break; | ||
2298 | |||
2299 | if( !(entry->attribute & ATTR_DIRECTORY) ) | ||
2300 | { | ||
2301 | int slen = rb->strlen(entry->d_name); | ||
2302 | |||
2303 | /* add all wav audio files */ | ||
2304 | if(!rb->strcasecmp(entry->d_name + slen - 4, ".wav")) | ||
2305 | { | ||
2306 | if(num_file >= 12) | ||
2307 | break; | ||
2308 | |||
2309 | rb->strncpy(filename[num_file], dirname, 79); | ||
2310 | slen = rb->strlen(filename[num_file]); | ||
2311 | rb->strncpy(filename[num_file++] + slen, entry->d_name, 79); | ||
2312 | } | ||
2313 | } | ||
2314 | } | ||
2315 | rb->closedir(dir); | ||
2316 | } | ||
2317 | |||
2318 | void get_mp3_filename(char *wav_name) | 2281 | void get_mp3_filename(char *wav_name) |
2319 | { | 2282 | { |
2320 | int slen = rb->strlen(wav_name); | 2283 | int slen = rb->strlen(wav_name); |
@@ -2358,20 +2321,24 @@ void get_mp3_filename(char *wav_name) | |||
2358 | 2321 | ||
2359 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 2322 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
2360 | { | 2323 | { |
2361 | int fil, sfil, nfil; /* for file selection */ | ||
2362 | int rat, srat, nrat; /* for rate selection */ | 2324 | int rat, srat, nrat; /* for rate selection */ |
2363 | int cont = 1, butt; | 2325 | int cont = 1, butt; |
2364 | long tim = 0; | 2326 | long tim = 0; |
2365 | char stg[40]; | 2327 | char stg[40]; |
2366 | char* bstrg[] = {"64","80","96","112","128","160","192","224","256","320"}; | 2328 | static const char* bstrg[] = { |
2367 | int brate[] = { 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 }; | 2329 | "64", "80", "96", "112", "128", "160", "192", "224", "256", "320" |
2330 | }; | ||
2331 | static const int brate[] = { | ||
2332 | 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 | ||
2333 | }; | ||
2368 | 2334 | ||
2369 | (void)parameter; | 2335 | if (parameter == NULL) |
2336 | return PLUGIN_ERROR; | ||
2370 | 2337 | ||
2371 | PLUGIN_IRAM_INIT(api) | 2338 | PLUGIN_IRAM_INIT(api) |
2372 | 2339 | ||
2373 | #ifdef CPU_COLDFIRE | 2340 | #ifdef CPU_COLDFIRE |
2374 | asm volatile ("move.l #0, %macsr"); /* integer mode */ | 2341 | coldfire_set_macsr(0); /* integer mode */ |
2375 | #endif | 2342 | #endif |
2376 | 2343 | ||
2377 | rb = api; | 2344 | rb = api; |
@@ -2382,42 +2349,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2382 | #endif | 2349 | #endif |
2383 | rb->button_clear_queue(); | 2350 | rb->button_clear_queue(); |
2384 | 2351 | ||
2385 | /* check 'viewer' or 'plugin' call */ | ||
2386 | if(parameter == NULL || *(char*)parameter == 0) | ||
2387 | { | ||
2388 | read_wav_files("/"); | ||
2389 | read_wav_files(REC_BASE_DIR"/"); | ||
2390 | |||
2391 | nfil = num_file - 1; | ||
2392 | sfil = 0; /* set first file as default */ | ||
2393 | |||
2394 | while(cont && (butt = rb->button_get_w_tmo(HZ/10)) != MP3ENC_SELECT) | ||
2395 | { | ||
2396 | switch(butt) | ||
2397 | { | ||
2398 | case MP3ENC_DONE: cont = 0; break; | ||
2399 | case MP3ENC_PREV: if(sfil > 0 ) sfil--; break; | ||
2400 | case MP3ENC_NEXT: if(sfil < nfil) sfil++; break; | ||
2401 | } | ||
2402 | |||
2403 | rb->lcd_clear_display(); | ||
2404 | rb->lcd_putsxy(2, 2, "-- Select WAV-File --"); | ||
2405 | |||
2406 | for(fil=0; fil<=nfil; fil++) | ||
2407 | rb->lcd_putsxy(2, 12 + fil*8, filename[fil]); | ||
2408 | |||
2409 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | ||
2410 | rb->lcd_fillrect(0, 12 + sfil*8, 127, 8); | ||
2411 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
2412 | rb->lcd_update(); | ||
2413 | } | ||
2414 | } | ||
2415 | else | ||
2416 | { | ||
2417 | sfil = 0; | ||
2418 | rb->strncpy(filename[0], (char*)parameter, 79); | ||
2419 | } | ||
2420 | |||
2421 | nrat = 9; | 2352 | nrat = 9; |
2422 | srat = 4; /* set 128kBit as default */ | 2353 | srat = 4; /* set 128kBit as default */ |
2423 | 2354 | ||
@@ -2441,7 +2372,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2441 | rb->lcd_update(); | 2372 | rb->lcd_update(); |
2442 | } | 2373 | } |
2443 | 2374 | ||
2444 | wav_filename = filename[sfil]; | 2375 | wav_filename = parameter; |
2445 | 2376 | ||
2446 | if(cont) | 2377 | if(cont) |
2447 | { | 2378 | { |