[xiph-commits] r13657 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Aug 29 19:40:29 PDT 2007


Author: xiphmont
Date: 2007-08-29 19:40:29 -0700 (Wed, 29 Aug 2007)
New Revision: 13657

Modified:
   trunk/vorbis/lib/block.c
   trunk/vorbis/lib/lpc.c
   trunk/vorbis/lib/mapping0.c
Log:
Fix to bug #1229



Modified: trunk/vorbis/lib/block.c
===================================================================
--- trunk/vorbis/lib/block.c	2007-08-29 18:43:39 UTC (rev 13656)
+++ trunk/vorbis/lib/block.c	2007-08-30 02:40:29 UTC (rev 13657)
@@ -403,7 +403,7 @@
 
 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 @@
       
       /* 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,

Modified: trunk/vorbis/lib/lpc.c
===================================================================
--- trunk/vorbis/lib/lpc.c	2007-08-29 18:43:39 UTC (rev 13656)
+++ trunk/vorbis/lib/lpc.c	2007-08-30 02:40:29 UTC (rev 13657)
@@ -62,6 +62,7 @@
   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 @@
   
   /* 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,11 +104,24 @@
       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.f-r*r;
+    error*=1.-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];
 
   /* we need the error value to know how big an impulse to hit the

Modified: trunk/vorbis/lib/mapping0.c
===================================================================
--- trunk/vorbis/lib/mapping0.c	2007-08-29 18:43:39 UTC (rev 13656)
+++ trunk/vorbis/lib/mapping0.c	2007-08-30 02:40:29 UTC (rev 13657)
@@ -280,22 +280,28 @@
                                      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 @@
       }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 @@
 	  _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 @@
 	  _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 @@
 	    _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 @@
 	  _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 @@
 	    _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 @@
 			   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]=



More information about the commits mailing list