Commit 7727de5c authored by Monty's avatar Monty

Fix to bug #1229


svn path=/trunk/vorbis/; revision=13657
parent f50cbf1c
......@@ -403,7 +403,7 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
static void _preextrapolate_helper(vorbis_dsp_state *v){
int i;
int order=32;
int order=16;
float *lpc=alloca(order*sizeof(*lpc));
float *work=alloca(v->pcm_current*sizeof(*work));
long j;
......@@ -417,7 +417,18 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){
/* prime as above */
vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
#if 0
if(v->vi->channels==2){
if(i==0)
_analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0);
else
_analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0);
}else{
_analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0);
}
#endif
/* run the predictor filter */
vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
order,
......
......@@ -62,6 +62,7 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
double *aut=alloca(sizeof(*aut)*(m+1));
double *lpc=alloca(sizeof(*lpc)*(m));
double error;
double epsilon;
int i,j;
/* autocorrelation, p+1 lag coefficients */
......@@ -74,14 +75,16 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
/* Generate lpc coefficients from autocorr values */
error=aut[0];
/* set our noise floor to about -100dB */
error=aut[0] * (1. + 1e-10);
epsilon=1e-9*aut[0]+1e-10;
for(i=0;i<m;i++){
double r= -aut[i+1];
if(error==0){
memset(lpci,0,m*sizeof(*lpci));
return 0;
if(error<epsilon){
memset(lpc+i,0,(m-i)*sizeof(*lpc));
goto done;
}
/* Sum up this iteration's reflection coefficient; note that in
......@@ -101,9 +104,22 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp;
}
if(i%2)lpc[j]+=lpc[j]*r;
if(i&1)lpc[j]+=lpc[j]*r;
error*=1.-r*r;
error*=1.f-r*r;
}
done:
/* slightly damp the filter */
{
double g = .99;
double damp = g;
for(j=0;j<m;j++){
lpc[j]*=damp;
damp*=g;
}
}
for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
......
......@@ -280,22 +280,28 @@ static int mapping0_forward(vorbis_block *vb){
next major model upgrade. */
#if 0
if(vi->channels==2)
if(vi->channels==2){
if(i==0)
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
else
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("pcm",seq,pcm,n,0,0,total-n/2);
}
#endif
/* window the PCM data */
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
#if 0
if(vi->channels==2)
if(vi->channels==2){
if(i==0)
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
else
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("windowed",seq,pcm,n,0,0,total-n/2);
}
#endif
/* transform the PCM data */
......@@ -349,6 +355,8 @@ static int mapping0_forward(vorbis_block *vb){
}else{
_analysis_output("fftR",seq,logfft,n/2,1,0,0);
}
}else{
_analysis_output("fft",seq,logfft,n/2,1,0,0);
}
#endif
......@@ -419,6 +427,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("noiseL",seq,noise,n/2,1,0,0);
else
_analysis_output("noiseR",seq,noise,n/2,1,0,0);
}else{
_analysis_output("noise",seq,noise,n/2,1,0,0);
}
#endif
......@@ -438,6 +448,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("toneL",seq,tone,n/2,1,0,0);
else
_analysis_output("toneR",seq,tone,n/2,1,0,0);
}else{
_analysis_output("tone",seq,tone,n/2,1,0,0);
}
#endif
......@@ -465,6 +477,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
else
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
}else{
_analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0);
}
}
#endif
......@@ -476,6 +490,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("mask1L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask1R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask1",seq,logmask,n/2,1,0,0);
}
#endif
......@@ -508,6 +524,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("mask2L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask2R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask2",seq,logmask,n/2,1,0,0);
}
#endif
......@@ -526,11 +544,14 @@ static int mapping0_forward(vorbis_block *vb){
logmdct);
#if 0
if(vi->channels==2)
if(vi->channels==2){
if(i==0)
_analysis_output("mask0L",seq,logmask,n/2,1,0,0);
else
_analysis_output("mask0R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask0",seq,logmask,n/2,1,0,0);
}
#endif
floor_posts[i][0]=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment