[xiph-commits] r12467 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Feb 14 00:26:59 PST 2007


Author: xiphmont
Date: 2007-02-14 00:26:58 -0800 (Wed, 14 Feb 2007)
New Revision: 12467

Modified:
   trunk/sushivision/panel-1d.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/scale.c
   trunk/sushivision/scale.h
Log:
Correct a locking error on remap abort.



Modified: trunk/sushivision/panel-1d.c
===================================================================
--- trunk/sushivision/panel-1d.c	2007-02-14 07:35:32 UTC (rev 12466)
+++ trunk/sushivision/panel-1d.c	2007-02-14 08:26:58 UTC (rev 12467)
@@ -580,10 +580,13 @@
   int w = plot->w.allocation.width;
   int h = plot->w.allocation.height;
   int dw = w;
+  int dwt;
   sushiv_panel_t *link = (p1->link_x ? p1->link_x : p1->link_y);
   sushiv_panel2d_t *p2 = (link?link->subtype->p2:NULL);
   int i,j;
 
+  scalespace sx,sx_v,sx_i,sy;
+
   if(p1->link_x){
     dw = p2->x_v.pixels;
     p1->x_d = p2->x_d;
@@ -597,40 +600,55 @@
 
   if(plot && GTK_WIDGET_REALIZED(GTK_WIDGET(plot))){
     if(p1->flip){
-      dw = _sushiv_dimension_scales(p1->x_d, 
+      dwt = _sushiv_dimension_scales(p1->x_d, 
 				    p1->x_d->bracket[1],
 				    p1->x_d->bracket[0],
 				    h,dw,
 				    plot->scalespacing,
 				    p1->x_d->name,
-				    &p1->x,
-				    &p1->x_v,
-				    &p1->x_i);
+				    &sx,
+				    &sx_v,
+				    &sx_i);
       
-      p1->y = scalespace_linear(p1->range_bracket[0],
-				p1->range_bracket[1],
-				w,
-				plot->scalespacing,
-				p1->range_scale->legend);
+      sy = scalespace_linear(p1->range_bracket[0],
+			     p1->range_bracket[1],
+			     w,
+			     plot->scalespacing,
+			     p1->range_scale->legend);
     
     }else{
-      dw = _sushiv_dimension_scales(p1->x_d, 
+      dwt = _sushiv_dimension_scales(p1->x_d, 
 				    p1->x_d->bracket[0],
 				    p1->x_d->bracket[1],
 				    w,dw,
 				    plot->scalespacing,
 				    p1->x_d->name,
-				    &p1->x,
-				    &p1->x_v,
-				    &p1->x_i);
+				    &sx,
+				    &sx_v,
+				    &sx_i);
 
-      p1->y = scalespace_linear(p1->range_bracket[1],
-				p1->range_bracket[0],
-				h,
-				plot->scalespacing,
-				p1->range_scale->legend);
+      sy = scalespace_linear(p1->range_bracket[1],
+			     p1->range_bracket[0],
+			     h,
+			     plot->scalespacing,
+			     p1->range_scale->legend);
     }
     
+    if(sx.massaged || sx_v.massaged || sx_i.massaged){
+      fprintf(stderr,"\nX axis resolution exceeded; keeping old X.\n");
+    }else{
+      p1->x = sx;
+      p1->x_v = sx_v;
+      p1->x_i = sx_i;
+      dw=dwt;
+    }
+
+    if(sy.massaged){
+      fprintf(stderr,"\nY axis resolution exceeded; keeping old Y.\n");
+    }else{
+      p1->y = sy;
+    }
+
     if(p1->data_size != dw){
       if(p1->data_vec){
 

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-02-14 07:35:32 UTC (rev 12466)
+++ trunk/sushivision/panel-2d.c	2007-02-14 08:26:58 UTC (rev 12467)
@@ -442,6 +442,7 @@
   return 0;
 }
 
+// enter with lock
 static int _sushiv_panel2d_remap(sushiv_panel_t *p){
   sushiv_panel2d_t *p2 = p->subtype->p2;
   Plot *plot = PLOT(p->private->graph);
@@ -490,8 +491,10 @@
     if (!resample_render_y_plane(p, plot_serialno, map_serialno, 
 				 mappings+i, alphadel[i],
 				 c, x, y,
-				 y_rects[o_ynum], x_v, y_v))
+				 y_rects[o_ynum], x_v, y_v)){
+      gdk_threads_enter ();  
       goto abort;
+    }
 
     /**** render Z plane */
     

Modified: trunk/sushivision/scale.c
===================================================================
--- trunk/sushivision/scale.c	2007-02-14 07:35:32 UTC (rev 12466)
+++ trunk/sushivision/scale.c	2007-02-14 08:26:58 UTC (rev 12467)
@@ -291,6 +291,7 @@
     // itself, but it will keep things on track until later checks
     orange = 1e-30 * pixels;
     highpoint = lowpoint + orange;
+    ret.massaged = 1;
   }
 
   while(1){
@@ -330,13 +331,21 @@
     first = (long long)(lowpoint/ret.m)/step*step;
 
     if(neg){
+      /* overflow check */
       if(LLONG_MAX * ret.m < highpoint){
+	lowpoint += orange/2;
 	orange *= 2;
+	highpoint = lowpoint - orange;
+	ret.massaged = 1;
 	continue;
       }
     }else{
+      /* overflow check */
       if(LLONG_MAX * ret.m < lowpoint){
+	lowpoint -= orange/2;
 	orange *= 2;
+	highpoint = lowpoint + orange;
+	ret.massaged = 1;
 	continue;
       }
     }
@@ -345,13 +354,21 @@
       first += step;
     
     if(neg){
+      /* overflow check */
       if(LLONG_MIN * ret.m > lowpoint){
+	lowpoint += orange/2;
 	orange *= 2;
+	highpoint = lowpoint - orange;
+	ret.massaged = 1;
 	continue;
       }
     }else{
+      /* overflow check */
       if(LLONG_MIN * ret.m > highpoint){
+	lowpoint -= orange/2;
 	orange *= 2;
+	highpoint = lowpoint + orange;
+	ret.massaged = 1;
 	continue;
       }
     }
@@ -363,7 +380,10 @@
     if( first*128/128 != first ||
 	first*16*ret.m == (first*16 +step)*ret.m ||
 	(first*16+step)*ret.m == (first*16 +step*2)*ret.m){
-      orange*=2;
+      lowpoint -= orange/(neg*2);
+      orange *= 2;
+      highpoint = lowpoint + neg*orange;
+      ret.massaged = 1;
       continue;
     }
 

Modified: trunk/sushivision/scale.h
===================================================================
--- trunk/sushivision/scale.h	2007-02-14 07:35:32 UTC (rev 12466)
+++ trunk/sushivision/scale.h	2007-02-14 08:26:58 UTC (rev 12467)
@@ -37,6 +37,7 @@
   int init;
   int pixels;
   int spacing;
+  int massaged; // set if range had to be adjusted to avoid underflows
 } scalespace;
 
 int del_depth(double A, double B);



More information about the commits mailing list