[xiph-cvs] cvs commit: vorbis/lib psy.c

Monty xiphmont at xiph.org
Thu Feb 1 18:52:35 PST 2001



xiphmont    01/02/01 18:52:35

  Modified:    lib      psy.c
  Log:
  Two bugfixes (float) not (float *) and an optimization to
  bark_noise_median by Atilla Padar.
  
  Monty

Revision  Changes    Path
1.40      +11 -10    vorbis/lib/psy.c

Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- psy.c	2001/02/01 02:10:55	1.39
+++ psy.c	2001/02/02 02:52:34	1.40
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.39 2001/02/01 02:10:55 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.40 2001/02/02 02:52:34 xiphmont Exp $
 
  ********************************************************************/
 
@@ -207,8 +207,8 @@
     p->octave[i]=toOC((i*.5f+.25f)*rate/n)*(1<<(p->shiftoc+1))+.5f;
 
   p->tonecurves=_ogg_malloc(P_BANDS*sizeof(float **));
-  p->noisemedian=_ogg_malloc(n*sizeof(float *));
-  p->noiseoffset=_ogg_malloc(n*sizeof(float *));
+  p->noisemedian=_ogg_malloc(n*sizeof(float));
+  p->noiseoffset=_ogg_malloc(n*sizeof(float));
   p->peakatt=_ogg_malloc(P_BANDS*sizeof(float *));
   for(i=0;i<P_BANDS;i++){
     p->tonecurves[i]=_ogg_malloc(P_LEVELS*sizeof(float *));
@@ -560,8 +560,8 @@
 
   for(i=0;i<n;i++){
     /* find new lo/hi */
-    bi=b[i];
-    for(;hi<n && (hi<i+himin || b[hi]<=bi+hiwidth);hi++){
+    bi=b[i]+hiwidth;
+    for(;hi<n && (hi<i+himin || b[hi]<=bi);hi++){
       int bin=BIN(f[hi]);
       if(bin>LASTBIN)bin=LASTBIN;
       if(bin<0)bin=0;
@@ -571,7 +571,8 @@
       else
         countbelow++;
     }
-    for(;lo<i && lo+lomin<i && b[lo]+lowidth<=bi;lo++){
+    bi=b[i]-lowidth;
+    for(;lo<i && lo+lomin<i && b[lo]<=bi;lo++){
       int bin=BIN(f[lo]);
       if(bin>LASTBIN)bin=LASTBIN;
       if(bin<0)bin=0;
@@ -584,16 +585,16 @@
 
     /* move the median if needed */
     if(countabove+countbelow){
-      threshi = thresh[i];
+      threshi = thresh[i]*(countabove+countbelow);
 
-      while((countabove+countbelow)*threshi>countbelow && median>0){
+      while(threshi>countbelow && median>0){
         median--;
         countabove-=radix[median];
         countbelow+=radix[median];
       }
 
-      while(median<LASTBIN && 
-	    (countabove+countbelow)*thresh[i]<(countbelow-radix[median])){
+      while(threshi<(countbelow-radix[median]) &&
+	    median<LASTBIN){
         countabove+=radix[median];
         countbelow-=radix[median];
         median++;

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list