about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/HISTORY7
-rw-r--r--lib/libppmcmap.c15
2 files changed, 18 insertions, 4 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index c40a7b12..8628a508 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -15,6 +15,10 @@ not yet  BJH  Release 10.56.00
               pnmtops: Add PBM fast path.  Thanks Prophet of the Way
               <afu@wta.att.ne.jp>.
 
+              libppmcmap and most programs that use color maps: speedup with
+              new color hash function.  Thanks Prophet of the Way
+              <afu@wta.att.ne.jp>.
+
               pnmtopng: fix bug: with -alpha specifying a mask which contains
               no fully transparent area, output PNG is fully opaque.
               Introduced in 10.29.
@@ -25,6 +29,9 @@ not yet  BJH  Release 10.56.00
               pnmquant: work with older Perl that doesn't have 3-argument open.
               Thanks Slaven Rezic <srezic@iconmobile.com>.
 
+              ppmcie: fix bug: fails with "X coordinate out of range" error.
+              Introduced in 10.51.
+
               Build: To find libpng, use the Pkgconfig database entry instead
               of libpng-config if it is available.
 
diff --git a/lib/libppmcmap.c b/lib/libppmcmap.c
index 1fd87441..1f7e459d 100644
--- a/lib/libppmcmap.c
+++ b/lib/libppmcmap.c
@@ -20,10 +20,17 @@
 
 #define HASH_SIZE 20023
 
-#define ppm_hashpixel(p) ( ( ( (long) PPM_GETR(p) * 33023 + \
-                               (long) PPM_GETG(p) * 30013 + \
-                               (long) PPM_GETB(p) * 27011 ) \
-                             & 0x7fffffff ) % HASH_SIZE )
+
+
+static __inline__ unsigned int
+ppm_hashpixel(pixel const p) {
+
+    return (unsigned int) (PPM_GETR(p) * 33 * 33
+                           + PPM_GETG(p) * 33
+                           + PPM_GETB(p)) % HASH_SIZE;
+}
+
+
 
 colorhist_vector
 ppm_computecolorhist( pixel ** const pixels,