Skip to content
Myr

fix old stb_image.h search&replace that screwed up comments

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

authored by Sean Barrett · committed by Sean Barrett · parent b000f92 · Browse files · 2 files+19 added−16 removed
This commit

State

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

Diff stats

2 files+19 added−16 removed

  • other:+19 added−16 removed

2 files+19 added−16 removed

modified:README.md+1 added-1 removed
modified:stb_image.h+18 added-15 removed
1/* stb_image - v1.40 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c1/* stb_image - v1.41 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c2 when you control the images you're loading3 no warranty implied; use at your own risk45 Do this:
14 unmodified lines
20 GIF (*comp always reports as 4-channel)21 HDR (radiance rgbE format)22 PIC (Softimage PIC)2324 - stbi__jpeg_huff_decode from memory or through FILE (define STBI_NO_STDIO to remove code)25 - stbi__jpeg_huff_decode from arbitrary I/O callbacks24 - decode from memory or through FILE (define STBI_NO_STDIO to remove code)25 - decode from arbitrary I/O callbacks26 - overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)2728 Latest revisions:29 1.41 (2014-06-25) fix search&replace that messed up comments/error messages30 1.40 (2014-06-22) gcc warning31 1.39 (2014-06-15) TGA optimization fix, multiple BMP fixes32 1.38 (2014-06-06) suppress MSVC run-time warnings, fix accidental rename of 'skip'33 1.37 (2014-06-04) remove duplicate typedef
392 unmodified lines
426427428static void stbi__refill_buffer(stbi__context *s);429429// initialize a memory-stbi__jpeg_huff_decode context430// initialize a memory-decode context431static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len)432{433 s->io.read = NULL;434 s->read_from_callbacks = 0;
648 unmodified lines
10831084// (1 << n) - 11085static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};10861086// stbi__jpeg_huff_decode a jpeg huffman value from the bitstream1087// decode a jpeg huffman value from the bitstream1088stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)1089{1090 unsigned int temp;1091 int c,k;
85 unmodified lines
1177 63, 63, 63, 63, 63, 63, 63, 63,1178 63, 63, 63, 63, 63, 63, 631179};11801180// stbi__jpeg_huff_decode one 64-entry block--1181// decode one 64-entry block--1182static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, int b)1183{1184 int diff,dc,k;1185 int t = stbi__jpeg_huff_decode(j, hdc);
6 unmodified lines
1192 dc = j->img_comp[b].dc_pred + diff;1193 j->img_comp[b].dc_pred = dc;1194 data[0] = (short) dc;11951195 // stbi__jpeg_huff_decode AC components, see JPEG spec1196 // decode AC components, see JPEG spec1197 k = 1;1198 do {1199 int r,s;1200 int rs = stbi__jpeg_huff_decode(j, hac);
4 unmodified lines
1205 if (rs != 0xf0) break; // end block1206 k += 16;1207 } else {1208 k += r;1208 // stbi__jpeg_huff_decode into unzigzag'd location1209 // decode into unzigzag'd location1210 data[stbi__jpeg_dezigzag[k++]] = (short) stbi__extend_receive(j,s);1211 }1212 } while (k < 64);1213 return 1;
357 unmodified lines
1571 }15721573 if (scan != SCAN_load) return 1;15741574 if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to stbi__jpeg_huff_decode");1575 if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");15761577 for (i=0; i < s->img_n; ++i) {1578 if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;1579 if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
10 unmodified lines
1590 for (i=0; i < s->img_n; ++i) {1591 // number of effective pixels (stbi__err.g. for non-interleaved MCU)1592 z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;1593 z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;1593 // to simplify generation, we'll allocate enough memory to stbi__jpeg_huff_decode1594 // to simplify generation, we'll allocate enough memory to decode1595 // the bogus oversized data from using interleaved MCUs and their1596 // big blocks (stbi__err.g. a 16x16 iMCU on an image of width 33); we won't1597 // discard the extra data until colorspace conversion1598 z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
364 unmodified lines
1963 j.s = s;1964 return stbi__jpeg_info_raw(&j, x, y, comp);1965}19661966// public domain zlib stbi__jpeg_huff_decode v0.2 Sean Barrett 2006-11-181967// public domain zlib decode v0.2 Sean Barrett 2006-11-181968// simple implementation1969// - all input must be provided in an upfront buffer1970// - all output is written to a single output buffer (can malloc/realloc)1971// performance
756 unmodified lines
2728 interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG");2729 if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG");2730 if (!pal_img_n) {2731 s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);2731 if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to stbi__jpeg_huff_decode");2732 if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");2733 if (scan == SCAN_header) return 1;2734 } else {2735 // if paletted, then pal_n is our final components, and2736 // img_n is # components to decompress/filter.
317 unmodified lines
3054 if (bpp < 16)3055 psize = (offset - 14 - hsz) >> 2;3056 }3057 s->img_n = ma ? 4 : 3;3057 if (req_comp && req_comp >= 3) // we can directly stbi__jpeg_huff_decode 3 or 43058 if (req_comp && req_comp >= 3) // we can directly decode 3 or 43059 target = req_comp;3060 else3061 target = s->img_n; // if they want monochrome, we'll post-convert3062 out = (stbi_uc *) malloc(target * s->img_x * s->img_y);
712 unmodified lines
37753776 x = stbi__get16be(s);3777 y = stbi__get16be(s);3778 if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)");3778 if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to stbi__jpeg_huff_decode");3779 if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to decode");37803781 stbi__get32be(s); //skip `ratio'3782 stbi__get16be(s); //skip `fields'3783 stbi__get16be(s); //skip `pad'
118 unmodified lines
3902static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)3903{3904 stbi_uc *p, *c;39053905 // recurse to stbi__jpeg_huff_decode the prefixes, since the linked-list is backwards,3906 // recurse to decode the prefixes, since the linked-list is backwards,3907 // and working backwards through an interleaved image would be nasty3908 if (g->codes[code].prefix >= 0)3909 stbi__out_gif_code(g, g->codes[code].prefix);3910
633 unmodified lines
454445454546/*4547 revision history:4548 1.41 (2014-06-25)4549 fix search&replace from 1.36 that messed up comments/error messages4550 1.40 (2014-06-22)4551 fix gcc struct-initialization warning4552 1.39 (2014-06-15)4553 fix to TGA optimization when req_comp != number of components in TGA;
102 unmodified lines