summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/Tremor/floor0.c10
-rw-r--r--apps/codecs/Tremor/sharedbook.c21
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 {
16.16 format
returns in m.8 format */
-static long ADJUST_SQRT2[2]={8192,5792};
+static long ADJUST_SQRT2[2] ICODE_ATTR ={8192,5792};
static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */
@@ -94,7 +94,7 @@ static inline ogg_int32_t vorbis_coslook2_i(long a){
return(a);
}
-static const int barklook[28]={
+static const int barklook[28] IDATA_ATTR ={
0,100,200,301, 405,516,635,766,
912,1077,1263,1476, 1720,2003,2333,2721,
3184,3742,4428,5285, 6376,7791,9662,12181,
@@ -117,21 +117,21 @@ static inline ogg_int32_t toBARK(int n){
}
}
-static const unsigned char MLOOP_1[64]={
+static const unsigned char MLOOP_1[64] IDATA_ATTR ={
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
};
-static const unsigned char MLOOP_2[64]={
+static const unsigned char MLOOP_2[64] IDATA_ATTR ={
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
};
-static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
+static const unsigned char MLOOP_3[8] IDATA_ATTR ={0,1,2,2,3,3,3,3};
void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
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 @@
#include "ivorbiscodec.h"
#include "codebook.h"
+/* Size (in number of entries) for static buffers in book_init_decode, so
+ * that large alloca() calls can be avoided, which is needed in Rockbox.
+ * This is enough for one certain test file...
+ */
+#define BOOK_INIT_MAXSIZE 3072
+
/**** pack/unpack helpers ******************************************/
int _ilog(unsigned int v){
int ret=0;
@@ -349,10 +355,18 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
by sorted bitreversed codeword to allow treeless decode. */
{
+ /* Static buffers to avoid heavy stack usage */
+ static int sortindex_buffer[BOOK_INIT_MAXSIZE];
+ static ogg_uint32_t* codep_buffer[BOOK_INIT_MAXSIZE];
+
/* perform sort */
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
- ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n);
-
+ /* ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n); */
+ ogg_uint32_t **codep=codep_buffer;
+
+ if (n > BOOK_INIT_MAXSIZE)
+ goto err_out;
+
if(codes==NULL)goto err_out;
for(i=0;i<n;i++){
@@ -362,7 +376,8 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
qsort(codep,n,sizeof(*codep),sort32a);
- sortindex=(int *)alloca(n*sizeof(*sortindex));
+ /*sortindex=(int *)alloca(n*sizeof(*sortindex));*/
+ sortindex=sortindex_buffer;
c->codelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist));
/* the index is a reverse index */
for(i=0;i<n;i++){