From effd705454e7d2a86dba60497b92805c57a8bcd1 Mon Sep 17 00:00:00 2001 From: xiphmont Date: Fri, 28 Sep 2007 15:21:50 +0000 Subject: [PATCH] Nothing to see here git-svn-id: http://svn.xiph.org/trunk@13912 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- sushivision/plane-2d.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++---- sushivision/slider.c | 27 +++------------- sushivision/slider.h | 7 ----- 3 files changed, 84 insertions(+), 35 deletions(-) diff --git a/sushivision/plane-2d.c b/sushivision/plane-2d.c index 60c5ac13f..e4bbdc35f 100644 --- a/sushivision/plane-2d.c +++ b/sushivision/plane-2d.c @@ -109,19 +109,84 @@ static float slow_scale_map(sv_scalespace_t *to, sv_scalespace_t *from, 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;jn-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 @@ static int image_work(sv_plane_t *in, sv_panel_t *p){ 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); diff --git a/sushivision/slider.c b/sushivision/slider.c index 0a42f42af..326be93bd 100644 --- a/sushivision/slider.c +++ b/sushivision/slider.c @@ -159,8 +159,8 @@ static void _sv_slider_draw_background(_sv_slider_t *s){ 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 @@ double _sv_slider_val_to_del(_sv_slider_t *s,double v){ 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 @@ static void update_gradient(_sv_slider_t *s){ 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;jlabels-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 @@ _sv_slider_t *_sv_slider_new(_sv_slice_t **slices, int num_slices, char **labels 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;ilabels-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;ilabels-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; } diff --git a/sushivision/slider.h b/sushivision/slider.h index 7598494fe..0058be5b3 100644 --- a/sushivision/slider.h +++ b/sushivision/slider.h @@ -43,15 +43,8 @@ struct _sv_slider { 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; -- 2.11.4.GIT