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.

This commit is contained in:
DRC
2014-03-28 18:50:30 +00:00
parent a60728cb34
commit 038cf66ab2
2 changed files with 4099 additions and 13 deletions

View File

@@ -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 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
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
}

4098
jpeg_nbits_table.h Normal file

File diff suppressed because it is too large Load Diff