void
quant_makemap(i_quantize *quant, i_img **imgs, int count) {
- i_color temp;
#ifdef HAVE_LIBGIF
/* giflib does it's own color table generation */
if (quant->translate == pt_giflib)
*/
i_palidx *quant_translate(i_quantize *quant, i_img *img) {
i_palidx *result;
- mm_log((1, "quant_translate(quant %p, img %p)\n", quant, img));
+ mm_log((1, "quant_translate(quant %p, img %p)\n", quant, img));
- result = mymalloc(img->xsize * img->ysize);
+ result = mymalloc(img->xsize * img->ysize);
switch (quant->translate) {
#ifdef HAVE_LIBGIF
case pt_closest:
translate_closest(quant, img, result);
break;
-
+
case pt_errdiff:
translate_errdiff(quant, img, result);
break;
-
+
case pt_perturb:
default:
translate_addi(quant, img, result);
break;
}
-
+
return result;
}
i_color col;
- mm_log((1,"i_writegif(quant %p, img %p, out %p)\n", quant, img, out));
+ mm_log((1,"translate_giflib(quant %p, img %p, out %p)\n", quant, img, out));
/*if (!(im->channels==1 || im->channels==3)) { fprintf(stderr,"Unable to write gif, improper colorspace.\n"); exit(3); }*/
}
if ((GreenBuffer = (GifByteType *) mymalloc((unsigned int) Size)) == NULL) {
m_fatal(0,"Failed to allocate memory required, aborted.");
- free(RedBuffer);
+ myfree(RedBuffer);
return;
}
if ((BlueBuffer = (GifByteType *) mymalloc((unsigned int) Size)) == NULL) {
m_fatal(0,"Failed to allocate memory required, aborted.");
- free(RedBuffer);
- free(GreenBuffer);
+ myfree(RedBuffer);
+ myfree(GreenBuffer);
return;
}
}
}
- free(RedBuffer);
- if (img->channels == 3) { free(GreenBuffer); free(BlueBuffer); }
+ myfree(RedBuffer);
+ if (img->channels == 3) { myfree(GreenBuffer); myfree(BlueBuffer); }
/* copy over the color map */
for (i = 0; i < ColorMapSize; ++i) {
int cnum, i, x, y, bst_idx=0, ld, cd, iter, currhb, img_num;
i_color val;
float dlt, accerr;
- hashbox hb[512];
+ hashbox *hb;
clr = (cvec *)mymalloc(sizeof(cvec) * quant->mc_size);
+ hb = mymalloc(sizeof(hashbox) * 512);
for (i=0; i < quant->mc_count; ++i) {
clr[i].r = quant->mc_colors[i].rgb.r;
clr[i].g = quant->mc_colors[i].rgb.g;
#endif
/* don't want to keep this */
+ myfree(hb);
myfree(clr);
}
#define HB_SORT
/* assume i is available */
-#define CF_VARS hashbox hb[512]; \
+#define CF_VARS hashbox *hb = mymalloc(sizeof(hashbox) * 512); \
int currhb; \
long ld, cd
#endif
}
}
- }
+ }
#ifdef HB_SORT
myfree(indices);
#endif
if (cd < ld) { ld = cd; bst_idx = hb[currhb].vec[i]; } \
}
-#define CF_CLEANUP
+#define CF_CLEANUP myfree(hb)
#endif
memset(err+(maph-1)*errw, 0, sizeof(*err)*errw);
}
CF_CLEANUP;
+ myfree(err);
}
/* Prescan finds the boxes in the image that have the highest number of colors
and that result is used as the initial value for the vectores */