summaryrefslogtreecommitdiff
path: root/apps/codecs/wavpack_enc.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-11-29 17:52:30 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-11-29 17:52:30 +0000
commit6ae46065b40691d5571252aeeb2ec5475e2f5e4c (patch)
tree6b53c5593a1b364fe078bfb1f82e2f54ff9b6a96 /apps/codecs/wavpack_enc.c
parentb57f23139bbcd3b631d4921e971095694f4a0d56 (diff)
downloadrockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.tar.gz
rockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.zip
Add support for compiling encoders without adjustable CPU frequency and/or IRAM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11625 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/wavpack_enc.c')
-rw-r--r--apps/codecs/wavpack_enc.c30
1 files changed, 23 insertions, 7 deletions
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);