[xiph-commits] r12473 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Feb 14 13:39:52 PST 2007


Author: xiphmont
Date: 2007-02-14 13:39:51 -0800 (Wed, 14 Feb 2007)
New Revision: 12473

Modified:
   trunk/sushivision/panel-2d.c
Log:
Correct scaling energy preservation algebra (helper generation used integer div, but reported energy divisor with untrucated float div)



Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-02-14 21:02:36 UTC (rev 12472)
+++ trunk/sushivision/panel-2d.c	2007-02-14 21:39:51 UTC (rev 12473)
@@ -228,6 +228,7 @@
   int bin = del / scaleden;
   del -= bin * scaleden; 
   int discscale = (scaleden>scalenum?scalenum:scaleden);
+  int total = xymul*scalenum/discscale;
 
   for(i=0;i<pw;i++){
     long del2 = del + scalenum;
@@ -242,12 +243,12 @@
     }
     
     if(del2 > scaleden && bin>=0 && bin<dw){
-      int total = xymul*scalenum/discscale;
+      int rem = total;
 
       delA[i] = (xymul * (scaleden - del)) / discscale;
       posA[i] = bin;
-      total -= delA[i];
-      total -= xymul*(sizeceil-2);
+      rem -= delA[i];
+      rem -= xymul*(sizeceil-2);
 
       while(bin+sizeceil>dw){
 	sizeceil--;
@@ -255,7 +256,7 @@
       }
 
       del2 %= scaleden;
-      delB[i] = total; // don't leak 
+      delB[i] = rem; // don't leak 
       posB[i] = bin+sizeceil;
 
     }else{
@@ -265,7 +266,7 @@
 	delB[i] = 0;
 	posB[i] = 0;
       }else{
-	delA[i] = (xymul * (del2-del)) / discscale;
+	delA[i] = xymul;
 	posA[i] = bin;
 	delB[i] = 0;
 	posB[i] = bin+1;
@@ -276,7 +277,7 @@
     bin += sizefloor;
     del = del2;
   }
-  return (float)discscale/scalenum;
+  return (float)xymul/total;
 }
 
 static inline void l_mapping_calc( void (*m)(int,int, lcolor*), 



More information about the commits mailing list