Integrate a slightly modified version of Mozilla's patch for precomputing the bit-counting LUT.  This is useful if the table needs to be shared among multiple processes, although the primary reason for doing that is reduced footprint on mobile devices, which are probably already covered by the clz intrinsic code.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1221 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/jchuff.c b/jchuff.c
index 68e4e0e..398d2a1 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -47,8 +47,7 @@
 #define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
 #define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
 #else
-static unsigned char jpeg_nbits_table[65536];
-static int jpeg_nbits_table_init = 0;
+#include "jpeg_nbits_table.h"
 #define JPEG_NBITS(x) (jpeg_nbits_table[x])
 #define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
 #endif
@@ -299,17 +298,6 @@
     dtbl->ehufco[i] = huffcode[p];
     dtbl->ehufsi[i] = huffsize[p];
   }
-
-#ifndef USE_CLZ_INTRINSIC
-  if(!jpeg_nbits_table_init) {
-    for(i = 0; i < 65536; i++) {
-      int nbits = 0, temp = i;
-      while (temp) {temp >>= 1;  nbits++;}
-      jpeg_nbits_table[i] = nbits;
-    }
-    jpeg_nbits_table_init = 1;
-  }
-#endif
 }