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

Monty xiphmont at xiph.org
Sun Jun 30 22:29:42 PDT 2002



xiphmont    02/06/30 22:29:42

  Modified:    lib      psy.c
  Log:
  patch a nasty bounds bug introduced a week or two ago.  It could nuke
  bass randomly.

Revision  Changes    Path
1.71      +6 -6      vorbis/lib/psy.c

Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- psy.c	2002/06/30 08:31:00	1.70
+++ psy.c	2002/07/01 05:29:41	1.71
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.70 2002/06/30 08:31:00 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.71 2002/07/01 05:29:41 xiphmont Exp $
 
  ********************************************************************/
 
@@ -272,8 +272,8 @@
   p->eighth_octave_lines=gi->eighth_octave_lines;
   p->shiftoc=rint(log(gi->eighth_octave_lines*8.f)/log(2.f))-1;
 
-  p->firstoc=toOC(.25f*rate/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines;
-  maxoc=toOC((n*.5f-.25f)*rate/n)*(1<<(p->shiftoc+1))+.5f;
+  p->firstoc=toOC(.25f*rate*.5/n)*(1<<(p->shiftoc+1))-gi->eighth_octave_lines;
+  maxoc=toOC((n+.25f)*rate*.5/n)*(1<<(p->shiftoc+1))+.5f;
   p->total_octave_lines=maxoc-p->firstoc+1;
   p->ath=_ogg_malloc(n*sizeof(*p->ath));
 
@@ -311,7 +311,7 @@
   }
 
   for(i=0;i<n;i++)
-    p->octave[i]=toOC(((i+.25f)*.5)*rate/n)*(1<<(p->shiftoc+1))+.5f;
+    p->octave[i]=toOC((i+.25f)*.5*rate/n)*(1<<(p->shiftoc+1))+.5f;
 
   p->tonecurves=setup_tone_curves(vi->toneatt,rate*.5/n,n,
                                   vi->tone_centerboost,vi->tone_decay);
@@ -494,6 +494,7 @@
 }
 
 /* bleaugh, this is more complicated than it needs to be */
+#include<stdio.h>
 static void max_seeds(vorbis_look_psy *p,
                       float *seed,
                       float *flr){
@@ -505,6 +506,7 @@
   seed_chase(seed,linesper,n); /* for masking */
  
   pos=p->octave[0]-p->firstoc-(linesper>>1);
+
   while(linpos+1<p->n){
     float minV=seed[pos];
     long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc;
@@ -515,7 +517,6 @@
         minV=seed[pos];
     }
     
-    /* seed scale is log.  Floor is linear.  Map back to it */
     end=pos+p->firstoc;
     for(;linpos<p->n && p->octave[linpos]<=end;linpos++)
       if(flr[linpos]<minV)flr[linpos]=minV;
@@ -962,7 +963,6 @@
   }
 }
 
-#include <stdio.h>
 void _vp_noise_normalize(vorbis_look_psy *p,
                          float *in,float *out,int *sortedindex){
   int flag=0,i,j=0,n=p->n;

<p><p><p>--- >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