summaryrefslogtreecommitdiff
path: root/apps
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 /apps
parentcae670ff1fc1e9b9dff3132ed6e6f1df98c764d6 (diff)
downloadrockbox-9a625ef7ac544976f45734d62294a52ef32cfe66.tar.gz
rockbox-9a625ef7ac544976f45734d62294a52ef32cfe66.zip
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
Diffstat (limited to 'apps')
-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)
356 /* Decode one block - returned samples will be host-endian */ 356 /* Decode one block - returned samples will be host-endian */
357 outputBytes = destBufferSize; 357 outputBytes = destBufferSize;
358 rb->yield(); 358 rb->yield();
359 pDestBuffer=decode_frame(&alac, buffer, &outputBytes); 359 pDestBuffer=decode_frame(&alac, buffer, &outputBytes, rb->yield);
360 360
361 /* Advance codec buffer - unless we did a read */ 361 /* Advance codec buffer - unless we did a read */
362 if ((char*)buffer!=(char*)inputBuffer) { 362 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,
645 645
646int16_t* decode_frame(alac_file *alac, 646int16_t* decode_frame(alac_file *alac,
647 unsigned char *inbuffer, 647 unsigned char *inbuffer,
648 int *outputsize) 648 int *outputsize,
649 void (*yield)(void))
649{ 650{
650 int channels; 651 int channels;
651 int16_t* outbuffer; 652 int16_t* outbuffer;
@@ -730,6 +731,8 @@ int16_t* decode_frame(alac_file *alac,
730 //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); 731 //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n");
731 } 732 }
732 733
734 yield();
735
733 basterdised_rice_decompress(alac, 736 basterdised_rice_decompress(alac,
734 predicterror_buffer_a, 737 predicterror_buffer_a,
735 outputsamples, 738 outputsamples,
@@ -739,6 +742,8 @@ int16_t* decode_frame(alac_file *alac,
739 ricemodifier * alac->setinfo_rice_historymult / 4, 742 ricemodifier * alac->setinfo_rice_historymult / 4,
740 (1 << alac->setinfo_rice_kmodifier) - 1); 743 (1 << alac->setinfo_rice_kmodifier) - 1);
741 744
745 yield();
746
742 if (prediction_type == 0) 747 if (prediction_type == 0)
743 { /* adaptive fir */ 748 { /* adaptive fir */
744 predictor_decompress_fir_adapt(predicterror_buffer_a, 749 predictor_decompress_fir_adapt(predicterror_buffer_a,
@@ -796,6 +801,8 @@ int16_t* decode_frame(alac_file *alac,
796 /* wasted_bytes = 0; // unused */ 801 /* wasted_bytes = 0; // unused */
797 } 802 }
798 803
804 yield();
805
799 switch(alac->setinfo_sample_size) 806 switch(alac->setinfo_sample_size)
800 { 807 {
801 case 16: 808 case 16:
@@ -853,6 +860,7 @@ int16_t* decode_frame(alac_file *alac,
853 860
854 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1; 861 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1;
855 862
863 yield();
856 if (!isnotcompressed) 864 if (!isnotcompressed)
857 { /* compressed */ 865 { /* compressed */
858 int predictor_coef_num_a; 866 int predictor_coef_num_a;
@@ -902,6 +910,7 @@ int16_t* decode_frame(alac_file *alac,
902 //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); 910 //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n");
903 } 911 }
904 912
913 yield();
905 /* channel 1 */ 914 /* channel 1 */
906 basterdised_rice_decompress(alac, 915 basterdised_rice_decompress(alac,
907 predicterror_buffer_a, 916 predicterror_buffer_a,
@@ -912,6 +921,7 @@ int16_t* decode_frame(alac_file *alac,
912 ricemodifier_a * alac->setinfo_rice_historymult / 4, 921 ricemodifier_a * alac->setinfo_rice_historymult / 4,
913 (1 << alac->setinfo_rice_kmodifier) - 1); 922 (1 << alac->setinfo_rice_kmodifier) - 1);
914 923
924 yield();
915 if (prediction_type_a == 0) 925 if (prediction_type_a == 0)
916 { /* adaptive fir */ 926 { /* adaptive fir */
917 predictor_decompress_fir_adapt(predicterror_buffer_a, 927 predictor_decompress_fir_adapt(predicterror_buffer_a,
@@ -927,6 +937,8 @@ int16_t* decode_frame(alac_file *alac,
927 //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a); 937 //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a);
928 } 938 }
929 939
940 yield();
941
930 /* channel 2 */ 942 /* channel 2 */
931 basterdised_rice_decompress(alac, 943 basterdised_rice_decompress(alac,
932 predicterror_buffer_b, 944 predicterror_buffer_b,
@@ -937,6 +949,7 @@ int16_t* decode_frame(alac_file *alac,
937 ricemodifier_b * alac->setinfo_rice_historymult / 4, 949 ricemodifier_b * alac->setinfo_rice_historymult / 4,
938 (1 << alac->setinfo_rice_kmodifier) - 1); 950 (1 << alac->setinfo_rice_kmodifier) - 1);
939 951
952 yield();
940 if (prediction_type_b == 0) 953 if (prediction_type_b == 0)
941 { /* adaptive fir */ 954 { /* adaptive fir */
942 predictor_decompress_fir_adapt(predicterror_buffer_b, 955 predictor_decompress_fir_adapt(predicterror_buffer_b,
@@ -997,6 +1010,8 @@ int16_t* decode_frame(alac_file *alac,
997 interlacing_leftweight = 0; 1010 interlacing_leftweight = 0;
998 } 1011 }
999 1012
1013 yield();
1014
1000 switch(alac->setinfo_sample_size) 1015 switch(alac->setinfo_sample_size)
1001 { 1016 {
1002 case 16: 1017 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
28void create_alac(int samplesize, int numchannels, alac_file* alac); 28void create_alac(int samplesize, int numchannels, alac_file* alac);
29int16_t* decode_frame(alac_file *alac, 29int16_t* decode_frame(alac_file *alac,
30 unsigned char *inbuffer, 30 unsigned char *inbuffer,
31 int *outputsize); 31 int *outputsize,
32 void (*yield)(void));
32void alac_set_info(alac_file *alac, char *inputbuffer); 33void alac_set_info(alac_file *alac, char *inputbuffer);
33 34
34#endif /* __ALAC__DECOMP_H */ 35#endif /* __ALAC__DECOMP_H */