Browse Source

tweak 16-bit quantization for clarity

Sean Barrett 8 năm trước cách đây
mục cha
commit
a6dc061137
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      stb_image.h

+ 4 - 3
stb_image.h

@@ -2798,13 +2798,14 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
          L = stbi__get16be(z->s)-2;
          L = stbi__get16be(z->s)-2;
          while (L > 0) {
          while (L > 0) {
             int q = stbi__get8(z->s);
             int q = stbi__get8(z->s);
-            int p = q >> 4;
+            int p = q >> 4, sixteen = (p != 0);
             int t = q & 15,i;
             int t = q & 15,i;
             if (p != 0 && p != 1) 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]] = 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;
          return L==0;