diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2005-11-26 13:39:57 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2005-11-26 13:39:57 +0000 |
commit | 265b16ecbaa74b8a8b8c70b2dd4a2e6919b48710 (patch) | |
tree | 214f29ac286f8022cc204ebe1180c569ec13b174 | |
parent | b715b71e404441302f41fa39493fd3a9d666666e (diff) | |
download | rockbox-265b16ecbaa74b8a8b8c70b2dd4a2e6919b48710.tar.gz rockbox-265b16ecbaa74b8a8b8c70b2dd4a2e6919b48710.zip |
iRiver: Reduced stack usage in the Vorbis decoder, so files created by old versions of the encoder can be played. Also moved some small floor0-related arrays to IRAM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8069 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/Tremor/floor0.c | 10 | ||||
-rw-r--r-- | apps/codecs/Tremor/sharedbook.c | 21 |
2 files changed, 23 insertions, 8 deletions
diff --git a/apps/codecs/Tremor/floor0.c b/apps/codecs/Tremor/floor0.c index c4f8c1c85b..0c9542b654 100644 --- a/apps/codecs/Tremor/floor0.c +++ b/apps/codecs/Tremor/floor0.c | |||
@@ -47,7 +47,7 @@ typedef struct { | |||
47 | 16.16 format | 47 | 16.16 format |
48 | returns in m.8 format */ | 48 | returns in m.8 format */ |
49 | 49 | ||
50 | static long ADJUST_SQRT2[2]={8192,5792}; | 50 | static long ADJUST_SQRT2[2] ICODE_ATTR ={8192,5792}; |
51 | static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){ | 51 | static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){ |
52 | long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); | 52 | long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); |
53 | long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */ | 53 | long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */ |
@@ -94,7 +94,7 @@ static inline ogg_int32_t vorbis_coslook2_i(long a){ | |||
94 | return(a); | 94 | return(a); |
95 | } | 95 | } |
96 | 96 | ||
97 | static const int barklook[28]={ | 97 | static const int barklook[28] IDATA_ATTR ={ |
98 | 0,100,200,301, 405,516,635,766, | 98 | 0,100,200,301, 405,516,635,766, |
99 | 912,1077,1263,1476, 1720,2003,2333,2721, | 99 | 912,1077,1263,1476, 1720,2003,2333,2721, |
100 | 3184,3742,4428,5285, 6376,7791,9662,12181, | 100 | 3184,3742,4428,5285, 6376,7791,9662,12181, |
@@ -117,21 +117,21 @@ static inline ogg_int32_t toBARK(int n){ | |||
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | static const unsigned char MLOOP_1[64]={ | 120 | static const unsigned char MLOOP_1[64] IDATA_ATTR ={ |
121 | 0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, | 121 | 0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, |
122 | 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, | 122 | 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, |
123 | 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | 123 | 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, |
124 | 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | 124 | 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, |
125 | }; | 125 | }; |
126 | 126 | ||
127 | static const unsigned char MLOOP_2[64]={ | 127 | static const unsigned char MLOOP_2[64] IDATA_ATTR ={ |
128 | 0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, | 128 | 0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, |
129 | 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, | 129 | 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, |
130 | 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | 130 | 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, |
131 | 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | 131 | 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, |
132 | }; | 132 | }; |
133 | 133 | ||
134 | static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3}; | 134 | static const unsigned char MLOOP_3[8] IDATA_ATTR ={0,1,2,2,3,3,3,3}; |
135 | 135 | ||
136 | void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln, | 136 | void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln, |
137 | ogg_int32_t *lsp,int m, | 137 | ogg_int32_t *lsp,int m, |
diff --git a/apps/codecs/Tremor/sharedbook.c b/apps/codecs/Tremor/sharedbook.c index f5b691a6e4..e163f3dc12 100644 --- a/apps/codecs/Tremor/sharedbook.c +++ b/apps/codecs/Tremor/sharedbook.c | |||
@@ -24,6 +24,12 @@ | |||
24 | #include "ivorbiscodec.h" | 24 | #include "ivorbiscodec.h" |
25 | #include "codebook.h" | 25 | #include "codebook.h" |
26 | 26 | ||
27 | /* Size (in number of entries) for static buffers in book_init_decode, so | ||
28 | * that large alloca() calls can be avoided, which is needed in Rockbox. | ||
29 | * This is enough for one certain test file... | ||
30 | */ | ||
31 | #define BOOK_INIT_MAXSIZE 3072 | ||
32 | |||
27 | /**** pack/unpack helpers ******************************************/ | 33 | /**** pack/unpack helpers ******************************************/ |
28 | int _ilog(unsigned int v){ | 34 | int _ilog(unsigned int v){ |
29 | int ret=0; | 35 | int ret=0; |
@@ -349,10 +355,18 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ | |||
349 | by sorted bitreversed codeword to allow treeless decode. */ | 355 | by sorted bitreversed codeword to allow treeless decode. */ |
350 | 356 | ||
351 | { | 357 | { |
358 | /* Static buffers to avoid heavy stack usage */ | ||
359 | static int sortindex_buffer[BOOK_INIT_MAXSIZE]; | ||
360 | static ogg_uint32_t* codep_buffer[BOOK_INIT_MAXSIZE]; | ||
361 | |||
352 | /* perform sort */ | 362 | /* perform sort */ |
353 | ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); | 363 | ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); |
354 | ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n); | 364 | /* ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n); */ |
355 | 365 | ogg_uint32_t **codep=codep_buffer; | |
366 | |||
367 | if (n > BOOK_INIT_MAXSIZE) | ||
368 | goto err_out; | ||
369 | |||
356 | if(codes==NULL)goto err_out; | 370 | if(codes==NULL)goto err_out; |
357 | 371 | ||
358 | for(i=0;i<n;i++){ | 372 | for(i=0;i<n;i++){ |
@@ -362,7 +376,8 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ | |||
362 | 376 | ||
363 | qsort(codep,n,sizeof(*codep),sort32a); | 377 | qsort(codep,n,sizeof(*codep),sort32a); |
364 | 378 | ||
365 | sortindex=(int *)alloca(n*sizeof(*sortindex)); | 379 | /*sortindex=(int *)alloca(n*sizeof(*sortindex));*/ |
380 | sortindex=sortindex_buffer; | ||
366 | c->codelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); | 381 | c->codelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); |
367 | /* the index is a reverse index */ | 382 | /* the index is a reverse index */ |
368 | for(i=0;i<n;i++){ | 383 | for(i=0;i<n;i++){ |