[vorbis-dev] trivial optimization to psy.c

Andy Key scsiprog at hotmail.com
Wed Jun 28 07:20:18 PDT 2000



Hi all,

The following is a trivial patch to psy.c, but combining the two loops saves 
a percent or two (according to gprof).

=================================================================
--- psy.c	Mon Jun 19 12:05:57 2000
+++ -	Wed Jun 28 15:14:17 2000
@@ -550,12 +550,11 @@
   frameno++;
   memset(flr,0,n*sizeof(double));

-  for(i=0;i<n;i++)work[i]=fabs(f[i]);
-
-  /* find the highest peak so we know the limits */
   for(i=0;i<n;i++){
-    if(work[i]>specmax)specmax=work[i];
-  }
+    work[i]=fabs(f[i]);
+    if(work[i]>specmax)
+      specmax=work[i];
+    }
   specmax=todB(specmax);

   /* don't use the smoothed data for noise */
=================================================================

-Andy
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/



More information about the Vorbis-dev mailing list