pike.git / src / modules / Image / colortable_lookup.h

version» Context lines:

pike.git/src/modules/Image/colortable_lookup.h:32:    nct_dither_line_function *dither_newline=dith->newline;    int rowpos=0,cd=1,rowcount=0;       cubs=&(nct->lu.cubicles);    if (!(cubs->cubicles))    {    int n2=cubs->r*cubs->g*cubs->b;      CHRONO("init flat/cubicles");    -  cub=cubs->cubicles=malloc(sizeof(struct nctlu_cubicle)*n2); +  cub=cubs->cubicles=calloc(sizeof(struct nctlu_cubicle), n2);       if (!cub) Pike_error("out of memory\n");       while (n2--) /* initiate all to empty */    {    cub->n=0;    cub->index=NULL;    cub++;    } /* yes, could be faster with a memset... */    }
pike.git/src/modules/Image/colortable_lookup.h:99:    cub=cubs->cubicles+r+g*red+b*redgreen;       if (!cub->index) /* need to build that cubicle */    _build_cubicle(nct,r,g,b,red,green,blue,cub);       /* now, compare with the colors in that cubicle */       m=cub->n;    ci=cub->index;    -  mindist=256*256*100; /* max dist is 256²*3 */ +  mindist=256*256*100; /* max dist is 256^2*3 */       while (m--)    {    int dist=sf.r*SQ(fe[*ci].color.r-val.r)+    sf.g*SQ(fe[*ci].color.g-val.g)+    sf.b*SQ(fe[*ci].color.b-val.b);       if (dist<mindist)    {    lc->dest=fe[*ci].color;
pike.git/src/modules/Image/colortable_lookup.h:200:    lc->src.r==rgbr &&    lc->src.g==rgbg &&    lc->src.b==rgbb)    {    NCTLU_CACHE_HIT_WRITE;    goto done_pixel;    }       lc->src=*s;    -  mindist=256*256*100; /* max dist is 256²*3 */ +  mindist=256*256*100; /* max dist is 256^2*3 */       fe=feprim;    m=mprim;       while (m--)    if (fe->no!=-1)    {    int dist=    sf.r*SQ(fe->color.r-rgbr)+    sf.g*SQ(fe->color.g-rgbg)+    sf.b*SQ(fe->color.b-rgbb);       if (dist<mindist)    {    lc->dest=fe->color;    mindist=dist; -  lc->index = DO_NOT_WARN((int)fe->no); +  lc->index = (int)fe->no;    NCTLU_CACHE_HIT_WRITE;    }       fe++;    }    else fe++;      done_pixel:    if (dither_encode)    {
pike.git/src/modules/Image/colortable_lookup.h:346:    int rowpos=0,cd=1,rowcount=0;    rgbl_group rgb;    nct_dither_encode_function *dither_encode=dith->encode;    nct_dither_got_function *dither_got=dith->got;    nct_dither_line_function *dither_newline=dith->newline;       red=cube->r; hred=red/2; redm=red-1;    green=cube->g; hgreen=green/2; greenm=green-1;    blue=cube->b; hblue=blue/2; bluem=blue-1;    -  redf = DO_NOT_WARN((float)(255.0/redm)); -  greenf = DO_NOT_WARN((float)(255.0/greenm)); -  bluef = DO_NOT_WARN((float)(255.0/bluem)); +  redf = (float)(255.0/redm); +  greenf = (float)(255.0/greenm); +  bluef = (float)(255.0/bluem);       CHRONO("begin cube map");       if (!cube->firstscale && red && green && blue)    {    if (!dither_encode)    while (n--)    {    NCTLU_CUBE_FAST_WRITE(s);    d++;
pike.git/src/modules/Image/colortable_lookup.h:388:    }    }    }    else    {    if (dith->firstline)    (dith->firstline)NCTLU_LINE_ARGS;       while (n--) /* similar to _find_cube_dist() */    { -  struct nct_scale *sc; +     int mindist; -  int i; -  int nc; +     struct lookupcache *lc;    rgbl_group val;       if (dither_encode)    {    val=dither_encode(dith,rowpos,*s);    }    else    {    val.r=s->r;
pike.git/src/modules/Image/colortable_lookup.h:424:    }       lc->src=*s;       if (red && green && blue)    {    lc->dest.r=((int)(((val.r*red+hred)>>8)*redf));    lc->dest.g=((int)(((val.g*green+hgreen)>>8)*greenf));    lc->dest.b=((int)(((val.b*blue+hblue)>>8)*bluef));    -  lc->index=i= +  lc->index=    ((val.r*red+hred)>>8)+    (((val.g*green+hgreen)>>8)+    ((val.b*blue+hblue)>>8)*green)*red;       NCTLU_CACHE_HIT_WRITE;       mindist=    sf.r*SQ(val.r-lc->dest.r)+    sf.g*SQ(val.g-lc->dest.g)+    sf.b*SQ(val.b-lc->dest.b);    }    else    {    mindist=10000000; -  i=0; +     }       if (mindist>=cube->disttrig)    {    /* check scales to get better distance if possible */ -  +  int i; +  int nc=cube->r*cube->g*cube->b; +  struct nct_scale *sc=cube->firstscale;    -  nc=cube->r*cube->g*cube->b; -  sc=cube->firstscale; +     while (sc)    {    /* what step is closest? project... */    -  i = DOUBLE_TO_INT((sc->steps * +  i = (int)((sc->steps *    (((int)val.r-(int)sc->low.r)*sc->vector.r +    ((int)val.g-(int)sc->low.g)*sc->vector.g +    ((int)val.b-(int)sc->low.b)*sc->vector.b)) *    sc->invsqvector);       if (i<0) i=0; else if (i>=sc->steps) i=sc->steps-1;    if (sc->no[i]>=nc)    {    double f= i * sc->mqsteps; -  int drgbr = sc->low.r + DOUBLE_TO_INT(sc->vector.r*f); -  int drgbg = sc->low.g + DOUBLE_TO_INT(sc->vector.g*f); -  int drgbb = sc->low.b + DOUBLE_TO_INT(sc->vector.b*f); +  int drgbr = sc->low.r + (int)(sc->vector.r*f); +  int drgbg = sc->low.g + (int)(sc->vector.g*f); +  int drgbb = sc->low.b + (int)(sc->vector.b*f);       int ldist=sf.r*SQ(val.r-drgbr)+    sf.g*SQ(val.g-drgbg)+sf.b*SQ(val.b-drgbb);       if (ldist<mindist)    {    lc->dest.r=(unsigned char)drgbr;    lc->dest.g=(unsigned char)drgbg;    lc->dest.b=(unsigned char)drgbb;    lc->index=sc->no[i];
pike.git/src/modules/Image/colortable_lookup.h:554:    return &NCTLU_FLAT_RIGID_NAME;    case NCT_CUBICLES:   #ifdef COLORTABLE_DEBUG    fprintf(stderr,    "COLORTABLE " DEFINETOSTR(NCTLU_SELECT_FUNCTION) ":"    DEFINETOSTR(NCTLU_DESTINATION) " => "    DEFINETOSTR(NCTLU_FLAT_CUBICLES_NAME) "\n");   #endif /* COLORTABLE_DEBUG */    return &NCTLU_FLAT_CUBICLES_NAME;    } -  /* FALL_THROUGH */ +  /* FALLTHRU */       default:    Pike_fatal("lookup select (%s:%d) couldn't find the lookup mode\n",    __FILE__,__LINE__);    } -  /* NOT_REACHED */ -  return 0; +  UNREACHABLE(return 0);   }      int NCTLU_EXECUTE_FUNCTION(struct neo_colortable *nct,    rgb_group *s,    NCTLU_DESTINATION *d,    int len,    int rowlen)   {    struct nct_dither dith;       if (nct->type==NCT_NONE) return 0;       image_colortable_initiate_dither(nct,&dith,rowlen);    (NCTLU_SELECT_FUNCTION(nct))(s,d,len,nct,&dith,rowlen);    image_colortable_free_dither(&dith);       return 1;   }