summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libtremor/block.c')
-rw-r--r--apps/codecs/libtremor/block.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/apps/codecs/libtremor/block.c b/apps/codecs/libtremor/block.c
index eb087e12a9..3947b90239 100644
--- a/apps/codecs/libtremor/block.c
+++ b/apps/codecs/libtremor/block.c
@@ -39,9 +39,6 @@ static int ilog(unsigned int v){
39static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR; 39static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR;
40static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; 40static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR;
41static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; 41static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR;
42/* if true, we have both pcm buffers in iram and we use a bufferflip.
43 if false, we have one in iram and one in mem, and we use a memcpy */
44static bool iram_pcm_doublebuffer IBSS_ATTR;
45 42
46/* pcm accumulator examples (not exhaustive): 43/* pcm accumulator examples (not exhaustive):
47 44
@@ -154,7 +151,6 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
154 int i; 151 int i;
155 long b_size[2]; 152 long b_size[2];
156 LOOKUP_TNC *iramposw; 153 LOOKUP_TNC *iramposw;
157 ogg_int32_t *internal_pcm=NULL;
158 154
159 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; 155 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
160 private_state *b=NULL; 156 private_state *b=NULL;
@@ -213,14 +209,12 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
213 _pcmp[1]=NULL; 209 _pcmp[1]=NULL;
214 _pcmbp[0]=NULL; 210 _pcmbp[0]=NULL;
215 _pcmbp[1]=NULL; 211 _pcmbp[1]=NULL;
216 212 if(NULL != (v->iram_double_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
217 if(NULL != (internal_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
218 { 213 {
219 /* one-time initialisation at codec start or on switch from 214 /* one-time initialisation at codec start or on switch from
220 blocksizes greater than IRAM_PCM_END to sizes that fit */ 215 blocksizes greater than IRAM_PCM_END to sizes that fit */
221 for(i=0;i<vi->channels;i++) 216 for(i=0;i<vi->channels;i++)
222 v->pcm[i]=&internal_pcm[i*v->pcm_storage]; 217 v->pcm[i]=&v->iram_double_pcm[i*v->pcm_storage];
223 iram_pcm_doublebuffer = true;
224 } 218 }
225 else 219 else
226 { 220 {
@@ -228,7 +222,6 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
228 blocksizes that fit in IRAM_PCM_END to those that don't */ 222 blocksizes that fit in IRAM_PCM_END to those that don't */
229 for(i=0;i<vi->channels;i++) 223 for(i=0;i<vi->channels;i++)
230 v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); 224 v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i]));
231 iram_pcm_doublebuffer = false;
232 } 225 }
233 226
234 /* all 1 (large block) or 0 (small block) */ 227 /* all 1 (large block) or 0 (small block) */
@@ -250,6 +243,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
250int vorbis_synthesis_restart(vorbis_dsp_state *v){ 243int vorbis_synthesis_restart(vorbis_dsp_state *v){
251 vorbis_info *vi=v->vi; 244 vorbis_info *vi=v->vi;
252 codec_setup_info *ci; 245 codec_setup_info *ci;
246 int i;
253 247
254 if(!v->backend_state)return -1; 248 if(!v->backend_state)return -1;
255 if(!vi)return -1; 249 if(!vi)return -1;
@@ -267,6 +261,10 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){
267 /* indicate to synthesis code that buffer pointers no longer valid 261 /* indicate to synthesis code that buffer pointers no longer valid
268 (if we're using double pcm buffer) and will need to reset them */ 262 (if we're using double pcm buffer) and will need to reset them */
269 v->reset_pcmb = true; 263 v->reset_pcmb = true;
264 /* also reset our copy of the double buffer pointers if we have one */
265 if(v->iram_double_pcm)
266 for(i=0;i<vi->channels;i++)
267 v->pcm[i]=&v->iram_double_pcm[i*v->pcm_storage];
270 268
271 return(0); 269 return(0);
272} 270}
@@ -285,12 +283,11 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
285 codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); 283 codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
286 private_state *b=(private_state *)v->backend_state; 284 private_state *b=(private_state *)v->backend_state;
287 285
288 if(!iram_pcm_doublebuffer) 286 if(NULL == v->iram_double_pcm)
289 { 287 {
290 if(v->pcm){ 288 /* pcm buffer came from oggmalloc rather than iram */
291 for(i=0;i<vi->channels;i++) 289 for(i=0;i<vi->channels;i++)
292 if(v->pcm[i])_ogg_free(v->pcm[i]); 290 if(v->pcm[i])_ogg_free(v->pcm[i]);
293 }
294 } 291 }
295 292
296 /* free mode lookups; these are actually vorbis_look_mapping structs */ 293 /* free mode lookups; these are actually vorbis_look_mapping structs */
@@ -322,6 +319,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
322 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; 319 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
323 private_state *b=v->backend_state; 320 private_state *b=v->backend_state;
324 int j; 321 int j;
322 bool iram_pcm_doublebuffer = (NULL != v->iram_double_pcm);
325 323
326 if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); 324 if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL);
327 325