summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/aiff_enc.c14
-rw-r--r--apps/codecs/mp3_enc.c30
-rw-r--r--apps/codecs/wav_enc.c18
-rw-r--r--apps/codecs/wavpack_enc.c30
4 files changed, 69 insertions, 23 deletions
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c
index ba7e36e99e..c1c2a9ec48 100644
--- a/apps/codecs/aiff_enc.c
+++ b/apps/codecs/aiff_enc.c
@@ -298,7 +298,9 @@ static bool init_encoder(void)
298 ci->enc_set_parameters == NULL || 298 ci->enc_set_parameters == NULL ||
299 ci->enc_get_chunk == NULL || 299 ci->enc_get_chunk == NULL ||
300 ci->enc_finish_chunk == NULL || 300 ci->enc_finish_chunk == NULL ||
301#ifdef HAVE_ADJUSTABLE_CPU_FREQ
301 ci->enc_pcm_buf_near_empty == NULL || 302 ci->enc_pcm_buf_near_empty == NULL ||
303#endif
302 ci->enc_get_pcm_data == NULL ) 304 ci->enc_get_pcm_data == NULL )
303 return false; 305 return false;
304 306
@@ -325,7 +327,9 @@ static bool init_encoder(void)
325/* main codec entry point */ 327/* main codec entry point */
326enum codec_status codec_main(void) 328enum codec_status codec_main(void)
327{ 329{
330#ifdef HAVE_ADJUSTABLE_CPU_FREQ
328 bool cpu_boosted; 331 bool cpu_boosted;
332#endif
329 333
330 if (!init_encoder()) 334 if (!init_encoder())
331 { 335 {
@@ -336,8 +340,10 @@ enum codec_status codec_main(void)
336 /* main application waits for this flag during encoder loading */ 340 /* main application waits for this flag during encoder loading */
337 ci->enc_codec_loaded = 1; 341 ci->enc_codec_loaded = 1;
338 342
343#ifdef HAVE_ADJUSTABLE_CPU_FREQ
339 ci->cpu_boost(true); 344 ci->cpu_boost(true);
340 cpu_boosted = true; 345 cpu_boosted = true;
346#endif
341 347
342 /* main encoding loop */ 348 /* main encoding loop */
343 while(!ci->stop_codec) 349 while(!ci->stop_codec)
@@ -351,12 +357,13 @@ enum codec_status codec_main(void)
351 if (ci->stop_codec) 357 if (ci->stop_codec)
352 break; 358 break;
353 359
360#ifdef HAVE_ADJUSTABLE_CPU_FREQ
354 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) 361 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
355 { 362 {
356 ci->cpu_boost(true); 363 ci->cpu_boost(true);
357 cpu_boosted = true; 364 cpu_boosted = true;
358 } 365 }
359 366#endif
360 chunk = ci->enc_get_chunk(); 367 chunk = ci->enc_get_chunk();
361 chunk->enc_size = enc_size; 368 chunk->enc_size = enc_size;
362 chunk->num_pcm = PCM_SAMP_PER_CHUNK; 369 chunk->num_pcm = PCM_SAMP_PER_CHUNK;
@@ -368,17 +375,20 @@ enum codec_status codec_main(void)
368 ci->yield(); 375 ci->yield();
369 } 376 }
370 377
378#ifdef HAVE_ADJUSTABLE_CPU_FREQ
371 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0) 379 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
372 { 380 {
373 ci->cpu_boost(false); 381 ci->cpu_boost(false);
374 cpu_boosted = false; 382 cpu_boosted = false;
375 } 383 }
376 384#endif
377 ci->yield(); 385 ci->yield();
378 } 386 }
379 387
388#ifdef HAVE_ADJUSTABLE_CPU_FREQ
380 if (cpu_boosted) /* set initial boost state */ 389 if (cpu_boosted) /* set initial boost state */
381 ci->cpu_boost(false); 390 ci->cpu_boost(false);
391#endif
382 392
383 /* reset parameters to initial state */ 393 /* reset parameters to initial state */
384 ci->enc_set_parameters(NULL); 394 ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c
index 12a24a7c9b..bbae3502bd 100644
--- a/apps/codecs/mp3_enc.c
+++ b/apps/codecs/mp3_enc.c
@@ -2265,9 +2265,9 @@ static void encode_frame(char *buffer, struct enc_chunk_hdr *chunk)
2265 2265
2266 chunk->enc_size = cfg.byte_per_frame + cfg.mpg.padding; 2266 chunk->enc_size = cfg.byte_per_frame + cfg.mpg.padding;
2267 2267
2268 /* finish this chunk by adding sideinfo header data */ 2268 /* finish this chunk by adding sideinfo header data */
2269 CodedData.bitpos = 0; 2269 CodedData.bitpos = 0;
2270 encodeSideInfo( cfg.cod_info ); 2270 encodeSideInfo( cfg.cod_info );
2271 2271
2272#ifdef ROCKBOX_BIG_ENDIAN 2272#ifdef ROCKBOX_BIG_ENDIAN
2273 /* copy chunk to enc_buffer */ 2273 /* copy chunk to enc_buffer */
@@ -2419,7 +2419,9 @@ static bool enc_init(void)
2419 ci->enc_set_parameters == NULL || 2419 ci->enc_set_parameters == NULL ||
2420 ci->enc_get_chunk == NULL || 2420 ci->enc_get_chunk == NULL ||
2421 ci->enc_finish_chunk == NULL || 2421 ci->enc_finish_chunk == NULL ||
2422#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2422 ci->enc_pcm_buf_near_empty == NULL || 2423 ci->enc_pcm_buf_near_empty == NULL ||
2424#endif
2423 ci->enc_get_pcm_data == NULL || 2425 ci->enc_get_pcm_data == NULL ||
2424 ci->enc_unget_pcm_data == NULL ) 2426 ci->enc_unget_pcm_data == NULL )
2425 return false; 2427 return false;
@@ -2453,7 +2455,9 @@ static bool enc_init(void)
2453 2455
2454enum codec_status codec_main(void) 2456enum codec_status codec_main(void)
2455{ 2457{
2458#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2456 bool cpu_boosted; 2459 bool cpu_boosted;
2460#endif
2457 2461
2458 /* Generic codec initialisation */ 2462 /* Generic codec initialisation */
2459 if (!enc_init()) 2463 if (!enc_init())
@@ -2465,8 +2469,10 @@ enum codec_status codec_main(void)
2465 /* main application waits for this flag during encoder loading */ 2469 /* main application waits for this flag during encoder loading */
2466 ci->enc_codec_loaded = 1; 2470 ci->enc_codec_loaded = 1;
2467 2471
2472#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2468 ci->cpu_boost(true); 2473 ci->cpu_boost(true);
2469 cpu_boosted = true; 2474 cpu_boosted = true;
2475#endif
2470 2476
2471 /* main encoding loop */ 2477 /* main encoding loop */
2472 while (!ci->stop_codec) 2478 while (!ci->stop_codec)
@@ -2480,12 +2486,13 @@ enum codec_status codec_main(void)
2480 if (ci->stop_codec) 2486 if (ci->stop_codec)
2481 break; 2487 break;
2482 2488
2489#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2483 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) 2490 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
2484 { 2491 {
2485 ci->cpu_boost(true); 2492 ci->cpu_boost(true);
2486 cpu_boosted = true; 2493 cpu_boosted = true;
2487 } 2494 }
2488 2495#endif
2489 chunk = ci->enc_get_chunk(); 2496 chunk = ci->enc_get_chunk();
2490 chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); 2497 chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk);
2491 2498
@@ -2502,17 +2509,20 @@ enum codec_status codec_main(void)
2502 ci->yield(); 2509 ci->yield();
2503 } 2510 }
2504 2511
2512#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2505 if (cpu_boosted && ci->enc_pcm_buf_near_empty()) 2513 if (cpu_boosted && ci->enc_pcm_buf_near_empty())
2506 { 2514 {
2507 ci->cpu_boost(false); 2515 ci->cpu_boost(false);
2508 cpu_boosted = false; 2516 cpu_boosted = false;
2509 } 2517 }
2510 2518#endif
2511 ci->yield(); 2519 ci->yield();
2512 } 2520 }
2513 2521
2514 if(cpu_boosted) /* set initial boost state */ 2522#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2523 if (cpu_boosted) /* set initial boost state */
2515 ci->cpu_boost(false); 2524 ci->cpu_boost(false);
2525#endif
2516 2526
2517 /* reset parameters to initial state */ 2527 /* reset parameters to initial state */
2518 ci->enc_set_parameters(NULL); 2528 ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c
index ff49238303..083465ab54 100644
--- a/apps/codecs/wav_enc.c
+++ b/apps/codecs/wav_enc.c
@@ -46,7 +46,7 @@ struct riff_header
46 uint8_t data_id[4]; /* 24h - "data" */ 46 uint8_t data_id[4]; /* 24h - "data" */
47 uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ 47 uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */
48/* unsigned char *data; 2ch - actual sound data */ 48/* unsigned char *data; 2ch - actual sound data */
49}; 49} __attribute__((packed));
50 50
51#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ 51#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */
52#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ 52#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */
@@ -287,7 +287,9 @@ static bool init_encoder(void)
287 ci->enc_set_parameters == NULL || 287 ci->enc_set_parameters == NULL ||
288 ci->enc_get_chunk == NULL || 288 ci->enc_get_chunk == NULL ||
289 ci->enc_finish_chunk == NULL || 289 ci->enc_finish_chunk == NULL ||
290#ifdef HAVE_ADJUSTABLE_CPU_FREQ
290 ci->enc_pcm_buf_near_empty == NULL || 291 ci->enc_pcm_buf_near_empty == NULL ||
292#endif
291 ci->enc_get_pcm_data == NULL ) 293 ci->enc_get_pcm_data == NULL )
292 return false; 294 return false;
293 295
@@ -314,7 +316,9 @@ static bool init_encoder(void)
314/* main codec entry point */ 316/* main codec entry point */
315enum codec_status codec_main(void) 317enum codec_status codec_main(void)
316{ 318{
319#ifdef HAVE_ADJUSTABLE_CPU_FREQ
317 bool cpu_boosted; 320 bool cpu_boosted;
321#endif
318 322
319 if (!init_encoder()) 323 if (!init_encoder())
320 { 324 {
@@ -325,8 +329,10 @@ enum codec_status codec_main(void)
325 /* main application waits for this flag during encoder loading */ 329 /* main application waits for this flag during encoder loading */
326 ci->enc_codec_loaded = 1; 330 ci->enc_codec_loaded = 1;
327 331
332#ifdef HAVE_ADJUSTABLE_CPU_FREQ
328 ci->cpu_boost(true); 333 ci->cpu_boost(true);
329 cpu_boosted = true; 334 cpu_boosted = true;
335#endif
330 336
331 /* main encoding loop */ 337 /* main encoding loop */
332 while(!ci->stop_codec) 338 while(!ci->stop_codec)
@@ -340,12 +346,13 @@ enum codec_status codec_main(void)
340 if (ci->stop_codec) 346 if (ci->stop_codec)
341 break; 347 break;
342 348
349#ifdef HAVE_ADJUSTABLE_CPU_FREQ
343 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) 350 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
344 { 351 {
345 ci->cpu_boost(true); 352 ci->cpu_boost(true);
346 cpu_boosted = true; 353 cpu_boosted = true;
347 } 354 }
348 355#endif
349 chunk = ci->enc_get_chunk(); 356 chunk = ci->enc_get_chunk();
350 chunk->enc_size = enc_size; 357 chunk->enc_size = enc_size;
351 chunk->num_pcm = PCM_SAMP_PER_CHUNK; 358 chunk->num_pcm = PCM_SAMP_PER_CHUNK;
@@ -357,17 +364,20 @@ enum codec_status codec_main(void)
357 ci->yield(); 364 ci->yield();
358 } 365 }
359 366
367#ifdef HAVE_ADJUSTABLE_CPU_FREQ
360 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0) 368 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
361 { 369 {
362 ci->cpu_boost(false); 370 ci->cpu_boost(false);
363 cpu_boosted = false; 371 cpu_boosted = false;
364 } 372 }
365 373#endif
366 ci->yield(); 374 ci->yield();
367 } 375 }
368 376
369 if(cpu_boosted) /* set initial boost state */ 377#ifdef HAVE_ADJUSTABLE_CPU_FREQ
378 if (cpu_boosted) /* set initial boost state */
370 ci->cpu_boost(false); 379 ci->cpu_boost(false);
380#endif
371 381
372 /* reset parameters to initial state */ 382 /* reset parameters to initial state */
373 ci->enc_set_parameters(NULL); 383 ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c
index 1c48c7e64e..c602ca4f55 100644
--- a/apps/codecs/wavpack_enc.c
+++ b/apps/codecs/wavpack_enc.c
@@ -29,7 +29,7 @@ typedef struct
29{ 29{
30 uint8_t type; /* Type of metadata */ 30 uint8_t type; /* Type of metadata */
31 uint8_t word_size; /* Size of metadata in words */ 31 uint8_t word_size; /* Size of metadata in words */
32} WavpackMetadataHeader; 32} __attribute__((packed)) WavpackMetadataHeader;
33 33
34struct riff_header 34struct riff_header
35{ 35{
@@ -53,7 +53,7 @@ struct riff_header
53 uint8_t data_id[4]; /* 24h - "data" */ 53 uint8_t data_id[4]; /* 24h - "data" */
54 uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ 54 uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */
55/* unsigned char *data; 2ch - actual sound data */ 55/* unsigned char *data; 2ch - actual sound data */
56}; 56} __attribute__((packed));
57 57
58#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ 58#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */
59#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ 59#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */
@@ -101,13 +101,19 @@ static const struct riff_header riff_header =
101static void chunk_to_int32(int32_t *src) ICODE_ATTR; 101static void chunk_to_int32(int32_t *src) ICODE_ATTR;
102static void chunk_to_int32(int32_t *src) 102static void chunk_to_int32(int32_t *src)
103{ 103{
104 int32_t *dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK; 104 int32_t *src_end, *dst;
105 int32_t *src_end = dst + PCM_SAMP_PER_CHUNK; 105#ifdef USE_IRAM
106
107 /* copy to IRAM before converting data */ 106 /* copy to IRAM before converting data */
107 dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK;
108 src_end = dst + PCM_SAMP_PER_CHUNK;
109
108 memcpy(dst, src, PCM_CHUNK_SIZE); 110 memcpy(dst, src, PCM_CHUNK_SIZE);
109 111
110 src = dst; 112 src = dst;
113#else
114 src_end = src + PCM_SAMP_PER_CHUNK;
115#endif
116
111 dst = (int32_t *)input_buffer; 117 dst = (int32_t *)input_buffer;
112 118
113 if (config.num_channels == 1) 119 if (config.num_channels == 1)
@@ -335,7 +341,9 @@ static bool init_encoder(void)
335 ci->enc_set_parameters == NULL || 341 ci->enc_set_parameters == NULL ||
336 ci->enc_get_chunk == NULL || 342 ci->enc_get_chunk == NULL ||
337 ci->enc_finish_chunk == NULL || 343 ci->enc_finish_chunk == NULL ||
344#ifdef HAVE_ADJUSTABLE_CPU_FREQ
338 ci->enc_pcm_buf_near_empty == NULL || 345 ci->enc_pcm_buf_near_empty == NULL ||
346#endif
339 ci->enc_get_pcm_data == NULL || 347 ci->enc_get_pcm_data == NULL ||
340 ci->enc_unget_pcm_data == NULL ) 348 ci->enc_unget_pcm_data == NULL )
341 return false; 349 return false;
@@ -374,7 +382,9 @@ static bool init_encoder(void)
374 382
375enum codec_status codec_main(void) 383enum codec_status codec_main(void)
376{ 384{
385#ifdef HAVE_ADJUSTABLE_CPU_FREQ
377 bool cpu_boosted; 386 bool cpu_boosted;
387#endif
378 388
379 /* initialize params and config */ 389 /* initialize params and config */
380 if (!init_encoder()) 390 if (!init_encoder())
@@ -386,8 +396,10 @@ enum codec_status codec_main(void)
386 /* main application waits for this flag during encoder loading */ 396 /* main application waits for this flag during encoder loading */
387 ci->enc_codec_loaded = 1; 397 ci->enc_codec_loaded = 1;
388 398
399#ifdef HAVE_ADJUSTABLE_CPU_FREQ
389 ci->cpu_boost(true); 400 ci->cpu_boost(true);
390 cpu_boosted = true; 401 cpu_boosted = true;
402#endif
391 403
392 /* main encoding loop */ 404 /* main encoding loop */
393 while(!ci->stop_codec) 405 while(!ci->stop_codec)
@@ -406,12 +418,13 @@ enum codec_status codec_main(void)
406 418
407 abort_chunk = true; 419 abort_chunk = true;
408 420
421#ifdef HAVE_ADJUSTABLE_CPU_FREQ
409 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) 422 if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
410 { 423 {
411 ci->cpu_boost(true); 424 ci->cpu_boost(true);
412 cpu_boosted = true; 425 cpu_boosted = true;
413 } 426 }
414 427#endif
415 chunk = ci->enc_get_chunk(); 428 chunk = ci->enc_get_chunk();
416 429
417 /* reset counts and pointer */ 430 /* reset counts and pointer */
@@ -455,17 +468,20 @@ enum codec_status codec_main(void)
455 } 468 }
456 } 469 }
457 470
471#ifdef HAVE_ADJUSTABLE_CPU_FREQ
458 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0) 472 if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
459 { 473 {
460 ci->cpu_boost(false); 474 ci->cpu_boost(false);
461 cpu_boosted = false; 475 cpu_boosted = false;
462 } 476 }
463 477#endif
464 ci->yield(); 478 ci->yield();
465 } 479 }
466 480
481#ifdef HAVE_ADJUSTABLE_CPU_FREQ
467 if (cpu_boosted) /* set initial boost state */ 482 if (cpu_boosted) /* set initial boost state */
468 ci->cpu_boost(false); 483 ci->cpu_boost(false);
484#endif
469 485
470 /* reset parameters to initial state */ 486 /* reset parameters to initial state */
471 ci->enc_set_parameters(NULL); 487 ci->enc_set_parameters(NULL);