diff options
-rw-r--r-- | Makefile.version | 2 | ||||
-rw-r--r-- | converter/other/pamtogif.c | 3 | ||||
-rw-r--r-- | converter/other/pamtoxvmini.c | 29 | ||||
-rw-r--r-- | doc/HISTORY | 12 | ||||
-rw-r--r-- | lib/libpbm3.c | 5 | ||||
-rw-r--r-- | lib/util/shhopt.c | 5 |
6 files changed, 42 insertions, 14 deletions
diff --git a/Makefile.version b/Makefile.version index 35e42187..bc174237 100644 --- a/Makefile.version +++ b/Makefile.version @@ -1,4 +1,4 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 37 -NETPBM_POINT_RELEASE = 03 +NETPBM_POINT_RELEASE = 04 diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c index e1f5f85b..81e8edb4 100644 --- a/converter/other/pamtogif.c +++ b/converter/other/pamtogif.c @@ -1660,7 +1660,8 @@ colormapFromFile(char const filespec[], pm_message("computing other colormap ..."); - pnm_computetuplefreqtable(mapPamP, colors, maxcolors, &colorCount); + *tupletableP = + pnm_computetuplefreqtable(mapPamP, colors, maxcolors, &colorCount); *colorCountP = colorCount; diff --git a/converter/other/pamtoxvmini.c b/converter/other/pamtoxvmini.c index 449b3c99..3207b0d5 100644 --- a/converter/other/pamtoxvmini.c +++ b/converter/other/pamtoxvmini.c @@ -75,15 +75,20 @@ makeXvPalette(xvPalette * const xvPaletteP) { static void writeXvHeader(FILE * const ofP, unsigned int const cols, - unsigned int const rows, - unsigned int const maxval) { + unsigned int const rows) { fprintf(ofP, "P7 332\n"); fprintf(ofP, "# Created by Pamtoxvmini\n"); fprintf(ofP, "#END_OF_COMMENTS\n"); - fprintf(ofP, "%u %u %u\n", cols, rows, maxval); + /* I don't know what the maxval number (3rd field) means here, since + the maxvals are fixed at red=7, grn=7, blu=3. We used to have + it put the maxval of the input image there. That generated an + output that Xv choked on when the input maxval was 65535. + */ + + fprintf(ofP, "%u %u 255\n", cols, rows); } @@ -105,7 +110,7 @@ findClosestColor(struct pam * const pamP, colors in the XV palette: */ assert(pamP->depth >= 3); - assert(pamP->maxval = 255); + assert(pamP->maxval == 255); bestPaletteIndex = 0; bestDistanceSoFar = UINT_MAX; @@ -185,30 +190,34 @@ writeXvRaster(struct pam * const pamP, tuple * tuplerow; unsigned int row; unsigned char * xvrow; + struct pam scaledPam; paletteHash = pnm_createtuplehash(); tuplerow = pnm_allocpamrow(pamP); xvrow = (unsigned char*)pm_allocrow(pamP->width, 1); + scaledPam = *pamP; + scaledPam.maxval = 255; + for (row = 0; row < pamP->height; ++row) { unsigned int col; pnm_readpamrow(pamP, tuplerow); - pnm_scaletuplerow(pamP, tuplerow, tuplerow, 255); - pnm_makerowrgb(pamP, tuplerow); + pnm_scaletuplerow(pamP, tuplerow, tuplerow, scaledPam.maxval); + pnm_makerowrgb(&scaledPam, tuplerow); - for (col = 0; col < pamP->width; ++col) { + for (col = 0; col < scaledPam.width; ++col) { unsigned int paletteIndex; - getPaletteIndexThroughCache(pamP, tuplerow[col], xvPaletteP, + getPaletteIndexThroughCache(&scaledPam, tuplerow[col], xvPaletteP, paletteHash, &paletteIndex); assert(paletteIndex < 256); xvrow[col] = paletteIndex; } - fwrite(xvrow, 1, pamP->width, ofP); + fwrite(xvrow, 1, scaledPam.width, ofP); } pm_freerow((char*)xvrow); @@ -240,7 +249,7 @@ main(int argc, pnm_setminallocationdepth(&pam, 3); - writeXvHeader(stdout, pam.width, pam.height, pam.maxval); + writeXvHeader(stdout, pam.width, pam.height); writeXvRaster(&pam, &xvPalette, stdout); diff --git a/doc/HISTORY b/doc/HISTORY index 17b179ac..f63be0aa 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,18 @@ Netpbm. CHANGE HISTORY -------------- +07.03.09 BJH Release 10.37.04 + + pamtogif: fix crash with -mapfile. + + libnetpbm: fix crash with PBM images < 8 columns on MMX/SSE + machine. + + pamtoxvmini: fix maxval != 255 bugs. + + libnetpbm: shhopt: reject signed number as value for + OPT_UINT option. + 07.02.21 BJH Release 10.37.03 pamtoxvmini: fix crash. diff --git a/lib/libpbm3.c b/lib/libpbm3.c index 8056a72d..34922edd 100644 --- a/lib/libpbm3.c +++ b/lib/libpbm3.c @@ -107,11 +107,12 @@ packBitsWithMmxSse(FILE * const fileP, typedef int v8qi __attribute__ ((mode(V8QI))); typedef int di __attribute__ ((mode(DI))); - int col; di const zero64 = 0; /* to clear with PXOR */ - for (col = 0; col < cols-7; col += 8) { + unsigned int col; + + for (col = 0; col + 7 < cols; col += 8) { v8qi const compare = __builtin_ia32_pcmpeqb(*(v8qi*) (&bitrow[col]), *(v8qi*) &zero64); unsigned char const backwardWhiteMask = (unsigned char) diff --git a/lib/util/shhopt.c b/lib/util/shhopt.c index 7722b5d5..15058bb5 100644 --- a/lib/util/shhopt.c +++ b/lib/util/shhopt.c @@ -427,6 +427,11 @@ optExecute(optEntry const opt, char *arg, int lng) if (arg == NULL) optFatal("internal error: optExecute() called with NULL argument " "'%s'", optString(opt, lng)); + + if (arg[0] == '-' || arg[1] == '+') + optFatal("unsigned number '%s' has a sign ('%c')", + arg, arg[0]); + tmp = strtoul(arg, &e, 10); if (*e) optFatal("invalid number `%s'", arg); |