зеркало из https://github.com/mozilla/gecko-dev.git
Bug 815473 - Replace runtime computed jpeg_nbits_table by constants. r=jlebar
This commit is contained in:
Родитель
daa4759375
Коммит
b70337e19a
|
@ -44,7 +44,7 @@ To upgrade to a new revision of libjpeg-turbo, do the following:
|
|||
* Restore files modified in the Mozilla repository.
|
||||
|
||||
$ hg revert --no-backup config.h jconfig.h Makefile.in MOZCHANGES \
|
||||
mozilla.diff simd/Makefile.in
|
||||
mozilla.diff simd/Makefile.in genTables.py
|
||||
|
||||
* Update config.h and jconfig.h as noted previously.
|
||||
|
||||
|
@ -58,6 +58,11 @@ To upgrade to a new revision of libjpeg-turbo, do the following:
|
|||
|
||||
$ hg addremove
|
||||
|
||||
== December 12, 2012 ==
|
||||
|
||||
* Replace the runtime computed jpeg_nbits_table with constants in
|
||||
jpeg_nbits_table.h to make it shareable among processes. (bug 815473)
|
||||
|
||||
== October 13, 2012 ==
|
||||
|
||||
* Modified config.h to use MOZ_ALWAYS_INLINE (bug 800106).
|
||||
|
|
|
@ -163,3 +163,9 @@ EXPORTS = \
|
|||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
.PHONY: CONSTANT_TABLES
|
||||
CONSTANT_TABLES:
|
||||
$(PYTHON) $(srcdir)/genTables.py
|
||||
|
||||
jchuff.$(OBJ_SUFFIX): CONSTANT_TABLES
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import math
|
||||
|
||||
f = open("jpeg_nbits_table.h", "w")
|
||||
|
||||
for i in range(65536):
|
||||
f.write('%2d' % math.ceil(math.log(i + 1, 2)))
|
||||
if i != 65535:
|
||||
f.write(',')
|
||||
if (i + 1) % 16 == 0:
|
||||
f.write('\n')
|
||||
else:
|
||||
f.write(' ')
|
||||
|
||||
f.close()
|
|
@ -21,8 +21,10 @@
|
|||
#include "jchuff.h" /* Declarations shared with jcphuff.c */
|
||||
#include <limits.h>
|
||||
|
||||
static unsigned char jpeg_nbits_table[65536];
|
||||
static int jpeg_nbits_table_init = 0;
|
||||
static const unsigned char jpeg_nbits_table[65536] = {
|
||||
/* Number i needs jpeg_nbits_table[i] bits to be represented. */
|
||||
#include "jpeg_nbits_table.h"
|
||||
};
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
@ -270,15 +272,6 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
|||
dtbl->ehufco[i] = huffcode[p];
|
||||
dtbl->ehufsi[i] = huffsize[p];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,3 +68,54 @@
|
|||
* can change this datatype.
|
||||
*/
|
||||
|
||||
--- jchuff.c
|
||||
+++ jchuff.c
|
||||
@@ -16,18 +16,20 @@
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jchuff.h" /* Declarations shared with jcphuff.c */
|
||||
#include <limits.h>
|
||||
|
||||
-static unsigned char jpeg_nbits_table[65536];
|
||||
-static int jpeg_nbits_table_init = 0;
|
||||
+static const unsigned char jpeg_nbits_table[65536] = {
|
||||
+/* Number i needs jpeg_nbits_table[i] bits to be represented. */
|
||||
+#include "jpeg_nbits_table.h"
|
||||
+};
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
/* Expanded entropy encoder object for Huffman encoding.
|
||||
*
|
||||
@@ -265,25 +267,16 @@ jpeg_make_c_derived_tbl (j_compress_ptr
|
||||
|
||||
for (p = 0; p < lastp; p++) {
|
||||
i = htbl->huffval[p];
|
||||
if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
dtbl->ehufco[i] = huffcode[p];
|
||||
dtbl->ehufsi[i] = huffsize[p];
|
||||
}
|
||||
-
|
||||
- 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;
|
||||
- }
|
||||
}
|
||||
|
||||
|
||||
/* Outputting bytes to the file */
|
||||
|
||||
/* Emit a byte, taking 'action' if must suspend. */
|
||||
#define emit_byte(state,val,action) \
|
||||
{ *(state)->next_output_byte++ = (JOCTET) (val); \
|
||||
|
|
Загрузка…
Ссылка в новой задаче