mirror of https://github.com/nothings/stb.git
Merge branch 'dequant-16-bits' of https://github.com/jeremysawicki/stb into working
This commit is contained in:
commit
0befbc3d78
12
stb_image.h
12
stb_image.h
|
@ -1655,7 +1655,7 @@ typedef struct
|
||||||
stbi__context *s;
|
stbi__context *s;
|
||||||
stbi__huffman huff_dc[4];
|
stbi__huffman huff_dc[4];
|
||||||
stbi__huffman huff_ac[4];
|
stbi__huffman huff_ac[4];
|
||||||
stbi_uc dequant[4][64];
|
stbi__uint16 dequant[4][64];
|
||||||
stbi__int16 fast_ac[4][1 << FAST_BITS];
|
stbi__int16 fast_ac[4][1 << FAST_BITS];
|
||||||
|
|
||||||
// sizes for components, interleaved MCUs
|
// sizes for components, interleaved MCUs
|
||||||
|
@ -1900,7 +1900,7 @@ static stbi_uc stbi__jpeg_dezigzag[64+15] =
|
||||||
};
|
};
|
||||||
|
|
||||||
// decode one 64-entry block--
|
// decode one 64-entry block--
|
||||||
static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi_uc *dequant)
|
static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant)
|
||||||
{
|
{
|
||||||
int diff,dc,k;
|
int diff,dc,k;
|
||||||
int t;
|
int t;
|
||||||
|
@ -2756,7 +2756,7 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stbi__jpeg_dequantize(short *data, stbi_uc *dequant)
|
static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i < 64; ++i)
|
for (i=0; i < 64; ++i)
|
||||||
|
@ -2800,11 +2800,11 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
|
||||||
int q = stbi__get8(z->s);
|
int q = stbi__get8(z->s);
|
||||||
int p = q >> 4;
|
int p = q >> 4;
|
||||||
int t = q & 15,i;
|
int t = q & 15,i;
|
||||||
if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG");
|
if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");
|
||||||
if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
|
if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
|
||||||
for (i=0; i < 64; ++i)
|
for (i=0; i < 64; ++i)
|
||||||
z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s);
|
z->dequant[t][stbi__jpeg_dezigzag[i]] = p == 0 ? stbi__get8(z->s) : stbi__get16be(z->s);
|
||||||
L -= 65;
|
L -= p == 0 ? 65 : 129;
|
||||||
}
|
}
|
||||||
return L==0;
|
return L==0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue