[xiph-commits] r13912 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Sep 28 08:21:50 PDT 2007


Author: xiphmont
Date: 2007-09-28 08:21:50 -0700 (Fri, 28 Sep 2007)
New Revision: 13912

Modified:
   trunk/sushivision/plane-2d.c
   trunk/sushivision/slider.c
   trunk/sushivision/slider.h
Log:
Nothing to see here



Modified: trunk/sushivision/plane-2d.c
===================================================================
--- trunk/sushivision/plane-2d.c	2007-09-28 01:39:26 UTC (rev 13911)
+++ trunk/sushivision/plane-2d.c	2007-09-28 15:21:50 UTC (rev 13912)
@@ -109,19 +109,84 @@
   return (float)xymul/total;
 }
 
+typedef struct {
+  int n;
+  int neg;
+  float al;
+  float lo;
+  float hi;
+  float *vals;
+  float *muls;
+  float *offs;
+} slider_map;
+
+void slidermap_init(slidermap_t *m, sv_slider_t *s){
+  sv_slice_t *sl = SLICE(s->slices[0]);
+  sv_slice_t *sa = SLICE(s->slices[1]);
+  sv_slice_t *sh = SLICE(s->slices[2]);
+  float ldel = _sv_slider_val_to_del(s,sl->thumb_val);
+  float hdel = _sv_slider_val_to_del(s,sh->thumb_val);
+
+  m->n = s->labels;
+  m->neg = s->neg;
+  m->lo = sl->thumb_val;
+  m->al = sa->thumb_val;
+  m->hi = sh->thumb_val;
+  
+  if(m->vals)free(m->vals);
+  if(m->muls)free(m->muls);
+  if(m->offs)free(m->offs);
+
+  m->vals = calloc(m->n,sizeof(*m->vals));
+  m->muls = calloc(m->n-1,sizeof(*m->muls));
+  m->offs = calloc(m->n-1,sizeof(*m->offs));
+  
+  for(j=0;j<m->n-1;j++){
+    float labeldel = 1./(s->label_vals[j+1]-s->label_vals[j]);
+    m->muls[j] = labeldel * s->idelrange * s->labelinv;
+    m->offs[j] = (j-s->label_vals[j]*s->labeldel-
+		       s->lodel*(s->labels-1))*s->idelrange*s->labelinv;
+    m->vals[j] = s->vals[j];
+  }
+  m->vals[j] = s->vals[j];
+
+}
+
+double slider_to_mapdel(slider_map *s,float v){
+  int j=s->n-1;
+
+  if(isnan(v))return NAN;
+  
+  if(s->neg){
+
+    if(v > s->al)return NAN;
+    if(v >= s->lo)return 0.;
+    if(v <= s->hi)return 1.;
+    while(--j)
+      if(v<=s->vals[j])break;
+
+  }else{
+
+    if(v < s->al)return NAN;
+    if(v <= s->lo)return 0.;
+    if(v >= s->hi)return 1.;
+    while(--j)
+      if(v>s->vals[j])break;
+
+  }
+
+  return v*s->muls[j] + s->offs[j];
+}
+
 static void slow_scale(sv_plane_t *pl, 
 		       sv_ucolor_t *work,
-		       sv_scalespace_t dx, sv_scalespace_t dy,
-		       sv_scalespace_t ix, sv_scalespace_t iy,
+		       int dw, int dh,
+		       int iw, int ih,
 		       void (*mapfunc)(int,int, _sv_lcolor_t *), 
 		       float alpha, int i){
 
   // sv_slider_t *scale= pl->scale; XXXXXXXXXXXx
   sv_ucolor_t *image = pl->image;
-  int iw = ix.pixels;
-  int ih = iy.pixels;
-  int dw = dx.pixels;
-  int dh = dy.pixels;
   sv_ccolor_t *cwork = work;
 
   if(ih!=dh || iw!=dw){
@@ -784,6 +849,14 @@
       pl->waiting--;
       pthread_mutex_unlock(pl->status_m);
       
+
+      slow_scale(pl, work, 
+		 
+		 sv_scalespace_t dx, sv_scalespace_t dy,
+		       sv_scalespace_t ix, sv_scalespace_t iy,
+		       void (*mapfunc)(int,int, _sv_lcolor_t *), 
+		       float alpha, int i){
+
       map_one_line(pl,p,i,work);
 
       pthread_mutex_lock(pl->status_m);

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2007-09-28 01:39:26 UTC (rev 13911)
+++ trunk/sushivision/slider.c	2007-09-28 15:21:50 UTC (rev 13912)
@@ -159,8 +159,8 @@
   
       s->mapfunc(rint(val*65536.f),255,&outc);
 
-  return m->mixfunc( (_sv_ucolor_t)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
-		     (_sv_ucolor_t)mix).u | 0xff000000;
+      //return m->mixfunc( (_sv_ucolor_t)(u_int32_t)((outc.a<<24) + (outc.r<<16) + (outc.g<<8) + outc.b),
+      //	     (_sv_ucolor_t)mix).u | 0xff000000;
 
       pixel[i]=_sv_mapping_calc(s->gradient,_sv_slider_pixel_to_mapdel(s,i), pixel[i]);
     
@@ -487,7 +487,9 @@
     while(--j)
       if(v>s->label_vals[j])break;
   }
-  return (j + (v-s->label_vals[j])*s->labeldel[j])*s->labelinv;
+  return (j + (v-s->label_vals[j])/
+	  (s->label_vals[j+1]-s->label_vals[j]))/
+    (ret->labels-1);
 }
 
 
@@ -791,17 +793,9 @@
        s->gradient->high != hdel){
       int j;
 
-      s->lo = sl->thumb_val;
-      s->hi = sh->thumb_val;
       s->idelrange = 1./(hdel-ldel);
       s->lodel = ldel;
 
-      for(j=0;j<s->labels-1;j++){
-	s->labeldelB[j] = s->labeldel[j] * s->idelrange * s->labelinv;
-	s->labelvalB[j] = (j-s->label_vals[j]*s->labeldel[j]-
-			   s->lodel*(s->labels-1))*s->idelrange*s->labelinv;
-      }
-
       _sv_mapping_set_lo(s->gradient,ldel);
       _sv_mapping_set_hi(s->gradient,hdel);
       _sv_slider_draw_background(s);
@@ -950,22 +944,11 @@
   ret->flags=flags;
   if(flags & _SV_SLIDER_FLAG_VERTICAL) ret->flip = 1;
 
-  ret->labelinv = 1./(ret->labels-1);
-  ret->labeldel = calloc(ret->labels-1,sizeof(*ret->labeldel));
-  for(i=0;i<ret->labels-1;i++)
-    ret->labeldel[i] = 1./(ret->label_vals[i+1]-ret->label_vals[i]);
   ret->lo = ret->label_vals[0];
   ret->hi = ret->label_vals[ret->labels-1];
   ret->lodel = 0.;
   ret->idelrange = 1.;
 
-  ret->labeldelB = calloc(ret->labels-1,sizeof(*ret->labeldelB));
-  ret->labelvalB = calloc(ret->labels-1,sizeof(*ret->labelvalB));
-  for(i=0;i<ret->labels-1;i++){
-    ret->labeldelB[i] = ret->labeldel[i] * ret->labelinv;
-    ret->labelvalB[i] = (i-ret->label_vals[i]*ret->labeldel[i])*ret->labelinv;
-  }
-
   return ret;
 }
 

Modified: trunk/sushivision/slider.h
===================================================================
--- trunk/sushivision/slider.h	2007-09-28 01:39:26 UTC (rev 13911)
+++ trunk/sushivision/slider.h	2007-09-28 15:21:50 UTC (rev 13912)
@@ -43,15 +43,8 @@
   int flags;
   
   // computation helpers
-  double labelinv;
-  double *labeldel;
-  double al;
-  double lo;
-  double hi;
   double lodel;
   double idelrange;
-  double *labeldelB;
-  double *labelvalB;
 
   double quant_num;
   double quant_denom;



More information about the commits mailing list