diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/libtremor/block.c | 8 | ||||
-rw-r--r-- | apps/codecs/libtremor/ivorbiscodec.h | 5 | ||||
-rw-r--r-- | apps/codecs/libtremor/synthesis.c | 29 |
3 files changed, 17 insertions, 25 deletions
diff --git a/apps/codecs/libtremor/block.c b/apps/codecs/libtremor/block.c index 8a461e325f..fe736c8def 100644 --- a/apps/codecs/libtremor/block.c +++ b/apps/codecs/libtremor/block.c | |||
@@ -164,9 +164,11 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ | |||
164 | 164 | ||
165 | /* allocate IRAM buffer for the PCM data generated by synthesis */ | 165 | /* allocate IRAM buffer for the PCM data generated by synthesis */ |
166 | iram_malloc_init(); | 166 | iram_malloc_init(); |
167 | v->iram_pcm=(ogg_int32_t *)iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); | 167 | v->first_pcm=(ogg_int32_t *)iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); |
168 | if(v->iram_pcm != NULL) v->iram_pcm_storage=ci->blocksizes[1]; | 168 | /* when can't allocate IRAM buffer, allocate normal RAM buffer */ |
169 | else v->iram_pcm_storage=0; | 169 | if(v->first_pcm == NULL){ |
170 | v->first_pcm=(ogg_int32_t *)_ogg_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); | ||
171 | } | ||
170 | 172 | ||
171 | v->centerW=0; | 173 | v->centerW=0; |
172 | 174 | ||
diff --git a/apps/codecs/libtremor/ivorbiscodec.h b/apps/codecs/libtremor/ivorbiscodec.h index f59d79194e..c2836ad8a9 100644 --- a/apps/codecs/libtremor/ivorbiscodec.h +++ b/apps/codecs/libtremor/ivorbiscodec.h | |||
@@ -77,9 +77,8 @@ typedef struct vorbis_dsp_state{ | |||
77 | 77 | ||
78 | void *backend_state; | 78 | void *backend_state; |
79 | 79 | ||
80 | ogg_int32_t *iram_pcm; /* IRAM PCM buffer */ | 80 | ogg_int32_t *first_pcm; /* PCM buffer (for normal RAM or IRAM)*/ |
81 | ogg_int32_t *iram_double_pcm; /* IRAM PCM 2nd buffer */ | 81 | ogg_int32_t *iram_double_pcm; /* PCM 2nd buffer for IRAM */ |
82 | int iram_pcm_storage; /* size of IRAM PCM buffer */ | ||
83 | bool reset_pcmb; | 82 | bool reset_pcmb; |
84 | } vorbis_dsp_state; | 83 | } vorbis_dsp_state; |
85 | 84 | ||
diff --git a/apps/codecs/libtremor/synthesis.c b/apps/codecs/libtremor/synthesis.c index b1c5eeccef..a882a6d07a 100644 --- a/apps/codecs/libtremor/synthesis.c +++ b/apps/codecs/libtremor/synthesis.c | |||
@@ -70,26 +70,17 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){ | |||
70 | if(decodep && vi->channels<=CHANNELS){ | 70 | if(decodep && vi->channels<=CHANNELS){ |
71 | vb->pcm = ipcm_vect; | 71 | vb->pcm = ipcm_vect; |
72 | 72 | ||
73 | /* alloc pcm passback storage */ | 73 | /* set pcm end point */ |
74 | vb->pcmend=ci->blocksizes[vb->W]; | 74 | vb->pcmend=ci->blocksizes[vb->W]; |
75 | if (vd->iram_pcm_storage >= vb->pcmend) { | 75 | /* use statically allocated buffer */ |
76 | /* use statically allocated iram buffer */ | 76 | if(vd->reset_pcmb || vb->pcm[0]==NULL) |
77 | if(vd->reset_pcmb || vb->pcm[0]==NULL) | 77 | { |
78 | { | 78 | /* one-time initialisation at codec start |
79 | /* one-time initialisation at codec start | 79 | NOT for every block synthesis start |
80 | NOT for every block synthesis start | 80 | allows us to flip between buffers once initialised |
81 | allows us to flip between buffers once initialised | 81 | by simply flipping pointers */ |
82 | by simply flipping pointers */ | 82 | for(i=0; i<vi->channels; i++) |
83 | for(i=0; i<vi->channels; i++) | 83 | vb->pcm[i] = &vd->first_pcm[i*ci->blocksizes[1]]; |
84 | vb->pcm[i] = &vd->iram_pcm[i*vd->iram_pcm_storage]; | ||
85 | } | ||
86 | } else { | ||
87 | if(vd->reset_pcmb || vb->pcm[0]==NULL) | ||
88 | { | ||
89 | /* dynamic allocation (slower) */ | ||
90 | for(i=0;i<vi->channels;i++) | ||
91 | vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); | ||
92 | } | ||
93 | } | 84 | } |
94 | vd->reset_pcmb = false; | 85 | vd->reset_pcmb = false; |
95 | 86 | ||