forked from len0rd/rockbox
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
This commit is contained in:
parent
b715b71e40
commit
265b16ecba
2 changed files with 23 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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++){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue