summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Hooper <dave@beermex.com>2009-05-02 11:26:53 +0000
committerDave Hooper <dave@beermex.com>2009-05-02 11:26:53 +0000
commitb10ba5e8b34eaac0c4b72bcf3be3db180c43126a (patch)
tree3e178987f029637c65eea684579b7475f00c0c7b
parentd2ffe43e1e6993174da4d58cc1a0998330c37b90 (diff)
downloadrockbox-b10ba5e8b34eaac0c4b72bcf3be3db180c43126a.zip
rockbox-b10ba5e8b34eaac0c4b72bcf3be3db180c43126a.tar.gz
rockbox-b10ba5e8b34eaac0c4b72bcf3be3db180c43126a.tar.bz2
rockbox-b10ba5e8b34eaac0c4b72bcf3be3db180c43126a.tar.xz
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
-rw-r--r--apps/codecs/libtremor/block.c26
-rw-r--r--apps/codecs/libtremor/ivorbiscodec.h5
2 files changed, 15 insertions, 16 deletions
diff --git a/apps/codecs/libtremor/block.c b/apps/codecs/libtremor/block.c
index eb087e1..3947b90 100644
--- a/apps/codecs/libtremor/block.c
+++ b/apps/codecs/libtremor/block.c
@@ -39,9 +39,6 @@ static int ilog(unsigned int v){
static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR;
static ogg_int32_t* _pcmbp[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):
@@ -154,7 +151,6 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
int i;
long b_size[2];
LOOKUP_TNC *iramposw;
- ogg_int32_t *internal_pcm=NULL;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
private_state *b=NULL;
@@ -213,14 +209,12 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
_pcmp[1]=NULL;
_pcmbp[0]=NULL;
_pcmbp[1]=NULL;
-
- if(NULL != (internal_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
+ if(NULL != (v->iram_double_pcm = iram_malloc(vi->channels*v->pcm_storage*sizeof(ogg_int32_t))))
{
/* one-time initialisation at codec start or on switch from
blocksizes greater than IRAM_PCM_END to sizes that fit */
for(i=0;i<vi->channels;i++)
- v->pcm[i]=&internal_pcm[i*v->pcm_storage];
- iram_pcm_doublebuffer = true;
+ v->pcm[i]=&v->iram_double_pcm[i*v->pcm_storage];
}
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 */
for(i=0;i<vi->channels;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) */
@@ -250,6 +243,7 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
int vorbis_synthesis_restart(vorbis_dsp_state *v){
vorbis_info *vi=v->vi;
codec_setup_info *ci;
+ int i;
if(!v->backend_state)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
(if we're using double pcm buffer) and will need to reset them */
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);
}
@@ -285,12 +283,11 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
private_state *b=(private_state *)v->backend_state;
- if(!iram_pcm_doublebuffer)
+ if(NULL == v->iram_double_pcm)
{
- if(v->pcm){
- for(i=0;i<vi->channels;i++)
- if(v->pcm[i])_ogg_free(v->pcm[i]);
- }
+ /* pcm buffer came from oggmalloc rather than iram */
+ for(i=0;i<vi->channels;i++)
+ if(v->pcm[i])_ogg_free(v->pcm[i]);
}
/* 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;
private_state *b=v->backend_state;
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);
diff --git a/apps/codecs/libtremor/ivorbiscodec.h b/apps/codecs/libtremor/ivorbiscodec.h
index a9526d5..c651aad 100644
--- a/apps/codecs/libtremor/ivorbiscodec.h
+++ b/apps/codecs/libtremor/ivorbiscodec.h
@@ -77,8 +77,9 @@ typedef struct vorbis_dsp_state{
void *backend_state;
- ogg_int32_t *iram_pcm; /* IRAM PCM buffer */
- int iram_pcm_storage; /* size of IRAM PCM buffer */
+ ogg_int32_t *iram_pcm; /* 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;
} vorbis_dsp_state;