diff options
Diffstat (limited to 'apps/codecs/Tremor/block.c')
-rw-r--r-- | apps/codecs/Tremor/block.c | 163 |
1 files changed, 93 insertions, 70 deletions
diff --git a/apps/codecs/Tremor/block.c b/apps/codecs/Tremor/block.c index 6f88fb812c..f51622b5ed 100644 --- a/apps/codecs/Tremor/block.c +++ b/apps/codecs/Tremor/block.c | |||
@@ -70,8 +70,8 @@ static int ilog(unsigned int v){ | |||
70 | | | |endSr | 70 | | | |endSr |
71 | | |beginSr | 71 | | |beginSr |
72 | | |endSl | 72 | | |endSl |
73 | |beginSl | 73 | |beginSl |
74 | |beginW | 74 | |beginW |
75 | */ | 75 | */ |
76 | 76 | ||
77 | /* block abstraction setup *********************************************/ | 77 | /* block abstraction setup *********************************************/ |
@@ -173,10 +173,8 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ | |||
173 | v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); | 173 | v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); |
174 | v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); | 174 | v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); |
175 | 175 | ||
176 | // pbv: allow for extra padding for windowing | ||
177 | for(i=0;i<vi->channels;i++) | 176 | for(i=0;i<vi->channels;i++) |
178 | v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); | 177 | v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); |
179 | // v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); | ||
180 | 178 | ||
181 | 179 | ||
182 | /* all 1 (large block) or 0 (small block) */ | 180 | /* all 1 (large block) or 0 (small block) */ |
@@ -190,7 +188,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ | |||
190 | int mapnum=ci->mode_param[i]->mapping; | 188 | int mapnum=ci->mode_param[i]->mapping; |
191 | int maptype=ci->map_type[mapnum]; | 189 | int maptype=ci->map_type[mapnum]; |
192 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], | 190 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], |
193 | ci->map_param[mapnum]); | 191 | ci->map_param[mapnum]); |
194 | } | 192 | } |
195 | return(0); | 193 | return(0); |
196 | } | 194 | } |
@@ -231,7 +229,7 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ | |||
231 | 229 | ||
232 | if(v->pcm){ | 230 | if(v->pcm){ |
233 | for(i=0;i<vi->channels;i++) | 231 | for(i=0;i<vi->channels;i++) |
234 | if(v->pcm[i])_ogg_free(v->pcm[i]); | 232 | if(v->pcm[i])_ogg_free(v->pcm[i]); |
235 | _ogg_free(v->pcm); | 233 | _ogg_free(v->pcm); |
236 | if(v->pcmret)_ogg_free(v->pcmret); | 234 | if(v->pcmret)_ogg_free(v->pcmret); |
237 | } | 235 | } |
@@ -239,9 +237,9 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ | |||
239 | /* free mode lookups; these are actually vorbis_look_mapping structs */ | 237 | /* free mode lookups; these are actually vorbis_look_mapping structs */ |
240 | if(ci){ | 238 | if(ci){ |
241 | for(i=0;i<ci->modes;i++){ | 239 | for(i=0;i<ci->modes;i++){ |
242 | int mapnum=ci->mode_param[i]->mapping; | 240 | int mapnum=ci->mode_param[i]->mapping; |
243 | int maptype=ci->map_type[mapnum]; | 241 | int maptype=ci->map_type[mapnum]; |
244 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); | 242 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); |
245 | } | 243 | } |
246 | } | 244 | } |
247 | 245 | ||
@@ -262,7 +260,11 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
262 | vorbis_info *vi=v->vi; | 260 | vorbis_info *vi=v->vi; |
263 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 261 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
264 | private_state *b=v->backend_state; | 262 | private_state *b=v->backend_state; |
263 | #if CONFIG_CPU == MCF5249 | ||
264 | int j; | ||
265 | #else | ||
265 | int i,j; | 266 | int i,j; |
267 | #endif | ||
266 | 268 | ||
267 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); | 269 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); |
268 | 270 | ||
@@ -304,43 +306,64 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
304 | for(j=0;j<vi->channels;j++){ | 306 | for(j=0;j<vi->channels;j++){ |
305 | /* the overlap/add section */ | 307 | /* the overlap/add section */ |
306 | if(v->lW){ | 308 | if(v->lW){ |
307 | if(v->W){ | 309 | if(v->W){ |
308 | /* large/large */ | 310 | /* large/large */ |
309 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | 311 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
310 | ogg_int32_t *p=vb->pcm[j]; | 312 | ogg_int32_t *p=vb->pcm[j]; |
311 | for(i=0;i<n1;i++) | 313 | #if CONFIG_CPU == MCF5249 |
312 | pcm[i]+=p[i]; | 314 | mcf5249_vect_add(pcm, p, n1); |
313 | }else{ | 315 | #else |
314 | /* large/small */ | 316 | for(i=0;i<n1;i++) |
315 | ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; | 317 | pcm[i]+=p[i]; |
316 | ogg_int32_t *p=vb->pcm[j]; | 318 | #endif |
317 | for(i=0;i<n0;i++) | 319 | }else{ |
318 | pcm[i]+=p[i]; | 320 | /* large/small */ |
319 | } | 321 | ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; |
322 | ogg_int32_t *p=vb->pcm[j]; | ||
323 | #if CONFIG_CPU == MCF5249 | ||
324 | mcf5249_vect_add(pcm, p, n0); | ||
325 | #else | ||
326 | for(i=0;i<n0;i++) | ||
327 | pcm[i]+=p[i]; | ||
328 | #endif | ||
329 | } | ||
320 | }else{ | 330 | }else{ |
321 | if(v->W){ | 331 | if(v->W){ |
322 | /* small/large */ | 332 | /* small/large */ |
323 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | 333 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
324 | ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; | 334 | ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; |
325 | for(i=0;i<n0;i++) | 335 | #if CONFIG_CPU == MCF5249 |
326 | pcm[i]+=p[i]; | 336 | mcf5249_vect_add(pcm, p, n0); |
327 | for(;i<n1/2+n0/2;i++) | 337 | mcf5249_vect_copy(&pcm[n0], &p[n0], n1/2-n0/2); |
328 | pcm[i]=p[i]; | 338 | #else |
329 | }else{ | 339 | for(i=0;i<n0;i++) |
330 | /* small/small */ | 340 | pcm[i]+=p[i]; |
331 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | 341 | for(;i<n1/2+n0/2;i++) |
332 | ogg_int32_t *p=vb->pcm[j]; | 342 | pcm[i]=p[i]; |
333 | for(i=0;i<n0;i++) | 343 | #endif |
334 | pcm[i]+=p[i]; | 344 | }else{ |
335 | } | 345 | /* small/small */ |
346 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | ||
347 | ogg_int32_t *p=vb->pcm[j]; | ||
348 | #if CONFIG_CPU == MCF5249 | ||
349 | mcf5249_vect_add(pcm, p, n0); | ||
350 | #else | ||
351 | for(i=0;i<n0;i++) | ||
352 | pcm[i]+=p[i]; | ||
353 | #endif | ||
354 | } | ||
336 | } | 355 | } |
337 | 356 | ||
338 | /* the copy section */ | 357 | /* the copy section */ |
339 | { | 358 | { |
340 | ogg_int32_t *pcm=v->pcm[j]+thisCenter; | 359 | ogg_int32_t *pcm=v->pcm[j]+thisCenter; |
341 | ogg_int32_t *p=vb->pcm[j]+n; | 360 | ogg_int32_t *p=vb->pcm[j]+n; |
342 | for(i=0;i<n;i++) | 361 | #if CONFIG_CPU == MCF5249 |
343 | pcm[i]=p[i]; | 362 | mcf5249_vect_copy(pcm, p, n); |
363 | #else | ||
364 | for(i=0;i<n;i++) | ||
365 | pcm[i]=p[i]; | ||
366 | #endif | ||
344 | } | 367 | } |
345 | } | 368 | } |
346 | 369 | ||
@@ -359,8 +382,8 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
359 | }else{ | 382 | }else{ |
360 | v->pcm_returned=prevCenter; | 383 | v->pcm_returned=prevCenter; |
361 | v->pcm_current=prevCenter+ | 384 | v->pcm_current=prevCenter+ |
362 | ci->blocksizes[v->lW]/4+ | 385 | ci->blocksizes[v->lW]/4+ |
363 | ci->blocksizes[v->W]/4; | 386 | ci->blocksizes[v->W]/4; |
364 | } | 387 | } |
365 | 388 | ||
366 | } | 389 | } |
@@ -389,23 +412,23 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
389 | 412 | ||
390 | /* is this a short page? */ | 413 | /* is this a short page? */ |
391 | if(b->sample_count>v->granulepos){ | 414 | if(b->sample_count>v->granulepos){ |
392 | /* corner case; if this is both the first and last audio page, | 415 | /* corner case; if this is both the first and last audio page, |
393 | then spec says the end is cut, not beginning */ | 416 | then spec says the end is cut, not beginning */ |
394 | if(vb->eofflag){ | 417 | if(vb->eofflag){ |
395 | /* trim the end */ | 418 | /* trim the end */ |
396 | /* no preceeding granulepos; assume we started at zero (we'd | 419 | /* no preceeding granulepos; assume we started at zero (we'd |
397 | have to in a short single-page stream) */ | 420 | have to in a short single-page stream) */ |
398 | /* granulepos could be -1 due to a seek, but that would result | 421 | /* granulepos could be -1 due to a seek, but that would result |
399 | in a long coun`t, not short count */ | 422 | in a long coun`t, not short count */ |
400 | 423 | ||
401 | v->pcm_current-=(b->sample_count-v->granulepos); | 424 | v->pcm_current-=(b->sample_count-v->granulepos); |
402 | }else{ | 425 | }else{ |
403 | /* trim the beginning */ | 426 | /* trim the beginning */ |
404 | v->pcm_returned+=(b->sample_count-v->granulepos); | 427 | v->pcm_returned+=(b->sample_count-v->granulepos); |
405 | if(v->pcm_returned>v->pcm_current) | 428 | if(v->pcm_returned>v->pcm_current) |
406 | v->pcm_returned=v->pcm_current; | 429 | v->pcm_returned=v->pcm_current; |
407 | } | 430 | } |
408 | 431 | ||
409 | } | 432 | } |
410 | 433 | ||
411 | } | 434 | } |
@@ -414,16 +437,16 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
414 | if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ | 437 | if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ |
415 | 438 | ||
416 | if(v->granulepos>vb->granulepos){ | 439 | if(v->granulepos>vb->granulepos){ |
417 | long extra=v->granulepos-vb->granulepos; | 440 | long extra=v->granulepos-vb->granulepos; |
418 | 441 | ||
419 | if(extra) | 442 | if(extra) |
420 | if(vb->eofflag){ | 443 | if(vb->eofflag){ |
421 | /* partial last frame. Strip the extra samples off */ | 444 | /* partial last frame. Strip the extra samples off */ |
422 | v->pcm_current-=extra; | 445 | v->pcm_current-=extra; |
423 | } /* else {Shouldn't happen *unless* the bitstream is out of | 446 | } /* else {Shouldn't happen *unless* the bitstream is out of |
424 | spec. Either way, believe the bitstream } */ | 447 | spec. Either way, believe the bitstream } */ |
425 | } /* else {Shouldn't happen *unless* the bitstream is out of | 448 | } /* else {Shouldn't happen *unless* the bitstream is out of |
426 | spec. Either way, believe the bitstream } */ | 449 | spec. Either way, believe the bitstream } */ |
427 | v->granulepos=vb->granulepos; | 450 | v->granulepos=vb->granulepos; |
428 | } | 451 | } |
429 | } | 452 | } |
@@ -441,7 +464,7 @@ int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ | |||
441 | if(pcm){ | 464 | if(pcm){ |
442 | int i; | 465 | int i; |
443 | for(i=0;i<vi->channels;i++) | 466 | for(i=0;i<vi->channels;i++) |
444 | v->pcmret[i]=v->pcm[i]+v->pcm_returned; | 467 | v->pcmret[i]=v->pcm[i]+v->pcm_returned; |
445 | *pcm=v->pcmret; | 468 | *pcm=v->pcmret; |
446 | } | 469 | } |
447 | return(v->pcm_current-v->pcm_returned); | 470 | return(v->pcm_current-v->pcm_returned); |