summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-09-24 12:35:18 +0000
committerDave Chapman <dave@dchapman.com>2005-09-24 12:35:18 +0000
commit9a625ef7ac544976f45734d62294a52ef32cfe66 (patch)
tree96900bf622e2b9032ca63ad874598c88a4b72202
parentcae670ff1fc1e9b9dff3132ed6e6f1df98c764d6 (diff)
Add yield() calls inside the monolithic ALAC decode_frame() function - improves responsiveness of UI during ALAC decoding
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7557 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/alac.c2
-rw-r--r--apps/codecs/libalac/alac.c17
-rw-r--r--apps/codecs/libalac/decomp.h3
3 files changed, 19 insertions, 3 deletions
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index f00ae979bf..5f39e5eacb 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -356,7 +356,7 @@ enum codec_status codec_start(struct codec_api* api)
/* Decode one block - returned samples will be host-endian */
outputBytes = destBufferSize;
rb->yield();
- pDestBuffer=decode_frame(&alac, buffer, &outputBytes);
+ pDestBuffer=decode_frame(&alac, buffer, &outputBytes, rb->yield);
/* Advance codec buffer - unless we did a read */
if ((char*)buffer!=(char*)inputBuffer) {
diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c
index ae1b413eab..bdfb714a57 100644
--- a/apps/codecs/libalac/alac.c
+++ b/apps/codecs/libalac/alac.c
@@ -645,7 +645,8 @@ void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b,
int16_t* decode_frame(alac_file *alac,
unsigned char *inbuffer,
- int *outputsize)
+ int *outputsize,
+ void (*yield)(void))
{
int channels;
int16_t* outbuffer;
@@ -730,6 +731,8 @@ int16_t* decode_frame(alac_file *alac,
//fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n");
}
+ yield();
+
basterdised_rice_decompress(alac,
predicterror_buffer_a,
outputsamples,
@@ -739,6 +742,8 @@ int16_t* decode_frame(alac_file *alac,
ricemodifier * alac->setinfo_rice_historymult / 4,
(1 << alac->setinfo_rice_kmodifier) - 1);
+ yield();
+
if (prediction_type == 0)
{ /* adaptive fir */
predictor_decompress_fir_adapt(predicterror_buffer_a,
@@ -796,6 +801,8 @@ int16_t* decode_frame(alac_file *alac,
/* wasted_bytes = 0; // unused */
}
+ yield();
+
switch(alac->setinfo_sample_size)
{
case 16:
@@ -853,6 +860,7 @@ int16_t* decode_frame(alac_file *alac,
readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1;
+ yield();
if (!isnotcompressed)
{ /* compressed */
int predictor_coef_num_a;
@@ -902,6 +910,7 @@ int16_t* decode_frame(alac_file *alac,
//fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n");
}
+ yield();
/* channel 1 */
basterdised_rice_decompress(alac,
predicterror_buffer_a,
@@ -912,6 +921,7 @@ int16_t* decode_frame(alac_file *alac,
ricemodifier_a * alac->setinfo_rice_historymult / 4,
(1 << alac->setinfo_rice_kmodifier) - 1);
+ yield();
if (prediction_type_a == 0)
{ /* adaptive fir */
predictor_decompress_fir_adapt(predicterror_buffer_a,
@@ -927,6 +937,8 @@ int16_t* decode_frame(alac_file *alac,
//fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a);
}
+ yield();
+
/* channel 2 */
basterdised_rice_decompress(alac,
predicterror_buffer_b,
@@ -937,6 +949,7 @@ int16_t* decode_frame(alac_file *alac,
ricemodifier_b * alac->setinfo_rice_historymult / 4,
(1 << alac->setinfo_rice_kmodifier) - 1);
+ yield();
if (prediction_type_b == 0)
{ /* adaptive fir */
predictor_decompress_fir_adapt(predicterror_buffer_b,
@@ -997,6 +1010,8 @@ int16_t* decode_frame(alac_file *alac,
interlacing_leftweight = 0;
}
+ yield();
+
switch(alac->setinfo_sample_size)
{
case 16:
diff --git a/apps/codecs/libalac/decomp.h b/apps/codecs/libalac/decomp.h
index e6fa82d3d7..15b8910681 100644
--- a/apps/codecs/libalac/decomp.h
+++ b/apps/codecs/libalac/decomp.h
@@ -28,7 +28,8 @@ typedef struct
void create_alac(int samplesize, int numchannels, alac_file* alac);
int16_t* decode_frame(alac_file *alac,
unsigned char *inbuffer,
- int *outputsize);
+ int *outputsize,
+ void (*yield)(void));
void alac_set_info(alac_file *alac, char *inputbuffer);
#endif /* __ALAC__DECOMP_H */