mirror of https://github.com/nothings/stb.git
Merge branch 'phprus-patch-1' of https://github.com/phprus/stb into working
This commit is contained in:
commit
351489803f
34
stb_image.h
34
stb_image.h
|
@ -3769,7 +3769,7 @@ stbi_inline static int stbi__bit_reverse(int v, int bits)
|
|||
return stbi__bitreverse16(v) >> (16-bits);
|
||||
}
|
||||
|
||||
static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num)
|
||||
static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num)
|
||||
{
|
||||
int i,k=0;
|
||||
int code, next_code[16], sizes[17];
|
||||
|
@ -4059,9 +4059,33 @@ static int stbi__parse_zlib_header(stbi__zbuf *a)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// @TODO: should statically initialize these for optimal thread safety
|
||||
static stbi_uc stbi__zdefault_length[288], stbi__zdefault_distance[32];
|
||||
static void stbi__init_zdefaults(void)
|
||||
static const stbi_uc stbi__zdefault_length[288] = {
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 8, 8, 8
|
||||
};
|
||||
static const stbi_uc stbi__zdefault_distance[32] = {
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
|
||||
};
|
||||
/*
|
||||
Init algorithm:
|
||||
{
|
||||
int i; // use <= to match clearly with spec
|
||||
for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8;
|
||||
|
@ -4071,6 +4095,7 @@ static void stbi__init_zdefaults(void)
|
|||
|
||||
for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5;
|
||||
}
|
||||
*/
|
||||
|
||||
static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
|
||||
{
|
||||
|
@ -4089,7 +4114,6 @@ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
|
|||
} else {
|
||||
if (type == 1) {
|
||||
// use fixed code lengths
|
||||
if (!stbi__zdefault_distance[31]) stbi__init_zdefaults();
|
||||
if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0;
|
||||
if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue