tweak 16-bit quantization for clarity

pull/415/merge
Sean Barrett 2017-03-03 08:35:14 -08:00
parent 0befbc3d78
commit a6dc061137
1 changed files with 4 additions and 3 deletions

View File

@ -2798,13 +2798,14 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
L = stbi__get16be(z->s)-2;
while (L > 0) {
int q = stbi__get8(z->s);
int p = q >> 4;
int p = q >> 4, sixteen = (p != 0);
int t = q & 15,i;
if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");
if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
for (i=0; i < 64; ++i)
z->dequant[t][stbi__jpeg_dezigzag[i]] = p == 0 ? stbi__get8(z->s) : stbi__get16be(z->s);
L -= p == 0 ? 65 : 129;
z->dequant[t][stbi__jpeg_dezigzag[i]] = sixteen ? stbi__get16be(z->s) : stbi__get8(z->s);
L -= (sixteen ? 129 : 65);
}
return L==0;