pike.git / src / modules / Image / togif.c

version» Context lines:

pike.git/src/modules/Image/togif.c:1:   /*      togif      Pontus Hagland, law@infovav.se    - $Id: togif.c,v 1.18 1997/10/12 21:11:12 mirar Exp $ + $Id: togif.c,v 1.19 1997/10/21 18:39:38 grubba Exp $      */      /*   **! module Image   **! note - **! $Id: togif.c,v 1.18 1997/10/12 21:11:12 mirar Exp $<br> + **! $Id: togif.c,v 1.19 1997/10/21 18:39:38 grubba Exp $<br>   **! class image   */      #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"
pike.git/src/modules/Image/togif.c:156:   #endif    return c;   }      void image_floyd_steinberg(rgb_group *rgb,int xsize,    rgbl_group *errl,    int way,int *res,    struct colortable *ct,    int closest)   { +  HIDE_GLOBAL_VARIABLES();    rgbl_group err;    int x;       if (way)    {    err.r=errl[xsize-1].r;    err.g=errl[xsize-1].g;    err.b=errl[xsize-1].b;    for (x=xsize-1; x>=0; x--)    res[x]=floyd_steinberg_add(errl+x,
pike.git/src/modules/Image/togif.c:181:    {    err.r=errl->r;    err.g=errl->g;    err.b=errl->b;    for (x=0; x<xsize; x++)    res[x]=floyd_steinberg_add(errl+x,    (x==xsize-1)?NULL:errl+x+1,    (x==0)?NULL:errl+x-1,    &err,rgb[x],ct,closest);    } +  REVEAL_GLOBAL_VARIABLES();   }      #define STD_ARENA_SIZE 16384      int image_decode_gif(struct image *dest,struct image *dest_alpha,    unsigned char *src,unsigned long len)   {    unsigned char *arena,*tmpstore,*q;    rgb_group *global_palette,*palette;    rgb_group *rgb;
pike.git/src/modules/Image/togif.c:612:       i=THIS->xsize*THIS->ysize;    rgb=THIS->img;      CHRONO("begin pack");    xs = THIS->xsize;    ys = THIS->ysize;       THREADS_ALLOW();    lzw_init(&lzw,bpp); +  THREADS_DISALLOW(); +     if (!fs)    { -  +  THREADS_ALLOW();    if (closest)    while (i--) lzw_add(&lzw,colortable_rgb_nearest(ct,*(rgb++)));    else    while (i--) lzw_add(&lzw,colortable_rgb(ct,*(rgb++))); -  } -  else -  { +  THREADS_DISALLOW(); +  } else {    rgbl_group *errb;    int w,*cres,j; -  +  /* NOTE: xalloc() is NOT thread-safe. */    errb=(rgbl_group*)xalloc(sizeof(rgbl_group)*xs);    cres=(int*)xalloc(sizeof(int)*xs); -  +  THREADS_ALLOW();    for (i=0; i<xs; i++)    errb[i].r=(rand()%(FS_SCALE*2+1))-FS_SCALE,    errb[i].g=(rand()%(FS_SCALE*2+1))-FS_SCALE,    errb[i].b=(rand()%(FS_SCALE*2+1))-FS_SCALE;       w=0; -  while (ys--) -  { +  while (ys--) {    image_floyd_steinberg(rgb,xs,errb,w=!w,cres,ct,closest);    for (j=0; j<xs; j++)    lzw_add(&lzw,cres[j]);    rgb+=xs;    } -  -  free(errb); +  THREADS_DISALLOW();    free(cres); -  +  free(errb);    }    -  +  THREADS_ALLOW();    lzw_write_last(&lzw); -  +  THREADS_DISALLOW();      CHRONO("end pack");    -  +  /* NOTE that the low_my_* functions are NOT thread-safe. +  */    for (i=0; i<(int)lzw.outpos; i+=254)    {    int wr;    if (i+254>(int)lzw.outpos) wr=lzw.outpos-i;    else wr=254;    low_my_putchar( (unsigned char)wr, &buf ); /* bytes in chunk */    low_my_binary_strcat( (char *) lzw.out+i, wr, &buf );    }    low_my_putchar( 0, &buf ); /* terminate stream */       lzw_quit(&lzw);    -  THREADS_DISALLOW(); -  +    CHRONO("done");       pop_n_elems(args);    push_string(low_free_buf(&buf));       return ct;   }      /*   **! method string gif_add()