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
Provenance
- Commit
df29024- Tree
f7cee54- Author
Sean Barrett <sean2@nothings.org>- Committer
Sean Barrett <sean2@nothings.org>- Parent
b000f92
2 files changed+19 added−16 removed
modified:README.md+1 added-1 removed
4 unmodified lines5678991011121370 unmodified lines4 unmodified lines
library | lastest version | category | description--------------------- | ---- | -------- | --------------------------------**stb_vorbis.c** | 1.01 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output**stb_image.h** | 1.40 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC**stb_image.h** | 1.41 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC**stb_truetype.h** | 0.8 | graphics | parse, decode, and rasterize characters from truetype fonts**stb_image_write.h** | 0.94 | graphics | image writing to disk: PNG, TGA, BMP**stretchy_buffer.h** | 1.01 | utility | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++**stb_textedit.h** | 1.3 | UI | guts of a text editor for games etc implementing them from scratch70 unmodified linesmodified: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 risk4 5 Do this:14 unmodified lines20 GIF (*comp always reports as 4-channel)21 HDR (radiance rgbE format)22 PIC (Softimage PIC)23 24- - 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)27 28 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 typedef392 unmodified lines426 427 428 static void stbi__refill_buffer(stbi__context *s);429 429-// initialize a memory-stbi__jpeg_huff_decode context430+// initialize a memory-decode context431 static 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 lines1083 1084 // (1 << n) - 11085 static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};1086 1086-// stbi__jpeg_huff_decode a jpeg huffman value from the bitstream1087+// decode a jpeg huffman value from the bitstream1088 stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)1089 {1090 unsigned int temp;1091 int c,k;85 unmodified lines1177 63, 63, 63, 63, 63, 63, 63, 63,1178 63, 63, 63, 63, 63, 63, 631179 };1180 1180-// stbi__jpeg_huff_decode one 64-entry block--1181+// decode one 64-entry block--1182 static 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 lines1192 dc = j->img_comp[b].dc_pred + diff;1193 j->img_comp[b].dc_pred = dc;1194 data[0] = (short) dc;1195 1195- // 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 lines1205 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 lines1571 }1572 1573 if (scan != SCAN_load) return 1;1574 1574- 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");1576 1577 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 lines1590 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 lines1963 j.s = s;1964 return stbi__jpeg_info_raw(&j, x, y, comp);1965 }1966 1966-// 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 // performance756 unmodified lines2728 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 lines3054 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 lines3775 3776 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");3780 3781 stbi__get32be(s); //skip `ratio'3782 stbi__get16be(s); //skip `fields'3783 stbi__get16be(s); //skip `pad'118 unmodified lines3902 static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)3903 {3904 stbi_uc *p, *c;3905 3905- // 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 lines4544 4545 4546 /*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