diff --git a/src/modules/image/image.h b/src/modules/image/image.h index 222d10773dbebfe59b53a99768c39b57374536c6..013cc34dcf4358d8df0d954c30e8935887b20c31 100644 --- a/src/modules/image/image.h +++ b/src/modules/image/image.h @@ -1,11 +1,21 @@ -/* $Id: image.h,v 1.12 1996/12/01 00:01:14 law Exp $ */ +/* $Id: image.h,v 1.13 1996/12/01 04:08:18 law Exp $ */ #define MAX_NUMCOL 32768 -#define QUANT_MAP_BITS 4 -#define QUANT_MAP_SKIP_BITS (8-(QUANT_MAP_BITS)) -#define QUANT_MAP_THIS(X) ((X)>>QUANT_MAP_SKIP_BITS) -#define QUANT_MAP_REAL (1L<<QUANT_MAP_BITS) -#define QUANT_SELECT_CACHE 5 + +#define QUANT_MAP_BITSR 3 +#define QUANT_MAP_SKIP_BITSR (8-(QUANT_MAP_BITSR)) +#define QUANT_MAP_THISR(X) ((X)>>QUANT_MAP_SKIP_BITSR) +#define QUANT_MAP_REALR (1L<<QUANT_MAP_BITSR) +#define QUANT_MAP_BITSG 8 +#define QUANT_MAP_SKIP_BITSG (8-(QUANT_MAP_BITSG)) +#define QUANT_MAP_THISG(X) ((X)>>QUANT_MAP_SKIP_BITSG) +#define QUANT_MAP_REALG (1L<<QUANT_MAP_BITSG) +#define QUANT_MAP_BITSB 2 +#define QUANT_MAP_SKIP_BITSB (8-(QUANT_MAP_BITSB)) +#define QUANT_MAP_THISB(X) ((X)>>QUANT_MAP_SKIP_BITSB) +#define QUANT_MAP_REALB (1L<<QUANT_MAP_BITSB) + +#define QUANT_SELECT_CACHE 4 #define COLOURTYPE unsigned char @@ -47,7 +57,7 @@ struct colortable unsigned char cl; unsigned char used; struct map_entry *next; - } map[QUANT_MAP_REAL][QUANT_MAP_REAL][QUANT_MAP_REAL]; + } map[QUANT_MAP_REALR][QUANT_MAP_REALG][QUANT_MAP_REALB]; struct rgb_cache { rgb_group index; diff --git a/src/modules/image/quant.c b/src/modules/image/quant.c index 90a1a4baf4a6e8b14874b34b4498f62c8f1377db..b60fcaf89b6bd287a4d7894471ef4442f5cfdae2 100644 --- a/src/modules/image/quant.c +++ b/src/modules/image/quant.c @@ -1,4 +1,4 @@ -/* $Id: quant.c,v 1.13 1996/11/22 20:28:18 law Exp $ */ +/* $Id: quant.c,v 1.14 1996/12/01 04:08:20 law Exp $ */ /* @@ -26,12 +26,12 @@ David K /* #define QUANT_DEBUG #define QUANT_DEBUG_DEEP -#define QUANT_CHRONO +#define QUANT_DEBUG_RGB */ /**********************************************************************/ -#ifdef QUANT_CHRONO +#if 0 #include <sys/resource.h> #define CHRONO(X) chrono(X) @@ -249,12 +249,12 @@ static void sort_tbl(rgb_hashtbl *ht, lower.r,lower.g,lower.b,upper.r,upper.g,upper.b); fprintf(stderr,"[%d,%d,%d] - [%d,%d,%d]\n", - QUANT_MAP_THIS(lower.r), - QUANT_MAP_THIS(lower.g), - QUANT_MAP_THIS(lower.b), - QUANT_MAP_THIS(upper.r), - QUANT_MAP_THIS(upper.g), - QUANT_MAP_THIS(upper.b)); + QUANT_MAP_THISR(lower.r), + QUANT_MAP_THISG(lower.g), + QUANT_MAP_THISB(lower.b), + QUANT_MAP_THISR(upper.r), + QUANT_MAP_THISG(upper.g), + QUANT_MAP_THISB(upper.b)); #endif @@ -363,26 +363,26 @@ static void sort_tbl(rgb_hashtbl *ht, lower.r, lower.g, lower.b, upper.r, upper.g, upper.b, (upper.r-lower.r+1)*(upper.g-lower.g+1)*(upper.b-lower.b+1)); fprintf(stderr,"[%d,%d,%d] - [%d,%d,%d]\n", - QUANT_MAP_THIS(lower.r), - QUANT_MAP_THIS(lower.g), - QUANT_MAP_THIS(lower.b), - QUANT_MAP_THIS(upper.r), - QUANT_MAP_THIS(upper.g), - QUANT_MAP_THIS(upper.b)); + QUANT_MAP_THISR(lower.r), + QUANT_MAP_THISG(lower.g), + QUANT_MAP_THISB(lower.b), + QUANT_MAP_THISR(upper.r), + QUANT_MAP_THISG(upper.g), + QUANT_MAP_THISB(upper.b)); #endif #ifdef QUANT_DEBUG #ifndef QUANT_DEBUG_DEEP fprintf(stderr,"[%d,%d,%d]-[%d,%d,%d] = %lu (%d,%d,%d)\n", - QUANT_MAP_THIS(lower.r), QUANT_MAP_THIS(lower.g), QUANT_MAP_THIS(lower.b), - QUANT_MAP_THIS(upper.r), QUANT_MAP_THIS(upper.g), QUANT_MAP_THIS(upper.b), + QUANT_MAP_THISR(lower.r), QUANT_MAP_THISR(lower.g), QUANT_MAP_THISB(lower.b), + QUANT_MAP_THISR(upper.r), QUANT_MAP_THISG(upper.g), QUANT_MAP_THISB(upper.b), idx, ct->clut[idx].r,ct->clut[idx].g,ct->clut[idx].b); #endif #endif - for(r = QUANT_MAP_THIS(lower.r); r <= QUANT_MAP_THIS(upper.r); r++) - for(g = QUANT_MAP_THIS(lower.g); g <= QUANT_MAP_THIS(upper.g); g++) - for(b = QUANT_MAP_THIS(lower.b); b <= QUANT_MAP_THIS(upper.b); b++) + for(r = QUANT_MAP_THISR(lower.r); r <= QUANT_MAP_THISR(upper.r); r++) + for(g = QUANT_MAP_THISG(lower.g); g <= QUANT_MAP_THISG(upper.g); g++) + for(b = QUANT_MAP_THISB(lower.b); b <= QUANT_MAP_THISB(upper.b); b++) { #ifdef QUANT_DEBUG_DEEP fprintf(stderr,"%*s[%d,%d,%d] = %lu (%d,%d,%d)\n",level,"", @@ -594,15 +594,15 @@ int colortable_rgb(struct colortable *ct,rgb_group rgb) ct->cache->index.b==rgb.b) return ct->cache->value; - feme=me=&(ct->map[QUANT_MAP_THIS(rgb.r)] - [QUANT_MAP_THIS(rgb.g)] - [QUANT_MAP_THIS(rgb.b)]); + feme=me=&(ct->map[QUANT_MAP_THISR(rgb.r)] + [QUANT_MAP_THISG(rgb.g)] + [QUANT_MAP_THISB(rgb.b)]); #ifdef QUANT_DEBUG_RGB fprintf(stderr,"%d,%d,%d -> %lu %lu %lu: ",rgb.r,rgb.g,rgb.b, - QUANT_MAP_THIS(rgb.r), - QUANT_MAP_THIS(rgb.g), - QUANT_MAP_THIS(rgb.b)); + QUANT_MAP_THISR(rgb.r), + QUANT_MAP_THISG(rgb.g), + QUANT_MAP_THISB(rgb.b)); fprintf(stderr,"%lx %d,%d,%d %lu ",me,ct->clut[me->cl].r,ct->clut[me->cl].g,ct->clut[me->cl].b,me->cl); if (!me->used) { fprintf(stderr,"unused "); } #endif @@ -679,11 +679,11 @@ fprintf(stderr," -> %lu: %d,%d,%d\n",best, void colortable_free(struct colortable *ct) { int r,g,b; - for (r=0; r<QUANT_MAP_REAL; r++) + for (r=0; r<QUANT_MAP_REALR; r++) { - for (g=0; g<QUANT_MAP_REAL; g++) + for (g=0; g<QUANT_MAP_REALG; g++) { - for (b=0; b<QUANT_MAP_REAL; b++) + for (b=0; b<QUANT_MAP_REALB; b++) { struct map_entry *me; while (me=ct->map[r][g][b].next) diff --git a/src/modules/image/togif.c b/src/modules/image/togif.c index 18b32ac4afa0174fbe6cf30bd4e35485575f6eec..0f5916aaef1e2f447a925956bcf798cf083abde3 100644 --- a/src/modules/image/togif.c +++ b/src/modules/image/togif.c @@ -1,4 +1,4 @@ -/* $Id: togif.c,v 1.18 1996/11/30 13:14:41 law Exp $ */ +/* $Id: togif.c,v 1.19 1996/12/01 04:08:21 law Exp $ */ /* togif @@ -184,6 +184,8 @@ struct pike_string * struct lzw lzw; int colors,bpp; +CHRONO("image_encode_gif begin"); + buf.s.str=NULL; initialize_buf(&buf); @@ -249,6 +251,8 @@ struct pike_string * i=img->xsize*img->ysize; rgb=img->img; +CHRONO("image_encode_gif header done"); + lzw_init(&lzw,bpp); if (!fs) while (i--) lzw_add(&lzw,colortable_rgb(ct,*(rgb++))); @@ -280,6 +284,8 @@ struct pike_string * lzw_write_last(&lzw); +CHRONO("lzw done"); + for (i=0; i<(int)lzw.outpos; i+=254) { int wr; @@ -290,10 +296,14 @@ struct pike_string * } low_my_putchar( 0, &buf ); /* terminate stream */ +CHRONO("image_encode_gif wrote ok"); + lzw_quit(&lzw); low_my_putchar( ';', &buf ); /* end gif file */ - + +CHRONO("image_encode_gif done"); + return low_free_buf(&buf); }