[xiph-commits] r12264 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Dec 29 17:08:55 PST 2006


Author: xiphmont
Date: 2006-12-29 17:08:53 -0800 (Fri, 29 Dec 2006)
New Revision: 12264

Modified:
   trunk/sushivision/example_fractal.c
   trunk/sushivision/example_submain.c
   trunk/sushivision/objective.c
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/sushivision.h
Log:
extend objective interface to allow returning of vectors in the future.



Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/example_fractal.c	2006-12-30 01:08:53 UTC (rev 12264)
@@ -27,20 +27,22 @@
 sushiv_instance_t *s;
 #define MAX_ITER 1024
 
-static double fractal_objective(double *d){
+static void fractal_objective(double *d, double *ret){
   int i;
   double z, zi, zz;
   const double c=d[0],ci=d[1];
 
+  *ret=NAN;
   z = d[2]; zi = d[3];
   for(i=0;i<MAX_ITER;i++){
     zz = z*z - zi*zi + c;
     zi = 2.0*z*zi + ci;
     z  = zz;
-    if (z*z + zi*zi > 4.0) return (double)i/MAX_ITER;
+    if (z*z + zi*zi > 4.0){
+      *ret = (double)i/MAX_ITER;
+      return;
+    }
   }
-
-  return NAN;
 }
 
 int sushiv_submain(int argc, char *argv[]){

Modified: trunk/sushivision/example_submain.c
===================================================================
--- trunk/sushivision/example_submain.c	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/example_submain.c	2006-12-30 01:08:53 UTC (rev 12264)
@@ -29,7 +29,7 @@
 /* time, blocksz, amp_0, amp_del, freq_0, phase_0, phase_del */
 int funcsize=64;
 double function[64];
-static double fourier_objective(double *d){
+static void fourier_objective(double *d, double *ret){
   int i;
   double re_obj=0;
   double im_obj=0;
@@ -44,7 +44,7 @@
   re_obj/=funcsize;
 
   obj = sqrt(im_obj*im_obj + re_obj*re_obj);
-  return todB(obj);
+  *ret = todB(obj);
 
 }
 

Modified: trunk/sushivision/objective.c
===================================================================
--- trunk/sushivision/objective.c	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/objective.c	2006-12-30 01:08:53 UTC (rev 12264)
@@ -30,7 +30,7 @@
 			 const char *name,
 			 unsigned scalevals,
 			 double *scaleval_list,
-			 double(*callback)(double *),
+			 void(*callback)(double *,double *),
 			 unsigned flags){
   sushiv_objective_t *o;
   

Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/panel-1d.c	2006-12-30 01:08:53 UTC (rev 12264)
@@ -367,7 +367,7 @@
       
       /* compute value for this objective for this pixel */
       dim_vals[x_d] = (x_max-x_min) * inv_w * j + x_min;
-      work[j] = o->callback(dim_vals);
+      o->callback(dim_vals,work+j);
       
     }
     

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/panel-2d.c	2006-12-30 01:08:53 UTC (rev 12264)
@@ -314,7 +314,7 @@
 
       /* compute value for this objective for this pixel */
       dim_vals[x_d] = (x_max-x_min) * inv_w * j + x_min;
-      work[j] = o->callback(dim_vals);
+      o->callback(dim_vals,work+j);
       
     }
     

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2006-12-30 00:40:36 UTC (rev 12263)
+++ trunk/sushivision/sushivision.h	2006-12-30 01:08:53 UTC (rev 12264)
@@ -80,7 +80,7 @@
   sushiv_scale_t *scale;
   unsigned flags;
 
-  double (*callback)(double[]);
+  void (*callback)(double *,double *);
   sushiv_instance_t *sushi;
   sushiv_objective_internal_t *private;
 };
@@ -134,7 +134,7 @@
 				const char *name,
 				unsigned scalevals, 
 				double *scaleval_list,
-				double (*callback)(double *),
+				void (*callback)(double *, double *),
 				unsigned flags);
 
 extern int sushiv_new_panel_2d(sushiv_instance_t *s,



More information about the commits mailing list