about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-08-22 19:32:33 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-08-22 19:32:33 +0000
commiteaefcd776d24134c5741bc908919988529ab74f7 (patch)
tree75d98247695137166d7eec706971d0fdc1e8546d
parentf187d36ed6d15d8826323fd8ab884bdfb8cbcfd8 (diff)
downloadnetpbm-mirror-eaefcd776d24134c5741bc908919988529ab74f7.tar.gz
netpbm-mirror-eaefcd776d24134c5741bc908919988529ab74f7.tar.xz
netpbm-mirror-eaefcd776d24134c5741bc908919988529ab74f7.zip
New ash function
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1553 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-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,