Index: apps/codecs/libtremor/block.c =================================================================== --- apps/codecs/libtremor/block.c (revision 19986) +++ apps/codecs/libtremor/block.c (working copy) @@ -145,6 +145,8 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ int i; + long b_size[2]; + LOOKUP_TNC *iramposw[2]; codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; private_state *b=NULL; @@ -154,9 +156,30 @@ v->vi=vi; b->modebits=ilog(ci->modes); + /* allocate IRAM buffer for the PCM data */ + iram_malloc_init(); + v->iram_pcm=(ogg_int32_t *)iram_malloc(CHANNELS*ci->blocksizes[1]*sizeof(ogg_int32_t)); + if(v->iram_pcm != NULL) v->iram_pcm_storage=ci->blocksizes[1]; + else{ + v->iram_pcm=(ogg_int32_t *)iram_malloc(CHANNELS*ci->blocksizes[0]*sizeof(ogg_int32_t)); + if(v->iram_pcm != NULL) v->iram_pcm_storage=ci->blocksizes[0]; + else v->iram_pcm_storage=0; + } + /* Vorbis I uses only window type 0 */ - b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); - b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); + b_size[0]=ci->blocksizes[0]/2; + b_size[1]=ci->blocksizes[1]/2; + b->window[0]=_vorbis_window(0,b_size[0]); + b->window[1]=_vorbis_window(0,b_size[1]); + + /* If fast internal ram sizes are enough, copy data there. */ + for(i=0; i<2; i++){ + iramposw[i]=(LOOKUP_TNC *)iram_malloc(b_size[i]*sizeof(LOOKUP_TNC)); + if(iramposw[i]!=NULL){ + memcpy(iramposw[i], b->window[i], b_size[i]*sizeof(LOOKUP_TNC)); + b->window[i]=iramposw[i]; + } + } /* finish the codebooks */ if(!ci->fullbooks){ Index: apps/codecs/libtremor/config-tremor.h =================================================================== --- apps/codecs/libtremor/config-tremor.h (revision 19986) +++ apps/codecs/libtremor/config-tremor.h (working copy) @@ -25,4 +25,29 @@ #define ICODE_ATTR_TREMOR_NOT_MDCT ICODE_ATTR #endif +/* Define CPU of large IRAM (MCF5250) */ +#if (CONFIG_CPU == MCF5250) +// PCM_BUFFER : 32768 Byte (4096*2*4) +// WINDOW_LOOKUP : 4608 Byte (128*4 + 1024*4) +// TOTAL : 37376 +#define IRAM_IBSS_SIZE 37376 + +/* Define CPU of large IRAM (PP5022/5024) */ +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +// PCM_BUFFER : 32768 byte (4096*2*4) +// WINDOW_LOOKUP : 9216 Byte (256*4 + 2048*4) +// TOTAL : 41984 +#define IRAM_IBSS_SIZE 41984 + +/* Define CPU of Normal IRAM (96KB)*/ +#else +// PCM_BUFFER : 16384 Byte (2048*2*4) +// WINDOW_LOOKUP : 4608 Byte (128*4 + 1024*4) +// TOTAL : 20992 +#define IRAM_IBSS_SIZE 20992 +#endif + +/* max 2 channels */ +#define CHANNELS 2 + // #define _LOW_ACCURACY_ Index: apps/codecs/libtremor/ivorbiscodec.h =================================================================== --- apps/codecs/libtremor/ivorbiscodec.h (revision 19986) +++ apps/codecs/libtremor/ivorbiscodec.h (working copy) @@ -76,6 +76,9 @@ ogg_int64_t sequence; void *backend_state; + + ogg_int32_t *iram_pcm; // IRAM buffer + int iram_pcm_storage; } vorbis_dsp_state; typedef struct vorbis_block{ Index: apps/codecs/libtremor/mapping0.c =================================================================== --- apps/codecs/libtremor/mapping0.c (revision 19986) +++ apps/codecs/libtremor/mapping0.c (working copy) @@ -182,8 +182,6 @@ static int seq = 0; -#define CHANNELS 2 /* max 2 channels on the ihp-1xx (stereo) */ - static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ vorbis_dsp_state *vd=vb->vd; vorbis_info *vi=vd->vi; Index: apps/codecs/libtremor/oggmalloc.c =================================================================== --- apps/codecs/libtremor/oggmalloc.c (revision 19986) +++ apps/codecs/libtremor/oggmalloc.c (working copy) @@ -1,4 +1,5 @@ #include "os_types.h" +#include "misc.h" // for LINE_ATTR static size_t tmp_ptr; @@ -72,3 +73,22 @@ { tmp_ptr = pos; } + +/* Allocate IRAM buffer */ +static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR LINE_ATTR; +static size_t iram_remain; + +void iram_malloc_init(void){ + iram_remain=IRAM_IBSS_SIZE; +} + +void *iram_malloc(size_t size){ + void* x; + + if(size>iram_remain)return NULL; + + x = &iram_buff[IRAM_IBSS_SIZE-iram_remain]; + iram_remain-=size; + + return x; +} Index: apps/codecs/libtremor/os_types.h =================================================================== --- apps/codecs/libtremor/os_types.h (revision 19986) +++ apps/codecs/libtremor/os_types.h (working copy) @@ -24,10 +24,12 @@ #ifdef _LOW_ACCURACY_ # define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9)) -# define LOOKUP_T const unsigned char +# define LOOKUP_T const unsigned char +# define LOOKUP_TNC unsigned char #else # define X(n) (n) # define LOOKUP_T const ogg_int32_t +# define LOOKUP_TNC ogg_int32_t #endif /* make it easy on the folks that want to compile the libs with a @@ -52,4 +54,7 @@ typedef unsigned int ogg_uint32_t; typedef long long ogg_int64_t; +void iram_malloc_init(void); +void *iram_malloc(size_t size); + #endif /* _OS_TYPES_H */ Index: apps/codecs/libtremor/res012.c =================================================================== --- apps/codecs/libtremor/res012.c (revision 19986) +++ apps/codecs/libtremor/res012.c (working copy) @@ -172,8 +172,6 @@ return(look); } -#define CHANNELS 2 - /* a truncated packet here just means 'stop working'; it's not an error */ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, ogg_int32_t **in,int ch, Index: apps/codecs/libtremor/synthesis.c =================================================================== --- apps/codecs/libtremor/synthesis.c (revision 19986) +++ apps/codecs/libtremor/synthesis.c (working copy) @@ -24,16 +24,7 @@ #include "misc.h" #include "os.h" - -/* IRAM buffer keep the block pcm data; only for windows size upto 2048 - for space restrictions. - libVorbis 1.1 Oggenc doesn't use larger windows anyway. */ -/* max 2 channels on the ihp-1xx (stereo), 2048 samples (2*2048*4=16Kb) */ -#define IRAM_PCM_END 2048 -#define CHANNELS 2 - static ogg_int32_t *ipcm_vect[CHANNELS] IBSS_ATTR; -static ogg_int32_t ipcm_buff[CHANNELS*IRAM_PCM_END] IBSS_ATTR LINE_ATTR; int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep) ICODE_ATTR_TREMOR_NOT_MDCT; @@ -78,11 +69,11 @@ if(decodep && vi->channels<=CHANNELS){ /* alloc pcm passback storage */ vb->pcmend=ci->blocksizes[vb->W]; - if (vb->pcmend<=IRAM_PCM_END) { + if (vd->iram_pcm_storage >= vb->pcmend) { /* use statically allocated iram buffer */ vb->pcm = ipcm_vect; for(i=0; ipcm[i] = &ipcm_buff[i*IRAM_PCM_END]; + vb->pcm[i] = &vd->iram_pcm[i*vd->iram_pcm_storage]; } else { /* dynamic allocation (slower) */ vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); Index: apps/codecs/libtremor/window_lookup.h =================================================================== --- apps/codecs/libtremor/window_lookup.h (revision 19986) +++ apps/codecs/libtremor/window_lookup.h (working copy) @@ -15,7 +15,6 @@ ********************************************************************/ - #include "os_types.h" /* libvorbis currently only use the window sizes 256 and 2048, so only put @@ -51,7 +50,7 @@ X(0x7ffdcf39), X(0x7fff6dac), X(0x7fffed01), X(0x7fffffc4), }; -static LOOKUP_T vwin256[128] ICONST_ATTR_TREMOR_WINDOW = { +static LOOKUP_T vwin256[128] = { X(0x0001f018), X(0x00117066), X(0x00306e9e), X(0x005ee5f1), X(0x009ccf26), X(0x00ea208b), X(0x0146cdea), X(0x01b2c87f), X(0x022dfedf), X(0x02b85ced), X(0x0351cbbd), X(0x03fa317f), @@ -284,7 +283,7 @@ X(0x7fffffdd), X(0x7ffffff7), X(0x7fffffff), X(0x7fffffff), }; -static LOOKUP_T vwin2048[1024] ICONST_ATTR_TREMOR_WINDOW = { +static LOOKUP_T vwin2048[1024] = { X(0x000007c0), X(0x000045c4), X(0x0000c1ca), X(0x00017bd3), X(0x000273de), X(0x0003a9eb), X(0x00051df9), X(0x0006d007), X(0x0008c014), X(0x000aee1e), X(0x000d5a25), X(0x00100428),