summaryrefslogtreecommitdiff
path: root/apps
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
parentb57f23139bbcd3b631d4921e971095694f4a0d56 (diff)
downloadrockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.zip
rockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.tar.gz
rockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.tar.bz2
rockbox-6ae46065b40691d5571252aeeb2ec5475e2f5e4c.tar.xz
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')
-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 ba7e36e..c1c2a9e 100644
--- a/apps/codecs/aiff_enc.c
+++ b/apps/codecs/aiff_enc.c
@@ -298,7 +298,9 @@ static bool init_encoder(void)
ci->enc_set_parameters == NULL ||
ci->enc_get_chunk == NULL ||
ci->enc_finish_chunk == NULL ||
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->enc_pcm_buf_near_empty == NULL ||
+#endif
ci->enc_get_pcm_data == NULL )
return false;
@@ -325,7 +327,9 @@ static bool init_encoder(void)
/* main codec entry point */
enum codec_status codec_main(void)
{
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
bool cpu_boosted;
+#endif
if (!init_encoder())
{
@@ -336,8 +340,10 @@ enum codec_status codec_main(void)
/* main application waits for this flag during encoder loading */
ci->enc_codec_loaded = 1;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->cpu_boost(true);
cpu_boosted = true;
+#endif
/* main encoding loop */
while(!ci->stop_codec)
@@ -351,12 +357,13 @@ enum codec_status codec_main(void)
if (ci->stop_codec)
break;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
{
ci->cpu_boost(true);
cpu_boosted = true;
}
-
+#endif
chunk = ci->enc_get_chunk();
chunk->enc_size = enc_size;
chunk->num_pcm = PCM_SAMP_PER_CHUNK;
@@ -368,17 +375,20 @@ enum codec_status codec_main(void)
ci->yield();
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
{
ci->cpu_boost(false);
cpu_boosted = false;
}
-
+#endif
ci->yield();
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted) /* set initial boost state */
ci->cpu_boost(false);
+#endif
/* reset parameters to initial state */
ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c
index 12a24a7..bbae350 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)
chunk->enc_size = cfg.byte_per_frame + cfg.mpg.padding;
- /* finish this chunk by adding sideinfo header data */
- CodedData.bitpos = 0;
- encodeSideInfo( cfg.cod_info );
+ /* finish this chunk by adding sideinfo header data */
+ CodedData.bitpos = 0;
+ encodeSideInfo( cfg.cod_info );
#ifdef ROCKBOX_BIG_ENDIAN
/* copy chunk to enc_buffer */
@@ -2419,7 +2419,9 @@ static bool enc_init(void)
ci->enc_set_parameters == NULL ||
ci->enc_get_chunk == NULL ||
ci->enc_finish_chunk == NULL ||
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->enc_pcm_buf_near_empty == NULL ||
+#endif
ci->enc_get_pcm_data == NULL ||
ci->enc_unget_pcm_data == NULL )
return false;
@@ -2453,7 +2455,9 @@ static bool enc_init(void)
enum codec_status codec_main(void)
{
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
bool cpu_boosted;
+#endif
/* Generic codec initialisation */
if (!enc_init())
@@ -2465,8 +2469,10 @@ enum codec_status codec_main(void)
/* main application waits for this flag during encoder loading */
ci->enc_codec_loaded = 1;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->cpu_boost(true);
cpu_boosted = true;
+#endif
/* main encoding loop */
while (!ci->stop_codec)
@@ -2480,12 +2486,13 @@ enum codec_status codec_main(void)
if (ci->stop_codec)
break;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
{
ci->cpu_boost(true);
cpu_boosted = true;
}
-
+#endif
chunk = ci->enc_get_chunk();
chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk);
@@ -2502,17 +2509,20 @@ enum codec_status codec_main(void)
ci->yield();
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted && ci->enc_pcm_buf_near_empty())
- {
- ci->cpu_boost(false);
- cpu_boosted = false;
- }
-
+ {
+ ci->cpu_boost(false);
+ cpu_boosted = false;
+ }
+#endif
ci->yield();
}
- if(cpu_boosted) /* set initial boost state */
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ if (cpu_boosted) /* set initial boost state */
ci->cpu_boost(false);
+#endif
/* reset parameters to initial state */
ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c
index ff49238..083465a 100644
--- a/apps/codecs/wav_enc.c
+++ b/apps/codecs/wav_enc.c
@@ -46,7 +46,7 @@ struct riff_header
uint8_t data_id[4]; /* 24h - "data" */
uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */
/* unsigned char *data; 2ch - actual sound data */
-};
+} __attribute__((packed));
#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */
#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */
@@ -287,7 +287,9 @@ static bool init_encoder(void)
ci->enc_set_parameters == NULL ||
ci->enc_get_chunk == NULL ||
ci->enc_finish_chunk == NULL ||
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->enc_pcm_buf_near_empty == NULL ||
+#endif
ci->enc_get_pcm_data == NULL )
return false;
@@ -314,7 +316,9 @@ static bool init_encoder(void)
/* main codec entry point */
enum codec_status codec_main(void)
{
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
bool cpu_boosted;
+#endif
if (!init_encoder())
{
@@ -325,8 +329,10 @@ enum codec_status codec_main(void)
/* main application waits for this flag during encoder loading */
ci->enc_codec_loaded = 1;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->cpu_boost(true);
cpu_boosted = true;
+#endif
/* main encoding loop */
while(!ci->stop_codec)
@@ -340,12 +346,13 @@ enum codec_status codec_main(void)
if (ci->stop_codec)
break;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
{
ci->cpu_boost(true);
cpu_boosted = true;
}
-
+#endif
chunk = ci->enc_get_chunk();
chunk->enc_size = enc_size;
chunk->num_pcm = PCM_SAMP_PER_CHUNK;
@@ -357,17 +364,20 @@ enum codec_status codec_main(void)
ci->yield();
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
{
ci->cpu_boost(false);
cpu_boosted = false;
}
-
+#endif
ci->yield();
}
- if(cpu_boosted) /* set initial boost state */
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ if (cpu_boosted) /* set initial boost state */
ci->cpu_boost(false);
+#endif
/* reset parameters to initial state */
ci->enc_set_parameters(NULL);
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c
index 1c48c7e..c602ca4 100644
--- a/apps/codecs/wavpack_enc.c
+++ b/apps/codecs/wavpack_enc.c
@@ -29,7 +29,7 @@ typedef struct
{
uint8_t type; /* Type of metadata */
uint8_t word_size; /* Size of metadata in words */
-} WavpackMetadataHeader;
+} __attribute__((packed)) WavpackMetadataHeader;
struct riff_header
{
@@ -53,7 +53,7 @@ struct riff_header
uint8_t data_id[4]; /* 24h - "data" */
uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */
/* unsigned char *data; 2ch - actual sound data */
-};
+} __attribute__((packed));
#define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */
#define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */
@@ -101,13 +101,19 @@ static const struct riff_header riff_header =
static void chunk_to_int32(int32_t *src) ICODE_ATTR;
static void chunk_to_int32(int32_t *src)
{
- int32_t *dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK;
- int32_t *src_end = dst + PCM_SAMP_PER_CHUNK;
-
+ int32_t *src_end, *dst;
+#ifdef USE_IRAM
/* copy to IRAM before converting data */
+ dst = (int32_t *)input_buffer + PCM_SAMP_PER_CHUNK;
+ src_end = dst + PCM_SAMP_PER_CHUNK;
+
memcpy(dst, src, PCM_CHUNK_SIZE);
src = dst;
+#else
+ src_end = src + PCM_SAMP_PER_CHUNK;
+#endif
+
dst = (int32_t *)input_buffer;
if (config.num_channels == 1)
@@ -335,7 +341,9 @@ static bool init_encoder(void)
ci->enc_set_parameters == NULL ||
ci->enc_get_chunk == NULL ||
ci->enc_finish_chunk == NULL ||
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->enc_pcm_buf_near_empty == NULL ||
+#endif
ci->enc_get_pcm_data == NULL ||
ci->enc_unget_pcm_data == NULL )
return false;
@@ -374,7 +382,9 @@ static bool init_encoder(void)
enum codec_status codec_main(void)
{
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
bool cpu_boosted;
+#endif
/* initialize params and config */
if (!init_encoder())
@@ -386,8 +396,10 @@ enum codec_status codec_main(void)
/* main application waits for this flag during encoder loading */
ci->enc_codec_loaded = 1;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
ci->cpu_boost(true);
cpu_boosted = true;
+#endif
/* main encoding loop */
while(!ci->stop_codec)
@@ -406,12 +418,13 @@ enum codec_status codec_main(void)
abort_chunk = true;
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0)
{
ci->cpu_boost(true);
cpu_boosted = true;
}
-
+#endif
chunk = ci->enc_get_chunk();
/* reset counts and pointer */
@@ -455,17 +468,20 @@ enum codec_status codec_main(void)
}
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0)
{
ci->cpu_boost(false);
cpu_boosted = false;
}
-
+#endif
ci->yield();
}
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
if (cpu_boosted) /* set initial boost state */
ci->cpu_boost(false);
+#endif
/* reset parameters to initial state */
ci->enc_set_parameters(NULL);