diff options
| author | Pedro Vasconcelos <pbv@rockbox.org> | 2005-06-06 23:01:51 +0000 |
|---|---|---|
| committer | Pedro Vasconcelos <pbv@rockbox.org> | 2005-06-06 23:01:51 +0000 |
| commit | 0f10e898f0040e30f0a23719e67223744c47f90d (patch) | |
| tree | 5283879581de1eb29fdb6e2c2838f9e152ea693b /apps/codecs/Tremor/mapping0.c | |
| parent | 127f14210fb632e069ac6c8891cf28d01bf79e2f (diff) | |
| download | rockbox-0f10e898f0040e30f0a23719e67223744c47f90d.zip rockbox-0f10e898f0040e30f0a23719e67223744c47f90d.tar.gz rockbox-0f10e898f0040e30f0a23719e67223744c47f90d.tar.bz2 rockbox-0f10e898f0040e30f0a23719e67223744c47f90d.tar.xz | |
Vorbis optimizations: allocation of PCM buffers in IRAM, avoiding copying.
Slight code improvements to the MDCT functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6590 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/Tremor/mapping0.c')
| -rw-r--r-- | apps/codecs/Tremor/mapping0.c | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/apps/codecs/Tremor/mapping0.c b/apps/codecs/Tremor/mapping0.c index 26d6289..c88f072 100644 --- a/apps/codecs/Tremor/mapping0.c +++ b/apps/codecs/Tremor/mapping0.c @@ -180,12 +180,6 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb) } -/* IRAM buffer keep the pcm data; only for windows size upto 2048 - for space restrictions. No real compromise, larger window sizes - are only used for very low quality settings (q<0?) */ -#define IRAM_PCM_SIZE 2048 -static ogg_int32_t pcm_iram[IRAM_PCM_SIZE] IDATA_ATTR; - static int seq = 0; #define CHANNELS 2 /* max 2 channels on the ihp-1xx (stereo) */ @@ -201,11 +195,12 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ int i,j; long n=vb->pcmend=ci->blocksizes[vb->W]; - /* statically allocate mapping structures in IRAM */ - static ogg_int32_t *pcmbundle[CHANNELS] IDATA_ATTR; - static int zerobundle[CHANNELS] IDATA_ATTR; - static int nonzero[CHANNELS] IDATA_ATTR; - static void *floormemo[CHANNELS] IDATA_ATTR; + /* bounded mapping arrays instead of using alloca(); + avoids memory leak; we can only deal with stereo anyway */ + ogg_int32_t *pcmbundle[CHANNELS]; + int zerobundle[CHANNELS]; + int nonzero[CHANNELS]; + void *floormemo[CHANNELS]; /* test for too many channels; (maybe this is can be checked at the stream level?) */ @@ -249,7 +244,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ pcmbundle[ch_in_bundle++]=vb->pcm[j]; } } - + look->residue_func[i]->inverse(vb,look->residue_look[i], pcmbundle,zerobundle,ch_in_bundle); } @@ -286,13 +281,10 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ } } + //for(j=0;j<vi->channels;j++) //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); - -/* pbv: removed this loop by fusion with the following one - to avoid recopying data to/from the IRAM */ -#if 0 /* compute and apply spectral envelope */ for(i=0;i<vi->channels;i++){ ogg_int32_t *pcm=vb->pcm[i]; @@ -300,7 +292,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ look->floor_func[submap]-> inverse2(vb,look->floor_look[submap],floormemo[i],pcm); } -#endif //for(j=0;j<vi->channels;j++) //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); @@ -308,32 +299,9 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ /* only MDCT right now.... */ - /* check if we can do this in IRAM */ - if(n <= IRAM_PCM_SIZE) { /* normal window size: yes */ - for(i=0;i<vi->channels;i++){ - ogg_int32_t *pcm=vb->pcm[i]; - int submap=info->chmuxlist[i]; - - if(nonzero[i]) { - memcpy(pcm_iram, pcm, sizeof(ogg_int32_t)*n); - look->floor_func[submap]-> - inverse2(vb,look->floor_look[submap],floormemo[i],pcm_iram); - mdct_backward(n, pcm_iram, pcm_iram); - /* window the data */ - _vorbis_apply_window(pcm_iram,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW); - memcpy(pcm, pcm_iram, sizeof(ogg_int32_t)*n); - } - else - memset(pcm, 0, sizeof(ogg_int32_t)*n); - } - } - else { /* large window: no, do it in the normal memory */ - for(i=0;i<vi->channels;i++){ - ogg_int32_t *pcm=vb->pcm[i]; - int submap=info->chmuxlist[i]; - - look->floor_func[submap]-> - inverse2(vb,look->floor_look[submap],floormemo[i],pcm); + for(i=0;i<vi->channels;i++){ + ogg_int32_t *pcm=vb->pcm[i]; + if(nonzero[i]) { mdct_backward(n, pcm, pcm); /* window the data */ @@ -341,7 +309,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ } else memset(pcm, 0, sizeof(ogg_int32_t)*n); - } } //for(j=0;j<vi->channels;j++) |