Skip to content
Myr

stb_image: JPEG: Accept 16-bit quantization tables

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jeremy Sawicki · committed by Jeremy Sawicki · parent 59a5a15 · Browse files · 1 file+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−6 removed

  • other:+6 added−6 removed

1 file+6 added−6 removed

modified:stb_image.h+6 added-6 removed
1728 unmodified lines
1729{1730 stbi__context *s;1731 stbi__huffman huff_dc[4];1732 stbi__huffman huff_ac[4];1733 stbi_uc dequant[4][64];1733 stbi__uint16 dequant[4][64];1734 stbi__int16 fast_ac[4][1 << FAST_BITS];17351736// sizes for components, interleaved MCUs1737 int img_h_max, img_v_max;
236 unmodified lines
1974 63, 63, 63, 63, 63, 63, 631975};19761977// decode one 64-entry block--1978static 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)1978static 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)1979{1980 int diff,dc,k;1981 int t;1982
847 unmodified lines
2830 }2831 }2832}28332834static void stbi__jpeg_dequantize(short *data, stbi_uc *dequant)2834static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)2835{2836 int i;2837 for (i=0; i < 64; ++i)2838 data[i] *= dequant[i];
35 unmodified lines
2874 while (L > 0) {2875 int q = stbi__get8(z->s);2876 int p = q >> 4;2877 int t = q & 15,i;2878 if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG");2878 if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");2879 if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");2880 for (i=0; i < 64; ++i)2881 z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s);2882 L -= 65;2881 z->dequant[t][stbi__jpeg_dezigzag[i]] = p == 0 ? stbi__get8(z->s) : stbi__get16be(z->s);2882 L -= p == 0 ? 65 : 129;2883 }2884 return L==0;28852886 case 0xC4: // DHT - define huffman table
4216 unmodified lines