1
0
Fork 0
forked from len0rd/rockbox

Fix for noise after vorbis skipping introduced in r20783 - thanks to Aoyumi and learman

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20843 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Hooper 2009-05-02 11:26:53 +00:00
parent d2ffe43e1e
commit b10ba5e8b3
2 changed files with 15 additions and 16 deletions

View file

@ -39,9 +39,6 @@ static int ilog(unsigned int v){
static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR;
static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR;
static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR;
/* if true, we have both pcm buffers in iram and we use a bufferflip.
if false, we have one in iram and one in mem, and we use a memcpy */
static bool iram_pcm_doublebuffer IBSS_ATTR;
/* pcm accumulator examples (not exhaustive): /* pcm accumulator examples (not exhaustive):
@ -154,7 +151,6 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
int i; int i;
long b_size[2]; long b_size[2];
LOOKUP_TNC *iramposw; LOOKUP_TNC *iramposw;
ogg_int32_t *internal_pcm=NULL;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
private_state *b=NULL; private_state *b=NULL;
@ -213,14 +209,12 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
_pcmp[1]=NULL; _pcmp[1]=NULL;
_pcmbp[0]=NULL; _pcmbp[0]=NULL;
_pcmbp[1]=NULL; _pcmbp[1]=NULL;
if(NULL != (v->iram_double_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
if(NULL != (internal_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
{ {
/* one-time initialisation at codec start or on switch from /* one-time initialisation at codec start or on switch from
blocksizes greater than IRAM_PCM_END to sizes that fit */ blocksizes greater than IRAM_PCM_END to sizes that fit */
for(i=0;i<vi->channels;i++) for(i=0;i<vi->channels;i++)
v->pcm[i]=&internal_pcm[i*v->pcm_storage]; v->pcm[i]=&v->iram_double_pcm[i*v->pcm_storage];
iram_pcm_doublebuffer = true;
} }
else else
{ {
@ -228,7 +222,6 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
blocksizes that fit in IRAM_PCM_END to those that don't */ blocksizes that fit in IRAM_PCM_END to those that don't */
for(i=0;i<vi->channels;i++) for(i=0;i<vi->channels;i++)
v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i]));
iram_pcm_doublebuffer = false;
} }
/* all 1 (large block) or 0 (small block) */ /* all 1 (large block) or 0 (small block) */
@ -250,6 +243,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
int vorbis_synthesis_restart(vorbis_dsp_state *v){ int vorbis_synthesis_restart(vorbis_dsp_state *v){
vorbis_info *vi=v->vi; vorbis_info *vi=v->vi;
codec_setup_info *ci; codec_setup_info *ci;
int i;
if(!v->backend_state)return -1; if(!v->backend_state)return -1;
if(!vi)return -1; if(!vi)return -1;
@ -267,6 +261,10 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){
/* indicate to synthesis code that buffer pointers no longer valid /* indicate to synthesis code that buffer pointers no longer valid
(if we're using double pcm buffer) and will need to reset them */ (if we're using double pcm buffer) and will need to reset them */
v->reset_pcmb = true; v->reset_pcmb = true;
/* also reset our copy of the double buffer pointers if we have one */
if(v->iram_double_pcm)
for(i=0;i<vi->channels;i++)
v->pcm[i]=&v->iram_double_pcm[i*v->pcm_storage];
return(0); return(0);
} }
@ -285,12 +283,11 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
private_state *b=(private_state *)v->backend_state; private_state *b=(private_state *)v->backend_state;
if(!iram_pcm_doublebuffer) if(NULL == v->iram_double_pcm)
{ {
if(v->pcm){ /* pcm buffer came from oggmalloc rather than iram */
for(i=0;i<vi->channels;i++) for(i=0;i<vi->channels;i++)
if(v->pcm[i])_ogg_free(v->pcm[i]); if(v->pcm[i])_ogg_free(v->pcm[i]);
}
} }
/* free mode lookups; these are actually vorbis_look_mapping structs */ /* 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){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
private_state *b=v->backend_state; private_state *b=v->backend_state;
int j; int j;
bool iram_pcm_doublebuffer = (NULL != v->iram_double_pcm);
if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL);

View file

@ -77,8 +77,9 @@ typedef struct vorbis_dsp_state{
void *backend_state; void *backend_state;
ogg_int32_t *iram_pcm; /* IRAM PCM buffer */ ogg_int32_t *iram_pcm; /* IRAM PCM buffer */
int iram_pcm_storage; /* size of IRAM PCM buffer */ ogg_int32_t *iram_double_pcm; /* IRAM PCM 2nd buffer */
int iram_pcm_storage; /* size of IRAM PCM buffer */
bool reset_pcmb; bool reset_pcmb;
} vorbis_dsp_state; } vorbis_dsp_state;